unioffice/common/common.go

407 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.
2021-04-23 20:00:00 +00:00
package common ;import (_af "archive/zip";_da "bytes";_c "encoding/xml";_a "errors";_ee "fmt";_gfe "github.com/unidoc/unioffice";_ggc "github.com/unidoc/unioffice/common/tempstorage";_aa "github.com/unidoc/unioffice/common/tempstorage/diskstore";_eb "github.com/unidoc/unioffice/measurement";_ggb "github.com/unidoc/unioffice/schema/soo/dml";_ef "github.com/unidoc/unioffice/schema/soo/ofc/custom_properties";_daf "github.com/unidoc/unioffice/schema/soo/ofc/docPropsVTypes";_aaea "github.com/unidoc/unioffice/schema/soo/ofc/extended_properties";_db "github.com/unidoc/unioffice/schema/soo/pkg/content_types";_ge "github.com/unidoc/unioffice/schema/soo/pkg/metadata/core_properties";_aae "github.com/unidoc/unioffice/schema/soo/pkg/relationships";_ec "github.com/unidoc/unioffice/zippkg";_gg "image";_ "image/gif";_ "image/jpeg";_ "image/png";_d "os";_g "reflect";_fff "regexp";_cg "strconv";_cb "strings";_e "time";);func (_cdad CustomProperties )SetPropertyAsBool (name string ,b bool ){_dbec :=_cdad .getNewProperty (name );_dbec .Bool =&b ;_cdad .setOrReplaceProperty (_dbec );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// ApplicationVersion returns the version of the application that created the
// document.
func (_adb AppProperties )ApplicationVersion ()string {if _adb ._ede .AppVersion !=nil {return *_adb ._ede .AppVersion ;};return "";};
2021-03-16 20:51:18 +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
2021-01-04 16:11:39 +00:00
// construct an Image directly if the file and size are known.
2021-03-16 20:51:18 +00:00
// NOTE: See also ImageFromStorage.
2021-04-23 20:00:00 +00:00
func ImageFromFile (path string )(Image ,error ){_gfcd ,_acf :=_d .Open (path );_cff :=Image {};if _acf !=nil {return _cff ,_ee .Errorf ("\u0065\u0072\u0072or\u0020\u0072\u0065\u0061\u0064\u0069\u006e\u0067\u0020\u0069\u006d\u0061\u0067\u0065\u003a\u0020\u0025\u0073",_acf );};defer _gfcd .Close ();_adgc ,_cfed ,_acf :=_gg .Decode (_gfcd );if _acf !=nil {return _cff ,_ee .Errorf ("\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s",_acf );};_cff .Path =path ;_cff .Format =_cfed ;_cff .Size =_adgc .Bounds ().Size ();return _cff ,nil ;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// RemoveOverrideByIndex removes an override given a path and override index.
func (_edd ContentTypes )RemoveOverrideByIndex (path string ,indexToFind int )error {_acg :=path [0:len (path )-5];if !_cb .HasPrefix (_acg ,"\u002f"){_acg ="\u002f"+_acg ;};_dea ,_edg :=_fff .Compile (_acg +"\u0028\u005b\u0030-\u0039\u005d\u002b\u0029\u002e\u0078\u006d\u006c");if _edg !=nil {return _edg ;};_gcd :=0;_def :=-1;for _gdg ,_bcfb :=range _edd ._cgg .Override {if _fcc :=_dea .FindStringSubmatch (_bcfb .PartNameAttr );len (_fcc )> 1{if _gcd ==indexToFind {_def =_gdg ;}else if _gcd > indexToFind {_dda ,_ :=_cg .Atoi (_fcc [1]);_dda --;_bcfb .PartNameAttr =_ee .Sprintf ("\u0025\u0073\u0025\u0064\u002e\u0078\u006d\u006c",_acg ,_dda );};_gcd ++;};};if _def > -1{copy (_edd ._cgg .Override [_def :],_edd ._cgg .Override [_def +1:]);_edd ._cgg .Override =_edd ._cgg .Override [0:len (_edd ._cgg .Override )-1];};return nil ;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// CoreProperties contains document specific properties.
type CoreProperties struct{_agf *_ge .CoreProperties };
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// TableCol represents a column in a table.
type TableCol struct{_gea *_ggb .CT_TableCol };
2021-03-16 20:51:18 +00:00
2021-04-23 20:00:00 +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 ){_deg :=Image {};_acc ,_bdc :=_ggc .Open (path );if _bdc !=nil {return _deg ,_ee .Errorf ("\u0065\u0072\u0072or\u0020\u0072\u0065\u0061\u0064\u0069\u006e\u0067\u0020\u0069\u006d\u0061\u0067\u0065\u003a\u0020\u0025\u0073",_bdc );};defer _acc .Close ();_ccc ,_daed ,_bdc :=_gg .Decode (_acc );if _bdc !=nil {return _deg ,_ee .Errorf ("\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s",_bdc );};_deg .Path =path ;_deg .Format =_daed ;_deg .Size =_ccc .Bounds ().Size ();return _deg ,nil ;};func (_ffg *ImageRef )SetRelID (id string ){_ffg ._ebb =id };
2021-03-16 20:51:18 +00:00
2021-04-23 20:00:00 +00:00
// Format returns the format of the underlying image
func (_cbd ImageRef )Format ()string {return _cbd ._dcg .Format };
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// ContentTypes is the top level "[Content_Types].xml" in a zip package.
type ContentTypes struct{_cgg *_db .Types };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetCompany sets the name of the company that created the document.
2021-04-23 20:00:00 +00:00
func (_dac AppProperties )SetCompany (s string ){_dac ._ede .Company =&s };
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// X returns the inner wrapped XML type.
func (_beeg Relationship )X ()*_aae .Relationship {return _beeg ._caf };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// NewRelationships creates a new relationship wrapper.
2021-04-23 20:00:00 +00:00
func NewRelationships ()Relationships {return Relationships {_deaa :_aae .NewRelationships ()}};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// CustomProperty contains document specific property.
// Using of this type is deprecated.
type CustomProperty struct{_ffb *_ef .CT_Property };
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// NewTable makes a new table.
func NewTable ()*Table {_cee :=_ggb .NewTbl ();_cee .TblPr =_ggb .NewCT_TableProperties ();return &Table {_fadc :_cee };};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// EnsureDefault esnures that an extension and default content type exist,
// adding it if necessary.
func (_gfd ContentTypes )EnsureDefault (ext ,contentType string ){ext =_cb .ToLower (ext );for _ ,_add :=range _gfd ._cgg .Default {if _add .ExtensionAttr ==ext {_add .ContentTypeAttr =contentType ;return ;};};_ba :=&_db .Default {};_ba .ContentTypeAttr =contentType ;_ba .ExtensionAttr =ext ;_gfd ._cgg .Default =append (_gfd ._cgg .Default ,_ba );};func (_faff CustomProperties )SetPropertyAsLpwstr (name string ,lpwstr string ){_ebe :=_faff .getNewProperty (name );_ebe .Lpwstr =&lpwstr ;_faff .setOrReplaceProperty (_ebe );};func (_cda CustomProperties )SetPropertyAsStream (name string ,stream string ){_egf :=_cda .getNewProperty (name );_egf .Stream =&stream ;_cda .setOrReplaceProperty (_egf );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// AddRelationship adds a relationship.
func (_gee Relationships )AddRelationship (target ,ctype string )Relationship {if !_cb .HasPrefix (ctype ,"\u0068t\u0074\u0070\u003a\u002f\u002f"){_gfe .Log ("\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 );};_deafd :=_aae .NewRelationship ();_fgcd :=len (_gee ._deaa .Relationship )+1;_bca :=map[string ]struct{}{};for _ ,_dgd :=range _gee ._deaa .Relationship {_bca [_dgd .IdAttr ]=struct{}{};};for _ ,_fdc :=_bca [_ee .Sprintf ("\u0072\u0049\u0064%\u0064",_fgcd )];_fdc ;_ ,_fdc =_bca [_ee .Sprintf ("\u0072\u0049\u0064%\u0064",_fgcd )]{_fgcd ++;};_deafd .IdAttr =_ee .Sprintf ("\u0072\u0049\u0064%\u0064",_fgcd );_deafd .TargetAttr =target ;_deafd .TypeAttr =ctype ;_gee ._deaa .Relationship =append (_gee ._deaa .Relationship ,_deafd );return Relationship {_caf :_deafd };};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// SetHeight sets row height, see measurement package.
func (_ada TableRow )SetHeight (m _eb .Distance ){_dee :=_eb .ToEMU (float64 (m ));_ada ._dgc .HAttr =_ggb .ST_Coordinate {ST_CoordinateUnqualified :&_dee };};func (_faf CustomProperties )SetPropertyAsEmpty (name string ){_efac :=_faf .getNewProperty (name );_efac .Empty =_daf .NewEmpty ();_faf .setOrReplaceProperty (_efac );};func _gca (_dcac *_gfe .XSDAny )_e .Time {if _dcac ==nil {return _e .Time {};};_eaa ,_cbg :=_e .Parse (_dfe ,string (_dcac .Data ));if _cbg !=nil {_gfe .Log ("\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 (_dcac .Data ),_cbg );};return _eaa ;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +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 (_fec *DocBase )AddExtraFileFromZip (f *_af .File )error {_eddf ,_cabb :=_ec .ExtractToDiskTmp (f ,_fec .TmpPath );if _cabb !=nil {return _ee .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",_cabb );};_fec .ExtraFiles =append (_fec .ExtraFiles ,ExtraFile {ZipPath :f .Name ,DiskPath :_eddf });return nil ;};func (_cfg CustomProperties )SetPropertyAsOstorage (name string ,ostorage string ){_afd :=_cfg .getNewProperty (name );_afd .Ostorage =&ostorage ;_cfg .setOrReplaceProperty (_afd );};func (_efaa CustomProperties )getNewProperty (_bbg string )*_ef .CT_Property {_afg :=_efaa ._gcaa .Property ;_fdd :=int32 (1);for _ ,_bdd :=range _afg {if _bdd .PidAttr > _fdd {_fdd =_bdd .PidAttr ;};};_bab :=_ef .NewCT_Property ();_bab .NameAttr =&_bbg ;_bab .PidAttr =_fdd +1;_bab .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 _bab ;};func (_gaag CustomProperties )SetPropertyAsBstr (name string ,bstr string ){_fae :=_gaag .getNewProperty (name );_fae .Bstr =&bstr ;_gaag .setOrReplaceProperty (_fae );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// X returns the inner wrapped XML type of CustomProperty.
func (_fbdb CustomProperty )X ()*_ef .CT_Property {return _fbdb ._ffb };
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// SetOffsetY sets vertical offset of a table in distance units (see measurement package).
func (_gab Table )SetOffsetY (offY float64 ){if _gab ._ggdg .Off ==nil {_gab ._ggdg .Off =_ggb .NewCT_Point2D ();_ebag :=int64 (0);_gab ._ggdg .Off .XAttr =_ggb .ST_Coordinate {ST_CoordinateUnqualified :&_ebag };};_fcfb :=_eb .ToEMU (offY );_gab ._ggdg .Off .YAttr =_ggb .ST_Coordinate {ST_CoordinateUnqualified :&_fcfb };};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// NewCustomProperties constructs a new CustomProperties.
func NewCustomProperties ()CustomProperties {return CustomProperties {_gcaa :_ef .NewProperties ()}};
2020-10-12 13:59:12 +00:00
2021-04-23 20:00:00 +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 (_cceg ImageRef )RelativeWidth (h _eb .Distance )_eb .Distance {_deaf :=float64 (_cceg .Size ().X )/float64 (_cceg .Size ().Y );return h *_eb .Distance (_deaf );};func (_dba CustomProperties )SetPropertyAsInt (name string ,i int ){_fgde :=_dba .getNewProperty (name );_afe :=int32 (i );_fgde .Int =&_afe ;_dba .setOrReplaceProperty (_fgde );};func (_fdaf CustomProperties )SetPropertyAsVstream (name string ,vstream *_daf .Vstream ){_gfb :=_fdaf .getNewProperty (name );_gfb .Vstream =vstream ;_fdaf .setOrReplaceProperty (_gfb );};
2020-10-12 13:59:12 +00:00
2021-04-23 20:00:00 +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 ){_addd :=Image {};_acee ,_ggfa ,_dbfc :=_gg .Decode (_da .NewReader (data ));if _dbfc !=nil {return _addd ,_ee .Errorf ("\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s",_dbfc );};_addd .Data =&data ;_addd .Format =_ggfa ;_addd .Size =_acee .Bounds ().Size ();return _addd ,nil ;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Author returns the author of the document
func (_fbd CoreProperties )Author ()string {if _fbd ._agf .Creator !=nil {return string (_fbd ._agf .Creator .Data );};return "";};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// AddCol adds a column to a table.
func (_efc Table )AddCol ()*TableCol {_gaef :=_ggb .NewCT_TableCol ();_efc ._fadc .TblGrid .GridCol =append (_efc ._fadc .TblGrid .GridCol ,_gaef );for _ ,_adfc :=range _efc ._fadc .Tr {_dead :=_ggb .NewCT_TableCell ();_adfc .Tc =append (_adfc .Tc ,_dead );};return &TableCol {_gea :_gaef };};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// DefAttr returns the DefAttr property.
func (_beecf TableStyles )DefAttr ()string {return _beecf ._gaed .DefAttr };
2020-11-09 01:00:18 +00:00
2021-04-23 20:00:00 +00:00
// NewRelationship constructs a new relationship.
func NewRelationship ()Relationship {return Relationship {_caf :_aae .NewRelationship ()}};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Relationships represents a .rels file.
type Relationships struct{_deaa *_aae .Relationships };func (_eba CustomProperties )SetPropertyAsArray (name string ,array *_daf .Array ){_dce :=_eba .getNewProperty (name );_dce .Array =array ;_eba .setOrReplaceProperty (_dce );};
2020-08-31 22:58:25 +00:00
2021-04-23 20:00:00 +00:00
// GetPropertyByName returns a custom property selected by it's name.
func (_eddb CustomProperties )GetPropertyByName (name string )CustomProperty {_bgg :=_eddb ._gcaa .Property ;for _ ,_fgf :=range _bgg {if *_fgf .NameAttr ==name {return CustomProperty {_ffb :_fgf };};};return CustomProperty {};};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// NewAppProperties constructs a new AppProperties.
func NewAppProperties ()AppProperties {_geb :=AppProperties {_ede :_aaea .NewProperties ()};_geb .SetCompany ("\u0046\u006f\u0078\u0079\u0055\u0074\u0069\u006c\u0073\u0020\u0065\u0068\u0066");_geb .SetApplication ("g\u0069\u0074\u0068\u0075\u0062\u002ec\u006f\u006d\u002f\u0075\u006e\u0069\u0064\u006f\u0063/\u0075\u006e\u0069o\u0066f\u0069\u0063\u0065");_geb .SetDocSecurity (0);_geb .SetLinksUpToDate (false );var _ddg ,_ag ,_gc int64 ;_ee .Sscanf (Version ,"\u0025\u0064\u002e\u0025\u0064\u002e\u0025\u0064",&_ddg ,&_ag ,&_gc );_ffa :=float64 (_ddg )+float64 (_ag )/10000.0;_geb .SetApplicationVersion (_ee .Sprintf ("\u0025\u0030\u0037\u002e\u0034\u0066",_ffa ));return _geb ;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// AddOverride adds an override content type for a given path name.
func (_aea ContentTypes )AddOverride (path ,contentType string ){if !_cb .HasPrefix (path ,"\u002f"){path ="\u002f"+path ;};if _cb .HasPrefix (contentType ,"\u0068\u0074\u0074\u0070"){_gfe .Log ("\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 _ ,_afc :=range _aea ._cgg .Override {if _afc .PartNameAttr ==path &&_afc .ContentTypeAttr ==contentType {return ;};};_eda :=_db .NewOverride ();_eda .PartNameAttr =path ;_eda .ContentTypeAttr =contentType ;_aea ._cgg .Override =append (_aea ._cgg .Override ,_eda );};func UtcTimeFormat (t _e .Time )string {return t .Format (_ddd )+"\u0020\u0055\u0054\u0043"};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Hyperlink is just an appropriately configured relationship.
type Hyperlink Relationship ;
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Modified returns the time that the document was modified.
func (_ecd CoreProperties )Modified ()_e .Time {return _gca (_ecd ._agf .Modified )};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// NewTableWithXfrm makes a new table with a pointer to its parent Xfrm for changing its offset and size.
func NewTableWithXfrm (xfrm *_ggb .CT_Transform2D )*Table {_fcfg :=_ggb .NewTbl ();_fcfg .TblPr =_ggb .NewCT_TableProperties ();return &Table {_fadc :_fcfg ,_ggdg :xfrm };};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetLinksUpToDate sets the links up to date flag.
2021-04-23 20:00:00 +00:00
func (_bf AppProperties )SetLinksUpToDate (v bool ){_bf ._ede .LinksUpToDate =_gfe .Bool (v )};func (_bed CustomProperties )SetPropertyAsBlob (name ,blob string ){_gce :=_bed .getNewProperty (name );_gce .Blob =&blob ;_bed .setOrReplaceProperty (_gce );};func (_cdfc CustomProperties )setOrReplaceProperty (_ggdb *_ef .CT_Property ){_cdfc .setPropertyHelper (_ggdb ,true );};func (_eee CustomProperties )SetPropertyAsOstream (name string ,ostream string ){_fee :=_eee .getNewProperty (name );_fee .Ostream =&ostream ;_eee .setOrReplaceProperty (_fee );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// LastModifiedBy returns the name of the last person to modify the document
func (_bg CoreProperties )LastModifiedBy ()string {if _bg ._agf .LastModifiedBy !=nil {return *_bg ._agf .LastModifiedBy ;};return "";};
2020-10-12 13:59:12 +00:00
2021-04-23 20:00:00 +00:00
// Type returns the type of a relationship.
func (_fbea Relationship )Type ()string {return _fbea ._caf .TypeAttr };
2020-10-12 13:59:12 +00:00
2021-04-23 20:00:00 +00:00
// X returns the inner wrapped XML type.
func (_ega Table )X ()*_ggb .Tbl {return _ega ._fadc };
2020-10-12 13:59:12 +00:00
2021-04-23 20:00:00 +00:00
// RelID returns the relationship ID.
func (_fef ImageRef )RelID ()string {return _fef ._ebb };
2020-10-12 13:59:12 +00:00
2021-04-23 20:00:00 +00:00
// Cells returns an array of row cells.
func (_cfef TableRow )Cells ()[]*_ggb .CT_TableCell {return _cfef ._dgc .Tc };const _dfe ="2\u00300\u0036\u002d\u0030\u0031\u002d\u0030\u0032\u00541\u0035\u003a\u0030\u0034:0\u0035\u005a";func (_fda CustomProperties )SetPropertyAsI4 (name string ,i4 int32 ){_ebf :=_fda .getNewProperty (name );_ebf .I4 =&i4 ;_fda .setOrReplaceProperty (_ebf );};func (_dgeg CustomProperties )SetPropertyAsStorage (name string ,storage string ){_gceb :=_dgeg .getNewProperty (name );_gceb .Storage =&storage ;_dgeg .setOrReplaceProperty (_gceb );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Clear removes any existing relationships.
func (_abf Relationships )Clear (){_abf ._deaa .Relationship =nil };
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// RemoveOverride removes an override given a path.
func (_cf ContentTypes )RemoveOverride (path string ){if !_cb .HasPrefix (path ,"\u002f"){path ="\u002f"+path ;};for _ab ,_bad :=range _cf ._cgg .Override {if _bad .PartNameAttr ==path {copy (_cf ._cgg .Override [_ab :],_cf ._cgg .Override [_ab +1:]);_cf ._cgg .Override =_cf ._cgg .Override [0:len (_cf ._cgg .Override )-1];};};};const _ddd ="\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034";
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Rows returns all table rows.
func (_ffbg Table )Rows ()[]*TableRow {_aebf :=_ffbg ._fadc .Tr ;_efca :=[]*TableRow {};for _ ,_abd :=range _aebf {_efca =append (_efca ,&TableRow {_dgc :_abd });};return _efca ;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// SetWidth sets column width, see measurement package.
func (_aebb TableCol )SetWidth (m _eb .Distance ){_dadc :=_eb .ToEMU (float64 (m ));_aebb ._gea .WAttr =_ggb .ST_Coordinate {ST_CoordinateUnqualified :&_dadc };};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// IsEmpty returns true if there are no relationships.
func (_beg Relationships )IsEmpty ()bool {return _beg ._deaa ==nil ||len (_beg ._deaa .Relationship )==0;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Remove removes an existing relationship.
func (_caa Relationships )Remove (rel Relationship )bool {for _fdg ,_efba :=range _caa ._deaa .Relationship {if _efba ==rel ._caf {copy (_caa ._deaa .Relationship [_fdg :],_caa ._deaa .Relationship [_fdg +1:]);_caa ._deaa .Relationship =_caa ._deaa .Relationship [0:len (_caa ._deaa .Relationship )-1];return true ;};};return false ;};
2020-11-09 01:00:18 +00:00
2021-04-23 20:00:00 +00:00
// AppProperties contains properties specific to the document and the
// application that created it.
type AppProperties struct{_ede *_aaea .Properties };func (_gbg CustomProperties )SetPropertyAsUi8 (name string ,ui8 uint64 ){_edeb :=_gbg .getNewProperty (name );_edeb .Ui8 =&ui8 ;_gbg .setOrReplaceProperty (_edeb );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// SetAuthor records the author of the document.
func (_gb CoreProperties )SetAuthor (s string ){if _gb ._agf .Creator ==nil {_gb ._agf .Creator =&_gfe .XSDAny {XMLName :_c .Name {Local :"\u0064\u0063\u003a\u0063\u0072\u0065\u0061\u0074\u006f\u0072"}};};_gb ._agf .Creator .Data =[]byte (s );};func (_bedc CustomProperties )SetPropertyAsFiletime (name string ,filetime _e .Time ){_beeb :=_bedc .getNewProperty (name );_beeb .Filetime =&filetime ;_bedc .setOrReplaceProperty (_beeb );};func (_deac CustomProperties )SetPropertyAsR4 (name string ,r4 float32 ){_bga :=_deac .getNewProperty (name );_bga .R4 =&r4 ;_deac .setOrReplaceProperty (_bga );};
2020-10-12 13:59:12 +00:00
2021-04-23 20:00:00 +00:00
// Path returns the path to an image file, if any.
func (_edc ImageRef )Path ()string {return _edc ._dcg .Path };
2020-10-12 13:59:12 +00:00
2021-04-23 20:00:00 +00:00
// ContentStatus returns the content status of the document (e.g. "Final", "Draft")
func (_bbb CoreProperties )ContentStatus ()string {if _bbb ._agf .ContentStatus !=nil {return *_bbb ._agf .ContentStatus ;};return "";};
2020-10-12 13:59:12 +00:00
2021-04-23 20:00:00 +00:00
// CustomProperties contains document specific properties.
type CustomProperties struct{_gcaa *_ef .Properties };
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +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 _gg .Point ;Format string ;Path string ;Data *[]byte ;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Append appends DocBase part of an office document to another DocBase.
2021-04-23 20:00:00 +00:00
func (_b DocBase )Append (docBase1 DocBase )DocBase {_ce :=docBase1 .ContentTypes .X ();for _ ,_de :=range _ce .Default {_b .ContentTypes .AddDefault (_de .ExtensionAttr ,_de .ContentTypeAttr );};for _ ,_dbd :=range _ce .Override {_b .ContentTypes .AddOverride (_dbd .PartNameAttr ,_dbd .ContentTypeAttr );};_cbc :=_b .AppProperties .X ();_gd :=docBase1 .AppProperties .X ();if _cbc .Pages !=nil {if _gd .Pages !=nil {*_cbc .Pages +=*_gd .Pages ;};}else if _gd .Pages !=nil {_cbc .Pages =_gd .Pages ;};if _cbc .Words !=nil {if _gd .Words !=nil {*_cbc .Words +=*_gd .Words ;};}else if _gd .Words !=nil {_cbc .Words =_gd .Words ;};if _cbc .Characters !=nil {if _gd .Characters !=nil {*_cbc .Characters +=*_gd .Characters ;};}else if _gd .Characters !=nil {_cbc .Characters =_gd .Characters ;};if _cbc .Lines !=nil {if _gd .Lines !=nil {*_cbc .Lines +=*_gd .Lines ;};}else if _gd .Lines !=nil {_cbc .Lines =_gd .Lines ;};if _cbc .Paragraphs !=nil {if _gd .Paragraphs !=nil {*_cbc .Paragraphs +=*_gd .Paragraphs ;};}else if _gd .Paragraphs !=nil {_cbc .Paragraphs =_gd .Paragraphs ;};if _cbc .Notes !=nil {if _gd .Notes !=nil {*_cbc .Notes +=*_gd .Notes ;};}else if _gd .Notes !=nil {_cbc .Notes =_gd .Notes ;};if _cbc .HiddenSlides !=nil {if _gd .HiddenSlides !=nil {*_cbc .HiddenSlides +=*_gd .HiddenSlides ;};}else if _gd .HiddenSlides !=nil {_cbc .HiddenSlides =_gd .HiddenSlides ;};if _cbc .MMClips !=nil {if _gd .MMClips !=nil {*_cbc .MMClips +=*_gd .MMClips ;};}else if _gd .MMClips !=nil {_cbc .MMClips =_gd .MMClips ;};if _cbc .LinksUpToDate !=nil {if _gd .LinksUpToDate !=nil {*_cbc .LinksUpToDate =*_cbc .LinksUpToDate &&*_gd .LinksUpToDate ;};}else if _gd .LinksUpToDate !=nil {_cbc .LinksUpToDate =_gd .LinksUpToDate ;};if _cbc .CharactersWithSpaces !=nil {if _gd .CharactersWithSpaces !=nil {*_cbc .CharactersWithSpaces +=*_gd .CharactersWithSpaces ;};}else if _gd .CharactersWithSpaces !=nil {_cbc .CharactersWithSpaces =_gd .CharactersWithSpaces ;};if _cbc .SharedDoc !=nil {if _gd .SharedDoc !=nil {*_cbc .SharedDoc =*_cbc .SharedDoc ||*_gd .SharedDoc ;};}else if _gd .SharedDoc !=nil {_cbc .SharedDoc =_gd .SharedDoc ;};if _cbc .HyperlinksChanged !=nil {if _gd .HyperlinksChanged !=nil {*_cbc .HyperlinksChanged =*_cbc .HyperlinksChanged ||*_gd .HyperlinksChanged ;};}else if _gd .HyperlinksChanged !=nil {_cbc .HyperlinksChanged =_gd .HyperlinksChanged ;};_cbc .DigSig =nil ;if _cbc .TitlesOfParts ==nil &&_gd .TitlesOfParts !=nil {_cbc .TitlesOfParts =_gd .TitlesOfParts ;};if _cbc .HeadingPairs !=nil {if _gd .HeadingPairs !=nil {_fd :=_cbc .HeadingPairs .Vector ;_gac :=_gd .HeadingPairs .Vector ;_cd :=_fd .Variant ;_bc :=_gac .Variant ;_fdf :=[]*_daf .Variant {};for _bd :=0;_bd < len (_bc );_bd +=2{_fc :=_bc [_bd ].Lpstr ;_cdd :=false ;for _df :=0;_df < len (_cd );_df +=2{_fcb :=_cd [_df ].Lpstr ;if _fcb !=nil &&_fc !=nil &&*_fcb ==*_fc {*_cd [_df +1].I4 =*_cd [_df +1].I4 +*_bc [_bd +1].I4 ;_cdd =true ;break ;};};if !_cdd {_fdf =append (_fdf ,&_daf .Variant {CT_Variant :_daf .CT_Variant {Lpstr :_bc [_bd ].Lpstr }});_fdf =append (_fdf ,&_daf .Variant {CT_Variant :_daf .CT_Variant {I4 :_bc [_bd ].I4 }});};};_cd =append (_cd ,_fdf ...);_fd .SizeAttr =uint32 (len (_cd ));};}else if _gd .HeadingPairs !=nil {_cbc .HeadingPairs =_gd .HeadingPairs ;};if _cbc .HLinks !=nil {if _gd .HLinks !=nil {_dfb :=_cbc .HLinks .Vector ;_eec :=_gd .HLinks .Vector ;_eg :=_dfb .Variant ;_dd :=_eec .Variant ;for _ ,_dc :=range _dd {_dfc :=true ;for _ ,_cdf :=range _eg {if _g .DeepEqual (_cdf ,_dc ){_dfc =false ;break ;};};if _dfc {_eg =append (_eg ,_dc );_dfb .SizeAttr ++;};};};}else if _gd .HLinks !=nil {_cbc .HLinks =_gd .HLinks ;};_dbf :=_b .GetOrCreateCustomProperties ();_dfd :=docBase1 .GetOrCreateCustomProperties ();for _ ,_bde :=range _dfd .PropertiesList (){_dbf .setProperty (_bde );};_b .CustomProperties =_dbf ;_adg :=_b .Rels .X ().Relationship ;for _ ,_gfc :=range docBase1 .Rels .X ().Relationship {_gdb :=true ;for _ ,_fga :=range _adg {if _fga .TargetAttr ==_gfc .TargetAttr &&_fga .TypeAttr ==_gfc .TypeAttr {_gdb =false ;break ;};};if _gdb {_b .Rels .AddRelati
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Table represents a table in the document.
type Table struct{_fadc *_ggb .Tbl ;_ggdg *_ggb .CT_Transform2D ;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// NewCoreProperties constructs a new CoreProperties.
func NewCoreProperties ()CoreProperties {return CoreProperties {_agf :_ge .NewCoreProperties ()}};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// SetTitle records the title of the document.
func (_adbd CoreProperties )SetTitle (s string ){if _adbd ._agf .Title ==nil {_adbd ._agf .Title =&_gfe .XSDAny {XMLName :_c .Name {Local :"\u0064\u0063\u003a\u0074\u0069\u0074\u006c\u0065"}};};_adbd ._agf .Title .Data =[]byte (s );};
2021-03-16 20:51:18 +00:00
2021-04-23 20:00:00 +00:00
// CopyOverride copies override content type for a given `path` and puts it with a path `newPath`.
func (_efbe ContentTypes )CopyOverride (path ,newPath string ){if !_cb .HasPrefix (path ,"\u002f"){path ="\u002f"+path ;};if !_cb .HasPrefix (newPath ,"\u002f"){newPath ="\u002f"+newPath ;};for _cfe :=range _efbe ._cgg .Override {if _efbe ._cgg .Override [_cfe ].PartNameAttr ==path {_bfe :=*_efbe ._cgg .Override [_cfe ];_bfe .PartNameAttr =newPath ;_efbe ._cgg .Override =append (_efbe ._cgg .Override ,&_bfe );};};};
2020-11-09 01:00:18 +00:00
2021-04-23 20:00:00 +00:00
// FindRIDForN returns the relationship ID for the i'th relationship of type t.
func (_aaef Relationships )FindRIDForN (i int ,t string )string {for _ ,_agag :=range _aaef ._deaa .CT_Relationships .Relationship {if _agag .TypeAttr ==t {if i ==0{return _agag .IdAttr ;};i --;};};return "";};
2020-11-09 01:00:18 +00:00
2021-04-23 20:00:00 +00:00
// SetTarget set the target (path) of a relationship.
func (_ebaa Relationship )SetTarget (s string ){_ebaa ._caf .TargetAttr =s };
2020-11-09 01:00:18 +00:00
2021-04-23 20:00:00 +00:00
// SetLanguage records the language of the document.
func (_egb CoreProperties )SetLanguage (s string ){_egb ._agf .Language =&_gfe .XSDAny {XMLName :_c .Name {Local :"d\u0063\u003a\u006c\u0061\u006e\u0067\u0075\u0061\u0067\u0065"}};_egb ._agf .Language .Data =[]byte (s );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Relationships returns a slice of all of the relationships.
func (_dag Relationships )Relationships ()[]Relationship {_ccd :=[]Relationship {};for _ ,_decf :=range _dag ._deaa .Relationship {_ccd =append (_ccd ,Relationship {_caf :_decf });};return _ccd ;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// NewContentTypes returns a wrapper around a newly constructed content-types.
func NewContentTypes ()ContentTypes {_dfdb :=ContentTypes {_cgg :_db .NewTypes ()};_dfdb .AddDefault ("\u0078\u006d\u006c","\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u0078\u006d\u006c");_dfdb .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");_dfdb .AddDefault ("\u0070\u006e\u0067","\u0069m\u0061\u0067\u0065\u002f\u0070\u006eg");_dfdb .AddDefault ("\u006a\u0070\u0065\u0067","\u0069\u006d\u0061\u0067\u0065\u002f\u006a\u0070\u0065\u0067");_dfdb .AddDefault ("\u006a\u0070\u0067","\u0069m\u0061\u0067\u0065\u002f\u006a\u0070g");_dfdb .AddDefault ("\u0077\u006d\u0066","i\u006d\u0061\u0067\u0065\u002f\u0078\u002d\u0077\u006d\u0066");_dfdb .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");_dfdb .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 _dfdb ;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// AddCustomRelationships adds relationships related to custom properties to the document.
func (_aec *DocBase )AddCustomRelationships (){_aec .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");_aec .Rels .AddRelationship ("\u0064\u006f\u0063\u0050ro\u0070\u0073\u002f\u0063\u0075\u0073\u0074\u006f\u006d\u002e\u0078\u006d\u006c",_gfe .CustomPropertiesType );};func (_aeb CustomProperties )SetPropertyAsClsid (name string ,clsid string ){_dae :=_aeb .getNewProperty (name );_dae .Clsid =&clsid ;_aeb .setOrReplaceProperty (_dae );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// NewRelationshipsCopy creates a new relationships wrapper as a copy of passed in instance.
func NewRelationshipsCopy (rels Relationships )Relationships {_fgg :=*rels ._deaa ;return Relationships {_deaa :&_fgg };};func (_bgf CustomProperties )SetPropertyAsCy (name string ,cy string ){_eddd :=_bgf .getNewProperty (name );_eddd .Cy =&cy ;_bgf .setOrReplaceProperty (_eddd );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// ID returns the ID of a relationship.
func (_cfae Relationship )ID ()string {return _cfae ._caf .IdAttr };func (_cebf TableRow )addCell ()*_ggb .CT_TableCell {_cbcc :=_ggb .NewCT_TableCell ();_cebf ._dgc .Tc =append (_cebf ._dgc .Tc ,_cbcc );return _cbcc ;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// WriteExtraFiles writes the extra files to the zip package.
func (_eaf *DocBase )WriteExtraFiles (z *_af .Writer )error {for _ ,_dcc :=range _eaf .ExtraFiles {if _ecdb :=_ec .AddFileFromDisk (z ,_dcc .ZipPath ,_dcc .DiskPath );_ecdb !=nil {return _ecdb ;};};return nil ;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// AddDefault registers a default content type for a given file extension.
func (_fbe ContentTypes )AddDefault (fileExtension string ,contentType string ){fileExtension =_cb .ToLower (fileExtension );for _ ,_bcfe :=range _fbe ._cgg .Default {if _bcfe .ExtensionAttr ==fileExtension &&_bcfe .ContentTypeAttr ==contentType {return ;};};_eecc :=_db .NewDefault ();_eecc .ExtensionAttr =fileExtension ;_eecc .ContentTypeAttr =contentType ;_fbe ._cgg .Default =append (_fbe ._cgg .Default ,_eecc );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// SetModified sets the time that the document was modified.
func (_gaa CoreProperties )SetModified (t _e .Time ){_gaa ._agf .Modified =_cab (t ,"\u0064\u0063t\u0065\u0072\u006ds\u003a\u006d\u006f\u0064\u0069\u0066\u0069\u0065\u0064");};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// TableRow represents a row in a table.
type TableRow struct{_dgc *_ggb .CT_TableRow };
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// SetDescription records the description of the document.
func (_bfa CoreProperties )SetDescription (s string ){if _bfa ._agf .Description ==nil {_bfa ._agf .Description =&_gfe .XSDAny {XMLName :_c .Name {Local :"\u0064\u0063\u003a\u0064\u0065\u0073\u0063\u0072\u0069p\u0074\u0069\u006f\u006e"}};};_bfa ._agf .Description .Data =[]byte (s );};func (_ead CustomProperties )SetPropertyAsI1 (name string ,i1 int8 ){_ced :=_ead .getNewProperty (name );_ced .I1 =&i1 ;_ead .setOrReplaceProperty (_ced );};func _cab (_cde _e .Time ,_fbec string )*_gfe .XSDAny {_agfc :=&_gfe .XSDAny {XMLName :_c .Name {Local :_fbec }};_agfc .Attrs =append (_agfc .Attrs ,_c .Attr {Name :_c .Name {Local :"\u0078\u0073\u0069\u003a\u0074\u0079\u0070\u0065"},Value :"\u0064\u0063\u0074\u0065\u0072\u006d\u0073\u003a\u00573\u0043\u0044\u0054\u0046"});_agfc .Attrs =append (_agfc .Attrs ,_c .Attr {Name :_c .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"});_agfc .Attrs =append (_agfc .Attrs ,_c .Attr {Name :_c .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/"});_agfc .Data =[]byte (_cde .Format (_dfe ));return _agfc ;};func (_cfa CustomProperties )SetPropertyAsDecimal (name string ,decimal float64 ){_efag :=_cfa .getNewProperty (name );_efag .Decimal =&decimal ;_cfa .setOrReplaceProperty (_efag );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// X returns the inner wrapped XML type.
func (_edag TableStyles )X ()*_ggb .TblStyleLst {return _edag ._gaed };const _gec =2021;
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Data returns the data of an image file, if any.
func (_cge ImageRef )Data ()*[]byte {return _cge ._dcg .Data };
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// SetCreated sets the time that the document was created.
func (_ecf CoreProperties )SetCreated (t _e .Time ){_ecf ._agf .Created =_cab (t ,"\u0064c\u0074e\u0072\u006d\u0073\u003a\u0063\u0072\u0065\u0061\u0074\u0065\u0064");};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// PropertiesList returns the list of all custom properties of the document.
func (_ddc CustomProperties )PropertiesList ()[]*_ef .CT_Property {return _ddc ._gcaa .Property };func (_ffed CustomProperties )SetPropertyAsNull (name string ){_cac :=_ffed .getNewProperty (name );_cac .Null =_daf .NewNull ();_ffed .setOrReplaceProperty (_cac );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// GetImageBytesByTarget returns Image object with Data bytes read from its target.
func (_cdfb *DocBase )GetImageBytesByTarget (target string )(Image ,error ){if target !=""{target ="\u0077\u006f\u0072d\u002f"+target ;for _ ,_ecc :=range _cdfb .Images {if _ecc .Target ()==target {return ImageFromStorage (_ecc .Path ());};};};return Image {},_ebd ;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// GetOrCreateCustomProperties returns the custom properties of the document (and if they not exist yet, creating them first).
func (_efd *DocBase )GetOrCreateCustomProperties ()CustomProperties {if _efd .CustomProperties .X ()==nil {_efd .CreateCustomProperties ();};return _efd .CustomProperties ;};
2020-10-12 13:59:12 +00:00
2021-04-23 20:00:00 +00:00
// SetDocSecurity sets the document security flag.
func (_dg AppProperties )SetDocSecurity (v int32 ){_dg ._ede .DocSecurity =_gfe .Int32 (v )};
2020-10-12 13:59:12 +00:00
2021-04-23 20:00:00 +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 (_bcfg AppProperties )Application ()string {if _bcfg ._ede .Application !=nil {return *_bcfg ._ede .Application ;};return "";};
2020-10-12 13:59:12 +00:00
2021-04-23 20:00:00 +00:00
// Relationship is a relationship within a .rels file.
type Relationship struct{_caf *_aae .Relationship };
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// SetLastModifiedBy records the last person to modify the document.
func (_cggf CoreProperties )SetLastModifiedBy (s string ){_cggf ._agf .LastModifiedBy =&s };func (_fge CustomProperties )setPropertyHelper (_ddf *_ef .CT_Property ,_be bool ){_dbff :=_fge .GetPropertyByName (*_ddf .NameAttr );if (_dbff ==CustomProperty {}){_fge ._gcaa .Property =append (_fge ._gcaa .Property ,_ddf );}else if _be {_ddf .FmtidAttr =_dbff ._ffb .FmtidAttr ;if _dbff ._ffb .PidAttr ==0{_ddf .PidAttr =_dbff ._ffb .PidAttr ;};_ddf .LinkTargetAttr =_dbff ._ffb .LinkTargetAttr ;*_dbff ._ffb =*_ddf ;};};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// CopyRelationship copies the relationship.
func (_gfeg Relationships )CopyRelationship (idAttr string )(Relationship ,bool ){for _eaab :=range _gfeg ._deaa .Relationship {if _gfeg ._deaa .Relationship [_eaab ].IdAttr ==idAttr {_eag :=*_gfeg ._deaa .Relationship [_eaab ];_ded :=len (_gfeg ._deaa .Relationship )+1;_dbdd :=map[string ]struct{}{};for _ ,_dbfd :=range _gfeg ._deaa .Relationship {_dbdd [_dbfd .IdAttr ]=struct{}{};};for _ ,_adf :=_dbdd [_ee .Sprintf ("\u0072\u0049\u0064%\u0064",_ded )];_adf ;_ ,_adf =_dbdd [_ee .Sprintf ("\u0072\u0049\u0064%\u0064",_ded )]{_ded ++;};_eag .IdAttr =_ee .Sprintf ("\u0072\u0049\u0064%\u0064",_ded );_gfeg ._deaa .Relationship =append (_gfeg ._deaa .Relationship ,&_eag );return Relationship {_caf :&_eag },true ;};};return Relationship {},false ;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// GetTargetByRelId returns a target path with the associated relation ID.
func (_fdfb Relationships )GetTargetByRelId (idAttr string )string {for _ ,_cca :=range _fdfb ._deaa .Relationship {if _cca .IdAttr ==idAttr {return _cca .TargetAttr ;};};return "";};
2021-03-16 20:51:18 +00:00
2021-04-23 20:00:00 +00:00
// SetOffsetX sets horizontal offset of a table in distance units (see measurement package).
func (_cfc Table )SetOffsetX (offX float64 ){if _cfc ._ggdg .Off ==nil {_cfc ._ggdg .Off =_ggb .NewCT_Point2D ();_abfb :=int64 (0);_cfc ._ggdg .Off .YAttr =_ggb .ST_Coordinate {ST_CoordinateUnqualified :&_abfb };};_agaa :=_eb .ToEMU (offX );_cfc ._ggdg .Off .XAttr =_ggb .ST_Coordinate {ST_CoordinateUnqualified :&_agaa };};func (_ade CustomProperties )SetPropertyAsUi4 (name string ,ui4 uint32 ){_gff :=_ade .getNewProperty (name );_gff .Ui4 =&ui4 ;_ade .setOrReplaceProperty (_gff );};
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 (_fe AppProperties )X ()*_aaea .Properties {return _fe ._ede };const _eed =30;
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Title returns the Title of the document
func (_ggf CoreProperties )Title ()string {if _ggf ._agf .Title !=nil {return string (_ggf ._agf .Title .Data );};return "";};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// TableStyles contains document specific properties.
type TableStyles struct{_gaed *_ggb .TblStyleLst };
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Theme is a drawingml theme.
type Theme struct{_cffd *_ggb .Theme };
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// SetApplicationVersion sets the version of the application that created the
// document. Per MS, the verison string mut be in the form 'XX.YYYY'.
func (_ggbe AppProperties )SetApplicationVersion (s string ){_ggbe ._ede .AppVersion =&s };
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Size returns the size of an image
func (_bag ImageRef )Size ()_gg .Point {return _bag ._dcg .Size };func (_gebc CustomProperties )SetPropertyAsError (name string ,error string ){_cggd :=_gebc .getNewProperty (name );_cggd .Error =&error ;_gebc .setOrReplaceProperty (_cggd );};var _ebd =_a .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
2021-04-23 20:00:00 +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).
func (_fgc *ImageRef )SetTarget (target string ){_fgc ._dbcd =target };
// 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 (_ae AppProperties )Pages ()int32 {if _ae ._ede .Pages !=nil {return *_ae ._ede .Pages ;};return 0;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// DocBase is the type embedded in in the Document/Workbook/Presentation types
// that contains members common to all.
2021-04-23 20:00:00 +00:00
type DocBase struct{ContentTypes ContentTypes ;AppProperties AppProperties ;Rels Relationships ;CoreProperties CoreProperties ;CustomProperties CustomProperties ;Thumbnail _gg .Image ;Images []ImageRef ;ExtraFiles []ExtraFile ;TmpPath string ;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// X returns the inner wrapped XML type.
func (_dab CustomProperties )X ()*_ef .Properties {return _dab ._gcaa };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Category returns the category of the document
2021-04-23 20:00:00 +00:00
func (_dbe CoreProperties )Category ()string {if _dbe ._agf .Category !=nil {return *_dbe ._agf .Category ;};return "";};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// NewTableStyles constructs a new TableStyles.
func NewTableStyles ()TableStyles {return TableStyles {_gaed :_ggb .NewTblStyleLst ()}};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +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 {_dcg :img ,_gae :d ,_fad :rels };};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// ImageRef is a reference to an image within a document.
type ImageRef struct{_gae *DocBase ;_fad Relationships ;_dcg Image ;_ebb string ;_dbcd string ;};func (_fgdf CustomProperties )SetPropertyAsLpstr (name string ,lpstr string ){_afcd :=_fgdf .getNewProperty (name );_afcd .Lpstr =&lpstr ;_fgdf .setOrReplaceProperty (_afcd );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Created returns the time that the document was created.
func (_cbb CoreProperties )Created ()_e .Time {return _gca (_cbb ._agf .Created )};func (_efdd Relationship )String ()string {return _ee .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",_efdd .ID (),_efdd .Target (),_efdd .Type ());};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Properties returns table properties.
func (_adc Table )Properties ()*_ggb .CT_TableProperties {return _adc ._fadc .TblPr };
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +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 (_beee CustomProperties )SetPropertyAsR8 (name string ,r8 float64 ){_dbab :=_beee .getNewProperty (name );_dbab .R8 =&r8 ;_beee .setOrReplaceProperty (_dbab );};func init (){_aa .SetAsStorage ()};func (_bff CustomProperties )SetPropertyAsVector (name string ,vector *_daf .Vector ){_feb :=_bff .getNewProperty (name );_feb .Vector =vector ;_bff .setOrReplaceProperty (_feb );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// AddHyperlink adds an external hyperlink relationship.
func (_agb Relationships )AddHyperlink (target string )Hyperlink {_fca :=_agb .AddRelationship (target ,_gfe .HyperLinkType );_fca ._caf .TargetModeAttr =_aae .ST_TargetModeExternal ;return Hyperlink (_fca );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Description returns the description of the document
func (_bbc CoreProperties )Description ()string {if _bbc ._agf .Description !=nil {return string (_bbc ._agf .Description .Data );};return "";};const Version ="\u0031\u002e\u0031\u0030\u002e\u0030";var ReleasedAt =_e .Date (_gec ,_edec ,_gffb ,_cef ,_eed ,0,0,_e .UTC );const _gffb =23;
// Company returns the name of the company that created the document.
// For unioffice created documents, it defaults to github.com/unidoc/unioffice
func (_edf AppProperties )Company ()string {if _edf ._ede .Company !=nil {return *_edf ._ede .Company ;};return "";};const _cef =19;
// SetContentStatus records the content status of the document.
func (_dca CoreProperties )SetContentStatus (s string ){_dca ._agf .ContentStatus =&s };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetCategory records the category of the document.
2021-04-23 20:00:00 +00:00
func (_cc CoreProperties )SetCategory (s string ){_cc ._agf .Category =&s };func (_cgd CustomProperties )SetPropertyAsI8 (name string ,i8 int64 ){_eac :=_cgd .getNewProperty (name );_eac .I8 =&i8 ;_cgd .setOrReplaceProperty (_eac );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// EnsureOverride ensures that an override for the given path exists, adding it if necessary
func (_dfbf ContentTypes )EnsureOverride (path ,contentType string ){for _ ,_bcb :=range _dfbf ._cgg .Override {if _bcb .PartNameAttr ==path {if _cb .HasPrefix (contentType ,"\u0068\u0074\u0074\u0070"){_gfe .Log ("\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 );};_bcb .ContentTypeAttr =contentType ;return ;};};_dfbf .AddOverride (path ,contentType );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// SetStyle assigns TableStyle to a table.
func (_gbf Table )SetStyle (style *_ggb .CT_TableStyle ){if _gbf ._fadc .TblPr ==nil {_gbf ._fadc .TblPr =_ggb .NewCT_TableProperties ();};if _gbf ._fadc .TblPr .Choice ==nil {_gbf ._fadc .TblPr .Choice =_ggb .NewCT_TablePropertiesChoice ();};_gbf ._fadc .TblPr .Choice .TableStyle =style ;};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// Target returns the target attrubute of the image reference (a path where the image file is located in the document structure).
func (_gddd *ImageRef )Target ()string {return _gddd ._dbcd };func (_cec CustomProperties )SetPropertyAsOblob (name ,oblob string ){_adbg :=_cec .getNewProperty (name );_adbg .Oblob =&oblob ;_cec .setOrReplaceProperty (_adbg );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// NewTheme constructs a new theme.
func NewTheme ()Theme {return Theme {_ggb .NewTheme ()}};func (_eae CustomProperties )SetPropertyAsUint (name string ,ui uint ){_dad :=_eae .getNewProperty (name );_edad :=uint32 (ui );_dad .Uint =&_edad ;_eae .setOrReplaceProperty (_dad );};
2020-08-23 14:15:53 +00:00
2021-04-23 20:00:00 +00:00
// TblStyle returns the TblStyle property.
func (_gcg TableStyles )TblStyle ()[]*_ggb .CT_TableStyle {return _gcg ._gaed .TblStyle };
2020-10-12 13:59:12 +00:00
2021-04-23 20:00:00 +00:00
// CreateCustomProperties creates the custom properties of the document.
func (_fddc *DocBase )CreateCustomProperties (){_fddc .CustomProperties =NewCustomProperties ();_fddc .AddCustomRelationships ();};func (_beb CustomProperties )SetPropertyAsUi1 (name string ,ui1 uint8 ){_bbd :=_beb .getNewProperty (name );_bbd .Ui1 =&ui1 ;_beb .setOrReplaceProperty (_bbd );};
2020-10-12 13:59:12 +00:00
2021-04-23 20:00:00 +00:00
// Properties returns table properties.
func (_eea Table )Grid ()*_ggb .CT_TableGrid {return _eea ._fadc .TblGrid };
2020-11-09 01:00:18 +00:00
2021-04-23 20:00:00 +00:00
// X returns the inner wrapped XML type.
func (_fgd CoreProperties )X ()*_ge .CoreProperties {return _fgd ._agf };
2020-11-09 01:00:18 +00:00
2021-04-23 20:00:00 +00:00
// X returns the underlying raw XML data.
func (_aga Relationships )X ()*_aae .Relationships {return _aga ._deaa };
2020-12-17 22:07:08 +00:00
2021-04-23 20:00:00 +00:00
// SetApplication sets the name of the application that created the document.
func (_bb AppProperties )SetApplication (s string ){_bb ._ede .Application =&s };
2020-12-17 22:07:08 +00:00
2021-04-23 20:00:00 +00:00
// AddRow adds a row to a table.
func (_egd Table )AddRow ()*TableRow {_fdb :=_ggb .NewCT_TableRow ();for _cfgc :=0;_cfgc < len (_egd ._fadc .TblGrid .GridCol );_cfgc ++{_fdb .Tc =append (_fdb .Tc ,_ggb .NewCT_TableCell ());};_egd ._fadc .Tr =append (_egd ._fadc .Tr ,_fdb );return &TableRow {_dgc :_fdb };};const _edec =4;
2020-12-17 22:07:08 +00:00
2021-04-23 20:00:00 +00:00
// X returns the inner raw content types.
func (_efb ContentTypes )X ()*_db .Types {return _efb ._cgg };
2020-12-17 22:07:08 +00:00
2021-04-23 20:00:00 +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 (_eef ImageRef )RelativeHeight (w _eb .Distance )_eb .Distance {_ddb :=float64 (_eef .Size ().Y )/float64 (_eef .Size ().X );return w *_eb .Distance (_ddb );};func (_beec CustomProperties )SetPropertyAsDate (name string ,date _e .Time ){date =date .UTC ();_bgd ,_ebeg ,_egg :=date .Date ();_ggdba ,_afgd ,_eeb :=date .Clock ();_bda :=_e .Date (_bgd ,_ebeg ,_egg ,_ggdba ,_afgd ,_eeb ,0,_e .UTC );_cdeb :=_beec .getNewProperty (name );_cdeb .Filetime =&_bda ;_beec .setOrReplaceProperty (_cdeb );};func (_bee CustomProperties )SetPropertyAsUi2 (name string ,ui2 uint16 ){_ecg :=_bee .getNewProperty (name );_ecg .Ui2 =&ui2 ;_bee .setOrReplaceProperty (_ecg );};
2020-12-17 22:07:08 +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 (_bfb Theme )X ()*_ggb .Theme {return _bfb ._cffd };
// Target returns the target (path) of a relationship.
func (_acgc Relationship )Target ()string {return _acgc ._caf .TargetAttr };
// AddImageToZip adds an image (either from bytes or from disk) and adds it to the zip file.
func AddImageToZip (z *_af .Writer ,img ImageRef ,imageNum int ,dt _gfe .DocType )error {_dfcd :=_gfe .AbsoluteImageFilename (dt ,imageNum ,_cb .ToLower (img .Format ()));if img .Data ()!=nil &&len (*img .Data ())> 0{if _cce :=_ec .AddFileFromBytes (z ,_dfcd ,*img .Data ());_cce !=nil {return _cce ;};}else if img .Path ()!=""{if _edadd :=_ec .AddFileFromDisk (z ,_dfcd ,img .Path ());_edadd !=nil {return _edadd ;};}else {return _ee .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 ;};func (_gda CustomProperties )setProperty (_dbc *_ef .CT_Property ){_gda .setPropertyHelper (_dbc ,false )};
// 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 (_dfbd Relationships )AddAutoRelationship (dt _gfe .DocType ,src string ,idx int ,ctype string )Relationship {return _dfbd .AddRelationship (_gfe .RelativeFilename (dt ,src ,ctype ,idx ),ctype );};