unioffice/drawing/drawing.go

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