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