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