unioffice/common/common.go

401 lines
47 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-03-16 20:51:18 +00:00
package common ;import (_fb "archive/zip";_dg "bytes";_e "encoding/xml";_ea "fmt";_ceg "github.com/unidoc/unioffice";_cef "github.com/unidoc/unioffice/common/tempstorage";_bc "github.com/unidoc/unioffice/common/tempstorage/diskstore";_ce "github.com/unidoc/unioffice/measurement";_gg "github.com/unidoc/unioffice/schema/soo/dml";_agb "github.com/unidoc/unioffice/schema/soo/ofc/custom_properties";_db "github.com/unidoc/unioffice/schema/soo/ofc/docPropsVTypes";_dag "github.com/unidoc/unioffice/schema/soo/ofc/extended_properties";_ga "github.com/unidoc/unioffice/schema/soo/pkg/content_types";_fe "github.com/unidoc/unioffice/schema/soo/pkg/metadata/core_properties";_da "github.com/unidoc/unioffice/schema/soo/pkg/relationships";_ceb "github.com/unidoc/unioffice/zippkg";_de "image";_ "image/gif";_ "image/jpeg";_ "image/png";_ab "os";_ag "reflect";_c "regexp";_b "strconv";_ff "strings";_ac "time";);
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// AddOverride adds an override content type for a given path name.
func (_fgb ContentTypes )AddOverride (path ,contentType string ){if !_ff .HasPrefix (path ,"\u002f"){path ="\u002f"+path ;};if _ff .HasPrefix (contentType ,"\u0068\u0074\u0074\u0070"){_ceg .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 _ ,_fd :=range _fgb ._eb .Override {if _fd .PartNameAttr ==path &&_fd .ContentTypeAttr ==contentType {return ;};};_bag :=_ga .NewOverride ();_bag .PartNameAttr =path ;_bag .ContentTypeAttr =contentType ;_fgb ._eb .Override =append (_fgb ._eb .Override ,_bag );};
// AddCustomRelationships adds relationships related to custom properties to the document.
func (_eeg *DocBase )AddCustomRelationships (){_eeg .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");_eeg .Rels .AddRelationship ("\u0064\u006f\u0063\u0050ro\u0070\u0073\u002f\u0063\u0075\u0073\u0074\u006f\u006d\u002e\u0078\u006d\u006c",_ceg .CustomPropertiesType );};
// X returns the inner raw content types.
func (_eab ContentTypes )X ()*_ga .Types {return _eab ._eb };
// 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.
func ImageFromFile (path string )(Image ,error ){_fdb ,_aged :=_ab .Open (path );_agg :=Image {};if _aged !=nil {return _agg ,_ea .Errorf ("\u0065\u0072\u0072or\u0020\u0072\u0065\u0061\u0064\u0069\u006e\u0067\u0020\u0069\u006d\u0061\u0067\u0065\u003a\u0020\u0025\u0073",_aged );};defer _fdb .Close ();_ddf ,_fdf ,_aged :=_de .Decode (_fdb );if _aged !=nil {return _agg ,_ea .Errorf ("\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s",_aged );};_agg .Path =path ;_agg .Format =_fdf ;_agg .Size =_ddf .Bounds ().Size ();return _agg ,nil ;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// NewCoreProperties constructs a new CoreProperties.
func NewCoreProperties ()CoreProperties {return CoreProperties {_cgc :_fe .NewCoreProperties ()}};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// X returns the inner wrapped XML type.
func (_acb Relationship )X ()*_da .Relationship {return _acb ._bef };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// NewCustomProperties constructs a new CustomProperties.
func NewCustomProperties ()CustomProperties {return CustomProperties {_aca :_agb .NewProperties ()}};
// AddDefault registers a default content type for a given file extension.
func (_cegbd ContentTypes )AddDefault (fileExtension string ,contentType string ){fileExtension =_ff .ToLower (fileExtension );for _ ,_ggbfd :=range _cegbd ._eb .Default {if _ggbfd .ExtensionAttr ==fileExtension &&_ggbfd .ContentTypeAttr ==contentType {return ;};};_daf :=_ga .NewDefault ();_daf .ExtensionAttr =fileExtension ;_daf .ContentTypeAttr =contentType ;_cegbd ._eb .Default =append (_cegbd ._eb .Default ,_daf );};func (_cgab CustomProperties )SetPropertyAsI2 (name string ,i2 int16 ){_feb :=_cgab .getNewProperty (name );_feb .I2 =&i2 ;_cgab .setOrReplaceProperty (_feb );};const Version ="\u0031\u002e\u0039.\u0030";
// SetStyle assigns TableStyle to a table.
func (_aff Table )SetStyle (style *_gg .CT_TableStyle ){if _aff ._cbaf .TblPr ==nil {_aff ._cbaf .TblPr =_gg .NewCT_TableProperties ();};if _aff ._cbaf .TblPr .Choice ==nil {_aff ._cbaf .TblPr .Choice =_gg .NewCT_TablePropertiesChoice ();};_aff ._cbaf .TblPr .Choice .TableStyle =style ;};func (_ebfe CustomProperties )SetPropertyAsUi8 (name string ,ui8 uint64 ){_ged :=_ebfe .getNewProperty (name );_ged .Ui8 =&ui8 ;_ebfe .setOrReplaceProperty (_ged );};
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Properties returns table properties.
2021-03-16 20:51:18 +00:00
func (_dcdf Table )Properties ()*_gg .CT_TableProperties {return _dcdf ._cbaf .TblPr };
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.
func (_adg AppProperties )SetCompany (s string ){_adg ._fbd .Company =&s };func (_caa CustomProperties )SetPropertyAsUi1 (name string ,ui1 uint8 ){_fde :=_caa .getNewProperty (name );_fde .Ui1 =&ui1 ;_caa .setOrReplaceProperty (_fde );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Format returns the format of the underlying image
func (_eef ImageRef )Format ()string {return _eef ._cbe .Format };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// NewRelationships creates a new relationship wrapper.
func NewRelationships ()Relationships {return Relationships {_ccdg :_da .NewRelationships ()}};func (_bbc CustomProperties )SetPropertyAsNull (name string ){_ebg :=_bbc .getNewProperty (name );_ebg .Null =_db .NewNull ();_bbc .setOrReplaceProperty (_ebg );};func (_fec CustomProperties )getNewProperty (_eed string )*_agb .CT_Property {_cegg :=_fec ._aca .Property ;_cga :=int32 (1);for _ ,_cb :=range _cegg {if _cb .PidAttr > _cga {_cga =_cb .PidAttr ;};};_fcf :=_agb .NewCT_Property ();_fcf .NameAttr =&_eed ;_fcf .PidAttr =_cga +1;_fcf .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 _fcf ;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// RemoveOverrideByIndex removes an override given a path and override index.
func (_bb ContentTypes )RemoveOverrideByIndex (path string ,indexToFind int )error {_cg :=path [0:len (path )-5];if !_ff .HasPrefix (_cg ,"\u002f"){_cg ="\u002f"+_cg ;};_dga ,_gade :=_c .Compile (_cg +"\u0028\u005b\u0030-\u0039\u005d\u002b\u0029\u002e\u0078\u006d\u006c");if _gade !=nil {return _gade ;};_cac :=0;_agba :=-1;for _gcc ,_dbb :=range _bb ._eb .Override {if _fcg :=_dga .FindStringSubmatch (_dbb .PartNameAttr );len (_fcg )> 1{if _cac ==indexToFind {_agba =_gcc ;}else if _cac > indexToFind {_eba ,_ :=_b .Atoi (_fcg [1]);_eba --;_dbb .PartNameAttr =_ea .Sprintf ("\u0025\u0073\u0025\u0064\u002e\u0078\u006d\u006c",_cg ,_eba );};_cac ++;};};if _agba > -1{copy (_bb ._eb .Override [_agba :],_bb ._eb .Override [_agba +1:]);_bb ._eb .Override =_bb ._eb .Override [0:len (_bb ._eb .Override )-1];};return nil ;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// NewAppProperties constructs a new AppProperties.
func NewAppProperties ()AppProperties {_ggbf :=AppProperties {_fbd :_dag .NewProperties ()};_ggbf .SetCompany ("\u0046\u006f\u0078\u0079\u0055\u0074\u0069\u006c\u0073\u0020\u0065\u0068\u0066");_ggbf .SetApplication ("g\u0069\u0074\u0068\u0075\u0062\u002ec\u006f\u006d\u002f\u0075\u006e\u0069\u0064\u006f\u0063/\u0075\u006e\u0069o\u0066f\u0069\u0063\u0065");_ggbf .SetDocSecurity (0);_ggbf .SetLinksUpToDate (false );var _age ,_cee ,_cfce int64 ;_ea .Sscanf (Version ,"\u0025\u0064\u002e\u0025\u0064\u002e\u0025\u0064",&_age ,&_cee ,&_cfce );_bcd :=float64 (_age )+float64 (_cee )/10000.0;_ggbf .SetApplicationVersion (_ea .Sprintf ("\u0025\u0030\u0037\u002e\u0034\u0066",_bcd ));return _ggbf ;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// NewContentTypes returns a wrapper around a newly constructed content-types.
func NewContentTypes ()ContentTypes {_cdf :=ContentTypes {_eb :_ga .NewTypes ()};_cdf .AddDefault ("\u0078\u006d\u006c","\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u0078\u006d\u006c");_cdf .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");_cdf .AddDefault ("\u0070\u006e\u0067","\u0069m\u0061\u0067\u0065\u002f\u0070\u006eg");_cdf .AddDefault ("\u006a\u0070\u0065\u0067","\u0069\u006d\u0061\u0067\u0065\u002f\u006a\u0070\u0065\u0067");_cdf .AddDefault ("\u006a\u0070\u0067","\u0069m\u0061\u0067\u0065\u002f\u006a\u0070g");_cdf .AddDefault ("\u0077\u006d\u0066","i\u006d\u0061\u0067\u0065\u002f\u0078\u002d\u0077\u006d\u0066");_cdf .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");_cdf .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 _cdf ;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +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 ;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +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 (_gad AppProperties )SetApplicationVersion (s string ){_gad ._fbd .AppVersion =&s };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Description returns the description of the document
func (_dbc CoreProperties )Description ()string {if _dbc ._cgc .Description !=nil {return string (_dbc ._cgc .Description .Data );};return "";};func (_fdad CustomProperties )SetPropertyAsBool (name string ,b bool ){_ecb :=_fdad .getNewProperty (name );_ecb .Bool =&b ;_fdad .setOrReplaceProperty (_ecb );};func (_eace CustomProperties )SetPropertyAsI8 (name string ,i8 int64 ){_fgba :=_eace .getNewProperty (name );_fgba .I8 =&i8 ;_eace .setOrReplaceProperty (_fgba );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// NewTable makes a new table.
func NewTable ()*Table {_fdeg :=_gg .NewTbl ();_fdeg .TblPr =_gg .NewCT_TableProperties ();return &Table {_cbaf :_fdeg };};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// CopyOverride copies override content type for a given `path` and puts it with a path `newPath`.
func (_cda ContentTypes )CopyOverride (path ,newPath string ){if !_ff .HasPrefix (path ,"\u002f"){path ="\u002f"+path ;};if !_ff .HasPrefix (newPath ,"\u002f"){newPath ="\u002f"+newPath ;};for _efg :=range _cda ._eb .Override {if _cda ._eb .Override [_efg ].PartNameAttr ==path {_bac :=*_cda ._eb .Override [_efg ];_bac .PartNameAttr =newPath ;_cda ._eb .Override =append (_cda ._eb .Override ,&_bac );};};};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// NewTheme constructs a new theme.
func NewTheme ()Theme {return Theme {_gg .NewTheme ()}};
2020-10-12 13:59:12 +00:00
2021-03-16 20:51:18 +00:00
// X returns the underlying raw XML data.
func (_abcf Relationships )X ()*_da .Relationships {return _abcf ._ccdg };func (_caeg CustomProperties )SetPropertyAsArray (name string ,array *_db .Array ){_cfff :=_caeg .getNewProperty (name );_cfff .Array =array ;_caeg .setOrReplaceProperty (_cfff );};
2020-10-12 13:59:12 +00:00
2021-03-16 20:51:18 +00:00
// AddHyperlink adds an external hyperlink relationship.
func (_fga Relationships )AddHyperlink (target string )Hyperlink {_afdga :=_fga .AddRelationship (target ,_ceg .HyperLinkType );_afdga ._bef .TargetModeAttr =_da .ST_TargetModeExternal ;return Hyperlink (_afdga );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Path returns the path to an image file, if any.
func (_aeb ImageRef )Path ()string {return _aeb ._cbe .Path };func (_ecc CustomProperties )SetPropertyAsBstr (name string ,bstr string ){_fed :=_ecc .getNewProperty (name );_fed .Bstr =&bstr ;_ecc .setOrReplaceProperty (_fed );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// X returns the inner wrapped XML type.
func (_gcf CustomProperties )X ()*_agb .Properties {return _gcf ._aca };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// TableRow represents a row in a table.
type TableRow struct{_aedc *_gg .CT_TableRow };func (_dcb CustomProperties )setPropertyHelper (_abce *_agb .CT_Property ,_dcd bool ){_eac :=_dcb .GetPropertyByName (*_abce .NameAttr );if (_eac ==CustomProperty {}){_dcb ._aca .Property =append (_dcb ._aca .Property ,_abce );}else if _dcd {_abce .FmtidAttr =_eac ._dff .FmtidAttr ;if _eac ._dff .PidAttr ==0{_abce .PidAttr =_eac ._dff .PidAttr ;};_abce .LinkTargetAttr =_eac ._dff .LinkTargetAttr ;*_eac ._dff =*_abce ;};};func (_aa CustomProperties )setOrReplaceProperty (_afb *_agb .CT_Property ){_aa .setPropertyHelper (_afb ,true );};func (_bfe CustomProperties )SetPropertyAsClsid (name string ,clsid string ){_ggg :=_bfe .getNewProperty (name );_ggg .Clsid =&clsid ;_bfe .setOrReplaceProperty (_ggg );};func (_edb CustomProperties )SetPropertyAsEmpty (name string ){_gfe :=_edb .getNewProperty (name );_gfe .Empty =_db .NewEmpty ();_edb .setOrReplaceProperty (_gfe );};
2020-11-09 01:00:18 +00:00
2021-03-16 20:51:18 +00:00
// AddCol adds a column to a table.
func (_bdfc Table )AddCol ()*TableCol {_gea :=_gg .NewCT_TableCol ();_bdfc ._cbaf .TblGrid .GridCol =append (_bdfc ._cbaf .TblGrid .GridCol ,_gea );for _ ,_dfeg :=range _bdfc ._cbaf .Tr {_dba :=_gg .NewCT_TableCell ();_dfeg .Tc =append (_dfeg .Tc ,_dba );};return &TableCol {_ebec :_gea };};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Author returns the author of the document
func (_ed CoreProperties )Author ()string {if _ed ._cgc .Creator !=nil {return string (_ed ._cgc .Creator .Data );};return "";};
2020-08-31 22:58:25 +00:00
2021-03-16 20:51:18 +00:00
// Target returns the target (path) of a relationship.
func (_eefc Relationship )Target ()string {return _eefc ._bef .TargetAttr };func (_dfa CustomProperties )SetPropertyAsVector (name string ,vector *_db .Vector ){_fdc :=_dfa .getNewProperty (name );_fdc .Vector =vector ;_dfa .setOrReplaceProperty (_fdc );};func (_cbg CustomProperties )SetPropertyAsInt (name string ,i int ){_eae :=_cbg .getNewProperty (name );_bbe :=int32 (i );_eae .Int =&_bbe ;_cbg .setOrReplaceProperty (_eae );};func (_efe CustomProperties )SetPropertyAsOstorage (name string ,ostorage string ){_efd :=_efe .getNewProperty (name );_efd .Ostorage =&ostorage ;_efe .setOrReplaceProperty (_efd );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetModified sets the time that the document was modified.
func (_beb CoreProperties )SetModified (t _ac .Time ){_beb ._cgc .Modified =_bfd (t ,"\u0064\u0063t\u0065\u0072\u006ds\u003a\u006d\u006f\u0064\u0069\u0066\u0069\u0065\u0064");};func (_dfb CustomProperties )SetPropertyAsOstream (name string ,ostream string ){_dbgd :=_dfb .getNewProperty (name );_dbgd .Ostream =&ostream ;_dfb .setOrReplaceProperty (_dbgd );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// WriteExtraFiles writes the extra files to the zip package.
func (_caege *DocBase )WriteExtraFiles (z *_fb .Writer )error {for _ ,_edcd :=range _caege .ExtraFiles {if _cfg :=_ceb .AddFileFromDisk (z ,_edcd .ZipPath ,_edcd .DiskPath );_cfg !=nil {return _cfg ;};};return nil ;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// FindRIDForN returns the relationship ID for the i'th relationship of type t.
func (_edd Relationships )FindRIDForN (i int ,t string )string {for _ ,_ebd :=range _edd ._ccdg .CT_Relationships .Relationship {if _ebd .TypeAttr ==t {if i ==0{return _ebd .IdAttr ;};i --;};};return "";};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetHeight sets row height, see measurement package.
func (_gbc TableRow )SetHeight (m _ce .Distance ){_aeee :=_ce .ToEMU (float64 (m ));_gbc ._aedc .HAttr =_gg .ST_Coordinate {ST_CoordinateUnqualified :&_aeee };};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetOffsetY sets vertical offset of a table in distance units (see measurement package).
func (_ffce Table )SetOffsetY (offY float64 ){if _ffce ._ade .Off ==nil {_ffce ._ade .Off =_gg .NewCT_Point2D ();_aaa :=int64 (0);_ffce ._ade .Off .XAttr =_gg .ST_Coordinate {ST_CoordinateUnqualified :&_aaa };};_faga :=_ce .ToEMU (offY );_ffce ._ade .Off .YAttr =_gg .ST_Coordinate {ST_CoordinateUnqualified :&_faga };};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetLinksUpToDate sets the links up to date flag.
func (_aga AppProperties )SetLinksUpToDate (v bool ){_aga ._fbd .LinksUpToDate =_ceg .Bool (v )};func (_dea CustomProperties )SetPropertyAsOblob (name ,oblob string ){_caec :=_dea .getNewProperty (name );_caec .Oblob =&oblob ;_dea .setOrReplaceProperty (_caec );};func (_add CustomProperties )SetPropertyAsR4 (name string ,r4 float32 ){_bdc :=_add .getNewProperty (name );_bdc .R4 =&r4 ;_add .setOrReplaceProperty (_bdc );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// ImageRef is a reference to an image within a document.
type ImageRef struct{_bcab *DocBase ;_fdeb Relationships ;_cbe Image ;_gce string ;_bfef string ;};
2020-10-12 13:59:12 +00:00
2021-03-16 20:51:18 +00:00
// CoreProperties contains document specific properties.
type CoreProperties struct{_cgc *_fe .CoreProperties };func (_edfd CustomProperties )SetPropertyAsCy (name string ,cy string ){_ffc :=_edfd .getNewProperty (name );_ffc .Cy =&cy ;_edfd .setOrReplaceProperty (_ffc );};
2020-10-12 13:59:12 +00:00
2021-03-16 20:51:18 +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 (_cbga *ImageRef )SetTarget (target string ){_cbga ._bfef =target };
2020-10-12 13:59:12 +00:00
2021-03-16 20:51:18 +00:00
// AddImageToZip adds an image (either from bytes or from disk) and adds it to the zip file.
func AddImageToZip (z *_fb .Writer ,img ImageRef ,imageNum int ,dt _ceg .DocType )error {_efgg :=_ceg .AbsoluteImageFilename (dt ,imageNum ,_ff .ToLower (img .Format ()));if img .Data ()!=nil &&len (*img .Data ())> 0{if _bgf :=_ceb .AddFileFromBytes (z ,_efgg ,*img .Data ());_bgf !=nil {return _bgf ;};}else if img .Path ()!=""{if _gde :=_ceb .AddFileFromDisk (z ,_efgg ,img .Path ());_gde !=nil {return _gde ;};}else {return _ea .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 (_dead TableRow )addCell ()*_gg .CT_TableCell {_gdc :=_gg .NewCT_TableCell ();_dead ._aedc .Tc =append (_dead ._aedc .Tc ,_gdc );return _gdc ;};
2020-10-12 13:59:12 +00:00
2021-03-16 20:51:18 +00:00
// Title returns the Title of the document
func (_caca CoreProperties )Title ()string {if _caca ._cgc .Title !=nil {return string (_caca ._cgc .Title .Data );};return "";};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetLanguage records the language of the document.
func (_cfb CoreProperties )SetLanguage (s string ){_cfb ._cgc .Language =&_ceg .XSDAny {XMLName :_e .Name {Local :"d\u0063\u003a\u006c\u0061\u006e\u0067\u0075\u0061\u0067\u0065"}};_cfb ._cgc .Language .Data =[]byte (s );};func (_cegd CustomProperties )SetPropertyAsDecimal (name string ,decimal float64 ){_cbd :=_cegd .getNewProperty (name );_cbd .Decimal =&decimal ;_cegd .setOrReplaceProperty (_cbd );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// AddRelationship adds a relationship.
func (_bdf Relationships )AddRelationship (target ,ctype string )Relationship {if !_ff .HasPrefix (ctype ,"\u0068t\u0074\u0070\u003a\u002f\u002f"){_ceg .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 );};_gcee :=_da .NewRelationship ();_gba :=len (_bdf ._ccdg .Relationship )+1;_aae :=map[string ]struct{}{};for _ ,_gcda :=range _bdf ._ccdg .Relationship {_aae [_gcda .IdAttr ]=struct{}{};};for _ ,_dgg :=_aae [_ea .Sprintf ("\u0072\u0049\u0064%\u0064",_gba )];_dgg ;_ ,_dgg =_aae [_ea .Sprintf ("\u0072\u0049\u0064%\u0064",_gba )]{_gba ++;};_gcee .IdAttr =_ea .Sprintf ("\u0072\u0049\u0064%\u0064",_gba );_gcee .TargetAttr =target ;_gcee .TypeAttr =ctype ;_bdf ._ccdg .Relationship =append (_bdf ._ccdg .Relationship ,_gcee );return Relationship {_bef :_gcee };};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetDocSecurity sets the document security flag.
func (_ccb AppProperties )SetDocSecurity (v int32 ){_ccb ._fbd .DocSecurity =_ceg .Int32 (v )};func (_ccbd CustomProperties )SetPropertyAsLpstr (name string ,lpstr string ){_bga :=_ccbd .getNewProperty (name );_bga .Lpstr =&lpstr ;_ccbd .setOrReplaceProperty (_bga );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetTitle records the title of the document.
func (_ded CoreProperties )SetTitle (s string ){if _ded ._cgc .Title ==nil {_ded ._cgc .Title =&_ceg .XSDAny {XMLName :_e .Name {Local :"\u0064\u0063\u003a\u0074\u0069\u0074\u006c\u0065"}};};_ded ._cgc .Title .Data =[]byte (s );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Cells returns an array of row cells.
func (_abab TableRow )Cells ()[]*_gg .CT_TableCell {return _abab ._aedc .Tc };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Table represents a table in the document.
type Table struct{_cbaf *_gg .Tbl ;_ade *_gg .CT_Transform2D ;};func (_fad CustomProperties )SetPropertyAsUi2 (name string ,ui2 uint16 ){_ec :=_fad .getNewProperty (name );_ec .Ui2 =&ui2 ;_fad .setOrReplaceProperty (_ec );};func (_ccg CustomProperties )SetPropertyAsLpwstr (name string ,lpwstr string ){_cbb :=_ccg .getNewProperty (name );_cbb .Lpwstr =&lpwstr ;_ccg .setOrReplaceProperty (_cbb );};
2020-11-09 01:00:18 +00:00
2021-03-16 20:51:18 +00:00
// TblStyle returns the TblStyle property.
func (_cagf TableStyles )TblStyle ()[]*_gg .CT_TableStyle {return _cagf ._dgbf .TblStyle };const _dcg =50;func (_ada CustomProperties )SetPropertyAsUint (name string ,ui uint ){_cdb :=_ada .getNewProperty (name );_bffa :=uint32 (ui );_cdb .Uint =&_bffa ;_ada .setOrReplaceProperty (_cdb );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// ID returns the ID of a relationship.
func (_fbfe Relationship )ID ()string {return _fbfe ._bef .IdAttr };
2020-10-12 13:59:12 +00:00
2021-03-16 20:51:18 +00:00
// NewTableStyles constructs a new TableStyles.
func NewTableStyles ()TableStyles {return TableStyles {_dgbf :_gg .NewTblStyleLst ()}};const _dcc =2021;
2020-10-12 13:59:12 +00:00
2021-03-16 20:51:18 +00:00
// SetCreated sets the time that the document was created.
func (_gcd CoreProperties )SetCreated (t _ac .Time ){_gcd ._cgc .Created =_bfd (t ,"\u0064c\u0074e\u0072\u006d\u0073\u003a\u0063\u0072\u0065\u0061\u0074\u0065\u0064");};func (_aba CustomProperties )SetPropertyAsI1 (name string ,i1 int8 ){_bca :=_aba .getNewProperty (name );_bca .I1 =&i1 ;_aba .setOrReplaceProperty (_bca );};
2020-10-12 13:59:12 +00:00
2021-03-16 20:51:18 +00:00
// LastModifiedBy returns the name of the last person to modify the document
func (_dfe CoreProperties )LastModifiedBy ()string {if _dfe ._cgc .LastModifiedBy !=nil {return *_dfe ._cgc .LastModifiedBy ;};return "";};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +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 (_ggf AppProperties )Company ()string {if _ggf ._fbd .Company !=nil {return *_ggf ._fbd .Company ;};return "";};func (_fba CustomProperties )SetPropertyAsUi4 (name string ,ui4 uint32 ){_cgf :=_fba .getNewProperty (name );_cgf .Ui4 =&ui4 ;_fba .setOrReplaceProperty (_cgf );};const _egc ="2\u00300\u0036\u002d\u0030\u0031\u002d\u0030\u0032\u00541\u0035\u003a\u0030\u0034:0\u0035\u005a";func (_ecd CustomProperties )SetPropertyAsFiletime (name string ,filetime _ac .Time ){_bggc :=_ecd .getNewProperty (name );_bggc .Filetime =&filetime ;_ecd .setOrReplaceProperty (_bggc );};
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.
func (_cf DocBase )Append (docBase1 DocBase )DocBase {_dbg :=docBase1 .ContentTypes .X ();for _ ,_cfc :=range _dbg .Default {_cf .ContentTypes .AddDefault (_cfc .ExtensionAttr ,_cfc .ContentTypeAttr );};for _ ,_bcb :=range _dbg .Override {_cf .ContentTypes .AddOverride (_bcb .PartNameAttr ,_bcb .ContentTypeAttr );};_cc :=_cf .AppProperties .X ();_def :=docBase1 .AppProperties .X ();if _cc .Pages !=nil {if _def .Pages !=nil {*_cc .Pages +=*_def .Pages ;};}else if _def .Pages !=nil {_cc .Pages =_def .Pages ;};if _cc .Words !=nil {if _def .Words !=nil {*_cc .Words +=*_def .Words ;};}else if _def .Words !=nil {_cc .Words =_def .Words ;};if _cc .Characters !=nil {if _def .Characters !=nil {*_cc .Characters +=*_def .Characters ;};}else if _def .Characters !=nil {_cc .Characters =_def .Characters ;};if _cc .Lines !=nil {if _def .Lines !=nil {*_cc .Lines +=*_def .Lines ;};}else if _def .Lines !=nil {_cc .Lines =_def .Lines ;};if _cc .Paragraphs !=nil {if _def .Paragraphs !=nil {*_cc .Paragraphs +=*_def .Paragraphs ;};}else if _def .Paragraphs !=nil {_cc .Paragraphs =_def .Paragraphs ;};if _cc .Notes !=nil {if _def .Notes !=nil {*_cc .Notes +=*_def .Notes ;};}else if _def .Notes !=nil {_cc .Notes =_def .Notes ;};if _cc .HiddenSlides !=nil {if _def .HiddenSlides !=nil {*_cc .HiddenSlides +=*_def .HiddenSlides ;};}else if _def .HiddenSlides !=nil {_cc .HiddenSlides =_def .HiddenSlides ;};if _cc .MMClips !=nil {if _def .MMClips !=nil {*_cc .MMClips +=*_def .MMClips ;};}else if _def .MMClips !=nil {_cc .MMClips =_def .MMClips ;};if _cc .LinksUpToDate !=nil {if _def .LinksUpToDate !=nil {*_cc .LinksUpToDate =*_cc .LinksUpToDate &&*_def .LinksUpToDate ;};}else if _def .LinksUpToDate !=nil {_cc .LinksUpToDate =_def .LinksUpToDate ;};if _cc .CharactersWithSpaces !=nil {if _def .CharactersWithSpaces !=nil {*_cc .CharactersWithSpaces +=*_def .CharactersWithSpaces ;};}else if _def .CharactersWithSpaces !=nil {_cc .CharactersWithSpaces =_def .CharactersWithSpaces ;};if _cc .SharedDoc !=nil {if _def .SharedDoc !=nil {*_cc .SharedDoc =*_cc .SharedDoc ||*_def .SharedDoc ;};}else if _def .SharedDoc !=nil {_cc .SharedDoc =_def .SharedDoc ;};if _cc .HyperlinksChanged !=nil {if _def .HyperlinksChanged !=nil {*_cc .HyperlinksChanged =*_cc .HyperlinksChanged ||*_def .HyperlinksChanged ;};}else if _def .HyperlinksChanged !=nil {_cc .HyperlinksChanged =_def .HyperlinksChanged ;};_cc .DigSig =nil ;if _cc .TitlesOfParts ==nil &&_def .TitlesOfParts !=nil {_cc .TitlesOfParts =_def .TitlesOfParts ;};if _cc .HeadingPairs !=nil {if _def .HeadingPairs !=nil {_ca :=_cc .HeadingPairs .Vector ;_eag :=_def .HeadingPairs .Vector ;_cff :=_ca .Variant ;_cd :=_eag .Variant ;_cag :=[]*_db .Variant {};for _fea :=0;_fea < len (_cd );_fea +=2{_ee :=_cd [_fea ].Lpstr ;_abc :=false ;for _ffa :=0;_ffa < len (_cff );_ffa +=2{_ba :=_cff [_ffa ].Lpstr ;if _ba !=nil &&_ee !=nil &&*_ba ==*_ee {*_cff [_ffa +1].I4 =*_cff [_ffa +1].I4 +*_cd [_fea +1].I4 ;_abc =true ;break ;};};if !_abc {_cag =append (_cag ,&_db .Variant {CT_Variant :_db .CT_Variant {Lpstr :_cd [_fea ].Lpstr }});_cag =append (_cag ,&_db .Variant {CT_Variant :_db .CT_Variant {I4 :_cd [_fea ].I4 }});};};_cff =append (_cff ,_cag ...);_ca .SizeAttr =uint32 (len (_cff ));};}else if _def .HeadingPairs !=nil {_cc .HeadingPairs =_def .HeadingPairs ;};if _cc .HLinks !=nil {if _def .HLinks !=nil {_cde :=_cc .HLinks .Vector ;_ad :=_def .HLinks .Vector ;_ae :=_cde .Variant ;_af :=_ad .Variant ;for _ ,_fg :=range _af {_deb :=true ;for _ ,_dd :=range _ae {if _ag .DeepEqual (_dd ,_fg ){_deb =false ;break ;};};if _deb {_ae =append (_ae ,_fg );_cde .SizeAttr ++;};};};}else if _def .HLinks !=nil {_cc .HLinks =_def .HLinks ;};_dec :=_cf .GetOrCreateCustomProperties ();_ggc :=docBase1 .GetOrCreateCustomProperties ();for _ ,_cae :=range _ggc .PropertiesList (){_dec .setProperty (_cae );};_cf .CustomProperties =_dec ;_bae :=_cf .Rels .X ().Relationship ;for _ ,_bce :=range docBase1 .Rels .X ().Relationship {_ge :=true ;for _ ,_ced :=range _bae {if _ced .TargetAttr ==_bce .TargetAttr &&_ced .TypeAttr ==_bce .TypeAttr {_ge =false ;break ;}
2020-08-31 22:58:25 +00:00
2021-03-16 20:51:18 +00:00
// CreateCustomProperties creates the custom properties of the document.
func (_fcd *DocBase )CreateCustomProperties (){_fcd .CustomProperties =NewCustomProperties ();_fcd .AddCustomRelationships ();};func (_bde CustomProperties )setProperty (_ffd *_agb .CT_Property ){_bde .setPropertyHelper (_ffd ,false )};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// IsEmpty returns true if there are no relationships.
func (_ega Relationships )IsEmpty ()bool {return _ega ._ccdg ==nil ||len (_ega ._ccdg .Relationship )==0;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Target returns the target attrubute of the image reference (a path where the image file is located in the document structure).
func (_eabg *ImageRef )Target ()string {return _eabg ._bfef };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// X returns the inner wrapped XML type.
func (_gaf CoreProperties )X ()*_fe .CoreProperties {return _gaf ._cgc };func (_fda CustomProperties )SetPropertyAsError (name string ,error string ){_bec :=_fda .getNewProperty (name );_bec .Error =&error ;_fda .setOrReplaceProperty (_bec );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +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 {_cbe :img ,_bcab :d ,_fdeb :rels };};
// SetDescription records the description of the document.
func (_aee CoreProperties )SetDescription (s string ){if _aee ._cgc .Description ==nil {_aee ._cgc .Description =&_ceg .XSDAny {XMLName :_e .Name {Local :"\u0064\u0063\u003a\u0064\u0065\u0073\u0063\u0072\u0069p\u0074\u0069\u006f\u006e"}};};_aee ._cgc .Description .Data =[]byte (s );};
2020-11-09 01:00:18 +00:00
2021-01-04 16:11:39 +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.
2021-03-16 20:51:18 +00:00
func (_agda ImageRef )RelativeWidth (h _ce .Distance )_ce .Distance {_ggga :=float64 (_agda .Size ().X )/float64 (_agda .Size ().Y );return h *_ce .Distance (_ggga );};
2020-11-09 01:00:18 +00:00
2021-03-16 20:51:18 +00:00
// SetContentStatus records the content status of the document.
func (_ccd CoreProperties )SetContentStatus (s string ){_ccd ._cgc .ContentStatus =&s };
2020-11-09 01:00:18 +00:00
2021-03-16 20:51:18 +00:00
// Modified returns the time that the document was modified.
func (_bg CoreProperties )Modified ()_ac .Time {return _cfe (_bg ._cgc .Modified )};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Relationship is a relationship within a .rels file.
type Relationship struct{_bef *_da .Relationship };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// GetOrCreateCustomProperties returns the custom properties of the document (and if they not exist yet, creating them first).
func (_fag *DocBase )GetOrCreateCustomProperties ()CustomProperties {if _fag .CustomProperties .X ()==nil {_fag .CreateCustomProperties ();};return _fag .CustomProperties ;};func _cfe (_cdag *_ceg .XSDAny )_ac .Time {if _cdag ==nil {return _ac .Time {};};_afdg ,_dgb :=_ac .Parse (_egc ,string (_cdag .Data ));if _dgb !=nil {_ceg .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 (_cdag .Data ),_dgb );};return _afdg ;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// RelID returns the relationship ID.
func (_dbbc ImageRef )RelID ()string {return _dbbc ._gce };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// CustomProperty contains document specific property.
// Using of this type is deprecated.
type CustomProperty struct{_dff *_agb .CT_Property };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Created returns the time that the document was created.
func (_eee CoreProperties )Created ()_ac .Time {return _cfe (_eee ._cgc .Created )};func (_dabg Relationship )String ()string {return _ea .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",_dabg .ID (),_dabg .Target (),_dabg .Type ());};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Theme is a drawingml theme.
type Theme struct{_eaa *_gg .Theme };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// DefAttr returns the DefAttr property.
func (_bcdd TableStyles )DefAttr ()string {return _bcdd ._dgbf .DefAttr };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// GetPropertyByName returns a custom property selected by it's name.
func (_bba CustomProperties )GetPropertyByName (name string )CustomProperty {_cea :=_bba ._aca .Property ;for _ ,_ebf :=range _cea {if *_ebf .NameAttr ==name {return CustomProperty {_dff :_ebf };};};return CustomProperty {};};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +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 (_cdc ImageRef )RelativeHeight (w _ce .Distance )_ce .Distance {_dbf :=float64 (_cdc .Size ().Y )/float64 (_cdc .Size ().X );return w *_ce .Distance (_dbf );};func (_abb CustomProperties )SetPropertyAsStream (name string ,stream string ){_eagg :=_abb .getNewProperty (name );_eagg .Stream =&stream ;_abb .setOrReplaceProperty (_eagg );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// ApplicationVersion returns the version of the application that created the
// document.
func (_decf AppProperties )ApplicationVersion ()string {if _decf ._fbd .AppVersion !=nil {return *_decf ._fbd .AppVersion ;};return "";};func (_edc CustomProperties )SetPropertyAsDate (name string ,date _ac .Time ){date =date .UTC ();_dgf ,_efac ,_agd :=date .Date ();_efdb ,_fbdb ,_gfb :=date .Clock ();_cfeb :=_ac .Date (_dgf ,_efac ,_agd ,_efdb ,_fbdb ,_gfb ,0,_ac .UTC );_bgg :=_edc .getNewProperty (name );_bgg .Filetime =&_cfeb ;_edc .setOrReplaceProperty (_bgg );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +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 (_ceaf Relationships )AddAutoRelationship (dt _ceg .DocType ,src string ,idx int ,ctype string )Relationship {return _ceaf .AddRelationship (_ceg .RelativeFilename (dt ,src ,ctype ,idx ),ctype );};func _bfd (_bff _ac .Time ,_fac string )*_ceg .XSDAny {_fee :=&_ceg .XSDAny {XMLName :_e .Name {Local :_fac }};_fee .Attrs =append (_fee .Attrs ,_e .Attr {Name :_e .Name {Local :"\u0078\u0073\u0069\u003a\u0074\u0079\u0070\u0065"},Value :"\u0064\u0063\u0074\u0065\u0072\u006d\u0073\u003a\u00573\u0043\u0044\u0054\u0046"});_fee .Attrs =append (_fee .Attrs ,_e .Attr {Name :_e .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"});_fee .Attrs =append (_fee .Attrs ,_e .Attr {Name :_e .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/"});_fee .Data =[]byte (_bff .Format (_egc ));return _fee ;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Rows returns all table rows.
func (_aed Table )Rows ()[]*TableRow {_acf :=_aed ._cbaf .Tr ;_bgaf :=[]*TableRow {};for _ ,_fcdb :=range _acf {_bgaf =append (_bgaf ,&TableRow {_aedc :_fcdb });};return _bgaf ;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetWidth sets column width, see measurement package.
func (_afff TableCol )SetWidth (m _ce .Distance ){_fbe :=_ce .ToEMU (float64 (m ));_afff ._ebec .WAttr =_gg .ST_Coordinate {ST_CoordinateUnqualified :&_fbe };};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Remove removes an existing relationship.
func (_bfgb Relationships )Remove (rel Relationship )bool {for _agf ,_ccgg :=range _bfgb ._ccdg .Relationship {if _ccgg ==rel ._bef {copy (_bfgb ._ccdg .Relationship [_agf :],_bfgb ._ccdg .Relationship [_agf +1:]);_bfgb ._ccdg .Relationship =_bfgb ._ccdg .Relationship [0:len (_bfgb ._ccdg .Relationship )-1];return true ;};};return false ;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// NewRelationship constructs a new relationship.
func NewRelationship ()Relationship {return Relationship {_bef :_da .NewRelationship ()}};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetApplication sets the name of the application that created the document.
func (_eg AppProperties )SetApplication (s string ){_eg ._fbd .Application =&s };func (_gec CustomProperties )SetPropertyAsBlob (name ,blob string ){_cfa :=_gec .getNewProperty (name );_cfa .Blob =&blob ;_gec .setOrReplaceProperty (_cfa );};const _dcf =16;
2020-10-12 13:59:12 +00:00
2021-03-16 20:51:18 +00:00
// Hyperlink is just an appropriately configured relationship.
type Hyperlink Relationship ;
2020-10-12 13:59:12 +00:00
2021-03-16 20:51:18 +00:00
// AppProperties contains properties specific to the document and the
// application that created it.
type AppProperties struct{_fbd *_dag .Properties };
2020-10-12 13:59:12 +00:00
2021-03-16 20:51:18 +00:00
// RemoveOverride removes an override given a path.
func (_gf ContentTypes )RemoveOverride (path string ){if !_ff .HasPrefix (path ,"\u002f"){path ="\u002f"+path ;};for _gae ,_eea :=range _gf ._eb .Override {if _eea .PartNameAttr ==path {copy (_gf ._eb .Override [_gae :],_gf ._eb .Override [_gae +1:]);_gf ._eb .Override =_gf ._eb .Override [0:len (_gf ._eb .Override )-1];};};};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// AddRow adds a row to a table.
func (_eceg Table )AddRow ()*TableRow {_aab :=_gg .NewCT_TableRow ();for _egb :=0;_egb < len (_eceg ._cbaf .TblGrid .GridCol );_egb ++{_aab .Tc =append (_aab .Tc ,_gg .NewCT_TableCell ());};_eceg ._cbaf .Tr =append (_eceg ._cbaf .Tr ,_aab );return &TableRow {_aedc :_aab };};const _daga =15;
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// NewTableWithXfrm makes a new table with a pointer to its parent Xfrm for changing its offset and size.
func NewTableWithXfrm (xfrm *_gg .CT_Transform2D )*Table {_gaa :=_gg .NewTbl ();_gaa .TblPr =_gg .NewCT_TableProperties ();return &Table {_cbaf :_gaa ,_ade :xfrm };};func UtcTimeFormat (t _ac .Time )string {return t .Format (_ffb )+"\u0020\u0055\u0054\u0043"};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Relationships represents a .rels file.
type Relationships struct{_ccdg *_da .Relationships };
// SetAuthor records the author of the document.
func (_dbe CoreProperties )SetAuthor (s string ){if _dbe ._cgc .Creator ==nil {_dbe ._cgc .Creator =&_ceg .XSDAny {XMLName :_e .Name {Local :"\u0064\u0063\u003a\u0063\u0072\u0065\u0061\u0074\u006f\u0072"}};};_dbe ._cgc .Creator .Data =[]byte (s );};
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
2021-03-16 20:51:18 +00:00
func (_bcbg Table )X ()*_gg .Tbl {return _bcbg ._cbaf };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// EnsureDefault esnures that an extension and default content type exist,
// adding it if necessary.
func (_abg ContentTypes )EnsureDefault (ext ,contentType string ){ext =_ff .ToLower (ext );for _ ,_ebe :=range _abg ._eb .Default {if _ebe .ExtensionAttr ==ext {_ebe .ContentTypeAttr =contentType ;return ;};};_fgd :=&_ga .Default {};_fgd .ContentTypeAttr =contentType ;_fgd .ExtensionAttr =ext ;_abg ._eb .Default =append (_abg ._eb .Default ,_fgd );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +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 (_dbd AppProperties )Pages ()int32 {if _dbd ._fbd .Pages !=nil {return *_dbd ._fbd .Pages ;};return 0;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +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 ){_fgg :=Image {};_afcg ,_dgca :=_cef .Open (path );if _dgca !=nil {return _fgg ,_ea .Errorf ("\u0065\u0072\u0072or\u0020\u0072\u0065\u0061\u0064\u0069\u006e\u0067\u0020\u0069\u006d\u0061\u0067\u0065\u003a\u0020\u0025\u0073",_dgca );};defer _afcg .Close ();_ffe ,_cgg ,_dgca :=_de .Decode (_afcg );if _dgca !=nil {return _fgg ,_ea .Errorf ("\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s",_dgca );};_fgg .Path =path ;_fgg .Format =_cgg ;_fgg .Size =_ffe .Bounds ().Size ();return _fgg ,nil ;};func (_aeg CustomProperties )SetPropertyAsR8 (name string ,r8 float64 ){_edf :=_aeg .getNewProperty (name );_edf .R8 =&r8 ;_aeg .setOrReplaceProperty (_edf );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Relationships returns a slice of all of the relationships.
func (_bgfe Relationships )Relationships ()[]Relationship {_ffea :=[]Relationship {};for _ ,_efee :=range _bgfe ._ccdg .Relationship {_ffea =append (_ffea ,Relationship {_bef :_efee });};return _ffea ;};func init (){_bc .SetAsStorage ()};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// TableStyles contains document specific properties.
type TableStyles struct{_dgbf *_gg .TblStyleLst };const _eddc =3;func (_ege CustomProperties )SetPropertyAsVstream (name string ,vstream *_db .Vstream ){_cdg :=_ege .getNewProperty (name );_cdg .Vstream =vstream ;_ege .setOrReplaceProperty (_cdg );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// ContentStatus returns the content status of the document (e.g. "Final", "Draft")
func (_afd CoreProperties )ContentStatus ()string {if _afd ._cgc .ContentStatus !=nil {return *_afd ._cgc .ContentStatus ;};return "";};
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.
type DocBase struct{ContentTypes ContentTypes ;AppProperties AppProperties ;Rels Relationships ;CoreProperties CoreProperties ;CustomProperties CustomProperties ;Thumbnail _de .Image ;Images []ImageRef ;ExtraFiles []ExtraFile ;TmpPath string ;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// NewRelationshipsCopy creates a new relationships wrapper as a copy of passed in instance.
func NewRelationshipsCopy (rels Relationships )Relationships {_fdag :=*rels ._ccdg ;return Relationships {_ccdg :&_fdag };};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Category returns the category of the document
func (_bad CoreProperties )Category ()string {if _bad ._cgc .Category !=nil {return *_bad ._cgc .Category ;};return "";};var ReleasedAt =_ac .Date (_dcc ,_eddc ,_dcf ,_daga ,_dcg ,0,0,_ac .UTC );
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Data returns the data of an image file, if any.
func (_egf ImageRef )Data ()*[]byte {return _egf ._cbe .Data };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Properties returns table properties.
func (_ecf Table )Grid ()*_gg .CT_TableGrid {return _ecf ._cbaf .TblGrid };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Clear removes any existing relationships.
func (_febb Relationships )Clear (){_febb ._ccdg .Relationship =nil };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// CopyRelationship copies the relationship.
func (_cgga Relationships )CopyRelationship (idAttr string )(Relationship ,bool ){for _abad :=range _cgga ._ccdg .Relationship {if _cgga ._ccdg .Relationship [_abad ].IdAttr ==idAttr {_abd :=*_cgga ._ccdg .Relationship [_abad ];_gedg :=len (_cgga ._ccdg .Relationship )+1;_bdg :=map[string ]struct{}{};for _ ,_ecg :=range _cgga ._ccdg .Relationship {_bdg [_ecg .IdAttr ]=struct{}{};};for _ ,_gbf :=_bdg [_ea .Sprintf ("\u0072\u0049\u0064%\u0064",_gedg )];_gbf ;_ ,_gbf =_bdg [_ea .Sprintf ("\u0072\u0049\u0064%\u0064",_gedg )]{_gedg ++;};_abd .IdAttr =_ea .Sprintf ("\u0072\u0049\u0064%\u0064",_gedg );_cgga ._ccdg .Relationship =append (_cgga ._ccdg .Relationship ,&_abd );return Relationship {_bef :&_abd },true ;};};return Relationship {},false ;};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// CustomProperties contains document specific properties.
type CustomProperties struct{_aca *_agb .Properties };
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
2021-03-16 20:51:18 +00:00
func (_cegb AppProperties )X ()*_dag .Properties {return _cegb ._fbd };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetTarget set the target (path) of a relationship.
func (_bee Relationship )SetTarget (s string ){_bee ._bef .TargetAttr =s };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetOffsetX sets horizontal offset of a table in distance units (see measurement package).
func (_bggd Table )SetOffsetX (offX float64 ){if _bggd ._ade .Off ==nil {_bggd ._ade .Off =_gg .NewCT_Point2D ();_gbfa :=int64 (0);_bggd ._ade .Off .YAttr =_gg .ST_Coordinate {ST_CoordinateUnqualified :&_gbfa };};_dbab :=_ce .ToEMU (offX );_bggd ._ade .Off .XAttr =_gg .ST_Coordinate {ST_CoordinateUnqualified :&_dbab };};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetCategory records the category of the document.
func (_fa CoreProperties )SetCategory (s string ){_fa ._cgc .Category =&s };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Size returns the size of an image
func (_fbg ImageRef )Size ()_de .Point {return _fbg ._cbe .Size };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// ContentTypes is the top level "[Content_Types].xml" in a zip package.
type ContentTypes struct{_eb *_ga .Types };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// SetLastModifiedBy records the last person to modify the document.
func (_adgd CoreProperties )SetLastModifiedBy (s string ){_adgd ._cgc .LastModifiedBy =&s };
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// Type returns the type of a relationship.
func (_ece Relationship )Type ()string {return _ece ._bef .TypeAttr };const _ffb ="\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034";func (_bcf CustomProperties )SetPropertyAsI4 (name string ,i4 int32 ){_afda :=_bcf .getNewProperty (name );_afda .I4 =&i4 ;_bcf .setOrReplaceProperty (_afda );};
2020-08-23 14:15:53 +00:00
2021-03-16 20:51:18 +00:00
// X returns the inner wrapped XML type of CustomProperty.
func (_dbba CustomProperty )X ()*_agb .CT_Property {return _dbba ._dff };
2020-10-12 13:59:12 +00:00
2021-01-04 16:11:39 +00:00
// Application returns the name of the application that created the document.
// For unioffice created documents, it defaults to github.com/unidoc/unioffice
2021-03-16 20:51:18 +00:00
func (_fbf AppProperties )Application ()string {if _fbf ._fbd .Application !=nil {return *_fbf ._fbd .Application ;};return "";};
2020-10-12 13:59:12 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
2021-03-16 20:51:18 +00:00
func (_gecg Theme )X ()*_gg .Theme {return _gecg ._eaa };
2020-11-09 01:00:18 +00:00
2021-03-16 20:51:18 +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 (_bdd *DocBase )AddExtraFileFromZip (f *_fb .File )error {_ace ,_abcc :=_ceb .ExtractToDiskTmp (f ,_bdd .TmpPath );if _abcc !=nil {return _ea .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",_abcc );};_bdd .ExtraFiles =append (_bdd .ExtraFiles ,ExtraFile {ZipPath :f .Name ,DiskPath :_ace });return nil ;};func (_ead *ImageRef )SetRelID (id string ){_ead ._gce =id };func (_gccd CustomProperties )SetPropertyAsStorage (name string ,storage string ){_bed :=_gccd .getNewProperty (name );_bed .Storage =&storage ;_gccd .setOrReplaceProperty (_bed );};
2020-11-09 01:00:18 +00:00
2021-01-04 16:11:39 +00:00
// PropertiesList returns the list of all custom properties of the document.
2021-03-16 20:51:18 +00:00
func (_ccc CustomProperties )PropertiesList ()[]*_agb .CT_Property {return _ccc ._aca .Property };
2020-12-17 22:07:08 +00:00
2021-03-16 20:51:18 +00:00
// EnsureOverride ensures that an override for the given path exists, adding it if necessary
func (_bfg ContentTypes )EnsureOverride (path ,contentType string ){for _ ,_gd :=range _bfg ._eb .Override {if _gd .PartNameAttr ==path {if _ff .HasPrefix (contentType ,"\u0068\u0074\u0074\u0070"){_ceg .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 );};_gd .ContentTypeAttr =contentType ;return ;};};_bfg .AddOverride (path ,contentType );};
2020-12-17 22:07:08 +00:00
2021-03-16 20:51:18 +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 _de .Point ;Format string ;Path string ;Data *[]byte ;};
2020-12-17 22:07:08 +00:00
2021-03-16 20:51:18 +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 ){_cbdd :=Image {};_afg ,_feac ,_gadef :=_de .Decode (_dg .NewReader (data ));if _gadef !=nil {return _cbdd ,_ea .Errorf ("\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s",_gadef );};_cbdd .Data =&data ;_cbdd .Format =_feac ;_cbdd .Size =_afg .Bounds ().Size ();return _cbdd ,nil ;};
2020-12-17 22:07:08 +00:00
2021-03-16 20:51:18 +00:00
// TableCol represents a column in a table.
type TableCol struct{_ebec *_gg .CT_TableCol };
2020-12-17 22:07:08 +00:00
2021-03-16 20:51:18 +00:00
// X returns the inner wrapped XML type.
func (_efed TableStyles )X ()*_gg .TblStyleLst {return _efed ._dgbf };