unioffice/drawing/drawing.go

127 lines
9.4 KiB
Go
Raw Normal View History

2020-08-23 14:15:53 +00:00
//
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// This is a commercial product and requires a license to operate.
// A trial license can be obtained at https://unidoc.io
//
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
//
// Use of this source code is governed by the UniDoc End User License Agreement
// terms that can be accessed at https://unidoc.io/eula/
2023-05-26 09:49:04 +00:00
package drawing ;import (_d "github.com/unidoc/unioffice";_da "github.com/unidoc/unioffice/color";_ga "github.com/unidoc/unioffice/measurement";_gd "github.com/unidoc/unioffice/schema/soo/dml";);
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// ParagraphProperties allows controlling paragraph properties.
type ParagraphProperties struct{_ea *_gd .CT_TextParagraphProperties ;};
2021-08-23 20:44:48 +00:00
2023-03-01 18:42:44 +00:00
// X returns the inner wrapped XML type.
2023-05-26 09:49:04 +00:00
func (_ce Paragraph )X ()*_gd .CT_TextParagraph {return _ce ._c };
2021-08-23 20:44:48 +00:00
2023-05-26 09:49:04 +00:00
// Properties returns the paragraph properties.
func (_caf Paragraph )Properties ()ParagraphProperties {if _caf ._c .PPr ==nil {_caf ._c .PPr =_gd .NewCT_TextParagraphProperties ();};return MakeParagraphProperties (_caf ._c .PPr );};func (_ge ShapeProperties )LineProperties ()LineProperties {if _ge ._ecf .Ln ==nil {_ge ._ecf .Ln =_gd .NewCT_LineProperties ();};return LineProperties {_ge ._ecf .Ln };};func (_cedf ShapeProperties )SetNoFill (){_cedf .clearFill ();_cedf ._ecf .NoFill =_gd .NewCT_NoFillProperties ();};
2022-09-02 11:46:53 +00:00
2023-05-26 09:49:04 +00:00
// SetFlipVertical controls if the shape is flipped vertically.
func (_adb ShapeProperties )SetFlipVertical (b bool ){_adb .ensureXfrm ();if !b {_adb ._ecf .Xfrm .FlipVAttr =nil ;}else {_adb ._ecf .Xfrm .FlipVAttr =_d .Bool (true );};};
// LineJoin is the type of line join
type LineJoin byte ;
2022-09-02 11:46:53 +00:00
2023-04-15 17:27:31 +00:00
// Properties returns the run's properties.
2023-05-26 09:49:04 +00:00
func (_cef Run )Properties ()RunProperties {if _cef ._bd .R ==nil {_cef ._bd .R =_gd .NewCT_RegularTextRun ();};if _cef ._bd .R .RPr ==nil {_cef ._bd .R .RPr =_gd .NewCT_TextCharacterProperties ();};return RunProperties {_cef ._bd .R .RPr };};
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// SetText sets the run's text contents.
func (_fd Run )SetText (s string ){_fd ._bd .Br =nil ;_fd ._bd .Fld =nil ;if _fd ._bd .R ==nil {_fd ._bd .R =_gd .NewCT_RegularTextRun ();};_fd ._bd .R .T =s ;};
// MakeRun constructs a new Run wrapper.
func MakeRun (x *_gd .EG_TextRun )Run {return Run {x }};
2022-04-09 14:27:46 +00:00
2023-04-15 17:27:31 +00:00
// X returns the inner wrapped XML type.
2023-05-26 09:49:04 +00:00
func (_bda ShapeProperties )X ()*_gd .CT_ShapeProperties {return _bda ._ecf };
2022-04-09 14:27:46 +00:00
2023-03-01 18:42:44 +00:00
// X returns the inner wrapped XML type.
2023-05-26 09:49:04 +00:00
func (_gdb LineProperties )X ()*_gd .CT_LineProperties {return _gdb ._a };
2020-08-23 14:15:53 +00:00
2023-04-15 17:27:31 +00:00
// SetAlign controls the paragraph alignment
2023-05-26 09:49:04 +00:00
func (_aba ParagraphProperties )SetAlign (a _gd .ST_TextAlignType ){_aba ._ea .AlgnAttr =a };
2021-04-23 20:00:00 +00:00
2023-05-26 09:49:04 +00:00
// SetPosition sets the position of the shape.
func (_gbg ShapeProperties )SetPosition (x ,y _ga .Distance ){_gbg .ensureXfrm ();if _gbg ._ecf .Xfrm .Off ==nil {_gbg ._ecf .Xfrm .Off =_gd .NewCT_Point2D ();};_gbg ._ecf .Xfrm .Off .XAttr .ST_CoordinateUnqualified =_d .Int64 (int64 (x /_ga .EMU ));_gbg ._ecf .Xfrm .Off .YAttr .ST_CoordinateUnqualified =_d .Int64 (int64 (y /_ga .EMU ));};func (_b LineProperties )SetSolidFill (c _da .Color ){_b .clearFill ();_b ._a .SolidFill =_gd .NewCT_SolidColorFillProperties ();_b ._a .SolidFill .SrgbClr =_gd .NewCT_SRgbColor ();_b ._a .SolidFill .SrgbClr .ValAttr =*c .AsRGBString ();};
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// SetNumbered controls if bullets are numbered or not.
func (_fe ParagraphProperties )SetNumbered (scheme _gd .ST_TextAutonumberScheme ){if scheme ==_gd .ST_TextAutonumberSchemeUnset {_fe ._ea .BuAutoNum =nil ;}else {_fe ._ea .BuAutoNum =_gd .NewCT_TextAutonumberBullet ();_fe ._ea .BuAutoNum .TypeAttr =scheme ;};};func (_dd ShapeProperties )ensureXfrm (){if _dd ._ecf .Xfrm ==nil {_dd ._ecf .Xfrm =_gd .NewCT_Transform2D ();};};
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// SetBulletChar sets the bullet character for the paragraph.
func (_ced ParagraphProperties )SetBulletChar (c string ){if c ==""{_ced ._ea .BuChar =nil ;}else {_ced ._ea .BuChar =_gd .NewCT_TextCharBullet ();_ced ._ea .BuChar .CharAttr =c ;};};
2021-03-16 20:51:18 +00:00
2023-05-26 09:49:04 +00:00
// SetLevel sets the level of indentation of a paragraph.
func (_ab ParagraphProperties )SetLevel (idx int32 ){_ab ._ea .LvlAttr =_d .Int32 (idx )};
2022-01-15 21:17:38 +00:00
2023-05-26 09:49:04 +00:00
// AddBreak adds a new line break to a paragraph.
func (_gbe Paragraph )AddBreak (){_ca :=_gd .NewEG_TextRun ();_ca .Br =_gd .NewCT_TextLineBreak ();_gbe ._c .EG_TextRun =append (_gbe ._c .EG_TextRun ,_ca );};
2020-11-09 01:00:18 +00:00
2023-05-26 09:49:04 +00:00
// RunProperties controls the run properties.
type RunProperties struct{_cf *_gd .CT_TextCharacterProperties ;};
2021-07-30 17:03:26 +00:00
2023-05-26 09:49:04 +00:00
// Run is a run within a paragraph.
type Run struct{_bd *_gd .EG_TextRun };
2022-04-09 14:27:46 +00:00
2023-05-26 09:49:04 +00:00
// SetSolidFill controls the text color of a run.
func (_gbc RunProperties )SetSolidFill (c _da .Color ){_gbc ._cf .NoFill =nil ;_gbc ._cf .BlipFill =nil ;_gbc ._cf .GradFill =nil ;_gbc ._cf .GrpFill =nil ;_gbc ._cf .PattFill =nil ;_gbc ._cf .SolidFill =_gd .NewCT_SolidColorFillProperties ();_gbc ._cf .SolidFill .SrgbClr =_gd .NewCT_SRgbColor ();_gbc ._cf .SolidFill .SrgbClr .ValAttr =*c .AsRGBString ();};
2021-09-22 16:41:01 +00:00
2023-05-26 09:49:04 +00:00
// Paragraph is a paragraph within a document.
type Paragraph struct{_c *_gd .CT_TextParagraph };
2022-12-06 11:56:49 +00:00
2023-05-26 09:49:04 +00:00
// AddRun adds a new run to a paragraph.
func (_e Paragraph )AddRun ()Run {_fa :=MakeRun (_gd .NewEG_TextRun ());_e ._c .EG_TextRun =append (_e ._c .EG_TextRun ,_fa .X ());return _fa ;};
2023-04-15 17:27:31 +00:00
// MakeRunProperties constructs a new RunProperties wrapper.
2023-05-26 09:49:04 +00:00
func MakeRunProperties (x *_gd .CT_TextCharacterProperties )RunProperties {return RunProperties {x }};
2023-04-15 17:27:31 +00:00
2023-05-26 09:49:04 +00:00
// X returns the inner wrapped XML type.
func (_bdb Run )X ()*_gd .EG_TextRun {return _bdb ._bd };
2022-12-06 11:56:49 +00:00
2023-05-26 09:49:04 +00:00
// SetHeight sets the height of the shape.
func (_gc ShapeProperties )SetHeight (h _ga .Distance ){_gc .ensureXfrm ();if _gc ._ecf .Xfrm .Ext ==nil {_gc ._ecf .Xfrm .Ext =_gd .NewCT_PositiveSize2D ();};_gc ._ecf .Xfrm .Ext .CyAttr =int64 (h /_ga .EMU );};
2022-04-09 14:27:46 +00:00
2023-05-26 09:49:04 +00:00
// SetJoin sets the line join style.
func (_gb LineProperties )SetJoin (e LineJoin ){_gb ._a .Round =nil ;_gb ._a .Miter =nil ;_gb ._a .Bevel =nil ;switch e {case LineJoinRound :_gb ._a .Round =_gd .NewCT_LineJoinRound ();case LineJoinBevel :_gb ._a .Bevel =_gd .NewCT_LineJoinBevel ();case LineJoinMiter :_gb ._a .Miter =_gd .NewCT_LineJoinMiterProperties ();};};
2022-04-09 14:27:46 +00:00
2023-04-15 17:27:31 +00:00
// SetWidth sets the width of the shape.
2023-05-26 09:49:04 +00:00
func (_cc ShapeProperties )SetWidth (w _ga .Distance ){_cc .ensureXfrm ();if _cc ._ecf .Xfrm .Ext ==nil {_cc ._ecf .Xfrm .Ext =_gd .NewCT_PositiveSize2D ();};_cc ._ecf .Xfrm .Ext .CxAttr =int64 (w /_ga .EMU );};
2022-02-25 19:20:45 +00:00
2023-05-26 09:49:04 +00:00
// GetPosition gets the position of the shape in EMU.
func (_ba ShapeProperties )GetPosition ()(int64 ,int64 ){_ba .ensureXfrm ();if _ba ._ecf .Xfrm .Off ==nil {_ba ._ecf .Xfrm .Off =_gd .NewCT_Point2D ();};return *_ba ._ecf .Xfrm .Off .XAttr .ST_CoordinateUnqualified ,*_ba ._ecf .Xfrm .Off .YAttr .ST_CoordinateUnqualified ;};
2022-12-06 11:56:49 +00:00
2023-05-26 09:49:04 +00:00
// SetFont controls the font of a run.
func (_gf RunProperties )SetFont (s string ){_gf ._cf .Latin =_gd .NewCT_TextFont ();_gf ._cf .Latin .TypefaceAttr =s ;};
2022-12-06 11:56:49 +00:00
2023-05-26 09:49:04 +00:00
// SetGeometry sets the shape type of the shape
func (_gg ShapeProperties )SetGeometry (g _gd .ST_ShapeType ){if _gg ._ecf .PrstGeom ==nil {_gg ._ecf .PrstGeom =_gd .NewCT_PresetGeometry2D ();};_gg ._ecf .PrstGeom .PrstAttr =g ;};func (_fga LineProperties )SetNoFill (){_fga .clearFill ();_fga ._a .NoFill =_gd .NewCT_NoFillProperties ();};
2022-02-25 19:20:45 +00:00
2023-05-26 09:49:04 +00:00
// SetWidth sets the line width, MS products treat zero as the minimum width
// that can be displayed.
func (_f LineProperties )SetWidth (w _ga .Distance ){_f ._a .WAttr =_d .Int32 (int32 (w /_ga .EMU ))};func (_bdg ShapeProperties )clearFill (){_bdg ._ecf .NoFill =nil ;_bdg ._ecf .BlipFill =nil ;_bdg ._ecf .GradFill =nil ;_bdg ._ecf .GrpFill =nil ;_bdg ._ecf .SolidFill =nil ;_bdg ._ecf .PattFill =nil ;};func MakeShapeProperties (x *_gd .CT_ShapeProperties )ShapeProperties {return ShapeProperties {x }};
2022-02-25 19:20:45 +00:00
2023-05-26 09:49:04 +00:00
// MakeParagraphProperties constructs a new ParagraphProperties wrapper.
func MakeParagraphProperties (x *_gd .CT_TextParagraphProperties )ParagraphProperties {return ParagraphProperties {x };};
2022-04-09 14:27:46 +00:00
2023-05-26 09:49:04 +00:00
// X returns the inner wrapped XML type.
func (_ec ParagraphProperties )X ()*_gd .CT_TextParagraphProperties {return _ec ._ea };
2023-03-01 18:42:44 +00:00
2023-05-26 09:49:04 +00:00
// SetFlipHorizontal controls if the shape is flipped horizontally.
func (_aa ShapeProperties )SetFlipHorizontal (b bool ){_aa .ensureXfrm ();if !b {_aa ._ecf .Xfrm .FlipHAttr =nil ;}else {_aa ._ecf .Xfrm .FlipHAttr =_d .Bool (true );};};func (_af ShapeProperties )SetSolidFill (c _da .Color ){_af .clearFill ();_af ._ecf .SolidFill =_gd .NewCT_SolidColorFillProperties ();_af ._ecf .SolidFill .SrgbClr =_gd .NewCT_SRgbColor ();_af ._ecf .SolidFill .SrgbClr .ValAttr =*c .AsRGBString ();};const (LineJoinRound LineJoin =iota ;LineJoinBevel ;LineJoinMiter ;);
2023-03-01 18:42:44 +00:00
2023-05-26 09:49:04 +00:00
// SetBold controls the bolding of a run.
func (_dcf RunProperties )SetBold (b bool ){_dcf ._cf .BAttr =_d .Bool (b )};
2023-03-01 18:42:44 +00:00
2023-05-26 09:49:04 +00:00
// MakeParagraph constructs a new paragraph wrapper.
func MakeParagraph (x *_gd .CT_TextParagraph )Paragraph {return Paragraph {x }};
2022-06-27 19:44:23 +00:00
2023-05-26 09:49:04 +00:00
// SetSize sets the font size of the run text
func (_ag RunProperties )SetSize (sz _ga .Distance ){_ag ._cf .SzAttr =_d .Int32 (int32 (sz /_ga .HundredthPoint ));};type ShapeProperties struct{_ecf *_gd .CT_ShapeProperties };
2022-06-27 19:44:23 +00:00
2023-05-26 09:49:04 +00:00
// SetSize sets the width and height of the shape.
func (_ad ShapeProperties )SetSize (w ,h _ga .Distance ){_ad .SetWidth (w );_ad .SetHeight (h )};
2023-03-01 18:42:44 +00:00
2023-05-26 09:49:04 +00:00
// SetBulletFont controls the font for the bullet character.
func (_dc ParagraphProperties )SetBulletFont (f string ){if f ==""{_dc ._ea .BuFont =nil ;}else {_dc ._ea .BuFont =_gd .NewCT_TextFont ();_dc ._ea .BuFont .TypefaceAttr =f ;};};type LineProperties struct{_a *_gd .CT_LineProperties };func (_fg LineProperties )clearFill (){_fg ._a .NoFill =nil ;_fg ._a .GradFill =nil ;_fg ._a .SolidFill =nil ;_fg ._a .PattFill =nil ;};