unioffice/drawing/drawing.go

127 lines
9.3 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/
2021-06-16 07:10:52 +00:00
package drawing ;import (_b "github.com/unidoc/unioffice";_g "github.com/unidoc/unioffice/color";_eb "github.com/unidoc/unioffice/measurement";_e "github.com/unidoc/unioffice/schema/soo/dml";);
2020-08-23 14:15:53 +00:00
2021-06-16 07:10:52 +00:00
// LineJoin is the type of line join
type LineJoin byte ;
2021-04-23 20:00:00 +00:00
2021-06-16 07:10:52 +00:00
// SetHeight sets the height of the shape.
func (_cc ShapeProperties )SetHeight (h _eb .Distance ){_cc .ensureXfrm ();if _cc ._gc .Xfrm .Ext ==nil {_cc ._gc .Xfrm .Ext =_e .NewCT_PositiveSize2D ();};_cc ._gc .Xfrm .Ext .CyAttr =int64 (h /_eb .EMU );};
2021-04-23 20:00:00 +00:00
2021-06-16 07:10:52 +00:00
// ParagraphProperties allows controlling paragraph properties.
type ParagraphProperties struct{_dd *_e .CT_TextParagraphProperties ;};
2020-08-23 14:15:53 +00:00
2021-06-16 07:10:52 +00:00
// AddBreak adds a new line break to a paragraph.
func (_gb Paragraph )AddBreak (){_abd :=_e .NewEG_TextRun ();_abd .Br =_e .NewCT_TextLineBreak ();_gb ._bda .EG_TextRun =append (_gb ._bda .EG_TextRun ,_abd );};func (_d LineProperties )SetNoFill (){_d .clearFill ();_d ._c .NoFill =_e .NewCT_NoFillProperties ()};
// SetBold controls the bolding of a run.
func (_eef RunProperties )SetBold (b bool ){_eef ._fdg .BAttr =_b .Bool (b )};
2020-08-23 14:15:53 +00:00
2021-05-31 16:22:30 +00:00
// SetText sets the run's text contents.
2021-06-16 07:10:52 +00:00
func (_ee Run )SetText (s string ){_ee ._gdg .Br =nil ;_ee ._gdg .Fld =nil ;if _ee ._gdg .R ==nil {_ee ._gdg .R =_e .NewCT_RegularTextRun ();};_ee ._gdg .R .T =s ;};
2020-08-31 22:58:25 +00:00
2021-06-16 07:10:52 +00:00
// GetPosition gets the position of the shape in EMU.
func (_ec ShapeProperties )GetPosition ()(int64 ,int64 ){_ec .ensureXfrm ();if _ec ._gc .Xfrm .Off ==nil {_ec ._gc .Xfrm .Off =_e .NewCT_Point2D ();};return *_ec ._gc .Xfrm .Off .XAttr .ST_CoordinateUnqualified ,*_ec ._gc .Xfrm .Off .YAttr .ST_CoordinateUnqualified ;};
2020-08-23 14:15:53 +00:00
2021-06-16 07:10:52 +00:00
// Paragraph is a paragraph within a document.
type Paragraph struct{_bda *_e .CT_TextParagraph };
2020-08-23 14:15:53 +00:00
2021-06-16 07:10:52 +00:00
// X returns the inner wrapped XML type.
func (_cd Paragraph )X ()*_e .CT_TextParagraph {return _cd ._bda };func (_fdf ShapeProperties )SetSolidFill (c _g .Color ){_fdf .clearFill ();_fdf ._gc .SolidFill =_e .NewCT_SolidColorFillProperties ();_fdf ._gc .SolidFill .SrgbClr =_e .NewCT_SRgbColor ();_fdf ._gc .SolidFill .SrgbClr .ValAttr =*c .AsRGBString ();};
// SetBulletChar sets the bullet character for the paragraph.
func (_bb ParagraphProperties )SetBulletChar (c string ){if c ==""{_bb ._dd .BuChar =nil ;}else {_bb ._dd .BuChar =_e .NewCT_TextCharBullet ();_bb ._dd .BuChar .CharAttr =c ;};};
2020-08-23 14:15:53 +00:00
2021-05-31 16:22:30 +00:00
// SetFont controls the font of a run.
2021-06-16 07:10:52 +00:00
func (_fe RunProperties )SetFont (s string ){_fe ._fdg .Latin =_e .NewCT_TextFont ();_fe ._fdg .Latin .TypefaceAttr =s ;};func MakeShapeProperties (x *_e .CT_ShapeProperties )ShapeProperties {return ShapeProperties {x }};
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
2021-06-16 07:10:52 +00:00
func (_ga LineProperties )X ()*_e .CT_LineProperties {return _ga ._c };
2020-08-23 14:15:53 +00:00
2021-06-16 07:10:52 +00:00
// RunProperties controls the run properties.
type RunProperties struct{_fdg *_e .CT_TextCharacterProperties ;};
2020-10-12 13:59:12 +00:00
2021-06-16 07:10:52 +00:00
// X returns the inner wrapped XML type.
func (_cf Run )X ()*_e .EG_TextRun {return _cf ._gdg };
2021-05-31 16:22:30 +00:00
2021-06-16 07:10:52 +00:00
// SetWidth sets the width of the shape.
func (_be ShapeProperties )SetWidth (w _eb .Distance ){_be .ensureXfrm ();if _be ._gc .Xfrm .Ext ==nil {_be ._gc .Xfrm .Ext =_e .NewCT_PositiveSize2D ();};_be ._gc .Xfrm .Ext .CxAttr =int64 (w /_eb .EMU );};
2021-05-31 16:22:30 +00:00
2021-06-16 07:10:52 +00:00
// MakeParagraphProperties constructs a new ParagraphProperties wrapper.
func MakeParagraphProperties (x *_e .CT_TextParagraphProperties )ParagraphProperties {return ParagraphProperties {x };};
2020-10-12 13:59:12 +00:00
2021-04-23 20:00:00 +00:00
// X returns the inner wrapped XML type.
2021-06-16 07:10:52 +00:00
func (_ff ShapeProperties )X ()*_e .CT_ShapeProperties {return _ff ._gc };func (_gba ShapeProperties )LineProperties ()LineProperties {if _gba ._gc .Ln ==nil {_gba ._gc .Ln =_e .NewCT_LineProperties ();};return LineProperties {_gba ._gc .Ln };};
2021-04-23 20:00:00 +00:00
2021-06-16 07:10:52 +00:00
// SetFlipVertical controls if the shape is flipped vertically.
func (_gad ShapeProperties )SetFlipVertical (b bool ){_gad .ensureXfrm ();if !b {_gad ._gc .Xfrm .FlipVAttr =nil ;}else {_gad ._gc .Xfrm .FlipVAttr =_b .Bool (true );};};
2020-08-23 14:15:53 +00:00
2021-06-16 07:10:52 +00:00
// Run is a run within a paragraph.
type Run struct{_gdg *_e .EG_TextRun };
// Properties returns the run's properties.
func (_cg Run )Properties ()RunProperties {if _cg ._gdg .R ==nil {_cg ._gdg .R =_e .NewCT_RegularTextRun ();};if _cg ._gdg .R .RPr ==nil {_cg ._gdg .R .RPr =_e .NewCT_TextCharacterProperties ();};return RunProperties {_cg ._gdg .R .RPr };};
2020-08-23 14:15:53 +00:00
2021-05-31 16:22:30 +00:00
// SetBulletFont controls the font for the bullet character.
2021-06-16 07:10:52 +00:00
func (_ag ParagraphProperties )SetBulletFont (f string ){if f ==""{_ag ._dd .BuFont =nil ;}else {_ag ._dd .BuFont =_e .NewCT_TextFont ();_ag ._dd .BuFont .TypefaceAttr =f ;};};
2020-08-23 14:15:53 +00:00
2021-06-16 07:10:52 +00:00
// SetAlign controls the paragraph alignment
func (_ae ParagraphProperties )SetAlign (a _e .ST_TextAlignType ){_ae ._dd .AlgnAttr =a };
2021-03-16 20:51:18 +00:00
2021-06-16 07:10:52 +00:00
// Properties returns the paragraph properties.
func (_gd Paragraph )Properties ()ParagraphProperties {if _gd ._bda .PPr ==nil {_gd ._bda .PPr =_e .NewCT_TextParagraphProperties ();};return MakeParagraphProperties (_gd ._bda .PPr );};
2021-03-16 20:51:18 +00:00
2021-06-16 07:10:52 +00:00
// SetNumbered controls if bullets are numbered or not.
func (_bfg ParagraphProperties )SetNumbered (scheme _e .ST_TextAutonumberScheme ){if scheme ==_e .ST_TextAutonumberSchemeUnset {_bfg ._dd .BuAutoNum =nil ;}else {_bfg ._dd .BuAutoNum =_e .NewCT_TextAutonumberBullet ();_bfg ._dd .BuAutoNum .TypeAttr =scheme ;};};
2021-03-16 20:51:18 +00:00
2021-06-16 07:10:52 +00:00
// MakeParagraph constructs a new paragraph wrapper.
func MakeParagraph (x *_e .CT_TextParagraph )Paragraph {return Paragraph {x }};
2020-08-23 14:15:53 +00:00
2021-06-16 07:10:52 +00:00
// SetFlipHorizontal controls if the shape is flipped horizontally.
func (_ad ShapeProperties )SetFlipHorizontal (b bool ){_ad .ensureXfrm ();if !b {_ad ._gc .Xfrm .FlipHAttr =nil ;}else {_ad ._gc .Xfrm .FlipHAttr =_b .Bool (true );};};
2020-08-23 14:15:53 +00:00
2021-06-16 07:10:52 +00:00
// SetSolidFill controls the text color of a run.
func (_fc RunProperties )SetSolidFill (c _g .Color ){_fc ._fdg .NoFill =nil ;_fc ._fdg .BlipFill =nil ;_fc ._fdg .GradFill =nil ;_fc ._fdg .GrpFill =nil ;_fc ._fdg .PattFill =nil ;_fc ._fdg .SolidFill =_e .NewCT_SolidColorFillProperties ();_fc ._fdg .SolidFill .SrgbClr =_e .NewCT_SRgbColor ();_fc ._fdg .SolidFill .SrgbClr .ValAttr =*c .AsRGBString ();};
2020-08-23 14:15:53 +00:00
2021-06-16 07:10:52 +00:00
// SetGeometry sets the shape type of the shape
func (_ddb ShapeProperties )SetGeometry (g _e .ST_ShapeType ){if _ddb ._gc .PrstGeom ==nil {_ddb ._gc .PrstGeom =_e .NewCT_PresetGeometry2D ();};_ddb ._gc .PrstGeom .PrstAttr =g ;};func (_bc LineProperties )SetSolidFill (c _g .Color ){_bc .clearFill ();_bc ._c .SolidFill =_e .NewCT_SolidColorFillProperties ();_bc ._c .SolidFill .SrgbClr =_e .NewCT_SRgbColor ();_bc ._c .SolidFill .SrgbClr .ValAttr =*c .AsRGBString ();};
2020-08-23 14:15:53 +00:00
2021-06-16 07:10:52 +00:00
// MakeRunProperties constructs a new RunProperties wrapper.
func MakeRunProperties (x *_e .CT_TextCharacterProperties )RunProperties {return RunProperties {x }};func (_ab LineProperties )clearFill (){_ab ._c .NoFill =nil ;_ab ._c .GradFill =nil ;_ab ._c .SolidFill =nil ;_ab ._c .PattFill =nil ;};type ShapeProperties struct{_gc *_e .CT_ShapeProperties };type LineProperties struct{_c *_e .CT_LineProperties };const (LineJoinRound LineJoin =iota ;LineJoinBevel ;LineJoinMiter ;);
2021-04-23 20:00:00 +00:00
2021-06-16 07:10:52 +00:00
// SetLevel sets the level of indentation of a paragraph.
func (_bf ParagraphProperties )SetLevel (idx int32 ){_bf ._dd .LvlAttr =_b .Int32 (idx )};
2020-08-23 14:15:53 +00:00
2021-06-16 07:10:52 +00:00
// SetSize sets the font size of the run text
func (_cgf RunProperties )SetSize (sz _eb .Distance ){_cgf ._fdg .SzAttr =_b .Int32 (int32 (sz /_eb .HundredthPoint ));};
2020-08-23 14:15:53 +00:00
2021-06-16 07:10:52 +00:00
// X returns the inner wrapped XML type.
func (_fd ParagraphProperties )X ()*_e .CT_TextParagraphProperties {return _fd ._dd };func (_aa ShapeProperties )SetNoFill (){_aa .clearFill ();_aa ._gc .NoFill =_e .NewCT_NoFillProperties ()};
2020-08-23 14:15:53 +00:00
2021-06-16 07:10:52 +00:00
// AddRun adds a new run to a paragraph.
func (_ge Paragraph )AddRun ()Run {_af :=MakeRun (_e .NewEG_TextRun ());_ge ._bda .EG_TextRun =append (_ge ._bda .EG_TextRun ,_af .X ());return _af ;};func (_bff ShapeProperties )clearFill (){_bff ._gc .NoFill =nil ;_bff ._gc .BlipFill =nil ;_bff ._gc .GradFill =nil ;_bff ._gc .GrpFill =nil ;_bff ._gc .SolidFill =nil ;_bff ._gc .PattFill =nil ;};
2020-08-23 14:15:53 +00:00
2021-06-16 07:10:52 +00:00
// SetSize sets the width and height of the shape.
func (_de ShapeProperties )SetSize (w ,h _eb .Distance ){_de .SetWidth (w );_de .SetHeight (h )};
2021-04-23 20:00:00 +00:00
2021-05-31 16:22:30 +00:00
// SetPosition sets the position of the shape.
2021-06-16 07:10:52 +00:00
func (_fg ShapeProperties )SetPosition (x ,y _eb .Distance ){_fg .ensureXfrm ();if _fg ._gc .Xfrm .Off ==nil {_fg ._gc .Xfrm .Off =_e .NewCT_Point2D ();};_fg ._gc .Xfrm .Off .XAttr .ST_CoordinateUnqualified =_b .Int64 (int64 (x /_eb .EMU ));_fg ._gc .Xfrm .Off .YAttr .ST_CoordinateUnqualified =_b .Int64 (int64 (y /_eb .EMU ));};
2021-03-16 20:51:18 +00:00
2021-06-16 07:10:52 +00:00
// MakeRun constructs a new Run wrapper.
func MakeRun (x *_e .EG_TextRun )Run {return Run {x }};
2021-03-16 20:51:18 +00:00
2021-06-16 07:10:52 +00:00
// SetJoin sets the line join style.
func (_bd LineProperties )SetJoin (e LineJoin ){_bd ._c .Round =nil ;_bd ._c .Miter =nil ;_bd ._c .Bevel =nil ;switch e {case LineJoinRound :_bd ._c .Round =_e .NewCT_LineJoinRound ();case LineJoinBevel :_bd ._c .Bevel =_e .NewCT_LineJoinBevel ();case LineJoinMiter :_bd ._c .Miter =_e .NewCT_LineJoinMiterProperties ();};};
2020-11-09 01:00:18 +00:00
2021-05-31 16:22:30 +00:00
// SetWidth sets the line width, MS products treat zero as the minimum width
// that can be displayed.
2021-06-16 07:10:52 +00:00
func (_f LineProperties )SetWidth (w _eb .Distance ){_f ._c .WAttr =_b .Int32 (int32 (w /_eb .EMU ))};func (_fdgb ShapeProperties )ensureXfrm (){if _fdgb ._gc .Xfrm ==nil {_fdgb ._gc .Xfrm =_e .NewCT_Transform2D ();};};