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.
2020-11-09 01:00:18 +00:00
package common ;import (_a "archive/zip";_g "bytes";_dc "encoding/xml";_eg "fmt";_fa "github.com/unidoc/unioffice";_ca "github.com/unidoc/unioffice/common/tempstorage";_dg "github.com/unidoc/unioffice/common/tempstorage/diskstore";_cf "github.com/unidoc/unioffice/measurement";_gf "github.com/unidoc/unioffice/schema/soo/dml";_gcb "github.com/unidoc/unioffice/schema/soo/ofc/custom_properties";_ce "github.com/unidoc/unioffice/schema/soo/ofc/docPropsVTypes";_bd "github.com/unidoc/unioffice/schema/soo/ofc/extended_properties";_ega "github.com/unidoc/unioffice/schema/soo/pkg/content_types";_dce "github.com/unidoc/unioffice/schema/soo/pkg/metadata/core_properties";_ed "github.com/unidoc/unioffice/schema/soo/pkg/relationships";_ba "github.com/unidoc/unioffice/zippkg";_c "image";_ "image/gif";_ "image/jpeg";_ "image/png";_bb "os";_b "reflect";_gcc "regexp";_de "strconv";_gc "strings";_ab "time";);const _gded =2020;
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// X returns the inner wrapped XML type.
func (_fgc AppProperties )X ()*_bd .Properties {return _fgc ._bcca };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// NewCustomProperties constructs a new CustomProperties.
func NewCustomProperties ()CustomProperties {return CustomProperties {_gfb :_gcb .NewProperties ()}};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// FindRIDForN returns the relationship ID for the i'th relationship of type t.
func (_gcbb Relationships )FindRIDForN (i int ,t string )string {for _ ,_ffb :=range _gcbb ._dafe .CT_Relationships .Relationship {if _ffb .TypeAttr ==t {if i ==0{return _ffb .IdAttr ;};i --;};};return "";};func (_bfgc CustomProperties )SetPropertyAsVstream (name string ,vstream *_ce .Vstream ){_gfc :=_bfgc .getNewProperty (name );_gfc .Vstream =vstream ;_bfgc .setOrReplaceProperty (_gfc );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// SetCompany sets the name of the company that created the document.
func (_dgc AppProperties )SetCompany (s string ){_dgc ._bcca .Company =&s };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Type returns the type of a relationship.
func (_feee Relationship )Type ()string {return _feee ._ege .TypeAttr };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// X returns the inner wrapped XML type.
func (_fdec Table )X ()*_gf .Tbl {return _fdec ._cfea };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// AddHyperlink adds an external hyperlink relationship.
func (_ffcc Relationships )AddHyperlink (target string )Hyperlink {_gdgg :=_ffcc .AddRelationship (target ,_fa .HyperLinkType );_gdgg ._ege .TargetModeAttr =_ed .ST_TargetModeExternal ;return Hyperlink (_gdgg );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// SetDocSecurity sets the document security flag.
func (_fff AppProperties )SetDocSecurity (v int32 ){_fff ._bcca .DocSecurity =_fa .Int32 (v )};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Relationships represents a .rels file.
type Relationships struct{_dafe *_ed .Relationships };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Title returns the Title of the document
func (_cdg CoreProperties )Title ()string {if _cdg ._bbc .Title !=nil {return string (_cdg ._bbc .Title .Data );};return "";};func (_edbbc CustomProperties )SetPropertyAsDecimal (name string ,decimal float64 ){_ggg :=_edbbc .getNewProperty (name );_ggg .Decimal =&decimal ;_edbbc .setOrReplaceProperty (_ggg );};const _faea =9;
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// LastModifiedBy returns the name of the last person to modify the document
func (_bbd CoreProperties )LastModifiedBy ()string {if _bbd ._bbc .LastModifiedBy !=nil {return *_bbd ._bbc .LastModifiedBy ;};return "";};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00: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
2020-10-12 13:59:12 +00:00
// construct an Image directly if the file and size are known.
2020-11-09 01:00:18 +00:00
// NOTE: See also ImageFromStorage.
func ImageFromFile (path string )(Image ,error ){_bbce ,_eaf :=_bb .Open (path );_gdc :=Image {};if _eaf !=nil {return _gdc ,_eg .Errorf ("\u0065\u0072\u0072or\u0020\u0072\u0065\u0061\u0064\u0069\u006e\u0067\u0020\u0069\u006d\u0061\u0067\u0065\u003a\u0020\u0025\u0073",_eaf );};defer _bbce .Close ();_bcg ,_bbf ,_eaf :=_c .Decode (_bbce );if _eaf !=nil {return _gdc ,_eg .Errorf ("\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s",_eaf );};_gdc .Path =path ;_gdc .Format =_bbf ;_gdc .Size =_bcg .Bounds ().Size ();return _gdc ,nil ;};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// NewRelationships creates a new relationship wrapper.
func NewRelationships ()Relationships {return Relationships {_dafe :_ed .NewRelationships ()}};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// PropertiesList returns the list of all custom properties of the document.
func (_egbf CustomProperties )PropertiesList ()[]*_gcb .CT_Property {return _egbf ._gfb .Property };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// CustomProperties contains document specific properties.
type CustomProperties struct{_gfb *_gcb .Properties };func (_bdfa CustomProperties )SetPropertyAsBool (name string ,b bool ){_feaf :=_bdfa .getNewProperty (name );_feaf .Bool =&b ;_bdfa .setOrReplaceProperty (_feaf );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Created returns the time that the document was created.
func (_fed CoreProperties )Created ()_ab .Time {return _egc (_fed ._bbc .Created )};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// X returns the inner wrapped XML type.
func (_ef CustomProperties )X ()*_gcb .Properties {return _ef ._gfb };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Size returns the size of an image
func (_acf ImageRef )Size ()_c .Point {return _acf ._eff .Size };func (_fdd CustomProperties )SetPropertyAsBlob (name ,blob string ){_ead :=_fdd .getNewProperty (name );_ead .Blob =&blob ;_fdd .setOrReplaceProperty (_ead );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// DefAttr returns the DefAttr property.
func (_gcf TableStyles )DefAttr ()string {return _gcf ._fbe .DefAttr };
2020-10-12 13:59:12 +00:00
2020-11-09 01:00:18 +00:00
// NewContentTypes returns a wrapper around a newly constructed content-types.
func NewContentTypes ()ContentTypes {_cg :=ContentTypes {_dcb :_ega .NewTypes ()};_cg .AddDefault ("\u0078\u006d\u006c","\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u0078\u006d\u006c");_cg .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");_cg .AddDefault ("\u0070\u006e\u0067","\u0069m\u0061\u0067\u0065\u002f\u0070\u006eg");_cg .AddDefault ("\u006a\u0070\u0065\u0067","\u0069\u006d\u0061\u0067\u0065\u002f\u006a\u0070\u0065\u0067");_cg .AddDefault ("\u006a\u0070\u0067","\u0069m\u0061\u0067\u0065\u002f\u006a\u0070g");_cg .AddDefault ("\u0077\u006d\u0066","i\u006d\u0061\u0067\u0065\u002f\u0078\u002d\u0077\u006d\u0066");_cg .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");_cg .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 _cg ;};func (_afe CustomProperties )SetPropertyAsUi1 (name string ,ui1 uint8 ){_aga :=_afe .getNewProperty (name );_aga .Ui1 =&ui1 ;_afe .setOrReplaceProperty (_aga );};
2020-10-12 13:59:12 +00:00
2020-11-09 01:00:18 +00:00
// X returns the inner wrapped XML type of CustomProperty.
func (_dbb CustomProperty )X ()*_gcb .CT_Property {return _dbb ._dgb };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// SetModified sets the time that the document was modified.
func (_aacc CoreProperties )SetModified (t _ab .Time ){_aacc ._bbc .Modified =_ac (t ,"\u0064\u0063t\u0065\u0072\u006ds\u003a\u006d\u006f\u0064\u0069\u0066\u0069\u0065\u0064");};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Properties returns table properties.
func (_aad Table )Properties ()*_gf .CT_TableProperties {return _aad ._cfea .TblPr };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00: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 (_efe ImageRef )RelativeHeight (w _cf .Distance )_cf .Distance {_deeb :=float64 (_efe .Size ().Y )/float64 (_efe .Size ().X );return w *_cf .Distance (_deeb );};const _eeaf ="\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034";
// 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 (_fde *ImageRef )SetTarget (target string ){_fde ._cff =target };
2020-08-23 14:15:53 +00:00
2020-10-12 13:59:12 +00:00
// Hyperlink is just an appropriately configured relationship.
2020-11-09 01:00:18 +00:00
type Hyperlink Relationship ;const _eea ="2\u00300\u0036\u002d\u0030\u0031\u002d\u0030\u0032\u00541\u0035\u003a\u0030\u0034:0\u0035\u005a";
2020-08-31 22:58:25 +00:00
2020-11-09 01:00:18 +00:00
// X returns the inner wrapped XML type.
func (_gffd CoreProperties )X ()*_dce .CoreProperties {return _gffd ._bbc };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// ApplicationVersion returns the version of the application that created the
// document.
func (_dfa AppProperties )ApplicationVersion ()string {if _dfa ._bcca .AppVersion !=nil {return *_dfa ._bcca .AppVersion ;};return "";};func (_fgad CustomProperties )SetPropertyAsCy (name string ,cy string ){_bbg :=_fgad .getNewProperty (name );_bbg .Cy =&cy ;_fgad .setOrReplaceProperty (_bbg );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// SetTitle records the title of the document.
func (_dcbd CoreProperties )SetTitle (s string ){if _dcbd ._bbc .Title ==nil {_dcbd ._bbc .Title =&_fa .XSDAny {XMLName :_dc .Name {Local :"\u0064\u0063\u003a\u0074\u0069\u0074\u006c\u0065"}};};_dcbd ._bbc .Title .Data =[]byte (s );};func (_aeca CustomProperties )SetPropertyAsUint (name string ,ui uint ){_cfe :=_aeca .getNewProperty (name );_cab :=uint32 (ui );_cfe .Uint =&_cab ;_aeca .setOrReplaceProperty (_cfe );};func (_dab CustomProperties )SetPropertyAsStream (name string ,stream string ){_fbc :=_dab .getNewProperty (name );_fbc .Stream =&stream ;_dab .setOrReplaceProperty (_fbc );};func (_eba CustomProperties )SetPropertyAsUi4 (name string ,ui4 uint32 ){_bfg :=_eba .getNewProperty (name );_bfg .Ui4 =&ui4 ;_eba .setOrReplaceProperty (_bfg );};func (_dfe CustomProperties )SetPropertyAsClsid (name string ,clsid string ){_dcg :=_dfe .getNewProperty (name );_dcg .Clsid =&clsid ;_dfe .setOrReplaceProperty (_dcg );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// X returns the underlying raw XML data.
func (_gaa Relationships )X ()*_ed .Relationships {return _gaa ._dafe };func (_fbda CustomProperties )SetPropertyAsBstr (name string ,bstr string ){_cce :=_fbda .getNewProperty (name );_cce .Bstr =&bstr ;_fbda .setOrReplaceProperty (_cce );};func (_ccfb CustomProperties )SetPropertyAsOstream (name string ,ostream string ){_edga :=_ccfb .getNewProperty (name );_edga .Ostream =&ostream ;_ccfb .setOrReplaceProperty (_edga );};func (_fbab CustomProperties )SetPropertyAsUi2 (name string ,ui2 uint16 ){_fcg :=_fbab .getNewProperty (name );_fcg .Ui2 =&ui2 ;_fbab .setOrReplaceProperty (_fcg );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Clear removes any existing relationships.
func (_bfd Relationships )Clear (){_bfd ._dafe .Relationship =nil };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// CopyRelationship copies the relationship.
func (_baa Relationships )CopyRelationship (idAttr string )(Relationship ,bool ){for _baf :=range _baa ._dafe .Relationship {if _baa ._dafe .Relationship [_baf ].IdAttr ==idAttr {_acg :=*_baa ._dafe .Relationship [_baf ];_deeba :=len (_baa ._dafe .Relationship )+1;_bgda :=map[string ]struct{}{};for _ ,_fcga :=range _baa ._dafe .Relationship {_bgda [_fcga .IdAttr ]=struct{}{};};for _ ,_gbd :=_bgda [_eg .Sprintf ("\u0072\u0049\u0064%\u0064",_deeba )];_gbd ;_ ,_gbd =_bgda [_eg .Sprintf ("\u0072\u0049\u0064%\u0064",_deeba )]{_deeba ++;};_acg .IdAttr =_eg .Sprintf ("\u0072\u0049\u0064%\u0064",_deeba );_baa ._dafe .Relationship =append (_baa ._dafe .Relationship ,&_acg );return Relationship {_ege :&_acg },true ;};};return Relationship {},false ;};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// SetCreated sets the time that the document was created.
func (_edfg CoreProperties )SetCreated (t _ab .Time ){_edfg ._bbc .Created =_ac (t ,"\u0064c\u0074e\u0072\u006d\u0073\u003a\u0063\u0072\u0065\u0061\u0074\u0065\u0064");};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00: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 ;};func UtcTimeFormat (t _ab .Time )string {return t .Format (_eeaf )+"\u0020\u0055\u0054\u0043"};
2020-10-12 13:59:12 +00:00
2020-11-09 01:00:18 +00:00
// SetOffsetY sets vertical offset of a table in distance units (see measurement package).
func (_fgd Table )SetOffsetY (offY float64 ){if _fgd ._cgdb .Off ==nil {_fgd ._cgdb .Off =_gf .NewCT_Point2D ();_dfff :=int64 (0);_fgd ._cgdb .Off .XAttr =_gf .ST_Coordinate {ST_CoordinateUnqualified :&_dfff };};_faed :=_cf .ToEMU (offY );_fgd ._cgdb .Off .YAttr =_gf .ST_Coordinate {ST_CoordinateUnqualified :&_faed };};
2020-10-12 13:59:12 +00:00
2020-11-09 01:00:18 +00:00
// AddCustomRelationships adds relationships related to custom properties to the document.
func (_cgd *DocBase )AddCustomRelationships (){_cgd .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");_cgd .Rels .AddRelationship ("\u0064\u006f\u0063\u0050ro\u0070\u0073\u002f\u0063\u0075\u0073\u0074\u006f\u006d\u002e\u0078\u006d\u006c",_fa .CustomPropertiesType );};func (_fga CustomProperties )SetPropertyAsOblob (name ,oblob string ){_fea :=_fga .getNewProperty (name );_fea .Oblob =&oblob ;_fga .setOrReplaceProperty (_fea );};func (_ffe CustomProperties )SetPropertyAsLpwstr (name string ,lpwstr string ){_agd :=_ffe .getNewProperty (name );_agd .Lpwstr =&lpwstr ;_ffe .setOrReplaceProperty (_agd );};
2020-10-12 13:59:12 +00:00
2020-11-09 01:00:18 +00:00
// SetLanguage records the language of the document.
func (_aec CoreProperties )SetLanguage (s string ){_aec ._bbc .Language =&_fa .XSDAny {XMLName :_dc .Name {Local :"d\u0063\u003a\u006c\u0061\u006e\u0067\u0075\u0061\u0067\u0065"}};_aec ._bbc .Language .Data =[]byte (s );};
2020-10-12 13:59:12 +00:00
2020-11-09 01:00:18 +00:00
// TableRow represents a row in a table.
type TableRow struct{_bab *_gf .CT_TableRow };
2020-08-23 14:15:53 +00:00
2020-08-31 22:58:25 +00:00
// AddImageToZip adds an image (either from bytes or from disk) and adds it to the zip file.
2020-11-09 01:00:18 +00:00
func AddImageToZip (z *_a .Writer ,img ImageRef ,imageNum int ,dt _fa .DocType )error {_ebaf :=_fa .AbsoluteImageFilename (dt ,imageNum ,_gc .ToLower (img .Format ()));if img .Data ()!=nil &&len (*img .Data ())> 0{if _ggd :=_ba .AddFileFromBytes (z ,_ebaf ,*img .Data ());_ggd !=nil {return _ggd ;};}else if img .Path ()!=""{if _faaa :=_ba .AddFileFromDisk (z ,_ebaf ,img .Path ());_faaa !=nil {return _faaa ;};}else {return _eg .Errorf ("\u0075\u006es\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0069\u006d\u0061\u0067\u0065\u0020\u0073\u006f\u0075\u0072\u0063\u0065\u003a %\u002b\u0076",img );};return nil ;};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// AddRow adds a row to a table.
func (_efcfb Table )AddRow ()*TableRow {_ecfa :=_gf .NewCT_TableRow ();for _ecd :=0;_ecd < len (_efcfb ._cfea .TblGrid .GridCol );_ecd ++{_ecfa .Tc =append (_ecfa .Tc ,_gf .NewCT_TableCell ());};_efcfb ._cfea .Tr =append (_efcfb ._cfea .Tr ,_ecfa );return &TableRow {_bab :_ecfa };};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// EnsureDefault esnures that an extension and default content type exist,
// adding it if necessary.
func (_fbd ContentTypes )EnsureDefault (ext ,contentType string ){ext =_gc .ToLower (ext );for _ ,_gbgd :=range _fbd ._dcb .Default {if _gbgd .ExtensionAttr ==ext {_gbgd .ContentTypeAttr =contentType ;return ;};};_fbaa :=&_ega .Default {};_fbaa .ContentTypeAttr =contentType ;_fbaa .ExtensionAttr =ext ;_fbd ._dcb .Default =append (_fbd ._dcb .Default ,_fbaa );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// NewAppProperties constructs a new AppProperties.
func NewAppProperties ()AppProperties {_gec :=AppProperties {_bcca :_bd .NewProperties ()};_gec .SetCompany ("\u0046\u006f\u0078\u0079\u0055\u0074\u0069\u006c\u0073\u0020\u0065\u0068\u0066");_gec .SetApplication ("g\u0069\u0074\u0068\u0075\u0062\u002ec\u006f\u006d\u002f\u0075\u006e\u0069\u0064\u006f\u0063/\u0075\u006e\u0069o\u0066f\u0069\u0063\u0065");_gec .SetDocSecurity (0);_gec .SetLinksUpToDate (false );var _gba ,_fb ,_cda int64 ;_eg .Sscanf (Version ,"\u0025\u0064\u002e\u0025\u0064\u002e\u0025\u0064",&_gba ,&_fb ,&_cda );_dcd :=float64 (_gba )+float64 (_fb )/10000.0;_gec .SetApplicationVersion (_eg .Sprintf ("\u0025\u0030\u0037\u002e\u0034\u0066",_dcd ));return _gec ;};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Description returns the description of the document
func (_bga CoreProperties )Description ()string {if _bga ._bbc .Description !=nil {return string (_bga ._bbc .Description .Data );};return "";};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Relationships returns a slice of all of the relationships.
func (_bbe Relationships )Relationships ()[]Relationship {_ebag :=[]Relationship {};for _ ,_bcgc :=range _bbe ._dafe .Relationship {_ebag =append (_ebag ,Relationship {_ege :_bcgc });};return _ebag ;};
// TableCol represents a column in a table.
type TableCol struct{_ada *_gf .CT_TableCol };
2020-08-23 14:15:53 +00:00
2020-10-12 13:59:12 +00:00
// ID returns the ID of a relationship.
2020-11-09 01:00:18 +00:00
func (_caba Relationship )ID ()string {return _caba ._ege .IdAttr };
2020-10-12 13:59:12 +00:00
2020-11-09 01:00:18 +00:00
// CustomProperty contains document specific property.
// Using of this type is deprecated.
type CustomProperty struct{_dgb *_gcb .CT_Property };
2020-10-12 13:59:12 +00:00
2020-11-09 01:00:18 +00:00
// SetOffsetX sets horizontal offset of a table in distance units (see measurement package).
func (_aadd Table )SetOffsetX (offX float64 ){if _aadd ._cgdb .Off ==nil {_aadd ._cgdb .Off =_gf .NewCT_Point2D ();_dfaf :=int64 (0);_aadd ._cgdb .Off .YAttr =_gf .ST_Coordinate {ST_CoordinateUnqualified :&_dfaf };};_cdgd :=_cf .ToEMU (offX );_aadd ._cgdb .Off .XAttr =_gf .ST_Coordinate {ST_CoordinateUnqualified :&_cdgd };};var ReleasedAt =_ab .Date (_gded ,_egga ,_faea ,_cabab ,_ede ,0,0,_ab .UTC );
2020-10-12 13:59:12 +00:00
2020-11-09 01:00:18 +00:00
// Format returns the format of the underlying image
func (_cbc ImageRef )Format ()string {return _cbc ._eff .Format };func (_fddb CustomProperties )SetPropertyAsStorage (name string ,storage string ){_agee :=_fddb .getNewProperty (name );_agee .Storage =&storage ;_fddb .setOrReplaceProperty (_agee );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// SetDescription records the description of the document.
func (_def CoreProperties )SetDescription (s string ){if _def ._bbc .Description ==nil {_def ._bbc .Description =&_fa .XSDAny {XMLName :_dc .Name {Local :"\u0064\u0063\u003a\u0064\u0065\u0073\u0063\u0072\u0069p\u0074\u0069\u006f\u006e"}};};_def ._bbc .Description .Data =[]byte (s );};func (_edd CustomProperties )SetPropertyAsLpstr (name string ,lpstr string ){_dd :=_edd .getNewProperty (name );_dd .Lpstr =&lpstr ;_edd .setOrReplaceProperty (_dd );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00: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 ){_dca :=Image {};_cddb ,_efeb :=_ca .Open (path );if _efeb !=nil {return _dca ,_eg .Errorf ("\u0065\u0072\u0072or\u0020\u0072\u0065\u0061\u0064\u0069\u006e\u0067\u0020\u0069\u006d\u0061\u0067\u0065\u003a\u0020\u0025\u0073",_efeb );};defer _cddb .Close ();_cbfe ,_beg ,_efeb :=_c .Decode (_cddb );if _efeb !=nil {return _dca ,_eg .Errorf ("\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s",_efeb );};_dca .Path =path ;_dca .Format =_beg ;_dca .Size =_cbfe .Bounds ().Size ();return _dca ,nil ;};
2020-08-31 22:58:25 +00:00
2020-11-09 01:00:18 +00:00
// AddDefault registers a default content type for a given file extension.
func (_ee ContentTypes )AddDefault (fileExtension string ,contentType string ){fileExtension =_gc .ToLower (fileExtension );for _ ,_ged :=range _ee ._dcb .Default {if _ged .ExtensionAttr ==fileExtension &&_ged .ContentTypeAttr ==contentType {return ;};};_bf :=_ega .NewDefault ();_bf .ExtensionAttr =fileExtension ;_bf .ContentTypeAttr =contentType ;_ee ._dcb .Default =append (_ee ._dcb .Default ,_bf );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Rows returns all table rows.
func (_bbdc Table )Rows ()[]*TableRow {_bgc :=_bbdc ._cfea .Tr ;_bgaf :=[]*TableRow {};for _ ,_bbdcf :=range _bgc {_bgaf =append (_bgaf ,&TableRow {_bab :_bbdcf });};return _bgaf ;};func (_afd CustomProperties )SetPropertyAsInt (name string ,i int ){_age :=_afd .getNewProperty (name );_eegg :=int32 (i );_age .Int =&_eegg ;_afd .setOrReplaceProperty (_age );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// SetHeight sets row height, see measurement package.
func (_ecbb TableRow )SetHeight (m _cf .Distance ){_cac :=_cf .ToEMU (float64 (m ));_ecbb ._bab .HAttr =_gf .ST_Coordinate {ST_CoordinateUnqualified :&_cac };};func (_adc CustomProperties )SetPropertyAsI8 (name string ,i8 int64 ){_abb :=_adc .getNewProperty (name );_abb .I8 =&i8 ;_adc .setOrReplaceProperty (_abb );};func (_eee CustomProperties )setOrReplaceProperty (_dbbf *_gcb .CT_Property ){_eee .setPropertyHelper (_dbbf ,true );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// GetPropertyByName returns a custom property selected by it's name.
func (_gdd CustomProperties )GetPropertyByName (name string )CustomProperty {_gde :=_gdd ._gfb .Property ;for _ ,_bce :=range _gde {if *_bce .NameAttr ==name {return CustomProperty {_dgb :_bce };};};return CustomProperty {};};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// NewTable makes a new table.
func NewTable ()*Table {_dgbg :=_gf .NewTbl ();_dgbg .TblPr =_gf .NewCT_TableProperties ();return &Table {_cfea :_dgbg };};
// 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 _c .Point ;Format string ;Path string ;Data *[]byte ;};
// X returns the inner wrapped XML type.
func (_afg TableStyles )X ()*_gf .TblStyleLst {return _afg ._fbe };func (_bad CustomProperties )setProperty (_bffg *_gcb .CT_Property ){_bad .setPropertyHelper (_bffg ,false );};
// SetLastModifiedBy records the last person to modify the document.
func (_fdf CoreProperties )SetLastModifiedBy (s string ){_fdf ._bbc .LastModifiedBy =&s };
2020-08-23 14:15:53 +00:00
2020-10-12 13:59:12 +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.
2020-11-09 01:00:18 +00:00
func (_bee ImageRef )RelativeWidth (h _cf .Distance )_cf .Distance {_ccc :=float64 (_bee .Size ().X )/float64 (_bee .Size ().Y );return h *_cf .Distance (_ccc );};func (_fgfc TableRow )addCell ()*_gf .CT_TableCell {_degf :=_gf .NewCT_TableCell ();_fgfc ._bab .Tc =append (_fgfc ._bab .Tc ,_degf );return _degf ;};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// SetAuthor records the author of the document.
func (_bbb CoreProperties )SetAuthor (s string ){if _bbb ._bbc .Creator ==nil {_bbb ._bbc .Creator =&_fa .XSDAny {XMLName :_dc .Name {Local :"\u0064\u0063\u003a\u0063\u0072\u0065\u0061\u0074\u006f\u0072"}};};_bbb ._bbc .Creator .Data =[]byte (s );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// CoreProperties contains document specific properties.
type CoreProperties struct{_bbc *_dce .CoreProperties };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// AddRelationship adds a relationship.
func (_gda Relationships )AddRelationship (target ,ctype string )Relationship {if !_gc .HasPrefix (ctype ,"\u0068t\u0074\u0070\u003a\u002f\u002f"){_fa .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 );};_eca :=_ed .NewRelationship ();_eegf :=len (_gda ._dafe .Relationship )+1;_bacd :=map[string ]struct{}{};for _ ,_cfae :=range _gda ._dafe .Relationship {_bacd [_cfae .IdAttr ]=struct{}{};};for _ ,_ccbe :=_bacd [_eg .Sprintf ("\u0072\u0049\u0064%\u0064",_eegf )];_ccbe ;_ ,_ccbe =_bacd [_eg .Sprintf ("\u0072\u0049\u0064%\u0064",_eegf )]{_eegf ++;};_eca .IdAttr =_eg .Sprintf ("\u0072\u0049\u0064%\u0064",_eegf );_eca .TargetAttr =target ;_eca .TypeAttr =ctype ;_gda ._dafe .Relationship =append (_gda ._dafe .Relationship ,_eca );return Relationship {_ege :_eca };};func (_aag CustomProperties )setPropertyHelper (_eag *_gcb .CT_Property ,_abe bool ){_cbf :=_aag .GetPropertyByName (*_eag .NameAttr );if (_cbf ==CustomProperty {}){_aag ._gfb .Property =append (_aag ._gfb .Property ,_eag );}else if _abe {_eag .FmtidAttr =_cbf ._dgb .FmtidAttr ;if _cbf ._dgb .PidAttr ==0{_eag .PidAttr =_cbf ._dgb .PidAttr ;};_eag .LinkTargetAttr =_cbf ._dgb .LinkTargetAttr ;*_cbf ._dgb =*_eag ;};};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// RelID returns the relationship ID.
func (_ddbb ImageRef )RelID ()string {return _ddbb ._fgg };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// SetCategory records the category of the document.
func (_cgc CoreProperties )SetCategory (s string ){_cgc ._bbc .Category =&s };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// RemoveOverride removes an override given a path.
func (_fee ContentTypes )RemoveOverride (path string ){if !_gc .HasPrefix (path ,"\u002f"){path ="\u002f"+path ;};for _egd ,_aac :=range _fee ._dcb .Override {if _aac .PartNameAttr ==path {copy (_fee ._dcb .Override [_egd :],_fee ._dcb .Override [_egd +1:]);_fee ._dcb .Override =_fee ._dcb .Override [0:len (_fee ._dcb .Override )-1];};};};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Author returns the author of the document
func (_bda CoreProperties )Author ()string {if _bda ._bbc .Creator !=nil {return string (_bda ._bbc .Creator .Data );};return "";};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// SetApplication sets the name of the application that created the document.
func (_afa AppProperties )SetApplication (s string ){_afa ._bcca .Application =&s };func (_agb CustomProperties )SetPropertyAsUi8 (name string ,ui8 uint64 ){_bfe :=_agb .getNewProperty (name );_bfe .Ui8 =&ui8 ;_agb .setOrReplaceProperty (_bfe );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// TblStyle returns the TblStyle property.
func (_aba TableStyles )TblStyle ()[]*_gf .CT_TableStyle {return _aba ._fbe .TblStyle };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// NewTheme constructs a new theme.
func NewTheme ()Theme {return Theme {_gf .NewTheme ()}};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// SetStyle assigns TableStyle to a table.
func (_eagg Table )SetStyle (style *_gf .CT_TableStyle ){if _eagg ._cfea .TblPr ==nil {_eagg ._cfea .TblPr =_gf .NewCT_TableProperties ();};if _eagg ._cfea .TblPr .Choice ==nil {_eagg ._cfea .TblPr .Choice =_gf .NewCT_TablePropertiesChoice ();};_eagg ._cfea .TblPr .Choice .TableStyle =style ;};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// SetWidth sets column width, see measurement package.
func (_ecc TableCol )SetWidth (m _cf .Distance ){_cbdb :=_cf .ToEMU (float64 (m ));_ecc ._ada .WAttr =_gf .ST_Coordinate {ST_CoordinateUnqualified :&_cbdb };};func (_agc CustomProperties )SetPropertyAsFiletime (name string ,filetime _ab .Time ){_feda :=_agc .getNewProperty (name );_feda .Filetime =&filetime ;_agc .setOrReplaceProperty (_feda );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Theme is a drawingml theme.
type Theme struct{_bgee *_gf .Theme };const Version ="\u0031\u002e\u0037.\u0030";
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// NewRelationshipsCopy creates a new relationships wrapper as a copy of passed in instance.
func NewRelationshipsCopy (rels Relationships )Relationships {_efgg :=*rels ._dafe ;return Relationships {_dafe :&_efgg };};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// NewTableStyles constructs a new TableStyles.
func NewTableStyles ()TableStyles {return TableStyles {_fbe :_gf .NewTblStyleLst ()}};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00: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 {_eff :img ,_fbbb :d ,_gcbe :rels };};func (_bdc CustomProperties )SetPropertyAsNull (name string ){_cfc :=_bdc .getNewProperty (name );_cfc .Null =_ce .NewNull ();_bdc .setOrReplaceProperty (_cfc );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// RemoveOverrideByIndex removes an override given a path and override index.
func (_bgf ContentTypes )RemoveOverrideByIndex (path string ,indexToFind int )error {_fbba :=path [0:len (path )-5];if !_gc .HasPrefix (_fbba ,"\u002f"){_fbba ="\u002f"+_fbba ;};_ag ,_bge :=_gcc .Compile (_fbba +"\u0028\u005b\u0030-\u0039\u005d\u002b\u0029\u002e\u0078\u006d\u006c");if _bge !=nil {return _bge ;};_ecb :=0;_fae :=-1;for _geca ,_caf :=range _bgf ._dcb .Override {if _fab :=_ag .FindStringSubmatch (_caf .PartNameAttr );len (_fab )> 1{if _ecb ==indexToFind {_fae =_geca ;}else if _ecb > indexToFind {_db ,_ :=_de .Atoi (_fab [1]);_db --;_caf .PartNameAttr =_eg .Sprintf ("\u0025\u0073\u0025\u0064\u002e\u0078\u006d\u006c",_fbba ,_db );};_ecb ++;};};if _fae > -1{copy (_bgf ._dcb .Override [_fae :],_bgf ._dcb .Override [_fae +1:]);_bgf ._dcb .Override =_bgf ._dcb .Override [0:len (_bgf ._dcb .Override )-1];};return nil ;};
2020-10-12 13:59:12 +00:00
2020-11-09 01:00:18 +00:00
// Relationship is a relationship within a .rels file.
type Relationship struct{_ege *_ed .Relationship };func (_cfg CustomProperties )getNewProperty (_dcf string )*_gcb .CT_Property {_ccf :=_cfg ._gfb .Property ;_ded :=int32 (1);for _ ,_dff :=range _ccf {if _dff .PidAttr > _ded {_ded =_dff .PidAttr ;};};_dgfb :=_gcb .NewCT_Property ();_dgfb .NameAttr =&_dcf ;_dgfb .PidAttr =_ded +1;_dgfb .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 _dgfb ;};
2020-10-12 13:59:12 +00:00
2020-11-09 01:00:18 +00:00
// SetLinksUpToDate sets the links up to date flag.
func (_be AppProperties )SetLinksUpToDate (v bool ){_be ._bcca .LinksUpToDate =_fa .Bool (v )};
2020-10-12 13:59:12 +00:00
2020-11-09 01:00:18 +00:00
// X returns the inner raw content types.
func (_cfd ContentTypes )X ()*_ega .Types {return _cfd ._dcb };const _cabab =10;
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Modified returns the time that the document was modified.
func (_gadf CoreProperties )Modified ()_ab .Time {return _egc (_gadf ._bbc .Modified )};func (_bccg Relationship )String ()string {return _eg .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",_bccg .ID (),_bccg .Target (),_bccg .Type ());};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// X returns the inner wrapped XML type.
func (_dede Relationship )X ()*_ed .Relationship {return _dede ._ege };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// SetTarget set the target (path) of a relationship.
func (_gcdd Relationship )SetTarget (s string ){_gcdd ._ege .TargetAttr =s };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// WriteExtraFiles writes the extra files to the zip package.
func (_ebc *DocBase )WriteExtraFiles (z *_a .Writer )error {for _ ,_fcf :=range _ebc .ExtraFiles {if _ebcf :=_ba .AddFileFromDisk (z ,_fcf .ZipPath ,_fcf .DiskPath );_ebcf !=nil {return _ebcf ;};};return nil ;};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// IsEmpty returns true if there are no relationships.
func (_bfed Relationships )IsEmpty ()bool {return _bfed ._dafe ==nil ||len (_bfed ._dafe .Relationship )==0;};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// NewRelationship constructs a new relationship.
func NewRelationship ()Relationship {return Relationship {_ege :_ed .NewRelationship ()}};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Category returns the category of the document
func (_ae CoreProperties )Category ()string {if _ae ._bbc .Category !=nil {return *_ae ._bbc .Category ;};return "";};func (_eef CustomProperties )SetPropertyAsEmpty (name string ){_cbe :=_eef .getNewProperty (name );_cbe .Empty =_ce .NewEmpty ();_eef .setOrReplaceProperty (_cbe );};
2020-08-23 14:15:53 +00:00
2020-10-12 13:59:12 +00:00
// Cells returns an array of row cells.
2020-11-09 01:00:18 +00:00
func (_dffe TableRow )Cells ()[]*_gf .CT_TableCell {return _dffe ._bab .Tc };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// NewTableWithXfrm makes a new table with a pointer to its parent Xfrm for changing its offset and size.
func NewTableWithXfrm (xfrm *_gf .CT_Transform2D )*Table {_cdef :=_gf .NewTbl ();_cdef .TblPr =_gf .NewCT_TableProperties ();return &Table {_cfea :_cdef ,_cgdb :xfrm };};func (_eefb CustomProperties )SetPropertyAsR4 (name string ,r4 float32 ){_efcf :=_eefb .getNewProperty (name );_efcf .R4 =&r4 ;_eefb .setOrReplaceProperty (_efcf );};func _egc (_edbb *_fa .XSDAny )_ab .Time {if _edbb ==nil {return _ab .Time {};};_adb ,_cbd :=_ab .Parse (_eea ,string (_edbb .Data ));if _cbd !=nil {_fa .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 (_edbb .Data ),_cbd );};return _adb ;};const _ede =40;func (_bgfe CustomProperties )SetPropertyAsError (name string ,error string ){_eeb :=_bgfe .getNewProperty (name );_eeb .Error =&error ;_bgfe .setOrReplaceProperty (_eeb );};func (_daf CustomProperties )SetPropertyAsI4 (name string ,i4 int32 ){_fbf :=_daf .getNewProperty (name );_fbf .I4 =&i4 ;_daf .setOrReplaceProperty (_fbf );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// EnsureOverride ensures that an override for the given path exists, adding it if necessary
func (_bgd ContentTypes )EnsureOverride (path ,contentType string ){for _ ,_fge :=range _bgd ._dcb .Override {if _fge .PartNameAttr ==path {if _gc .HasPrefix (contentType ,"\u0068\u0074\u0074\u0070"){_fa .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 );};_fge .ContentTypeAttr =contentType ;return ;};};_bgd .AddOverride (path ,contentType );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// CreateCustomProperties creates the custom properties of the document.
func (_fdb *DocBase )CreateCustomProperties (){_fdb .CustomProperties =NewCustomProperties ();_fdb .AddCustomRelationships ();};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00: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 (_ecgg *DocBase )AddExtraFileFromZip (f *_a .File )error {_eebb ,_ecf :=_ba .ExtractToDiskTmp (f ,_ecgg .TmpPath );if _ecf !=nil {return _eg .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",_ecf );};_ecgg .ExtraFiles =append (_ecgg .ExtraFiles ,ExtraFile {ZipPath :f .Name ,DiskPath :_eebb });return nil ;};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Properties returns table properties.
func (_bacc Table )Grid ()*_gf .CT_TableGrid {return _bacc ._cfea .TblGrid };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// CopyOverride copies override content type for a given `path` and puts it with a path `newPath`.
func (_gab ContentTypes )CopyOverride (path ,newPath string ){if !_gc .HasPrefix (path ,"\u002f"){path ="\u002f"+path ;};if !_gc .HasPrefix (newPath ,"\u002f"){newPath ="\u002f"+newPath ;};for _gffa :=range _gab ._dcb .Override {if _gab ._dcb .Override [_gffa ].PartNameAttr ==path {_dgf :=*_gab ._dcb .Override [_gffa ];_dgf .PartNameAttr =newPath ;_gab ._dcb .Override =append (_gab ._dcb .Override ,&_dgf );};};};func init (){_dg .SetAsStorage ()};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00: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 (_aeg Relationships )AddAutoRelationship (dt _fa .DocType ,src string ,idx int ,ctype string )Relationship {return _aeg .AddRelationship (_fa .RelativeFilename (dt ,src ,ctype ,idx ),ctype );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Data returns the data of an image file, if any.
func (_fcfe ImageRef )Data ()*[]byte {return _fcfe ._eff .Data };
2020-08-23 14:15:53 +00:00
2020-10-12 13:59:12 +00:00
// Target returns the target (path) of a relationship.
2020-11-09 01:00:18 +00:00
func (_bffd Relationship )Target ()string {return _bffd ._ege .TargetAttr };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// ContentStatus returns the content status of the document (e.g. "Final", "Draft")
func (_fgec CoreProperties )ContentStatus ()string {if _fgec ._bbc .ContentStatus !=nil {return *_fgec ._bbc .ContentStatus ;};return "";};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00: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 (_cfa AppProperties )Pages ()int32 {if _cfa ._bcca .Pages !=nil {return *_cfa ._bcca .Pages ;};return 0;};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// SetContentStatus records the content status of the document.
func (_eeg CoreProperties )SetContentStatus (s string ){_eeg ._bbc .ContentStatus =&s };func (_ddb CustomProperties )SetPropertyAsDate (name string ,date _ab .Time ){date =date .UTC ();_ebg ,_ecg ,_gfd :=date .Date ();_aca ,_bgdd ,_gece :=date .Clock ();_abbe :=_ab .Date (_ebg ,_ecg ,_gfd ,_aca ,_bgdd ,_gece ,0,_ab .UTC );_adf :=_ddb .getNewProperty (name );_adf .Filetime =&_abbe ;_ddb .setOrReplaceProperty (_adf );};func _ac (_eb _ab .Time ,_fef string )*_fa .XSDAny {_cdab :=&_fa .XSDAny {XMLName :_dc .Name {Local :_fef }};_cdab .Attrs =append (_cdab .Attrs ,_dc .Attr {Name :_dc .Name {Local :"\u0078\u0073\u0069\u003a\u0074\u0079\u0070\u0065"},Value :"\u0064\u0063\u0074\u0065\u0072\u006d\u0073\u003a\u00573\u0043\u0044\u0054\u0046"});_cdab .Attrs =append (_cdab .Attrs ,_dc .Attr {Name :_dc .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"});_cdab .Attrs =append (_cdab .Attrs ,_dc .Attr {Name :_dc .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/"});_cdab .Data =[]byte (_eb .Format (_eea ));return _cdab ;};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// GetOrCreateCustomProperties returns the custom properties of the document (and if they not exist yet, creating them first).
func (_cga *DocBase )GetOrCreateCustomProperties ()CustomProperties {if _cga .CustomProperties .X ()==nil {_cga .CreateCustomProperties ();};return _cga .CustomProperties ;};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00: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 (_cabf *ImageRef )Target ()string {return _cabf ._cff };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// ContentTypes is the top level "[Content_Types].xml" in a zip package.
type ContentTypes struct{_dcb *_ega .Types };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Append appends DocBase part of an office document to another DocBase.
func (_gb DocBase )Append (docBase1 DocBase )DocBase {_ge :=docBase1 .ContentTypes .X ();for _ ,_faa :=range _ge .Default {_gb .ContentTypes .AddDefault (_faa .ExtensionAttr ,_faa .ContentTypeAttr );};for _ ,_aa :=range _ge .Override {_gb .ContentTypes .AddOverride (_aa .PartNameAttr ,_aa .ContentTypeAttr );};_edg :=_gb .AppProperties .X ();_gca :=docBase1 .AppProperties .X ();if _edg .Pages !=nil {if _gca .Pages !=nil {*_edg .Pages +=*_gca .Pages ;};}else if _gca .Pages !=nil {_edg .Pages =_gca .Pages ;};if _edg .Words !=nil {if _gca .Words !=nil {*_edg .Words +=*_gca .Words ;};}else if _gca .Words !=nil {_edg .Words =_gca .Words ;};if _edg .Characters !=nil {if _gca .Characters !=nil {*_edg .Characters +=*_gca .Characters ;};}else if _gca .Characters !=nil {_edg .Characters =_gca .Characters ;};if _edg .Lines !=nil {if _gca .Lines !=nil {*_edg .Lines +=*_gca .Lines ;};}else if _gca .Lines !=nil {_edg .Lines =_gca .Lines ;};if _edg .Paragraphs !=nil {if _gca .Paragraphs !=nil {*_edg .Paragraphs +=*_gca .Paragraphs ;};}else if _gca .Paragraphs !=nil {_edg .Paragraphs =_gca .Paragraphs ;};if _edg .Notes !=nil {if _gca .Notes !=nil {*_edg .Notes +=*_gca .Notes ;};}else if _gca .Notes !=nil {_edg .Notes =_gca .Notes ;};if _edg .HiddenSlides !=nil {if _gca .HiddenSlides !=nil {*_edg .HiddenSlides +=*_gca .HiddenSlides ;};}else if _gca .HiddenSlides !=nil {_edg .HiddenSlides =_gca .HiddenSlides ;};if _edg .MMClips !=nil {if _gca .MMClips !=nil {*_edg .MMClips +=*_gca .MMClips ;};}else if _gca .MMClips !=nil {_edg .MMClips =_gca .MMClips ;};if _edg .LinksUpToDate !=nil {if _gca .LinksUpToDate !=nil {*_edg .LinksUpToDate =*_edg .LinksUpToDate &&*_gca .LinksUpToDate ;};}else if _gca .LinksUpToDate !=nil {_edg .LinksUpToDate =_gca .LinksUpToDate ;};if _edg .CharactersWithSpaces !=nil {if _gca .CharactersWithSpaces !=nil {*_edg .CharactersWithSpaces +=*_gca .CharactersWithSpaces ;};}else if _gca .CharactersWithSpaces !=nil {_edg .CharactersWithSpaces =_gca .CharactersWithSpaces ;};if _edg .SharedDoc !=nil {if _gca .SharedDoc !=nil {*_edg .SharedDoc =*_edg .SharedDoc ||*_gca .SharedDoc ;};}else if _gca .SharedDoc !=nil {_edg .SharedDoc =_gca .SharedDoc ;};if _edg .HyperlinksChanged !=nil {if _gca .HyperlinksChanged !=nil {*_edg .HyperlinksChanged =*_edg .HyperlinksChanged ||*_gca .HyperlinksChanged ;};}else if _gca .HyperlinksChanged !=nil {_edg .HyperlinksChanged =_gca .HyperlinksChanged ;};_edg .DigSig =nil ;if _edg .TitlesOfParts ==nil &&_gca .TitlesOfParts !=nil {_edg .TitlesOfParts =_gca .TitlesOfParts ;};if _edg .HeadingPairs !=nil {if _gca .HeadingPairs !=nil {_cc :=_edg .HeadingPairs .Vector ;_bc :=_gca .HeadingPairs .Vector ;_ff :=_cc .Variant ;_ffc :=_bc .Variant ;_bac :=[]*_ce .Variant {};for _cd :=0;_cd < len (_ffc );_cd +=2{_egg :=_ffc [_cd ].Lpstr ;_gbc :=false ;for _gccg :=0;_gccg < len (_ff );_gccg +=2{_ga :=_ff [_gccg ].Lpstr ;if _ga !=nil &&_egg !=nil &&*_ga ==*_egg {*_ff [_gccg +1].I4 =*_ff [_gccg +1].I4 +*_ffc [_cd +1].I4 ;_gbc =true ;break ;};};if !_gbc {_bac =append (_bac ,&_ce .Variant {CT_Variant :_ce .CT_Variant {Lpstr :_ffc [_cd ].Lpstr }});_bac =append (_bac ,&_ce .Variant {CT_Variant :_ce .CT_Variant {I4 :_ffc [_cd ].I4 }});};};_ff =append (_ff ,_bac ...);_cc .SizeAttr =uint32 (len (_ff ));};}else if _gca .HeadingPairs !=nil {_edg .HeadingPairs =_gca .HeadingPairs ;};if _edg .HLinks !=nil {if _gca .HLinks !=nil {_fd :=_edg .HLinks .Vector ;_cde :=_gca .HLinks .Vector ;_faab :=_fd .Variant ;_bdf :=_cde .Variant ;for _ ,_abg :=range _bdf {_af :=true ;for _ ,_fg :=range _faab {if _b .DeepEqual (_fg ,_abg ){_af =false ;break ;};};if _af {_faab =append (_faab ,_abg );_fd .SizeAttr ++;};};};}else if _gca .HLinks !=nil {_edg .HLinks =_gca .HLinks ;};_ffd :=_gb .GetOrCreateCustomProperties ();_ec :=docBase1 .GetOrCreateCustomProperties ();for _ ,_gad :=range _ec .PropertiesList (){_ffd .setProperty (_gad );};_gb .CustomProperties =_ffd ;_gff :=_gb .Rels .X ().Relationship ;for _ ,_ea :=range docBase1 .Rels .X ().Relationship {_gd :=true ;for _ ,_gdg :=range _gff {if _gdg .TargetAttr ==_ea .TargetAttr &&_gdg .Ty
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Table represents a table in the document.
type Table struct{_cfea *_gf .Tbl ;_cgdb *_gf .CT_Transform2D ;};func (_dbc CustomProperties )SetPropertyAsR8 (name string ,r8 float64 ){_egad :=_dbc .getNewProperty (name );_egad .R8 =&r8 ;_dbc .setOrReplaceProperty (_egad );};func (_cdeg CustomProperties )SetPropertyAsI1 (name string ,i1 int8 ){_egag :=_cdeg .getNewProperty (name );_egag .I1 =&i1 ;_cdeg .setOrReplaceProperty (_egag );};func (_abfg CustomProperties )SetPropertyAsArray (name string ,array *_ce .Array ){_gcd :=_abfg .getNewProperty (name );_gcd .Array =array ;_abfg .setOrReplaceProperty (_gcd );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00: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 ){_fdbb :=Image {};_gfa ,_gfbf ,_gbac :=_c .Decode (_g .NewReader (data ));if _gbac !=nil {return _fdbb ,_eg .Errorf ("\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s",_gbac );};_fdbb .Data =&data ;_fdbb .Format =_gfbf ;_fdbb .Size =_gfa .Bounds ().Size ();return _fdbb ,nil ;};func (_dee CustomProperties )SetPropertyAsI2 (name string ,i2 int16 ){_fedf :=_dee .getNewProperty (name );_fedf .I2 =&i2 ;_dee .setOrReplaceProperty (_fedf );};
2020-08-23 14:15:53 +00:00
2020-11-09 01:00: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 (_gbg AppProperties )SetApplicationVersion (s string ){_gbg ._bcca .AppVersion =&s };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// TableStyles contains document specific properties.
type TableStyles struct{_fbe *_gf .TblStyleLst };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// Path returns the path to an image file, if any.
func (_eebe ImageRef )Path ()string {return _eebe ._eff .Path };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +00:00
// X returns the inner wrapped XML type.
func (_acd Theme )X ()*_gf .Theme {return _acd ._bgee };
2020-08-23 14:15:53 +00:00
2020-11-09 01:00:18 +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 (_bcf AppProperties )Application ()string {if _bcf ._bcca .Application !=nil {return *_bcf ._bcca .Application ;};return "";};
2020-10-12 13:59:12 +00:00
// Company returns the name of the company that created the document.
// For unioffice created documents, it defaults to github.com/unidoc/unioffice
2020-11-09 01:00:18 +00:00
func (_fe AppProperties )Company ()string {if _fe ._bcca .Company !=nil {return *_fe ._bcca .Company ;};return "";};
2020-10-12 13:59:12 +00:00
2020-11-09 01:00:18 +00:00
// AddOverride adds an override content type for a given path name.
func (_abf ContentTypes )AddOverride (path ,contentType string ){if !_gc .HasPrefix (path ,"\u002f"){path ="\u002f"+path ;};if _gc .HasPrefix (contentType ,"\u0068\u0074\u0074\u0070"){_fa .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 _ ,_fba :=range _abf ._dcb .Override {if _fba .PartNameAttr ==path &&_fba .ContentTypeAttr ==contentType {return ;};};_bg :=_ega .NewOverride ();_bg .PartNameAttr =path ;_bg .ContentTypeAttr =contentType ;_abf ._dcb .Override =append (_abf ._dcb .Override ,_bg );};func (_ccb *ImageRef )SetRelID (id string ){_ccb ._fgg =id };func (_efc CustomProperties )SetPropertyAsVector (name string ,vector *_ce .Vector ){_dad :=_efc .getNewProperty (name );_dad .Vector =vector ;_efc .setOrReplaceProperty (_dad );};
2020-10-12 13:59:12 +00:00
2020-11-09 01:00:18 +00:00
// AppProperties contains properties specific to the document and the
// application that created it.
type AppProperties struct{_bcca *_bd .Properties };
2020-10-12 13:59:12 +00:00
2020-11-09 01:00:18 +00:00
// Remove removes an existing relationship.
func (_effc Relationships )Remove (rel Relationship )bool {for _gfg ,_bcb :=range _effc ._dafe .Relationship {if _bcb ==rel ._ege {copy (_effc ._dafe .Relationship [_gfg :],_effc ._dafe .Relationship [_gfg +1:]);_effc ._dafe .Relationship =_effc ._dafe .Relationship [0:len (_effc ._dafe .Relationship )-1];return true ;};};return false ;};
2020-10-12 13:59:12 +00:00
2020-11-09 01:00: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 _c .Image ;Images []ImageRef ;ExtraFiles []ExtraFile ;TmpPath string ;};
// NewCoreProperties constructs a new CoreProperties.
func NewCoreProperties ()CoreProperties {return CoreProperties {_bbc :_dce .NewCoreProperties ()}};func (_bdcb CustomProperties )SetPropertyAsOstorage (name string ,ostorage string ){_fgaf :=_bdcb .getNewProperty (name );_fgaf .Ostorage =&ostorage ;_bdcb .setOrReplaceProperty (_fgaf );};const _egga =11;
// AddCol adds a column to a table.
func (_cdabe Table )AddCol ()*TableCol {_acfg :=_gf .NewCT_TableCol ();_cdabe ._cfea .TblGrid .GridCol =append (_cdabe ._cfea .TblGrid .GridCol ,_acfg );for _ ,_cgaf :=range _cdabe ._cfea .Tr {_ebf :=_gf .NewCT_TableCell ();_cgaf .Tc =append (_cgaf .Tc ,_ebf );};return &TableCol {_ada :_acfg };};
// ImageRef is a reference to an image within a document.
type ImageRef struct{_fbbb *DocBase ;_gcbe Relationships ;_eff Image ;_fgg string ;_cff string ;};