unioffice/common/common.go

416 lines
48 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/
// Package common contains wrapper types and utilities common to all of the
// OOXML document formats.
//
// Package common contains common properties used by the subpackages.
2022-09-02 11:46:53 +00:00
package common ;import (_gf "archive/zip";_eg "bytes";_fg "encoding/xml";_ea "errors";_cf "fmt";_cdc "github.com/unidoc/unioffice";_cda "github.com/unidoc/unioffice/common/logger";_baa "github.com/unidoc/unioffice/common/tempstorage";_ba "github.com/unidoc/unioffice/common/tempstorage/diskstore";_ce "github.com/unidoc/unioffice/measurement";_dg "github.com/unidoc/unioffice/schema/soo/dml";_cd "github.com/unidoc/unioffice/schema/soo/ofc/custom_properties";_dc "github.com/unidoc/unioffice/schema/soo/ofc/docPropsVTypes";_bag "github.com/unidoc/unioffice/schema/soo/ofc/extended_properties";_cb "github.com/unidoc/unioffice/schema/soo/pkg/content_types";_gc "github.com/unidoc/unioffice/schema/soo/pkg/metadata/core_properties";_bg "github.com/unidoc/unioffice/schema/soo/pkg/relationships";_a "github.com/unidoc/unioffice/zippkg";_ff "image";_ "image/gif";_ "image/jpeg";_ "image/png";_d "os";_f "reflect";_db "regexp";_gg "strconv";_b "strings";_dd "time";);func (_gfde CustomProperties )SetPropertyAsError (name string ,error string ){_dcf :=_gfde .getNewProperty (name );_dcf .Error =&error ;_gfde .setOrReplaceProperty (_dcf );};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// TableStyles contains document specific properties.
type TableStyles struct{_afa *_dg .TblStyleLst };
2020-08-23 14:15:53 +00:00
2022-06-27 19:44:23 +00:00
// Path returns the path to an image file, if any.
2022-09-02 11:46:53 +00:00
func (_ffgc ImageRef )Path ()string {return _ffgc ._bace .Path };func (_ebf CustomProperties )SetPropertyAsLpwstr (name string ,lpwstr string ){_adb :=_ebf .getNewProperty (name );_adb .Lpwstr =&lpwstr ;_ebf .setOrReplaceProperty (_adb );};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// RelativeWidth returns the relative width of an image given a fixed height.
// This is used when setting image to a fixed height to calculate the width
// required to keep the same image aspect ratio.
func (_afg ImageRef )RelativeWidth (h _ce .Distance )_ce .Distance {_cdae :=float64 (_afg .Size ().X )/float64 (_afg .Size ().Y );return h *_ce .Distance (_cdae );};func (_cbe CustomProperties )SetPropertyAsI2 (name string ,i2 int16 ){_eb :=_cbe .getNewProperty (name );_eb .I2 =&i2 ;_cbe .setOrReplaceProperty (_eb );};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// RemoveOverrideByIndex removes an override given a path and override index.
func (_ffad ContentTypes )RemoveOverrideByIndex (path string ,indexToFind int )error {_ggae :=path [0:len (path )-5];if !_b .HasPrefix (_ggae ,"\u002f"){_ggae ="\u002f"+_ggae ;};_gbc ,_bgf :=_db .Compile (_ggae +"\u0028\u005b\u0030-\u0039\u005d\u002b\u0029\u002e\u0078\u006d\u006c");if _bgf !=nil {return _bgf ;};_gcc :=0;_bdf :=-1;for _ffc ,_cbd :=range _ffad ._gdb .Override {if _egd :=_gbc .FindStringSubmatch (_cbd .PartNameAttr );len (_egd )> 1{if _gcc ==indexToFind {_bdf =_ffc ;}else if _gcc > indexToFind {_gda ,_ :=_gg .Atoi (_egd [1]);_gda --;_cbd .PartNameAttr =_cf .Sprintf ("\u0025\u0073\u0025\u0064\u002e\u0078\u006d\u006c",_ggae ,_gda );};_gcc ++;};};if _bdf > -1{copy (_ffad ._gdb .Override [_bdf :],_ffad ._gdb .Override [_bdf +1:]);_ffad ._gdb .Override =_ffad ._gdb .Override [0:len (_ffad ._gdb .Override )-1];};return nil ;};func (_aedg CustomProperties )SetPropertyAsFiletime (name string ,filetime _dd .Time ){_ebd :=_aedg .getNewProperty (name );_ebd .Filetime =&filetime ;_aedg .setOrReplaceProperty (_ebd );};
2020-10-12 13:59:12 +00:00
2022-09-02 11:46:53 +00:00
// CoreProperties contains document specific properties.
type CoreProperties struct{_bfe *_gc .CoreProperties };func (_fcc CustomProperties )SetPropertyAsUi2 (name string ,ui2 uint16 ){_cac :=_fcc .getNewProperty (name );_cac .Ui2 =&ui2 ;_fcc .setOrReplaceProperty (_cac );};
2020-10-12 13:59:12 +00:00
2022-09-02 11:46:53 +00:00
// SetContentStatus records the content status of the document.
func (_debe CoreProperties )SetContentStatus (s string ){_debe ._bfe .ContentStatus =&s };
2020-10-12 13:59:12 +00:00
2022-09-02 11:46:53 +00:00
// AddImageToZip adds an image (either from bytes or from disk) and adds it to the zip file.
func AddImageToZip (z *_gf .Writer ,img ImageRef ,imageNum int ,dt _cdc .DocType )error {_ebc :=_cdc .AbsoluteImageFilename (dt ,imageNum ,_b .ToLower (img .Format ()));if img .Data ()!=nil &&len (*img .Data ())> 0{if _bfgc :=_a .AddFileFromBytes (z ,_ebc ,*img .Data ());_bfgc !=nil {return _bfgc ;};}else if img .Path ()!=""{if _abc :=_a .AddFileFromDisk (z ,_ebc ,img .Path ());_abc !=nil {return _abc ;};}else {return _cf .Errorf ("\u0075\u006es\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0069\u006d\u0061\u0067\u0065\u0020\u0073\u006f\u0075\u0072\u0063\u0065\u003a %\u002b\u0076",img );};return nil ;};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// SetLastModifiedBy records the last person to modify the document.
func (_aefb CoreProperties )SetLastModifiedBy (s string ){_aefb ._bfe .LastModifiedBy =&s };func (_fde CustomProperties )SetPropertyAsBstr (name string ,bstr string ){_bcb :=_fde .getNewProperty (name );_bcb .Bstr =&bstr ;_fde .setOrReplaceProperty (_bcb );};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// EnsureOverride ensures that an override for the given path exists, adding it if necessary
func (_cee ContentTypes )EnsureOverride (path ,contentType string ){for _ ,_bbdc :=range _cee ._gdb .Override {if _bbdc .PartNameAttr ==path {if _b .HasPrefix (contentType ,"\u0068\u0074\u0074\u0070"){_cda .Log .Debug ("\u0063\u006f\u006e\u0074\u0065\u006et\u0020\u0074\u0079p\u0065\u0020\u0027%\u0073\u0027\u0020\u0069\u0073\u0020\u0069\u006e\u0063\u006fr\u0072\u0065\u0063\u0074\u002c m\u0075\u0073\u0074\u0020\u006e\u006f\u0074\u0020\u0073\u0074\u0061\u0072\u0074\u0020\u0077\u0069\u0074\u0068\u0020\u0068\u0074\u0074\u0070",contentType );};_bbdc .ContentTypeAttr =contentType ;return ;};};_cee .AddOverride (path ,contentType );};func (_cfg CustomProperties )SetPropertyAsOstream (name string ,ostream string ){_aed :=_cfg .getNewProperty (name );_aed .Ostream =&ostream ;_cfg .setOrReplaceProperty (_aed );};func (_cedd CustomProperties )SetPropertyAsUi1 (name string ,ui1 uint8 ){_eba :=_cedd .getNewProperty (name );_eba .Ui1 =&ui1 ;_cedd .setOrReplaceProperty (_eba );};
2021-07-30 17:03:26 +00:00
2022-09-02 11:46:53 +00:00
// RelID returns the relationship ID.
func (_cag ImageRef )RelID ()string {return _cag ._eeb };func (_ega CustomProperties )SetPropertyAsArray (name string ,array *_dc .Array ){_dbe :=_ega .getNewProperty (name );_dbe .Array =array ;_ega .setOrReplaceProperty (_dbe );};func (_fba CustomProperties )setOrReplaceProperty (_gfa *_cd .CT_Property ){_fba .setPropertyHelper (_gfa ,true );};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// NewTableStyles constructs a new TableStyles.
func NewTableStyles ()TableStyles {return TableStyles {_afa :_dg .NewTblStyleLst ()}};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// SetOffsetX sets horizontal offset of a table in distance units (see measurement package).
func (_adg Table )SetOffsetX (offX float64 ){if _adg ._bee .Off ==nil {_adg ._bee .Off =_dg .NewCT_Point2D ();_gbaa :=int64 (0);_adg ._bee .Off .YAttr =_dg .ST_Coordinate {ST_CoordinateUnqualified :&_gbaa };};_cdbb :=_ce .ToEMU (offX );_adg ._bee .Off .XAttr =_dg .ST_Coordinate {ST_CoordinateUnqualified :&_cdbb };};
2021-09-22 16:41:01 +00:00
2022-09-02 11:46:53 +00:00
// RelativeHeight returns the relative height of an image given a fixed width.
// This is used when setting image to a fixed width to calculate the height
// required to keep the same image aspect ratio.
func (_fced ImageRef )RelativeHeight (w _ce .Distance )_ce .Distance {_gefg :=float64 (_fced .Size ().Y )/float64 (_fced .Size ().X );return w *_ce .Distance (_gefg );};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// X returns the inner wrapped XML type.
func (_fbae TableStyles )X ()*_dg .TblStyleLst {return _fbae ._afa };
2020-10-12 13:59:12 +00:00
2022-09-02 11:46:53 +00:00
// SetStyle assigns TableStyle to a table.
func (_fgbae Table )SetStyle (style *_dg .CT_TableStyle ){if _fgbae ._dega .TblPr ==nil {_fgbae ._dega .TblPr =_dg .NewCT_TableProperties ();};if _fgbae ._dega .TblPr .Choice ==nil {_fgbae ._dega .TblPr .Choice =_dg .NewCT_TablePropertiesChoice ();};_fgbae ._dega .TblPr .Choice .TableStyle =style ;};
2022-02-05 13:05:36 +00:00
2022-06-27 19:44:23 +00:00
// ContentStatus returns the content status of the document (e.g. "Final", "Draft")
2022-09-02 11:46:53 +00:00
func (_egg CoreProperties )ContentStatus ()string {if _egg ._bfe .ContentStatus !=nil {return *_egg ._bfe .ContentStatus ;};return "";};
2022-02-05 13:05:36 +00:00
2022-09-02 11:46:53 +00:00
// WriteExtraFiles writes the extra files to the zip package.
func (_effc *DocBase )WriteExtraFiles (z *_gf .Writer )error {for _ ,_dab :=range _effc .ExtraFiles {if _cge :=_a .AddFileFromDisk (z ,_dab .ZipPath ,_dab .DiskPath );_cge !=nil {return _cge ;};};return nil ;};
2020-10-12 13:59:12 +00:00
2022-09-02 11:46:53 +00:00
// GetTargetByRelIdAndType returns a target path with the associated relation ID.
func (_fcdd Relationships )GetTargetByRelIdAndType (idAttr string ,typeAttr string )string {for _ ,_befgg :=range _fcdd ._eag .Relationship {if _befgg .IdAttr ==idAttr &&_befgg .TypeAttr ==typeAttr {return _befgg .TargetAttr ;};};return "";};
2020-10-12 13:59:12 +00:00
2022-09-02 11:46:53 +00:00
// SetCategory records the category of the document.
func (_gac CoreProperties )SetCategory (s string ){_gac ._bfe .Category =&s };
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// GetPropertyByName returns a custom property selected by it's name.
func (_gag CustomProperties )GetPropertyByName (name string )CustomProperty {_fab :=_gag ._cea .Property ;for _ ,_cad :=range _fab {if *_cad .NameAttr ==name {return CustomProperty {_eab :_cad };};};return CustomProperty {};};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// ImageFromStorage reads an image using the currently set
// temporary storage mechanism (see tempstorage). You can also
// construct an Image directly if the file and size are known.
func ImageFromStorage (path string )(Image ,error ){_efc :=Image {};_ead ,_aegf :=_baa .Open (path );if _aegf !=nil {return _efc ,_cf .Errorf ("\u0065\u0072\u0072or\u0020\u0072\u0065\u0061\u0064\u0069\u006e\u0067\u0020\u0069\u006d\u0061\u0067\u0065\u003a\u0020\u0025\u0073",_aegf );};defer _ead .Close ();_bagd ,_abe ,_aegf :=_ff .Decode (_ead );if _aegf !=nil {return _efc ,_cf .Errorf ("\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s",_aegf );};_efc .Path =path ;_efc .Format =_abe ;_efc .Size =_bagd .Bounds ().Size ();return _efc ,nil ;};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// Modified returns the time that the document was modified.
func (_cgf CoreProperties )Modified ()_dd .Time {return _gef (_cgf ._bfe .Modified )};func _ecc (_ecb _dd .Time ,_ggd string )*_cdc .XSDAny {_dbce :=&_cdc .XSDAny {XMLName :_fg .Name {Local :_ggd }};_dbce .Attrs =append (_dbce .Attrs ,_fg .Attr {Name :_fg .Name {Local :"\u0078\u0073\u0069\u003a\u0074\u0079\u0070\u0065"},Value :"\u0064\u0063\u0074\u0065\u0072\u006d\u0073\u003a\u00573\u0043\u0044\u0054\u0046"});_dbce .Attrs =append (_dbce .Attrs ,_fg .Attr {Name :_fg .Name {Local :"\u0078m\u006c\u006e\u0073\u003a\u0078\u0073i"},Value :"\u0068\u0074\u0074\u0070\u003a/\u002f\u0077\u0077\u0077\u002e\u0077\u0033\u002e\u006f\u0072\u0067\u002f\u00320\u0030\u0031\u002f\u0058\u004d\u004c\u0053\u0063\u0068\u0065\u006d\u0061\u002d\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065"});_dbce .Attrs =append (_dbce .Attrs ,_fg .Attr {Name :_fg .Name {Local :"\u0078\u006d\u006c\u006e\u0073\u003a\u0064\u0063\u0074\u0065\u0072\u006d\u0073"},Value :"\u0068t\u0074\u0070\u003a\u002f/\u0070\u0075\u0072\u006c\u002eo\u0072g\u002fd\u0063\u002f\u0074\u0065\u0072\u006d\u0073/"});_dbce .Data =[]byte (_ecb .Format (_agg ));return _dbce ;};func (_bcea *ImageRef )SetRelID (id string ){_bcea ._eeb =id };func (_faeb CustomProperties )SetPropertyAsCy (name string ,cy string ){_aab :=_faeb .getNewProperty (name );_aab .Cy =&cy ;_faeb .setOrReplaceProperty (_aab );};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// AddOverride adds an override content type for a given path name.
func (_ece ContentTypes )AddOverride (path ,contentType string ){if !_b .HasPrefix (path ,"\u002f"){path ="\u002f"+path ;};if _b .HasPrefix (contentType ,"\u0068\u0074\u0074\u0070"){_cda .Log .Debug ("\u0063\u006f\u006e\u0074\u0065\u006et\u0020\u0074\u0079p\u0065\u0020\u0027%\u0073\u0027\u0020\u0069\u0073\u0020\u0069\u006e\u0063\u006fr\u0072\u0065\u0063\u0074\u002c m\u0075\u0073\u0074\u0020\u006e\u006f\u0074\u0020\u0073\u0074\u0061\u0072\u0074\u0020\u0077\u0069\u0074\u0068\u0020\u0068\u0074\u0074\u0070",contentType );};for _ ,_eff :=range _ece ._gdb .Override {if _eff .PartNameAttr ==path &&_eff .ContentTypeAttr ==contentType {return ;};};_befg :=_cb .NewOverride ();_befg .PartNameAttr =path ;_befg .ContentTypeAttr =contentType ;_ece ._gdb .Override =append (_ece ._gdb .Override ,_befg );};
2021-03-16 20:51:18 +00:00
2022-09-02 11:46:53 +00:00
// AddExtraFileFromZip is used when reading an unsupported file from an OOXML
// file. This ensures that unsupported file content will at least round-trip
// correctly.
func (_dea *DocBase )AddExtraFileFromZip (f *_gf .File )error {_ceca ,_gdc :=_a .ExtractToDiskTmp (f ,_dea .TmpPath );if _gdc !=nil {return _cf .Errorf ("\u0065\u0072r\u006f\u0072\u0020\u0065x\u0074\u0072a\u0063\u0074\u0069\u006e\u0067\u0020\u0075\u006es\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0066\u0069\u006ce\u003a\u0020\u0025\u0073",_gdc );};_dea .ExtraFiles =append (_dea .ExtraFiles ,ExtraFile {ZipPath :f .Name ,DiskPath :_ceca });return nil ;};const _cagd =30;
2021-08-23 20:44:48 +00:00
2022-09-02 11:46:53 +00:00
// Application returns the name of the application that created the document.
// For unioffice created documents, it defaults to github.com/unidoc/unioffice
func (_bde AppProperties )Application ()string {if _bde ._gca .Application !=nil {return *_bde ._gca .Application ;};return "";};const _cdgg =2022;
2020-11-09 01:00:18 +00:00
2022-09-02 11:46:53 +00:00
// Theme is a drawingml theme.
type Theme struct{_ffeg *_dg .Theme };
2020-11-09 01:00:18 +00:00
2022-09-02 11:46:53 +00:00
// NewTableWithXfrm makes a new table with a pointer to its parent Xfrm for changing its offset and size.
func NewTableWithXfrm (xfrm *_dg .CT_Transform2D )*Table {_efed :=_dg .NewTbl ();_efed .TblPr =_dg .NewCT_TableProperties ();return &Table {_dega :_efed ,_bee :xfrm };};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// CopyRelationship copies the relationship.
func (_egb Relationships )CopyRelationship (idAttr string )(Relationship ,bool ){for _fga :=range _egb ._eag .Relationship {if _egb ._eag .Relationship [_fga ].IdAttr ==idAttr {_bbdd :=*_egb ._eag .Relationship [_fga ];_ceeg :=len (_egb ._eag .Relationship )+1;_bfbc :=map[string ]struct{}{};for _ ,_bfge :=range _egb ._eag .Relationship {_bfbc [_bfge .IdAttr ]=struct{}{};};for _ ,_ddb :=_bfbc [_cf .Sprintf ("\u0072\u0049\u0064%\u0064",_ceeg )];_ddb ;_ ,_ddb =_bfbc [_cf .Sprintf ("\u0072\u0049\u0064%\u0064",_ceeg )]{_ceeg ++;};_bbdd .IdAttr =_cf .Sprintf ("\u0072\u0049\u0064%\u0064",_ceeg );_egb ._eag .Relationship =append (_egb ._eag .Relationship ,&_bbdd );return Relationship {_cead :&_bbdd },true ;};};return Relationship {},false ;};const _gcfa ="\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034";func (_baad CustomProperties )SetPropertyAsR4 (name string ,r4 float32 ){_cgac :=_baad .getNewProperty (name );_cgac .R4 =&r4 ;_baad .setOrReplaceProperty (_cgac );};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// Relationship is a relationship within a .rels file.
type Relationship struct{_cead *_bg .Relationship };const Version ="\u0031\u002e\u0032\u0031\u002e\u0030";func (_gbcce CustomProperties )SetPropertyAsInt (name string ,i int ){_ecfb :=_gbcce .getNewProperty (name );_bdb :=int32 (i );_ecfb .Int =&_bdb ;_gbcce .setOrReplaceProperty (_ecfb );};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// Target returns the target attrubute of the image reference (a path where the image file is located in the document structure).
func (_ebg *ImageRef )Target ()string {return _ebg ._bbf };
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// X returns the inner wrapped XML type.
func (_gga AppProperties )X ()*_bag .Properties {return _gga ._gca };func (_cfe Relationship )String ()string {return _cf .Sprintf ("\u007b\u0049\u0044\u003a \u0025\u0073\u0020\u0054\u0061\u0072\u0067\u0065\u0074\u003a \u0025s\u0020\u0054\u0079\u0070\u0065\u003a\u0020%\u0073\u007d",_cfe .ID (),_cfe .Target (),_cfe .Type ());};
2022-02-05 13:05:36 +00:00
2022-09-02 11:46:53 +00:00
// GetImageBytesByTarget returns Image object with Data bytes read from its target.
func (_caf *DocBase )GetImageBytesByTarget (target string )(Image ,error ){if target !=""{target ="\u0077\u006f\u0072d\u002f"+target ;for _ ,_efe :=range _caf .Images {if _efe .Target ()==target {return ImageFromStorage (_efe .Path ());};};};return Image {},_egac ;};func (_afc CustomProperties )SetPropertyAsDate (name string ,date _dd .Time ){date =date .UTC ();_bfgb ,_fcf ,_cbed :=date .Date ();_edde ,_cecd ,_fbe :=date .Clock ();_bbb :=_dd .Date (_bfgb ,_fcf ,_cbed ,_edde ,_cecd ,_fbe ,0,_dd .UTC );_cgb :=_afc .getNewProperty (name );_cgb .Filetime =&_bbb ;_afc .setOrReplaceProperty (_cgb );};
2021-07-30 17:03:26 +00:00
2022-09-02 11:46:53 +00:00
// Target returns the target (path) of a relationship.
func (_eacg Relationship )Target ()string {return _eacg ._cead .TargetAttr };
2021-05-31 16:22:30 +00:00
2022-09-02 11:46:53 +00:00
// MakeImageRef constructs an image reference which is a reference to a
// particular image file inside a document. The same image can be used multiple
// times in a document by re-use the ImageRef.
func MakeImageRef (img Image ,d *DocBase ,rels Relationships )ImageRef {return ImageRef {_bace :img ,_dbcc :d ,_gce :rels };};func (_gbe CustomProperties )SetPropertyAsUint (name string ,ui uint ){_edd :=_gbe .getNewProperty (name );_fce :=uint32 (ui );_edd .Uint =&_fce ;_gbe .setOrReplaceProperty (_edd );};
2022-02-25 19:20:45 +00:00
2022-09-02 11:46:53 +00:00
// AddCustomRelationships adds relationships related to custom properties to the document.
func (_fge *DocBase )AddCustomRelationships (){_fge .ContentTypes .AddOverride ("/\u0064o\u0063\u0050\u0072\u006f\u0070\u0073\u002f\u0063u\u0073\u0074\u006f\u006d.x\u006d\u006c","\u0061\u0070\u0070\u006c\u0069\u0063a\u0074\u0069\u006f\u006e\u002fv\u006e\u0064\u002e\u006f\u0070\u0065n\u0078\u006d\u006c\u0066\u006fr\u006d\u0061\u0074\u0073\u002d\u006f\u0066\u0066\u0069\u0063\u0065\u0064o\u0063\u0075\u006d\u0065\u006e\u0074\u002e\u0063\u0075\u0073\u0074\u006f\u006d\u002d\u0070r\u006f\u0070\u0065\u0072\u0074\u0069\u0065\u0073+\u0078\u006d\u006c");_fge .Rels .AddRelationship ("\u0064\u006f\u0063\u0050ro\u0070\u0073\u002f\u0063\u0075\u0073\u0074\u006f\u006d\u002e\u0078\u006d\u006c",_cdc .CustomPropertiesType );};func (_ffb CustomProperties )SetPropertyAsUi4 (name string ,ui4 uint32 ){_gcf :=_ffb .getNewProperty (name );_gcf .Ui4 =&ui4 ;_ffb .setOrReplaceProperty (_gcf );};
2021-09-22 16:41:01 +00:00
2022-09-02 11:46:53 +00:00
// ExtraFile is an unsupported file type extracted from, or to be written to a
// zip package
type ExtraFile struct{ZipPath string ;DiskPath string ;};func (_dcg CustomProperties )SetPropertyAsBool (name string ,b bool ){_gge :=_dcg .getNewProperty (name );_gge .Bool =&b ;_dcg .setOrReplaceProperty (_gge );};
2021-09-22 16:41:01 +00:00
2022-09-02 11:46:53 +00:00
// Image is a container for image information. It's used as we need format and
// and size information to use images.
// It contains either the filesystem path to the image, or the image itself.
type Image struct{Size _ff .Point ;Format string ;Path string ;Data *[]byte ;};
2021-09-22 16:41:01 +00:00
2022-09-02 11:46:53 +00:00
// DefAttr returns the DefAttr property.
func (_aagg TableStyles )DefAttr ()string {return _aagg ._afa .DefAttr };
2021-05-31 16:22:30 +00:00
2022-09-02 11:46:53 +00:00
// X returns the inner wrapped XML type.
func (_fefd Theme )X ()*_dg .Theme {return _fefd ._ffeg };
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// FindRIDForN returns the relationship ID for the i'th relationship of type t.
func (_dgb Relationships )FindRIDForN (i int ,t string )string {for _ ,_eefc :=range _dgb ._eag .CT_Relationships .Relationship {if _eefc .TypeAttr ==t {if i ==0{return _eefc .IdAttr ;};i --;};};return "";};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// ImageRef is a reference to an image within a document.
type ImageRef struct{_dbcc *DocBase ;_gce Relationships ;_bace Image ;_eeb string ;_bbf string ;};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// ApplicationVersion returns the version of the application that created the
// document.
func (_gb AppProperties )ApplicationVersion ()string {if _gb ._gca .AppVersion !=nil {return *_gb ._gca .AppVersion ;};return "";};func (_fbd CustomProperties )SetPropertyAsOblob (name ,oblob string ){_da :=_fbd .getNewProperty (name );_da .Oblob =&oblob ;_fbd .setOrReplaceProperty (_da );};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// Company returns the name of the company that created the document.
// For unioffice created documents, it defaults to github.com/unidoc/unioffice
func (_cbc AppProperties )Company ()string {if _cbc ._gca .Company !=nil {return *_cbc ._gca .Company ;};return "";};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// Table represents a table in the document.
type Table struct{_dega *_dg .Tbl ;_bee *_dg .CT_Transform2D ;};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// NewRelationshipsCopy creates a new relationships wrapper as a copy of passed in instance.
func NewRelationshipsCopy (rels Relationships )Relationships {_cc :=*rels ._eag ;return Relationships {_eag :&_cc };};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// NewCustomProperties constructs a new CustomProperties.
func NewCustomProperties ()CustomProperties {return CustomProperties {_cea :_cd .NewProperties ()}};func (_aee CustomProperties )SetPropertyAsStream (name string ,stream string ){_aaa :=_aee .getNewProperty (name );_aaa .Stream =&stream ;_aee .setOrReplaceProperty (_aaa );};const _agg ="2\u00300\u0036\u002d\u0030\u0031\u002d\u0030\u0032\u00541\u0035\u003a\u0030\u0034:0\u0035\u005a";
2020-10-12 13:59:12 +00:00
2022-09-02 11:46:53 +00:00
// GetOrCreateCustomProperties returns the custom properties of the document (and if they not exist yet, creating them first).
func (_gefd *DocBase )GetOrCreateCustomProperties ()CustomProperties {if _gefd .CustomProperties .X ()==nil {_gefd .CreateCustomProperties ();};return _gefd .CustomProperties ;};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// AddDefault registers a default content type for a given file extension.
func (_aef ContentTypes )AddDefault (fileExtension string ,contentType string ){fileExtension =_b .ToLower (fileExtension );for _ ,_ga :=range _aef ._gdb .Default {if _ga .ExtensionAttr ==fileExtension &&_ga .ContentTypeAttr ==contentType {return ;};};_bcd :=_cb .NewDefault ();_bcd .ExtensionAttr =fileExtension ;_bcd .ContentTypeAttr =contentType ;_aef ._gdb .Default =append (_aef ._gdb .Default ,_bcd );};
2022-02-05 13:05:36 +00:00
2022-09-02 11:46:53 +00:00
// Description returns the description of the document
func (_ffg CoreProperties )Description ()string {if _ffg ._bfe .Description !=nil {return string (_ffg ._bfe .Description .Data );};return "";};var _egac =_ea .New ("\u0069\u006d\u0061\u0067\u0065\u0020\u006e\u006f\u0074\u0020\u0066o\u0075\u006e\u0064\u0020\u0069\u006e\u0020\u0073\u0074\u006fr\u0061\u0067\u0065");
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// Title returns the Title of the document
func (_gfcd CoreProperties )Title ()string {if _gfcd ._bfe .Title !=nil {return string (_gfcd ._bfe .Title .Data );};return "";};
2021-06-16 07:10:52 +00:00
2022-09-02 11:46:53 +00:00
// AddHyperlink adds an external hyperlink relationship.
func (_eed Relationships )AddHyperlink (target string )Hyperlink {_dfb :=_eed .AddRelationship (target ,_cdc .HyperLinkType );_dfb ._cead .TargetModeAttr =_bg .ST_TargetModeExternal ;return Hyperlink (_dfb );};
2021-06-16 07:10:52 +00:00
2022-09-02 11:46:53 +00:00
// Created returns the time that the document was created.
func (_fcd CoreProperties )Created ()_dd .Time {return _gef (_fcd ._bfe .Created )};
2021-06-16 07:10:52 +00:00
2022-09-02 11:46:53 +00:00
// Relationships represents a .rels file.
type Relationships struct{_eag *_bg .Relationships };
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// Properties returns table properties.
func (_cgeg Table )Grid ()*_dg .CT_TableGrid {return _cgeg ._dega .TblGrid };
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// Size returns the size of an image
func (_cbf ImageRef )Size ()_ff .Point {return _cbf ._bace .Size };func (_gagb CustomProperties )getNewProperty (_ceg string )*_cd .CT_Property {_bac :=_gagb ._cea .Property ;_ced :=int32 (1);for _ ,_dde :=range _bac {if _dde .PidAttr > _ced {_ced =_dde .PidAttr ;};};_gcgd :=_cd .NewCT_Property ();_gcgd .NameAttr =&_ceg ;_gcgd .PidAttr =_ced +1;_gcgd .FmtidAttr ="\u007b\u0044\u0035\u0043\u0044\u0044\u0035\u0030\u0035\u002d\u0032\u0045\u0039\u0043\u002d\u0031\u0030\u0031\u0042\u002d\u0039\u0033\u0039\u0037-\u0030\u0038\u0030\u0030\u0032B\u0032\u0043F\u0039\u0041\u0045\u007d";return _gcgd ;};
2022-04-09 14:27:46 +00:00
2022-09-02 11:46:53 +00:00
// SetApplication sets the name of the application that created the document.
func (_ag AppProperties )SetApplication (s string ){_ag ._gca .Application =&s };
2022-04-09 14:27:46 +00:00
2022-09-02 11:46:53 +00:00
// Pages returns total number of pages which are saved by the text editor which produced the document.
// For unioffice created documents, it is 0.
func (_affg AppProperties )Pages ()int32 {if _affg ._gca .Pages !=nil {return *_affg ._gca .Pages ;};return 0;};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// TblStyle returns the TblStyle property.
func (_fgfg TableStyles )TblStyle ()[]*_dg .CT_TableStyle {return _fgfg ._afa .TblStyle };const _gfdef =15;
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// AddAutoRelationship adds a relationship with an automatically generated
// filename based off of the type. It should be preferred over AddRelationship
// to ensure consistent filenames are maintained.
func (_cgec Relationships )AddAutoRelationship (dt _cdc .DocType ,src string ,idx int ,ctype string )Relationship {return _cgec .AddRelationship (_cdc .RelativeFilename (dt ,src ,ctype ,idx ),ctype );};func (_cfd CustomProperties )SetPropertyAsI8 (name string ,i8 int64 ){_dda :=_cfd .getNewProperty (name );_dda .I8 =&i8 ;_cfd .setOrReplaceProperty (_dda );};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// CreateCustomProperties creates the custom properties of the document.
func (_dfe *DocBase )CreateCustomProperties (){_dfe .CustomProperties =NewCustomProperties ();_dfe .AddCustomRelationships ();};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// Category returns the category of the document
func (_ee CoreProperties )Category ()string {if _ee ._bfe .Category !=nil {return *_ee ._bfe .Category ;};return "";};
2021-11-10 11:45:21 +00:00
2022-09-02 11:46:53 +00:00
// SetDescription records the description of the document.
func (_cdg CoreProperties )SetDescription (s string ){if _cdg ._bfe .Description ==nil {_cdg ._bfe .Description =&_cdc .XSDAny {XMLName :_fg .Name {Local :"\u0064\u0063\u003a\u0064\u0065\u0073\u0063\u0072\u0069p\u0074\u0069\u006f\u006e"}};};_cdg ._bfe .Description .Data =[]byte (s );};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// X returns the inner wrapped XML type of CustomProperty.
func (_ddc CustomProperty )X ()*_cd .CT_Property {return _ddc ._eab };
2021-04-23 20:00:00 +00:00
2022-06-27 19:44:23 +00:00
// X returns the inner wrapped XML type.
2022-09-02 11:46:53 +00:00
func (_gagbe Table )X ()*_dg .Tbl {return _gagbe ._dega };
2020-08-23 14:15:53 +00:00
2022-06-27 19:44:23 +00:00
// SetTarget changes the target attribute of the image reference (e.g. in the case of the creation of the reference or if the image which the reference is related to was moved from one location to another).
2022-09-02 11:46:53 +00:00
func (_dgf *ImageRef )SetTarget (target string ){_dgf ._bbf =target };
2022-04-09 14:27:46 +00:00
2022-09-02 11:46:53 +00:00
// SetDocSecurity sets the document security flag.
func (_ffee AppProperties )SetDocSecurity (v int32 ){_ffee ._gca .DocSecurity =_cdc .Int32 (v )};func (_ggaeg CustomProperties )SetPropertyAsOstorage (name string ,ostorage string ){_gaf :=_ggaeg .getNewProperty (name );_gaf .Ostorage =&ostorage ;_ggaeg .setOrReplaceProperty (_gaf );};
2021-05-31 16:22:30 +00:00
2022-09-02 11:46:53 +00:00
// RemoveOverride removes an override given a path.
func (_fec ContentTypes )RemoveOverride (path string ){if !_b .HasPrefix (path ,"\u002f"){path ="\u002f"+path ;};for _fgb ,_cg :=range _fec ._gdb .Override {if _cg .PartNameAttr ==path {copy (_fec ._gdb .Override [_fgb :],_fec ._gdb .Override [_fgb +1:]);_fec ._gdb .Override =_fec ._gdb .Override [0:len (_fec ._gdb .Override )-1];};};};func (_cec CustomProperties )SetPropertyAsUi8 (name string ,ui8 uint64 ){_cede :=_cec .getNewProperty (name );_cede .Ui8 =&ui8 ;_cec .setOrReplaceProperty (_cede );};
2021-05-31 16:22:30 +00:00
2022-09-02 11:46:53 +00:00
// Data returns the data of an image file, if any.
func (_fccc ImageRef )Data ()*[]byte {return _fccc ._bace .Data };
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// NewTheme constructs a new theme.
func NewTheme ()Theme {return Theme {_dg .NewTheme ()}};func (_cbdf CustomProperties )SetPropertyAsVector (name string ,vector *_dc .Vector ){_gbcc :=_cbdf .getNewProperty (name );_gbcc .Vector =vector ;_cbdf .setOrReplaceProperty (_gbcc );};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// EnsureDefault esnures that an extension and default content type exist,
// adding it if necessary.
func (_fa ContentTypes )EnsureDefault (ext ,contentType string ){ext =_b .ToLower (ext );for _ ,_bae :=range _fa ._gdb .Default {if _bae .ExtensionAttr ==ext {_bae .ContentTypeAttr =contentType ;return ;};};_fb :=&_cb .Default {};_fb .ContentTypeAttr =contentType ;_fb .ExtensionAttr =ext ;_fa ._gdb .Default =append (_fa ._gdb .Default ,_fb );};
2020-08-23 14:15:53 +00:00
2022-09-02 11:46:53 +00:00
// PropertiesList returns the list of all custom properties of the document.
func (_bfec CustomProperties )PropertiesList ()[]*_cd .CT_Property {return _bfec ._cea .Property };
2021-11-10 11:45:21 +00:00
2022-09-02 11:46:53 +00:00
// NewTable makes a new table.
func NewTable ()*Table {_ded :=_dg .NewTbl ();_ded .TblPr =_dg .NewCT_TableProperties ();return &Table {_dega :_ded };};
2021-11-10 11:45:21 +00:00
2022-09-02 11:46:53 +00:00
// SetLanguage records the language of the document.
func (_bfb CoreProperties )SetLanguage (s string ){_bfb ._bfe .Language =&_cdc .XSDAny {XMLName :_fg .Name {Local :"d\u0063\u003a\u006c\u0061\u006e\u0067\u0075\u0061\u0067\u0065"}};_bfb ._bfe .Language .Data =[]byte (s );};
2020-10-12 13:59:12 +00:00
2022-09-02 11:46:53 +00:00
// SetHeight sets row height, see measurement package.
func (_aaf TableRow )SetHeight (m _ce .Distance ){_daa :=_ce .ToEMU (float64 (m ));_aaf ._bcf .HAttr =_dg .ST_Coordinate {ST_CoordinateUnqualified :&_daa };};func (_acf CustomProperties )SetPropertyAsBlob (name ,blob string ){_cae :=_acf .getNewProperty (name );_cae .Blob =&blob ;_acf .setOrReplaceProperty (_cae );};func (_ddea CustomProperties )SetPropertyAsVstream (name string ,vstream *_dc .Vstream ){_feca :=_ddea .getNewProperty (name );_feca .Vstream =vstream ;_ddea .setOrReplaceProperty (_feca );};func _gef (_cga *_cdc .XSDAny )_dd .Time {if _cga ==nil {return _dd .Time {};};_ged ,_fgba :=_dd .Parse (_agg ,string (_cga .Data ));if _fgba !=nil {_cda .Log .Debug ("\u0065\u0072\u0072\u006f\u0072\u0020\u0070\u0061\u0072\u0073i\u006e\u0067\u0020\u0074\u0069\u006d\u0065 \u0066\u0072\u006f\u006d\u0020\u0025\u0073\u003a\u0020\u0025\u0073",string (_cga .Data ),_fgba );};return _ged ;};
2021-11-10 11:45:21 +00:00
2022-09-02 11:46:53 +00:00
// X returns the inner raw content types.
func (_caa ContentTypes )X ()*_cb .Types {return _caa ._gdb };
2021-11-10 11:45:21 +00:00
2022-09-02 11:46:53 +00:00
// CustomProperties contains document specific properties.
type CustomProperties struct{_cea *_cd .Properties };
2021-11-10 11:45:21 +00:00
2022-09-02 11:46:53 +00:00
// DocBase is the type embedded in in the Document/Workbook/Presentation types
// that contains members common to all.
type DocBase struct{ContentTypes ContentTypes ;AppProperties AppProperties ;Rels Relationships ;CoreProperties CoreProperties ;CustomProperties CustomProperties ;Thumbnail _ff .Image ;Images []ImageRef ;ExtraFiles []ExtraFile ;TmpPath string ;};
2021-11-10 11:45:21 +00:00
2022-09-02 11:46:53 +00:00
// SetID set the ID of a relationship.
func (_gdba Relationship )SetID (ID string ){_gdba ._cead .IdAttr =ID ;};
2021-11-10 11:45:21 +00:00
2022-09-02 11:46:53 +00:00
// Hyperlink is just an appropriately configured relationship.
type Hyperlink Relationship ;
2022-04-09 14:27:46 +00:00
2022-06-27 19:44:23 +00:00
// Type returns the type of a relationship.
2022-09-02 11:46:53 +00:00
func (_cafb Relationship )Type ()string {return _cafb ._cead .TypeAttr };
2021-06-16 07:10:52 +00:00
2022-09-02 11:46:53 +00:00
// SetModified sets the time that the document was modified.
func (_dga CoreProperties )SetModified (t _dd .Time ){_dga ._bfe .Modified =_ecc (t ,"\u0064\u0063t\u0065\u0072\u006ds\u003a\u006d\u006f\u0064\u0069\u0066\u0069\u0065\u0064");};
2022-01-15 21:17:38 +00:00
2022-09-02 11:46:53 +00:00
// ImageFromFile reads an image from a file on disk. It doesn't keep the image
// in memory and only reads it to determine the format and size. You can also
// construct an Image directly if the file and size are known.
// NOTE: See also ImageFromStorage.
func ImageFromFile (path string )(Image ,error ){_ggec ,_caec :=_d .Open (path );_eac :=Image {};if _caec !=nil {return _eac ,_cf .Errorf ("\u0065\u0072\u0072or\u0020\u0072\u0065\u0061\u0064\u0069\u006e\u0067\u0020\u0069\u006d\u0061\u0067\u0065\u003a\u0020\u0025\u0073",_caec );};defer _ggec .Close ();_dcb ,_cfb ,_caec :=_ff .Decode (_ggec );if _caec !=nil {return _eac ,_cf .Errorf ("\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s",_caec );};_eac .Path =path ;_eac .Format =_cfb ;_eac .Size =_dcb .Bounds ().Size ();return _eac ,nil ;};func (_efg CustomProperties )SetPropertyAsEmpty (name string ){_fac :=_efg .getNewProperty (name );_fac .Empty =_dc .NewEmpty ();_efg .setOrReplaceProperty (_fac );};
2020-10-12 13:59:12 +00:00
2022-09-02 11:46:53 +00:00
// Rows returns all table rows.
func (_bcbf Table )Rows ()[]*TableRow {_bced :=_bcbf ._dega .Tr ;_fcg :=[]*TableRow {};for _ ,_gfae :=range _bced {_fcg =append (_fcg ,&TableRow {_bcf :_gfae });};return _fcg ;};const _afb =8;
2021-05-31 16:22:30 +00:00
2022-09-02 11:46:53 +00:00
// Cells returns an array of row cells.
func (_gbdf TableRow )Cells ()[]*_dg .CT_TableCell {return _gbdf ._bcf .Tc };
2021-05-31 16:22:30 +00:00
2022-09-02 11:46:53 +00:00
// Author returns the author of the document
func (_egf CoreProperties )Author ()string {if _egf ._bfe .Creator !=nil {return string (_egf ._bfe .Creator .Data );};return "";};
2022-01-15 21:17:38 +00:00
2022-09-02 11:46:53 +00:00
// IsEmpty returns true if there are no relationships.
func (_aag Relationships )IsEmpty ()bool {return _aag ._eag ==nil ||len (_aag ._eag .Relationship )==0};
2022-01-15 21:17:38 +00:00
2022-09-02 11:46:53 +00:00
// GetTargetByRelId returns a target path with the associated relation ID.
func (_acfg Relationships )GetTargetByRelId (idAttr string )string {for _ ,_efd :=range _acfg ._eag .Relationship {if _efd .IdAttr ==idAttr {return _efd .TargetAttr ;};};return "";};
2022-01-15 21:17:38 +00:00
2022-09-02 11:46:53 +00:00
// GetByRelId returns a relationship with the associated relation ID.
func (_fcfc Relationships )GetByRelId (idAttr string )Relationship {for _ ,_eefcb :=range _fcfc ._eag .Relationship {if _eefcb .IdAttr ==idAttr {return Relationship {_cead :_eefcb };};};return Relationship {};};const _gdgb =31;func (_bce CustomProperties )SetPropertyAsLpstr (name string ,lpstr string ){_faf :=_bce .getNewProperty (name );_faf .Lpstr =&lpstr ;_bce .setOrReplaceProperty (_faf );};
2021-06-16 07:10:52 +00:00
2022-09-02 11:46:53 +00:00
// SetTitle records the title of the document.
func (_dfd CoreProperties )SetTitle (s string ){if _dfd ._bfe .Title ==nil {_dfd ._bfe .Title =&_cdc .XSDAny {XMLName :_fg .Name {Local :"\u0064\u0063\u003a\u0074\u0069\u0074\u006c\u0065"}};};_dfd ._bfe .Title .Data =[]byte (s );};func (_fdc CustomProperties )setPropertyHelper (_efb *_cd .CT_Property ,_gefe bool ){_cdaf :=_fdc .GetPropertyByName (*_efb .NameAttr );if (_cdaf ==CustomProperty {}){_fdc ._cea .Property =append (_fdc ._cea .Property ,_efb );}else if _gefe {_efb .FmtidAttr =_cdaf ._eab .FmtidAttr ;if _cdaf ._eab .PidAttr ==0{_efb .PidAttr =_cdaf ._eab .PidAttr ;};_efb .LinkTargetAttr =_cdaf ._eab .LinkTargetAttr ;*_cdaf ._eab =*_efb ;};};func (_bfg CustomProperties )SetPropertyAsR8 (name string ,r8 float64 ){_bgc :=_bfg .getNewProperty (name );_bgc .R8 =&r8 ;_bfg .setOrReplaceProperty (_bgc );};
2022-01-15 21:17:38 +00:00
2022-06-27 19:44:23 +00:00
// X returns the inner wrapped XML type.
2022-09-02 11:46:53 +00:00
func (_feg Relationship )X ()*_bg .Relationship {return _feg ._cead };
2022-01-15 21:17:38 +00:00
2022-09-02 11:46:53 +00:00
// SetTarget set the target (path) of a relationship.
func (_affe Relationship )SetTarget (s string ){_affe ._cead .TargetAttr =s };
2020-11-09 01:00:18 +00:00
2022-09-02 11:46:53 +00:00
// LastModifiedBy returns the name of the last person to modify the document
func (_bfeb CoreProperties )LastModifiedBy ()string {if _bfeb ._bfe .LastModifiedBy !=nil {return *_bfeb ._bfe .LastModifiedBy ;};return "";};
2020-11-09 01:00:18 +00:00
2022-09-02 11:46:53 +00:00
// SetCreated sets the time that the document was created.
func (_ffef CoreProperties )SetCreated (t _dd .Time ){_ffef ._bfe .Created =_ecc (t ,"\u0064c\u0074e\u0072\u006d\u0073\u003a\u0063\u0072\u0065\u0061\u0074\u0065\u0064");};func (_aa CustomProperties )SetPropertyAsDecimal (name string ,decimal float64 ){_acfe :=_aa .getNewProperty (name );_acfe .Decimal =&decimal ;_aa .setOrReplaceProperty (_acfe );};
2020-12-17 22:07:08 +00:00
2022-09-02 11:46:53 +00:00
// NewCoreProperties constructs a new CoreProperties.
func NewCoreProperties ()CoreProperties {return CoreProperties {_bfe :_gc .NewCoreProperties ()}};func UtcTimeFormat (t _dd .Time )string {return t .Format (_gcfa )+"\u0020\u0055\u0054\u0043"};
2020-12-17 22:07:08 +00:00
2022-09-02 11:46:53 +00:00
// ContentTypes is the top level "[Content_Types].xml" in a zip package.
type ContentTypes struct{_gdb *_cb .Types };
2020-12-17 22:07:08 +00:00
2022-09-02 11:46:53 +00:00
// TableCol represents a column in a table.
type TableCol struct{_eabb *_dg .CT_TableCol };
2020-12-17 22:07:08 +00:00
2022-09-02 11:46:53 +00:00
// X returns the underlying raw XML data.
func (_gee Relationships )X ()*_bg .Relationships {return _gee ._eag };func init (){_ba .SetAsStorage ()};
2020-12-17 22:07:08 +00:00
2022-09-02 11:46:53 +00:00
// AddRelationship adds a relationship.
func (_geeg Relationships )AddRelationship (target ,ctype string )Relationship {if !_b .HasPrefix (ctype ,"\u0068t\u0074\u0070\u003a\u002f\u002f"){_cda .Log .Debug ("\u0072\u0065\u006c\u0061\u0074\u0069\u006f\u006es\u0068\u0069\u0070 t\u0079\u0070\u0065\u0020\u0025\u0073 \u0073\u0068\u006f\u0075\u006c\u0064\u0020\u0073\u0074\u0061\u0072\u0074\u0020\u0077\u0069t\u0068\u0020\u0027\u0068\u0074\u0074\u0070\u003a/\u002f\u0027",ctype );};_ddf :=_bg .NewRelationship ();_abg :=len (_geeg ._eag .Relationship )+1;_fca :=map[string ]struct{}{};for _ ,_efa :=range _geeg ._eag .Relationship {_fca [_efa .IdAttr ]=struct{}{};};for _ ,_bdfc :=_fca [_cf .Sprintf ("\u0072\u0049\u0064%\u0064",_abg )];_bdfc ;_ ,_bdfc =_fca [_cf .Sprintf ("\u0072\u0049\u0064%\u0064",_abg )]{_abg ++;};_ddf .IdAttr =_cf .Sprintf ("\u0072\u0049\u0064%\u0064",_abg );_ddf .TargetAttr =target ;_ddf .TypeAttr =ctype ;_geeg ._eag .Relationship =append (_geeg ._eag .Relationship ,_ddf );return Relationship {_cead :_ddf };};
2021-11-10 11:45:21 +00:00
2022-09-02 11:46:53 +00:00
// NewRelationships creates a new relationship wrapper.
func NewRelationships ()Relationships {return Relationships {_eag :_bg .NewRelationships ()}};var ReleasedAt =_dd .Date (_cdgg ,_afb ,_gdgb ,_gfdef ,_cagd ,0,0,_dd .UTC );
2021-11-10 11:45:21 +00:00
2022-09-02 11:46:53 +00:00
// Relationships returns a slice of all of the relationships.
func (_ggg Relationships )Relationships ()[]Relationship {_fcca :=[]Relationship {};for _ ,_gccg :=range _ggg ._eag .Relationship {_fcca =append (_fcca ,Relationship {_cead :_gccg });};return _fcca ;};
2021-11-10 11:45:21 +00:00
2022-09-02 11:46:53 +00:00
// SetOffsetY sets vertical offset of a table in distance units (see measurement package).
func (_agb Table )SetOffsetY (offY float64 ){if _agb ._bee .Off ==nil {_agb ._bee .Off =_dg .NewCT_Point2D ();_cefe :=int64 (0);_agb ._bee .Off .XAttr =_dg .ST_Coordinate {ST_CoordinateUnqualified :&_cefe };};_ebde :=_ce .ToEMU (offY );_agb ._bee .Off .YAttr =_dg .ST_Coordinate {ST_CoordinateUnqualified :&_ebde };};
2022-04-09 14:27:46 +00:00
2022-09-02 11:46:53 +00:00
// Properties returns table properties.
func (_cfde Table )Properties ()*_dg .CT_TableProperties {return _cfde ._dega .TblPr };
2021-04-23 20:00:00 +00:00
2022-09-02 11:46:53 +00:00
// AddCol adds a column to a table.
func (_abcc Table )AddCol ()*TableCol {_abeg :=_dg .NewCT_TableCol ();_abcc ._dega .TblGrid .GridCol =append (_abcc ._dega .TblGrid .GridCol ,_abeg );for _ ,_fcaa :=range _abcc ._dega .Tr {_fdg :=_dg .NewCT_TableCell ();_fcaa .Tc =append (_fcaa .Tc ,_fdg );};return &TableCol {_eabb :_abeg };};func (_ebe CustomProperties )SetPropertyAsClsid (name string ,clsid string ){_ggdb :=_ebe .getNewProperty (name );_ggdb .Clsid =&clsid ;_ebe .setOrReplaceProperty (_ggdb );};
2021-05-31 16:22:30 +00:00
2022-09-02 11:46:53 +00:00
// TableRow represents a row in a table.
type TableRow struct{_bcf *_dg .CT_TableRow };
2021-06-16 07:10:52 +00:00
2022-09-02 11:46:53 +00:00
// SetLinksUpToDate sets the links up to date flag.
func (_bba AppProperties )SetLinksUpToDate (v bool ){_bba ._gca .LinksUpToDate =_cdc .Bool (v )};
2021-06-16 07:10:52 +00:00
2022-09-02 11:46:53 +00:00
// NewContentTypes returns a wrapper around a newly constructed content-types.
func NewContentTypes ()ContentTypes {_cdb :=ContentTypes {_gdb :_cb .NewTypes ()};_cdb .AddDefault ("\u0078\u006d\u006c","\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u0078\u006d\u006c");_cdb .AddDefault ("\u0072\u0065\u006c\u0073","\u0061\u0070\u0070\u006c\u0069\u0063a\u0074\u0069\u006fn\u002f\u0076\u006ed\u002e\u006f\u0070\u0065\u006e\u0078\u006d\u006c\u0066\u006fr\u006d\u0061\u0074\u0073\u002dpa\u0063\u006b\u0061\u0067\u0065\u002e\u0072\u0065\u006c\u0061\u0074\u0069\u006f\u006e\u0073\u0068\u0069\u0070\u0073\u002b\u0078\u006d\u006c");_cdb .AddDefault ("\u0070\u006e\u0067","\u0069m\u0061\u0067\u0065\u002f\u0070\u006eg");_cdb .AddDefault ("\u006a\u0070\u0065\u0067","\u0069\u006d\u0061\u0067\u0065\u002f\u006a\u0070\u0065\u0067");_cdb .AddDefault ("\u006a\u0070\u0067","\u0069m\u0061\u0067\u0065\u002f\u006a\u0070g");_cdb .AddDefault ("\u0077\u006d\u0066","i\u006d\u0061\u0067\u0065\u002f\u0078\u002d\u0077\u006d\u0066");_cdb .AddOverride ("\u002fd\u006fc\u0050\u0072\u006f\u0070\u0073/\u0063\u006fr\u0065\u002e\u0078\u006d\u006c","\u0061\u0070\u0070\u006c\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u0076\u006e\u0064\u002e\u006f\u0070\u0065\u006ex\u006d\u006c\u0066\u006f\u0072\u006d\u0061\u0074\u0073-\u0070\u0061\u0063\u006b\u0061\u0067\u0065\u002e\u0063\u006f\u0072\u0065\u002dp\u0072\u006f\u0070\u0065\u0072\u0074i\u0065\u0073\u002bx\u006d\u006c");_cdb .AddOverride ("\u002f\u0064\u006f\u0063\u0050\u0072\u006f\u0070\u0073\u002f\u0061\u0070p\u002e\u0078\u006d\u006c","a\u0070\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u0076\u006e\u0064\u002e\u006f\u0070\u0065\u006e\u0078\u006d\u006c\u0066o\u0072\u006d\u0061\u0074\u0073\u002d\u006f\u0066\u0066\u0069\u0063\u0065\u0064\u006f\u0063\u0075m\u0065\u006e\u0074\u002e\u0065\u0078\u0074\u0065\u006e\u0064\u0065\u0064\u002dp\u0072\u006f\u0070\u0065\u0072\u0074\u0069\u0065\u0073\u002b\u0078m\u006c");return _cdb ;};
2021-06-16 07:10:52 +00:00
2022-09-02 11:46:53 +00:00
// SetAuthor records the author of the document.
func (_aefc CoreProperties )SetAuthor (s string ){if _aefc ._bfe .Creator ==nil {_aefc ._bfe .Creator =&_cdc .XSDAny {XMLName :_fg .Name {Local :"\u0064\u0063\u003a\u0063\u0072\u0065\u0061\u0074\u006f\u0072"}};};_aefc ._bfe .Creator .Data =[]byte (s );};
2021-06-16 07:10:52 +00:00
2022-09-02 11:46:53 +00:00
// AddRow adds a row to a table.
func (_ffeeg Table )AddRow ()*TableRow {_afeg :=_dg .NewCT_TableRow ();for _dcd :=0;_dcd < len (_ffeeg ._dega .TblGrid .GridCol );_dcd ++{_afeg .Tc =append (_afeg .Tc ,_dg .NewCT_TableCell ());};_ffeeg ._dega .Tr =append (_ffeeg ._dega .Tr ,_afeg );return &TableRow {_bcf :_afeg };};func (_cef CustomProperties )setProperty (_edf *_cd .CT_Property ){_cef .setPropertyHelper (_edf ,false )};func (_cefc CustomProperties )SetPropertyAsI1 (name string ,i1 int8 ){_dbcea :=_cefc .getNewProperty (name );_dbcea .I1 =&i1 ;_cefc .setOrReplaceProperty (_dbcea );};func (_dfc CustomProperties )SetPropertyAsStorage (name string ,storage string ){_eef :=_dfc .getNewProperty (name );_eef .Storage =&storage ;_dfc .setOrReplaceProperty (_eef );};
2021-06-16 07:10:52 +00:00
2022-09-02 11:46:53 +00:00
// X returns the inner wrapped XML type.
func (_caae CustomProperties )X ()*_cd .Properties {return _caae ._cea };
2021-06-16 07:10:52 +00:00
2022-09-02 11:46:53 +00:00
// NewAppProperties constructs a new AppProperties.
func NewAppProperties ()AppProperties {_df :=AppProperties {_gca :_bag .NewProperties ()};_df .SetCompany ("\u0046\u006f\u0078\u0079\u0055\u0074\u0069\u006c\u0073\u0020\u0065\u0068\u0066");_df .SetApplication ("g\u0069\u0074\u0068\u0075\u0062\u002ec\u006f\u006d\u002f\u0075\u006e\u0069\u0064\u006f\u0063/\u0075\u006e\u0069o\u0066f\u0069\u0063\u0065");_df .SetDocSecurity (0);_df .SetLinksUpToDate (false );var _bd ,_bc ,_ggf int64 ;_cf .Sscanf (Version ,"\u0025\u0064\u002e\u0025\u0064\u002e\u0025\u0064",&_bd ,&_bc ,&_ggf );_bgb :=float64 (_bd )+float64 (_bc )/10000.0;_df .SetApplicationVersion (_cf .Sprintf ("\u0025\u0030\u0037\u002e\u0034\u0066",_bgb ));return _df ;};
2021-06-16 07:10:52 +00:00
2022-09-02 11:46:53 +00:00
// Append appends DocBase part of an office document to another DocBase.
func (_ed DocBase )Append (docBase1 DocBase )DocBase {_be :=docBase1 .ContentTypes .X ();for _ ,_cdf :=range _be .Default {_ed .ContentTypes .AddDefault (_cdf .ExtensionAttr ,_cdf .ContentTypeAttr );};for _ ,_gfd :=range _be .Override {_ed .ContentTypes .AddOverride (_gfd .PartNameAttr ,_gfd .ContentTypeAttr );};_bb :=_ed .AppProperties .X ();_bef :=docBase1 .AppProperties .X ();if _bb .Pages !=nil {if _bef .Pages !=nil {*_bb .Pages +=*_bef .Pages ;};}else if _bef .Pages !=nil {_bb .Pages =_bef .Pages ;};if _bb .Words !=nil {if _bef .Words !=nil {*_bb .Words +=*_bef .Words ;};}else if _bef .Words !=nil {_bb .Words =_bef .Words ;};if _bb .Characters !=nil {if _bef .Characters !=nil {*_bb .Characters +=*_bef .Characters ;};}else if _bef .Characters !=nil {_bb .Characters =_bef .Characters ;};if _bb .Lines !=nil {if _bef .Lines !=nil {*_bb .Lines +=*_bef .Lines ;};}else if _bef .Lines !=nil {_bb .Lines =_bef .Lines ;};if _bb .Paragraphs !=nil {if _bef .Paragraphs !=nil {*_bb .Paragraphs +=*_bef .Paragraphs ;};}else if _bef .Paragraphs !=nil {_bb .Paragraphs =_bef .Paragraphs ;};if _bb .Notes !=nil {if _bef .Notes !=nil {*_bb .Notes +=*_bef .Notes ;};}else if _bef .Notes !=nil {_bb .Notes =_bef .Notes ;};if _bb .HiddenSlides !=nil {if _bef .HiddenSlides !=nil {*_bb .HiddenSlides +=*_bef .HiddenSlides ;};}else if _bef .HiddenSlides !=nil {_bb .HiddenSlides =_bef .HiddenSlides ;};if _bb .MMClips !=nil {if _bef .MMClips !=nil {*_bb .MMClips +=*_bef .MMClips ;};}else if _bef .MMClips !=nil {_bb .MMClips =_bef .MMClips ;};if _bb .LinksUpToDate !=nil {if _bef .LinksUpToDate !=nil {*_bb .LinksUpToDate =*_bb .LinksUpToDate &&*_bef .LinksUpToDate ;};}else if _bef .LinksUpToDate !=nil {_bb .LinksUpToDate =_bef .LinksUpToDate ;};if _bb .CharactersWithSpaces !=nil {if _bef .CharactersWithSpaces !=nil {*_bb .CharactersWithSpaces +=*_bef .CharactersWithSpaces ;};}else if _bef .CharactersWithSpaces !=nil {_bb .CharactersWithSpaces =_bef .CharactersWithSpaces ;};if _bb .SharedDoc !=nil {if _bef .SharedDoc !=nil {*_bb .SharedDoc =*_bb .SharedDoc ||*_bef .SharedDoc ;};}else if _bef .SharedDoc !=nil {_bb .SharedDoc =_bef .SharedDoc ;};if _bb .HyperlinksChanged !=nil {if _bef .HyperlinksChanged !=nil {*_bb .HyperlinksChanged =*_bb .HyperlinksChanged ||*_bef .HyperlinksChanged ;};}else if _bef .HyperlinksChanged !=nil {_bb .HyperlinksChanged =_bef .HyperlinksChanged ;};_bb .DigSig =nil ;if _bb .TitlesOfParts ==nil &&_bef .TitlesOfParts !=nil {_bb .TitlesOfParts =_bef .TitlesOfParts ;};if _bb .HeadingPairs !=nil {if _bef .HeadingPairs !=nil {_gfc :=_bb .HeadingPairs .Vector ;_ffa :=_bef .HeadingPairs .Vector ;_dba :=_gfc .Variant ;_fe :=_ffa .Variant ;_ae :=[]*_dc .Variant {};for _fgf :=0;_fgf < len (_fe );_fgf +=2{_edg :=_fe [_fgf ].Lpstr ;_ge :=false ;for _fgd :=0;_fgd < len (_dba );_fgd +=2{_bbe :=_dba [_fgd ].Lpstr ;if _bbe !=nil &&_edg !=nil &&*_bbe ==*_edg {*_dba [_fgd +1].I4 =*_dba [_fgd +1].I4 +*_fe [_fgf +1].I4 ;_ge =true ;break ;};};if !_ge {_ae =append (_ae ,&_dc .Variant {CT_Variant :_dc .CT_Variant {Lpstr :_fe [_fgf ].Lpstr }});_ae =append (_ae ,&_dc .Variant {CT_Variant :_dc .CT_Variant {I4 :_fe [_fgf ].I4 }});};};_dba =append (_dba ,_ae ...);_gfc .SizeAttr =uint32 (len (_dba ));};}else if _bef .HeadingPairs !=nil {_bb .HeadingPairs =_bef .HeadingPairs ;};if _bb .HLinks !=nil {if _bef .HLinks !=nil {_ab :=_bb .HLinks .Vector ;_fed :=_bef .HLinks .Vector ;_cfa :=_ab .Variant ;_bf :=_fed .Variant ;for _ ,_ca :=range _bf {_bbd :=true ;for _ ,_af :=range _cfa {if _f .DeepEqual (_af ,_ca ){_bbd =false ;break ;};};if _bbd {_cfa =append (_cfa ,_ca );_ab .SizeAttr ++;};};};}else if _bef .HLinks !=nil {_bb .HLinks =_bef .HLinks ;};_ec :=_ed .GetOrCreateCustomProperties ();_cde :=docBase1 .GetOrCreateCustomProperties ();for _ ,_de :=range _cde .PropertiesList (){_ec .setProperty (_de );};_ed .CustomProperties =_ec ;_deb :=_ed .Rels .X ().Relationship ;for _ ,_ecf :=range docBase1 .Rels .X ().Relationship {_cddb :=true ;for _ ,_aff :=range _deb {if _aff .TargetAttr ==_ecf .TargetAttr &&_aff .TypeAttr ==_ecf .TypeAttr {_cddb =false ;break ;};}
2022-02-25 19:20:45 +00:00
2022-09-02 11:46:53 +00:00
// Format returns the format of the underlying image
func (_cdgd ImageRef )Format ()string {return _cdgd ._bace .Format };
2022-02-25 19:20:45 +00:00
2022-09-02 11:46:53 +00:00
// SetWidth sets column width, see measurement package.
func (_gbdc TableCol )SetWidth (m _ce .Distance ){_dca :=_ce .ToEMU (float64 (m ));_gbdc ._eabb .WAttr =_dg .ST_Coordinate {ST_CoordinateUnqualified :&_dca };};
2021-08-23 20:44:48 +00:00
2022-09-02 11:46:53 +00:00
// ImageFromBytes returns an Image struct for an in-memory image. You can also
// construct an Image directly if the file and size are known.
func ImageFromBytes (data []byte )(Image ,error ){_gbcb :=Image {};_caea ,_dec ,_fgeg :=_ff .Decode (_eg .NewReader (data ));if _fgeg !=nil {return _gbcb ,_cf .Errorf ("\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s",_fgeg );};_gbcb .Data =&data ;_gbcb .Format =_dec ;_gbcb .Size =_caea .Bounds ().Size ();return _gbcb ,nil ;};func (_ddd CustomProperties )SetPropertyAsNull (name string ){_edfd :=_ddd .getNewProperty (name );_edfd .Null =_dc .NewNull ();_ddd .setOrReplaceProperty (_edfd );};
2021-11-10 11:45:21 +00:00
2022-09-02 11:46:53 +00:00
// CustomProperty contains document specific property.
// Using of this type is deprecated.
type CustomProperty struct{_eab *_cd .CT_Property };
2022-02-25 19:20:45 +00:00
2022-09-02 11:46:53 +00:00
// NewRelationship constructs a new relationship.
func NewRelationship ()Relationship {return Relationship {_cead :_bg .NewRelationship ()}};
2022-02-25 19:20:45 +00:00
2022-09-02 11:46:53 +00:00
// CopyOverride copies override content type for a given `path` and puts it with a path `newPath`.
func (_gba ContentTypes )CopyOverride (path ,newPath string ){if !_b .HasPrefix (path ,"\u002f"){path ="\u002f"+path ;};if !_b .HasPrefix (newPath ,"\u002f"){newPath ="\u002f"+newPath ;};for _dbc :=range _gba ._gdb .Override {if _gba ._gdb .Override [_dbc ].PartNameAttr ==path {_fd :=*_gba ._gdb .Override [_dbc ];_fd .PartNameAttr =newPath ;_gba ._gdb .Override =append (_gba ._gdb .Override ,&_fd );};};};
2022-02-25 19:20:45 +00:00
2022-09-02 11:46:53 +00:00
// ID returns the ID of a relationship.
func (_cfbc Relationship )ID ()string {return _cfbc ._cead .IdAttr };
2022-06-27 19:44:23 +00:00
2022-09-02 11:46:53 +00:00
// Clear removes any existing relationships.
func (_fbg Relationships )Clear (){_fbg ._eag .Relationship =nil };
2022-06-27 19:44:23 +00:00
2022-09-02 11:46:53 +00:00
// SetCompany sets the name of the company that created the document.
func (_afe AppProperties )SetCompany (s string ){_afe ._gca .Company =&s };
2022-06-27 19:44:23 +00:00
// X returns the inner wrapped XML type.
2022-09-02 11:46:53 +00:00
func (_fc CoreProperties )X ()*_gc .CoreProperties {return _fc ._bfe };
// AppProperties contains properties specific to the document and the
// application that created it.
type AppProperties struct{_gca *_bag .Properties };
// Remove removes an existing relationship.
func (_fcdb Relationships )Remove (rel Relationship )bool {for _ddec ,_bga :=range _fcdb ._eag .Relationship {if _bga ==rel ._cead {copy (_fcdb ._eag .Relationship [_ddec :],_fcdb ._eag .Relationship [_ddec +1:]);_fcdb ._eag .Relationship =_fcdb ._eag .Relationship [0:len (_fcdb ._eag .Relationship )-1];return true ;};};return false ;};func (_aeae CustomProperties )SetPropertyAsI4 (name string ,i4 int32 ){_cgfe :=_aeae .getNewProperty (name );_cgfe .I4 =&i4 ;_aeae .setOrReplaceProperty (_cgfe );};func (_cgg TableRow )addCell ()*_dg .CT_TableCell {_fgdc :=_dg .NewCT_TableCell ();_cgg ._bcf .Tc =append (_cgg ._bcf .Tc ,_fgdc );return _fgdc ;};
// SetApplicationVersion sets the version of the application that created the
// document. Per MS, the verison string mut be in the form 'XX.YYYY'.
func (_bagb AppProperties )SetApplicationVersion (s string ){_bagb ._gca .AppVersion =&s };