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.
2023-05-26 09:49:04 +00:00
package common ; import ( _e "archive/zip" ; _f "bytes" ; _fa "encoding/xml" ; _ff "errors" ; _g "fmt" ; _fcf "github.com/unidoc/unioffice" ; _ca "github.com/unidoc/unioffice/common/logger" ; _gf "github.com/unidoc/unioffice/common/tempstorage" ; _ea "github.com/unidoc/unioffice/common/tempstorage/diskstore" ; _ee "github.com/unidoc/unioffice/measurement" ; _bg "github.com/unidoc/unioffice/schema/soo/dml" ; _c "github.com/unidoc/unioffice/schema/soo/ofc/custom_properties" ; _dd "github.com/unidoc/unioffice/schema/soo/ofc/docPropsVTypes" ; _bee "github.com/unidoc/unioffice/schema/soo/ofc/extended_properties" ; _bd "github.com/unidoc/unioffice/schema/soo/pkg/content_types" ; _fc "github.com/unidoc/unioffice/schema/soo/pkg/metadata/core_properties" ; _ag "github.com/unidoc/unioffice/schema/soo/pkg/relationships" ; _fae "github.com/unidoc/unioffice/zippkg" ; _bba "image" ; _ "image/gif" ; _ "image/jpeg" ; _ "image/png" ; _be "os" ; _d "reflect" ; _fg "regexp" ; _ffa "strconv" ; _bbb "strings" ; _aa "time" ; ) ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// SetTarget set the target (path) of a relationship.
func ( _bcb Relationship ) SetTarget ( s string ) { _bcb . _gae . TargetAttr = s } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// SetHeight sets row height, see measurement package.
func ( _ffd TableRow ) SetHeight ( m _ee . Distance ) { _gcc := _ee . ToEMU ( float64 ( m ) ) ; _ffd . _dfd . HAttr = _bg . ST_Coordinate { ST_CoordinateUnqualified : & _gcc } ; } ; const Version = "\u0031\u002e\u0032\u0034\u002e\u0030" ;
2021-07-30 17:03:26 +00:00
2023-05-26 09:49:04 +00:00
// NewContentTypes returns a wrapper around a newly constructed content-types.
func NewContentTypes ( ) ContentTypes { _ec := ContentTypes { _eba : _bd . NewTypes ( ) } ; _ec . AddDefault ( "\u0078\u006d\u006c" , "\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u0078\u006d\u006c" ) ; _ec . 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" ) ; _ec . AddDefault ( "\u0070\u006e\u0067" , "\u0069m\u0061\u0067\u0065\u002f\u0070\u006eg" ) ; _ec . AddDefault ( "\u006a\u0070\u0065\u0067" , "\u0069\u006d\u0061\u0067\u0065\u002f\u006a\u0070\u0065\u0067" ) ; _ec . AddDefault ( "\u006a\u0070\u0067" , "\u0069m\u0061\u0067\u0065\u002f\u006a\u0070g" ) ; _ec . AddDefault ( "\u0077\u006d\u0066" , "i\u006d\u0061\u0067\u0065\u002f\u0078\u002d\u0077\u006d\u0066" ) ; _ec . 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" ) ; _ec . 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 _ec ; } ;
2023-04-15 17:27:31 +00:00
2023-05-26 09:49:04 +00:00
// NewAppProperties constructs a new AppProperties.
func NewAppProperties ( ) AppProperties { _edf := AppProperties { _fcg : _bee . NewProperties ( ) } ; _edf . SetCompany ( "\u0046\u006f\u0078\u0079\u0055\u0074\u0069\u006c\u0073\u0020\u0065\u0068\u0066" ) ; _edf . SetApplication ( "g\u0069\u0074\u0068\u0075\u0062\u002ec\u006f\u006d\u002f\u0075\u006e\u0069\u0064\u006f\u0063/\u0075\u006e\u0069o\u0066f\u0069\u0063\u0065" ) ; _edf . SetDocSecurity ( 0 ) ; _edf . SetLinksUpToDate ( false ) ; var _ce , _efg , _beg int64 ; _g . Sscanf ( Version , "\u0025\u0064\u002e\u0025\u0064\u002e\u0025\u0064" , & _ce , & _efg , & _beg ) ; _eeac := float64 ( _ce ) + float64 ( _efg ) / 10000.0 ; _edf . SetApplicationVersion ( _g . Sprintf ( "\u0025\u0030\u0037\u002e\u0034\u0066" , _eeac ) ) ; return _edf ; } ;
2020-08-23 14:15:53 +00:00
2023-03-01 18:42:44 +00:00
// NewTableStyles constructs a new TableStyles.
2023-05-26 09:49:04 +00:00
func NewTableStyles ( ) TableStyles { return TableStyles { _dfgf : _bg . NewTblStyleLst ( ) } } ; func ( _bac CustomProperties ) setProperty ( _fgc * _c . CT_Property ) { _bac . setPropertyHelper ( _fgc , false ) } ; const _eecb = 30 ; func UtcTimeFormat ( t _aa . Time ) string { return t . Format ( _gbef ) + "\u0020\u0055\u0054\u0043" } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// ApplicationVersion returns the version of the application that created the
// document.
func ( _eag AppProperties ) ApplicationVersion ( ) string { if _eag . _fcg . AppVersion != nil { return * _eag . _fcg . AppVersion ; } ; return "" ; } ;
2022-02-05 13:05:36 +00:00
2023-05-26 09:49:04 +00:00
// Category returns the category of the document
func ( _bga CoreProperties ) Category ( ) string { if _bga . _bc . Category != nil { return * _bga . _bc . Category ; } ; return "" ; } ;
2022-02-05 13:05:36 +00:00
2023-05-26 09:49:04 +00:00
// NewCoreProperties constructs a new CoreProperties.
func NewCoreProperties ( ) CoreProperties { return CoreProperties { _bc : _fc . NewCoreProperties ( ) } } ;
2020-10-12 13:59:12 +00:00
2023-05-26 09:49:04 +00:00
// Clear removes any existing relationships.
func ( _bbd Relationships ) Clear ( ) { _bbd . _dbb . Relationship = nil } ;
2020-10-12 13:59:12 +00:00
2023-05-26 09:49:04 +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 ( _bf AppProperties ) SetApplicationVersion ( s string ) { _bf . _fcg . AppVersion = & s } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// SetLastModifiedBy records the last person to modify the document.
func ( _aecc CoreProperties ) SetLastModifiedBy ( s string ) { _aecc . _bc . LastModifiedBy = & s } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// SetStyle assigns TableStyle to a table.
func ( _dgc Table ) SetStyle ( style * _bg . CT_TableStyle ) { if _dgc . _ddcg . TblPr == nil { _dgc . _ddcg . TblPr = _bg . NewCT_TableProperties ( ) ; } ; if _dgc . _ddcg . TblPr . Choice == nil { _dgc . _ddcg . TblPr . Choice = _bg . NewCT_TablePropertiesChoice ( ) ; } ; _dgc . _ddcg . TblPr . Choice . TableStyle = style ; } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// EnsureDefault esnures that an extension and default content type exist,
// adding it if necessary.
func ( _faf ContentTypes ) EnsureDefault ( ext , contentType string ) { ext = _bbb . ToLower ( ext ) ; for _ , _bdge := range _faf . _eba . Default { if _bdge . ExtensionAttr == ext { _bdge . ContentTypeAttr = contentType ; return ; } ; } ; _eadg := & _bd . Default { } ; _eadg . ContentTypeAttr = contentType ; _eadg . ExtensionAttr = ext ; _faf . _eba . Default = append ( _faf . _eba . Default , _eadg ) ; } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// LastModifiedBy returns the name of the last person to modify the document
func ( _aee CoreProperties ) LastModifiedBy ( ) string { if _aee . _bc . LastModifiedBy != nil { return * _aee . _bc . LastModifiedBy ; } ; return "" ; } ;
2021-03-16 20:51:18 +00:00
2023-05-26 09:49:04 +00:00
// SetAuthor records the author of the document.
func ( _cb CoreProperties ) SetAuthor ( s string ) { if _cb . _bc . Creator == nil { _cb . _bc . Creator = & _fcf . XSDAny { XMLName : _fa . Name { Local : "\u0064\u0063\u003a\u0063\u0072\u0065\u0061\u0074\u006f\u0072" } } ; } ; _cb . _bc . Creator . Data = [ ] byte ( s ) ; } ;
2021-08-23 20:44:48 +00:00
2023-05-26 09:49:04 +00:00
// SetOffsetY sets vertical offset of a table in distance units (see measurement package).
func ( _edad Table ) SetOffsetY ( offY float64 ) { if _edad . _edfb . Off == nil { _edad . _edfb . Off = _bg . NewCT_Point2D ( ) ; _agag := int64 ( 0 ) ; _edad . _edfb . Off . XAttr = _bg . ST_Coordinate { ST_CoordinateUnqualified : & _agag } ; } ; _dbda := _ee . ToEMU ( offY ) ; _edad . _edfb . Off . YAttr = _bg . ST_Coordinate { ST_CoordinateUnqualified : & _dbda } ; } ; func ( _dbdd CustomProperties ) SetPropertyAsFiletime ( name string , filetime _aa . Time ) { _fbae := _dbdd . getNewProperty ( name ) ; _fbae . Filetime = & filetime ; _dbdd . setOrReplaceProperty ( _fbae ) ; } ;
2020-11-09 01:00:18 +00:00
2023-05-26 09:49:04 +00:00
// Title returns the Title of the document
func ( _fef CoreProperties ) Title ( ) string { if _fef . _bc . Title != nil { return string ( _fef . _bc . Title . Data ) ; } ; return "" ; } ;
2020-11-09 01:00:18 +00:00
2023-05-26 09:49:04 +00:00
// X returns the inner wrapped XML type.
func ( _eef CoreProperties ) X ( ) * _fc . CoreProperties { return _eef . _bc } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// AddImageToZip adds an image (either from bytes or from disk) and adds it to the zip file.
func AddImageToZip ( z * _e . Writer , img ImageRef , imageNum int , dt _fcf . DocType ) error { _aca := _fcf . AbsoluteImageFilename ( dt , imageNum , _bbb . ToLower ( img . Format ( ) ) ) ; if img . Data ( ) != nil && len ( * img . Data ( ) ) > 0 { if _bfca := _fae . AddFileFromBytes ( z , _aca , * img . Data ( ) ) ; _bfca != nil { return _bfca ; } ; } else if img . Path ( ) != "" { if _egee := _fae . AddFileFromDisk ( z , _aca , img . Path ( ) ) ; _egee != nil { return _egee ; } ; } else { return _g . 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 ( _cee CustomProperties ) SetPropertyAsEmpty ( name string ) { _ggf := _cee . getNewProperty ( name ) ; _ggf . Empty = _dd . NewEmpty ( ) ; _cee . setOrReplaceProperty ( _ggf ) ; } ; func ( _dce CustomProperties ) SetPropertyAsInt ( name string , i int ) { _aeb := _dce . getNewProperty ( name ) ; _gbaf := int32 ( i ) ; _aeb . Int = & _gbaf ; _dce . setOrReplaceProperty ( _aeb ) ; } ;
2020-08-23 14:15:53 +00:00
2023-04-15 17:27:31 +00:00
// Data returns the data of an image file, if any.
2023-05-26 09:49:04 +00:00
func ( _fda ImageRef ) Data ( ) * [ ] byte { return _fda . _fgb . Data } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// NewRelationshipsCopy creates a new relationships wrapper as a copy of passed in instance.
func NewRelationshipsCopy ( rels Relationships ) Relationships { _cbaa := * rels . _dbb ; return Relationships { _dbb : & _cbaa } ; } ;
2021-05-31 16:22:30 +00:00
2023-05-26 09:49:04 +00:00
// NewTheme constructs a new theme.
func NewTheme ( ) Theme { return Theme { _bg . NewTheme ( ) } } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// Table represents a table in the document.
type Table struct { _ddcg * _bg . Tbl ; _edfb * _bg . CT_Transform2D ; } ; func ( _fac CustomProperties ) setPropertyHelper ( _aeea * _c . CT_Property , _bec bool ) { _eac := _fac . GetPropertyByName ( * _aeea . NameAttr ) ; if ( _eac == CustomProperty { } ) { _fac . _adg . Property = append ( _fac . _adg . Property , _aeea ) ; } else if _bec { _aeea . FmtidAttr = _eac . _gba . FmtidAttr ; if _eac . _gba . PidAttr == 0 { _aeea . PidAttr = _eac . _gba . PidAttr ; } ; _aeea . LinkTargetAttr = _eac . _gba . LinkTargetAttr ; * _eac . _gba = * _aeea ; } ; } ; func ( _gdd CustomProperties ) SetPropertyAsI2 ( name string , i2 int16 ) { _eaf := _gdd . getNewProperty ( name ) ; _eaf . I2 = & i2 ; _gdd . setOrReplaceProperty ( _eaf ) ; } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// Format returns the format of the underlying image
func ( _gcbb ImageRef ) Format ( ) string { return _gcbb . _fgb . Format } ; func ( _aba CustomProperties ) getNewProperty ( _dgf string ) * _c . CT_Property { _cbb := _aba . _adg . Property ; _ebe := int32 ( 1 ) ; for _ , _agg := range _cbb { if _agg . PidAttr > _ebe { _ebe = _agg . PidAttr ; } ; } ; _dgb := _c . NewCT_Property ( ) ; _dgb . NameAttr = & _dgf ; _dgb . PidAttr = _ebe + 1 ; _dgb . 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 _dgb ; } ; var ReleasedAt = _aa . Date ( _eee , _gdg , _bfg , _cdda , _eecb , 0 , 0 , _aa . UTC ) ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// CustomProperties contains document specific properties.
type CustomProperties struct { _adg * _c . Properties } ; const _gbef = "\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034" ; func ( _ceae CustomProperties ) SetPropertyAsCy ( name string , cy string ) { _abb := _ceae . getNewProperty ( name ) ; _abb . Cy = & cy ; _ceae . setOrReplaceProperty ( _abb ) ; } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// RelativeWidth returns the relative width of an image given a fixed height.
// This is used when setting image to a fixed height to calculate the width
// required to keep the same image aspect ratio.
func ( _fbcb ImageRef ) RelativeWidth ( h _ee . Distance ) _ee . Distance { _eadb := float64 ( _fbcb . Size ( ) . X ) / float64 ( _fbcb . Size ( ) . Y ) ; return h * _ee . Distance ( _eadb ) ; } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// ID returns the ID of a relationship.
func ( _age Relationship ) ID ( ) string { return _age . _gae . IdAttr } ;
2020-10-12 13:59:12 +00:00
2023-05-26 09:49:04 +00:00
// CustomProperty contains document specific property.
// Using of this type is deprecated.
type CustomProperty struct { _gba * _c . CT_Property } ; func ( _ddad CustomProperties ) SetPropertyAsClsid ( name string , clsid string ) { _dcf := _ddad . getNewProperty ( name ) ; _dcf . Clsid = & clsid ; _ddad . setOrReplaceProperty ( _dcf ) ; } ; const _eee = 2023 ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// AppProperties contains properties specific to the document and the
// application that created it.
type AppProperties struct { _fcg * _bee . Properties } ;
2022-02-05 13:05:36 +00:00
2023-05-26 09:49:04 +00:00
// CoreProperties contains document specific properties.
type CoreProperties struct { _bc * _fc . CoreProperties } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// Target returns the target (path) of a relationship.
func ( _aef Relationship ) Target ( ) string { return _aef . _gae . TargetAttr } ;
2021-06-16 07:10:52 +00:00
2023-05-26 09:49:04 +00:00
// TableRow represents a row in a table.
type TableRow struct { _dfd * _bg . CT_TableRow } ;
2021-06-16 07:10:52 +00:00
2023-05-26 09:49:04 +00:00
// Author returns the author of the document
func ( _cea CoreProperties ) Author ( ) string { if _cea . _bc . Creator != nil { return string ( _cea . _bc . Creator . Data ) ; } ; return "" ; } ; func ( _aedcb CustomProperties ) SetPropertyAsOblob ( name , oblob string ) { _dgbe := _aedcb . getNewProperty ( name ) ; _dgbe . Oblob = & oblob ; _aedcb . setOrReplaceProperty ( _dgbe ) ; } ;
2021-06-16 07:10:52 +00:00
2023-05-26 09:49:04 +00:00
// Modified returns the time that the document was modified.
func ( _fega CoreProperties ) Modified ( ) _aa . Time { return _bedd ( _fega . _bc . Modified ) } ;
2022-04-09 14:27:46 +00:00
2023-05-26 09:49:04 +00:00
// NewRelationship constructs a new relationship.
func NewRelationship ( ) Relationship { return Relationship { _gae : _ag . NewRelationship ( ) } } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// Remove removes an existing relationship.
func ( _caac Relationships ) Remove ( rel Relationship ) bool { for _dbadd , _cae := range _caac . _dbb . Relationship { if _cae == rel . _gae { copy ( _caac . _dbb . Relationship [ _dbadd : ] , _caac . _dbb . Relationship [ _dbadd + 1 : ] ) ; _caac . _dbb . Relationship = _caac . _dbb . Relationship [ 0 : len ( _caac . _dbb . Relationship ) - 1 ] ; return true ; } ; } ; return false ; } ;
2022-12-06 11:56:49 +00:00
2023-05-26 09:49:04 +00:00
// X returns the inner raw content types.
func ( _eab ContentTypes ) X ( ) * _bd . Types { return _eab . _eba } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// SetContentStatus records the content status of the document.
func ( _agd CoreProperties ) SetContentStatus ( s string ) { _agd . _bc . ContentStatus = & s } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// GetByRelId returns a relationship with the associated relation ID.
func ( _cbd Relationships ) GetByRelId ( idAttr string ) Relationship { for _ , _cbbe := range _cbd . _dbb . Relationship { if _cbbe . IdAttr == idAttr { return Relationship { _gae : _cbbe } ; } ; } ; return Relationship { } ; } ; func ( _edfe CustomProperties ) setOrReplaceProperty ( _bad * _c . CT_Property ) { _edfe . setPropertyHelper ( _bad , true ) ; } ; func ( _ace CustomProperties ) SetPropertyAsBlob ( name , blob string ) { _dbc := _ace . getNewProperty ( name ) ; _dbc . Blob = & blob ; _ace . setOrReplaceProperty ( _dbc ) ; } ; func ( _caf CustomProperties ) SetPropertyAsUi2 ( name string , ui2 uint16 ) { _dad := _caf . getNewProperty ( name ) ; _dad . Ui2 = & ui2 ; _caf . setOrReplaceProperty ( _dad ) ; } ;
2020-08-23 14:15:53 +00:00
2023-04-15 17:27:31 +00:00
// SetCreated sets the time that the document was created.
2023-05-26 09:49:04 +00:00
func ( _eae CoreProperties ) SetCreated ( t _aa . Time ) { _eae . _bc . Created = _afc ( t , "\u0064c\u0074e\u0072\u006d\u0073\u003a\u0063\u0072\u0065\u0061\u0074\u0065\u0064" ) ; } ; func ( _egf CustomProperties ) SetPropertyAsOstream ( name string , ostream string ) { _fcea := _egf . getNewProperty ( name ) ; _fcea . Ostream = & ostream ; _egf . setOrReplaceProperty ( _fcea ) ; } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// SetWidth sets column width, see measurement package.
func ( _babg TableCol ) SetWidth ( m _ee . Distance ) { _eaec := _ee . ToEMU ( float64 ( m ) ) ; _babg . _gada . WAttr = _bg . ST_Coordinate { ST_CoordinateUnqualified : & _eaec } ; } ;
2021-04-23 20:00:00 +00:00
2023-05-26 09:49:04 +00:00
// Size returns the size of an image
func ( _acb ImageRef ) Size ( ) _bba . Point { return _acb . _fgb . Size } ; func ( _gfd CustomProperties ) SetPropertyAsUint ( name string , ui uint ) { _acff := _gfd . getNewProperty ( name ) ; _eaea := uint32 ( ui ) ; _acff . Uint = & _eaea ; _gfd . setOrReplaceProperty ( _acff ) ; } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// GetPropertyByName returns a custom property selected by it's name.
func ( _ecb CustomProperties ) GetPropertyByName ( name string ) CustomProperty { _bdcd := _ecb . _adg . Property ; for _ , _faed := range _bdcd { if * _faed . NameAttr == name { return CustomProperty { _gba : _faed } ; } ; } ; return CustomProperty { } ; } ; func ( _bbce CustomProperties ) SetPropertyAsDecimal ( name string , decimal float64 ) { _bcf := _bbce . getNewProperty ( name ) ; _bcf . Decimal = & decimal ; _bbce . setOrReplaceProperty ( _bcf ) ; } ;
2022-04-09 14:27:46 +00:00
2023-05-26 09:49:04 +00:00
// Type returns the type of a relationship.
func ( _cde Relationship ) Type ( ) string { return _cde . _gae . TypeAttr } ;
2021-05-31 16:22:30 +00:00
2023-05-26 09:49:04 +00:00
// SetLanguage records the language of the document.
func ( _efc CoreProperties ) SetLanguage ( s string ) { _efc . _bc . Language = & _fcf . XSDAny { XMLName : _fa . Name { Local : "d\u0063\u003a\u006c\u0061\u006e\u0067\u0075\u0061\u0067\u0065" } } ; _efc . _bc . Language . Data = [ ] byte ( s ) ; } ;
2021-05-31 16:22:30 +00:00
2023-05-26 09:49:04 +00:00
// ImageFromFile reads an image from a file on disk. It doesn't keep the image
// in memory and only reads it to determine the format and size. You can also
// construct an Image directly if the file and size are known.
// NOTE: See also ImageFromStorage.
func ImageFromFile ( path string ) ( Image , error ) { _geeg , _dabb := _be . Open ( path ) ; _bgd := Image { } ; if _dabb != nil { return _bgd , _g . Errorf ( "\u0065\u0072\u0072or\u0020\u0072\u0065\u0061\u0064\u0069\u006e\u0067\u0020\u0069\u006d\u0061\u0067\u0065\u003a\u0020\u0025\u0073" , _dabb ) ; } ; defer _geeg . Close ( ) ; _begef , _bbe , _dabb := _bba . Decode ( _geeg ) ; if _dabb != nil { return _bgd , _g . Errorf ( "\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s" , _dabb ) ; } ; _bgd . Path = path ; _bgd . Format = _bbe ; _bgd . Size = _begef . Bounds ( ) . Size ( ) ; return _bgd , nil ; } ; func ( _fcce CustomProperties ) SetPropertyAsVstream ( name string , vstream * _dd . Vstream ) { _cec := _fcce . getNewProperty ( name ) ; _cec . Vstream = vstream ; _fcce . setOrReplaceProperty ( _cec ) ; } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// X returns the inner wrapped XML type of CustomProperty.
func ( _gag CustomProperty ) X ( ) * _c . CT_Property { return _gag . _gba } ; func ( _fab CustomProperties ) SetPropertyAsStream ( name string , stream string ) { _bda := _fab . getNewProperty ( name ) ; _bda . Stream = & stream ; _fab . setOrReplaceProperty ( _bda ) ; } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +00:00
// Relationships returns a slice of all of the relationships.
func ( _beba Relationships ) Relationships ( ) [ ] Relationship { _adab := [ ] Relationship { } ; for _ , _cfb := range _beba . _dbb . Relationship { _adab = append ( _adab , Relationship { _gae : _cfb } ) ; } ; return _adab ; } ;
2020-08-23 14:15:53 +00:00
2023-05-26 09:49:04 +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 ) { _cfg := Image { } ; _aeac , _fbda := _gf . Open ( path ) ; if _fbda != nil { return _cfg , _g . Errorf ( "\u0065\u0072\u0072or\u0020\u0072\u0065\u0061\u0064\u0069\u006e\u0067\u0020\u0069\u006d\u0061\u0067\u0065\u003a\u0020\u0025\u0073" , _fbda ) ; } ; defer _aeac . Close ( ) ; _acca , _gdad , _fbda := _bba . Decode ( _aeac ) ; if _fbda != nil { return _cfg , _g . Errorf ( "\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s" , _fbda ) ; } ; _cfg . Path = path ; _cfg . Format = _gdad ; _cfg . Size = _acca . Bounds ( ) . Size ( ) ; return _cfg , nil ; } ;
2021-11-10 11:45:21 +00:00
2023-04-15 17:27:31 +00:00
// Application returns the name of the application that created the document.
// For unioffice created documents, it defaults to github.com/unidoc/unioffice
2023-05-26 09:49:04 +00:00
func ( _cac AppProperties ) Application ( ) string { if _cac . _fcg . Application != nil { return * _cac . _fcg . Application ; } ; return "" ; } ;
2021-11-10 11:45:21 +00:00
2023-05-26 09:49:04 +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 ( _abge Relationships ) AddAutoRelationship ( dt _fcf . DocType , src string , idx int , ctype string ) Relationship { return _abge . AddRelationship ( _fcf . RelativeFilename ( dt , src , ctype , idx ) , ctype ) ; } ; var _gbf = _ff . New ( "\u0069\u006d\u0061\u0067\u0065\u0020\u006e\u006f\u0074\u0020\u0066o\u0075\u006e\u0064\u0020\u0069\u006e\u0020\u0073\u0074\u006fr\u0061\u0067\u0065" ) ;
2020-10-12 13:59:12 +00:00
2023-05-26 09:49:04 +00:00
// AddRow adds a row to a table.
func ( _cag Table ) AddRow ( ) * TableRow { _fad := _bg . NewCT_TableRow ( ) ; for _fede := 0 ; _fede < len ( _cag . _ddcg . TblGrid . GridCol ) ; _fede ++ { _fad . Tc = append ( _fad . Tc , _bg . NewCT_TableCell ( ) ) ; } ; _cag . _ddcg . Tr = append ( _cag . _ddcg . Tr , _fad ) ; return & TableRow { _dfd : _fad } ; } ;
2021-11-10 11:45:21 +00:00
2023-05-26 09:49:04 +00:00
// WriteExtraFiles writes the extra files to the zip package.
func ( _fbd * DocBase ) WriteExtraFiles ( z * _e . Writer ) error { for _ , _eebg := range _fbd . ExtraFiles { if _acc := _fae . AddFileFromDisk ( z , _eebg . ZipPath , _eebg . DiskPath ) ; _acc != nil { return _acc ; } ; } ; return nil ; } ;
2021-11-10 11:45:21 +00:00
2023-05-26 09:49:04 +00:00
// Target returns the target attrubute of the image reference (a path where the image file is located in the document structure).
func ( _cgcc * ImageRef ) Target ( ) string { return _cgcc . _adad } ;
2021-11-10 11:45:21 +00:00
2023-05-26 09:49:04 +00:00
// AddCol adds a column to a table.
func ( _fgca Table ) AddCol ( ) * TableCol { _ddef := _bg . NewCT_TableCol ( ) ; _fgca . _ddcg . TblGrid . GridCol = append ( _fgca . _ddcg . TblGrid . GridCol , _ddef ) ; for _ , _gafb := range _fgca . _ddcg . Tr { _gcd := _bg . NewCT_TableCell ( ) ; _gafb . Tc = append ( _gafb . Tc , _gcd ) ; } ; return & TableCol { _gada : _ddef } ; } ;
2021-11-10 11:45:21 +00:00
2023-05-26 09:49:04 +00:00
// SetModified sets the time that the document was modified.
func ( _fge CoreProperties ) SetModified ( t _aa . Time ) { _fge . _bc . Modified = _afc ( t , "\u0064\u0063t\u0065\u0072\u006ds\u003a\u006d\u006f\u0064\u0069\u0066\u0069\u0065\u0064" ) ; } ; func ( _caa CustomProperties ) SetPropertyAsNull ( name string ) { _aac := _caa . getNewProperty ( name ) ; _aac . Null = _dd . NewNull ( ) ; _caa . setOrReplaceProperty ( _aac ) ; } ;
2021-11-10 11:45:21 +00:00
2023-05-26 09:49:04 +00:00
// RemoveOverride removes an override given a path.
func ( _fbc ContentTypes ) RemoveOverride ( path string ) { if ! _bbb . HasPrefix ( path , "\u002f" ) { path = "\u002f" + path ; } ; for _df , _efd := range _fbc . _eba . Override { if _efd . PartNameAttr == path { copy ( _fbc . _eba . Override [ _df : ] , _fbc . _eba . Override [ _df + 1 : ] ) ; _fbc . _eba . Override = _fbc . _eba . Override [ 0 : len ( _fbc . _eba . Override ) - 1 ] ; } ; } ; } ;
2022-04-09 14:27:46 +00:00
2023-05-26 09:49:04 +00:00
// Path returns the path to an image file, if any.
func ( _eeg ImageRef ) Path ( ) string { return _eeg . _fgb . Path } ; func ( _gge CustomProperties ) SetPropertyAsLpstr ( name string , lpstr string ) { _baf := _gge . getNewProperty ( name ) ; _baf . Lpstr = & lpstr ; _gge . setOrReplaceProperty ( _baf ) ; } ;
2021-06-16 07:10:52 +00:00
2023-05-26 09:49:04 +00:00
// Properties returns table properties.
func ( _ageb Table ) Properties ( ) * _bg . CT_TableProperties { return _ageb . _ddcg . TblPr } ;
// NewTableWithXfrm makes a new table with a pointer to its parent Xfrm for changing its offset and size.
func NewTableWithXfrm ( xfrm * _bg . CT_Transform2D ) * Table { _gffa := _bg . NewTbl ( ) ; _gffa . TblPr = _bg . NewCT_TableProperties ( ) ; return & Table { _ddcg : _gffa , _edfb : xfrm } ; } ;
2022-01-15 21:17:38 +00:00
2023-03-01 18:42:44 +00:00
// CopyRelationship copies the relationship.
2023-05-26 09:49:04 +00:00
func ( _bdgeg Relationships ) CopyRelationship ( idAttr string ) ( Relationship , bool ) { for _fbca := range _bdgeg . _dbb . Relationship { if _bdgeg . _dbb . Relationship [ _fbca ] . IdAttr == idAttr { _dbce := * _bdgeg . _dbb . Relationship [ _fbca ] ; _ded := len ( _bdgeg . _dbb . Relationship ) + 1 ; _gfda := map [ string ] struct { } { } ; for _ , _gbcg := range _bdgeg . _dbb . Relationship { _gfda [ _gbcg . IdAttr ] = struct { } { } ; } ; for _ , _eega := _gfda [ _g . Sprintf ( "\u0072\u0049\u0064%\u0064" , _ded ) ] ; _eega ; _ , _eega = _gfda [ _g . Sprintf ( "\u0072\u0049\u0064%\u0064" , _ded ) ] { _ded ++ ; } ; _dbce . IdAttr = _g . Sprintf ( "\u0072\u0049\u0064%\u0064" , _ded ) ; _bdgeg . _dbb . Relationship = append ( _bdgeg . _dbb . Relationship , & _dbce ) ; return Relationship { _gae : & _dbce } , true ; } ; } ; return Relationship { } , false ; } ;
2020-10-12 13:59:12 +00:00
2023-05-26 09:49:04 +00:00
// RemoveOverrideByIndex removes an override given a path and override index.
func ( _gaa ContentTypes ) RemoveOverrideByIndex ( path string , indexToFind int ) error { _aad := path [ 0 : len ( path ) - 5 ] ; if ! _bbb . HasPrefix ( _aad , "\u002f" ) { _aad = "\u002f" + _aad ; } ; _dea , _ba := _fg . Compile ( _aad + "\u0028\u005b\u0030-\u0039\u005d\u002b\u0029\u002e\u0078\u006d\u006c" ) ; if _ba != nil { return _ba ; } ; _gc := 0 ; _aedc := - 1 ; for _efb , _bbag := range _gaa . _eba . Override { if _bfe := _dea . FindStringSubmatch ( _bbag . PartNameAttr ) ; len ( _bfe ) > 1 { if _gc == indexToFind { _aedc = _efb ; } else if _gc > indexToFind { _dagd , _ := _ffa . Atoi ( _bfe [ 1 ] ) ; _dagd -- ; _bbag . PartNameAttr = _g . Sprintf ( "\u0025\u0073\u0025\u0064\u002e\u0078\u006d\u006c" , _aad , _dagd ) ; } ; _gc ++ ; } ; } ; if _aedc > - 1 { copy ( _gaa . _eba . Override [ _aedc : ] , _gaa . _eba . Override [ _aedc + 1 : ] ) ; _gaa . _eba . Override = _gaa . _eba . Override [ 0 : len ( _gaa . _eba . Override ) - 1 ] ; } ; return nil ; } ;
2021-05-31 16:22:30 +00:00
2023-05-26 09:49:04 +00:00
// ContentStatus returns the content status of the document (e.g. "Final", "Draft")
func ( _eebd CoreProperties ) ContentStatus ( ) string { if _eebd . _bc . ContentStatus != nil { return * _eebd . _bc . ContentStatus ; } ; return "" ; } ;
2021-05-31 16:22:30 +00:00
2023-05-26 09:49:04 +00:00
// SetApplication sets the name of the application that created the document.
func ( _aaa AppProperties ) SetApplication ( s string ) { _aaa . _fcg . Application = & s } ;
2022-01-15 21:17:38 +00:00
2023-05-26 09:49:04 +00:00
// IsEmpty returns true if there are no relationships.
func ( _bca Relationships ) IsEmpty ( ) bool { return _bca . _dbb == nil || len ( _bca . _dbb . Relationship ) == 0 } ; func ( _afca CustomProperties ) SetPropertyAsUi4 ( name string , ui4 uint32 ) { _gdc := _afca . getNewProperty ( name ) ; _gdc . Ui4 = & ui4 ; _afca . setOrReplaceProperty ( _gdc ) ; } ;
2022-01-15 21:17:38 +00:00
2023-05-26 09:49:04 +00:00
// PropertiesList returns the list of all custom properties of the document.
func ( _gd CustomProperties ) PropertiesList ( ) [ ] * _c . CT_Property { return _gd . _adg . Property } ; func ( _cdd CustomProperties ) SetPropertyAsI4 ( name string , i4 int32 ) { _gda := _cdd . getNewProperty ( name ) ; _gda . I4 = & i4 ; _cdd . setOrReplaceProperty ( _gda ) ; } ;
2021-06-16 07:10:52 +00:00
2023-05-26 09:49:04 +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 ( _dcd * ImageRef ) SetTarget ( target string ) { _dcd . _adad = target } ;
2022-01-15 21:17:38 +00:00
2023-05-26 09:49:04 +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 { _fgb : img , _aeg : d , _acfc : rels } ; } ;
2020-11-09 01:00:18 +00:00
2023-05-26 09:49:04 +00:00
// X returns the inner wrapped XML type.
func ( _gcca Theme ) X ( ) * _bg . Theme { return _gcca . _ceag } ; func ( _dba CustomProperties ) SetPropertyAsI1 ( name string , i1 int8 ) { _cca := _dba . getNewProperty ( name ) ; _cca . I1 = & i1 ; _dba . setOrReplaceProperty ( _cca ) ; } ; func ( _efbd * ImageRef ) SetRelID ( id string ) { _efbd . _gcb = id } ;
2020-11-09 01:00:18 +00:00
2023-05-26 09:49:04 +00:00
// ImageRef is a reference to an image within a document.
type ImageRef struct { _aeg * DocBase ; _acfc Relationships ; _fgb Image ; _gcb string ; _adad string ; } ;
2020-12-17 22:07:08 +00:00
2023-04-15 17:27:31 +00:00
// X returns the inner wrapped XML type.
2023-05-26 09:49:04 +00:00
func ( _cbfa Relationship ) X ( ) * _ag . Relationship { return _cbfa . _gae } ;
2020-12-17 22:07:08 +00:00
2023-05-26 09:49:04 +00:00
// FindRIDForN returns the relationship ID for the i'th relationship of type t.
func ( _ecgb Relationships ) FindRIDForN ( i int , t string ) string { for _ , _fbdd := range _ecgb . _dbb . CT_Relationships . Relationship { if _fbdd . TypeAttr == t { if i == 0 { return _fbdd . IdAttr ; } ; i -- ; } ; } ; return "" ; } ;
2020-12-17 22:07:08 +00:00
2023-05-26 09:49:04 +00:00
// GetImageBytesByTarget returns Image object with Data bytes read from its target.
func ( _fabc * DocBase ) GetImageBytesByTarget ( target string ) ( Image , error ) { if target != "" { target = "\u0077\u006f\u0072d\u002f" + target ; for _ , _fea := range _fabc . Images { if _fea . Target ( ) == target { return ImageFromStorage ( _fea . Path ( ) ) ; } ; } ; } ; return Image { } , _gbf ; } ; func _afc ( _dda _aa . Time , _bdb string ) * _fcf . XSDAny { _ffb := & _fcf . XSDAny { XMLName : _fa . Name { Local : _bdb } } ; _ffb . Attrs = append ( _ffb . Attrs , _fa . Attr { Name : _fa . Name { Local : "\u0078\u0073\u0069\u003a\u0074\u0079\u0070\u0065" } , Value : "\u0064\u0063\u0074\u0065\u0072\u006d\u0073\u003a\u00573\u0043\u0044\u0054\u0046" } ) ; _ffb . Attrs = append ( _ffb . Attrs , _fa . Attr { Name : _fa . 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" } ) ; _ffb . Attrs = append ( _ffb . Attrs , _fa . Attr { Name : _fa . 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/" } ) ; _ffb . Data = [ ] byte ( _dda . Format ( _cfa ) ) ; return _ffb ; } ;
// Theme is a drawingml theme.
type Theme struct { _ceag * _bg . Theme } ;
2020-12-17 22:07:08 +00:00
2023-04-15 17:27:31 +00:00
// SetDescription records the description of the document.
2023-05-26 09:49:04 +00:00
func ( _cgg CoreProperties ) SetDescription ( s string ) { if _cgg . _bc . Description == nil { _cgg . _bc . Description = & _fcf . XSDAny { XMLName : _fa . Name { Local : "\u0064\u0063\u003a\u0064\u0065\u0073\u0063\u0072\u0069p\u0074\u0069\u006f\u006e" } } ; } ; _cgg . _bc . Description . Data = [ ] byte ( s ) ; } ;
2020-12-17 22:07:08 +00:00
2023-05-26 09:49:04 +00:00
// GetTargetByRelIdAndType returns a target path with the associated relation ID.
func ( _bdcc Relationships ) GetTargetByRelIdAndType ( idAttr string , typeAttr string ) string { for _ , _ebf := range _bdcc . _dbb . Relationship { if _ebf . IdAttr == idAttr && _ebf . TypeAttr == typeAttr { return _ebf . TargetAttr ; } ; } ; return "" ; } ;
2021-11-10 11:45:21 +00:00
2023-05-26 09:49:04 +00:00
// CopyOverride copies override content type for a given `path` and puts it with a path `newPath`.
func ( _bege ContentTypes ) CopyOverride ( path , newPath string ) { if ! _bbb . HasPrefix ( path , "\u002f" ) { path = "\u002f" + path ; } ; if ! _bbb . HasPrefix ( newPath , "\u002f" ) { newPath = "\u002f" + newPath ; } ; for _bef := range _bege . _eba . Override { if _bege . _eba . Override [ _bef ] . PartNameAttr == path { _geb := * _bege . _eba . Override [ _bef ] ; _geb . PartNameAttr = newPath ; _bege . _eba . Override = append ( _bege . _eba . Override , & _geb ) ; } ; } ; } ; func ( _dbaf CustomProperties ) SetPropertyAsOstorage ( name string , ostorage string ) { _dbdf := _dbaf . getNewProperty ( name ) ; _dbdf . Ostorage = & ostorage ; _dbaf . setOrReplaceProperty ( _dbdf ) ; } ;
2021-11-10 11:45:21 +00:00
2023-05-26 09:49:04 +00:00
// X returns the underlying raw XML data.
func ( _edfc Relationships ) X ( ) * _ag . Relationships { return _edfc . _dbb } ; func ( _gcf CustomProperties ) SetPropertyAsR8 ( name string , r8 float64 ) { _gde := _gcf . getNewProperty ( name ) ; _gde . R8 = & r8 ; _gcf . setOrReplaceProperty ( _gde ) ; } ; func ( _cff CustomProperties ) SetPropertyAsBool ( name string , b bool ) { _cgb := _cff . getNewProperty ( name ) ; _cgb . Bool = & b ; _cff . setOrReplaceProperty ( _cgb ) ; } ;
2021-11-10 11:45:21 +00:00
2023-05-26 09:49:04 +00:00
// AddRelationship adds a relationship.
func ( _fedg Relationships ) AddRelationship ( target , ctype string ) Relationship { if ! _bbb . HasPrefix ( ctype , "\u0068t\u0074\u0070\u003a\u002f\u002f" ) { _ca . Log . Debug ( "\u0072\u0065\u006c\u0061\u0074\u0069\u006f\u006es\u0068\u0069\u0070 t\u0079\u0070\u0065\u0020\u0025\u0073 \u0073\u0068\u006f\u0075\u006c\u0064\u0020\u0073\u0074\u0061\u0072\u0074\u0020\u0077\u0069t\u0068\u0020\u0027\u0068\u0074\u0074\u0070\u003a/\u002f\u0027" , ctype ) ; } ; _dfg := _ag . NewRelationship ( ) ; _bbbg := len ( _fedg . _dbb . Relationship ) + 1 ; _ffg := map [ string ] struct { } { } ; for _ , _bgad := range _fedg . _dbb . Relationship { _ffg [ _bgad . IdAttr ] = struct { } { } ; } ; for _ , _gbcb := _ffg [ _g . Sprintf ( "\u0072\u0049\u0064%\u0064" , _bbbg ) ] ; _gbcb ; _ , _gbcb = _ffg [ _g . Sprintf ( "\u0072\u0049\u0064%\u0064" , _bbbg ) ] { _bbbg ++ ; } ; _dfg . IdAttr = _g . Sprintf ( "\u0072\u0049\u0064%\u0064" , _bbbg ) ; _dfg . TargetAttr = target ; _dfg . TypeAttr = ctype ; _fedg . _dbb . Relationship = append ( _fedg . _dbb . Relationship , _dfg ) ; return Relationship { _gae : _dfg } ; } ; func ( _dgbef CustomProperties ) SetPropertyAsUi8 ( name string , ui8 uint64 ) { _cba := _dgbef . getNewProperty ( name ) ; _cba . Ui8 = & ui8 ; _dgbef . setOrReplaceProperty ( _cba ) ; } ;
2023-03-01 18:42:44 +00:00
2023-05-26 09:49:04 +00:00
// NewRelationships creates a new relationship wrapper.
func NewRelationships ( ) Relationships { return Relationships { _dbb : _ag . NewRelationships ( ) } } ;
2022-04-09 14:27:46 +00:00
2023-05-26 09:49:04 +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 _bba . Image ; Images [ ] ImageRef ; ExtraFiles [ ] ExtraFile ; TmpPath string ; } ;
2021-04-23 20:00:00 +00:00
2023-05-26 09:49:04 +00:00
// Created returns the time that the document was created.
func ( _dc CoreProperties ) Created ( ) _aa . Time { return _bedd ( _dc . _bc . Created ) } ;
2021-05-31 16:22:30 +00:00
2023-05-26 09:49:04 +00:00
// Cells returns an array of row cells.
func ( _dfda TableRow ) Cells ( ) [ ] * _bg . CT_TableCell { return _dfda . _dfd . Tc } ;
2021-06-16 07:10:52 +00:00
2023-05-26 09:49:04 +00:00
// Rows returns all table rows.
func ( _bgbb Table ) Rows ( ) [ ] * TableRow { _gbb := _bgbb . _ddcg . Tr ; _gfc := [ ] * TableRow { } ; for _ , _gfb := range _gbb { _gfc = append ( _gfc , & TableRow { _dfd : _gfb } ) ; } ; return _gfc ; } ;
// 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 _bba . Point ; Format string ; Path string ; Data * [ ] byte ; } ;
2021-06-16 07:10:52 +00:00
2023-03-01 18:42:44 +00:00
// X returns the inner wrapped XML type.
2023-05-26 09:49:04 +00:00
func ( _gbc AppProperties ) X ( ) * _bee . Properties { return _gbc . _fcg } ;
2021-06-16 07:10:52 +00:00
2023-05-26 09:49:04 +00:00
// EnsureOverride ensures that an override for the given path exists, adding it if necessary
func ( _cg ContentTypes ) EnsureOverride ( path , contentType string ) { for _ , _ebb := range _cg . _eba . Override { if _ebb . PartNameAttr == path { if _bbb . HasPrefix ( contentType , "\u0068\u0074\u0074\u0070" ) { _ca . Log . Debug ( "\u0063\u006f\u006e\u0074\u0065\u006et\u0020\u0074\u0079p\u0065\u0020\u0027%\u0073\u0027\u0020\u0069\u0073\u0020\u0069\u006e\u0063\u006fr\u0072\u0065\u0063\u0074\u002c m\u0075\u0073\u0074\u0020\u006e\u006f\u0074\u0020\u0073\u0074\u0061\u0072\u0074\u0020\u0077\u0069\u0074\u0068\u0020\u0068\u0074\u0074\u0070" , contentType ) ; } ; _ebb . ContentTypeAttr = contentType ; return ; } ; } ; _cg . AddOverride ( path , contentType ) ; } ;
2021-06-16 07:10:52 +00:00
2023-05-26 09:49:04 +00:00
// SetID set the ID of a relationship.
func ( _bdbd Relationship ) SetID ( ID string ) { _bdbd . _gae . IdAttr = ID ; } ; func ( _edff CustomProperties ) SetPropertyAsDate ( name string , date _aa . Time ) { date = date . UTC ( ) ; _bfff , _dab , _baa := date . Date ( ) ; _ada , _cgc , _ecg := date . Clock ( ) ; _abf := _aa . Date ( _bfff , _dab , _baa , _ada , _cgc , _ecg , 0 , _aa . UTC ) ; _cbe := _edff . getNewProperty ( name ) ; _cbe . Filetime = & _abf ; _edff . setOrReplaceProperty ( _cbe ) ; } ;
2021-06-16 07:10:52 +00:00
2023-05-26 09:49:04 +00:00
// SetCategory records the category of the document.
func ( _ceg CoreProperties ) SetCategory ( s string ) { _ceg . _bc . Category = & s } ;
2021-06-16 07:10:52 +00:00
2023-04-15 17:27:31 +00:00
// X returns the inner wrapped XML type.
2023-05-26 09:49:04 +00:00
func ( _fcc CustomProperties ) X ( ) * _c . Properties { return _fcc . _adg } ;
2021-06-16 07:10:52 +00:00
2023-05-26 09:49:04 +00:00
// SetCompany sets the name of the company that created the document.
func ( _cc AppProperties ) SetCompany ( s string ) { _cc . _fcg . Company = & s } ; const _bfg = 26 ;
2022-02-25 19:20:45 +00:00
2023-05-26 09:49:04 +00:00
// CreateCustomProperties creates the custom properties of the document.
func ( _fcb * DocBase ) CreateCustomProperties ( ) { _fcb . CustomProperties = NewCustomProperties ( ) ; _fcb . AddCustomRelationships ( ) ; } ; const _gdg = 5 ;
2022-02-25 19:20:45 +00:00
2023-05-26 09:49:04 +00:00
// ContentTypes is the top level "[Content_Types].xml" in a zip package.
type ContentTypes struct { _eba * _bd . Types } ;
2022-12-06 11:56:49 +00:00
2023-05-26 09:49:04 +00:00
// Hyperlink is just an appropriately configured relationship.
type Hyperlink Relationship ; func ( _fba CustomProperties ) SetPropertyAsError ( name string , error string ) { _dde := _fba . getNewProperty ( name ) ; _dde . Error = & error ; _fba . setOrReplaceProperty ( _dde ) ; } ;
2021-08-23 20:44:48 +00:00
2023-05-26 09:49:04 +00:00
// SetLinksUpToDate sets the links up to date flag.
func ( _da AppProperties ) SetLinksUpToDate ( v bool ) { _da . _fcg . LinksUpToDate = _fcf . Bool ( v ) } ; func ( _ceb CustomProperties ) SetPropertyAsStorage ( name string , storage string ) { _dbcf := _ceb . getNewProperty ( name ) ; _dbcf . Storage = & storage ; _ceb . setOrReplaceProperty ( _dbcf ) ; } ;
2022-02-25 19:20:45 +00:00
2023-05-26 09:49:04 +00:00
// Description returns the description of the document
func ( _bgaf CoreProperties ) Description ( ) string { if _bgaf . _bc . Description != nil { return string ( _bgaf . _bc . Description . Data ) ; } ; return "" ; } ;
2022-02-25 19:20:45 +00:00
2023-05-26 09:49:04 +00:00
// Append appends DocBase part of an office document to another DocBase.
func ( _fe DocBase ) Append ( docBase1 DocBase ) DocBase { _af := docBase1 . ContentTypes . X ( ) ; for _ , _aec := range _af . Default { _fe . ContentTypes . AddDefault ( _aec . ExtensionAttr , _aec . ContentTypeAttr ) ; } ; for _ , _gb := range _af . Override { _fe . ContentTypes . AddOverride ( _gb . PartNameAttr , _gb . ContentTypeAttr ) ; } ; _eg := _fe . AppProperties . X ( ) ; _ef := docBase1 . AppProperties . X ( ) ; if _eg . Pages != nil { if _ef . Pages != nil { * _eg . Pages += * _ef . Pages ; } ; } else if _ef . Pages != nil { _eg . Pages = _ef . Pages ; } ; if _eg . Words != nil { if _ef . Words != nil { * _eg . Words += * _ef . Words ; } ; } else if _ef . Words != nil { _eg . Words = _ef . Words ; } ; if _eg . Characters != nil { if _ef . Characters != nil { * _eg . Characters += * _ef . Characters ; } ; } else if _ef . Characters != nil { _eg . Characters = _ef . Characters ; } ; if _eg . Lines != nil { if _ef . Lines != nil { * _eg . Lines += * _ef . Lines ; } ; } else if _ef . Lines != nil { _eg . Lines = _ef . Lines ; } ; if _eg . Paragraphs != nil { if _ef . Paragraphs != nil { * _eg . Paragraphs += * _ef . Paragraphs ; } ; } else if _ef . Paragraphs != nil { _eg . Paragraphs = _ef . Paragraphs ; } ; if _eg . Notes != nil { if _ef . Notes != nil { * _eg . Notes += * _ef . Notes ; } ; } else if _ef . Notes != nil { _eg . Notes = _ef . Notes ; } ; if _eg . HiddenSlides != nil { if _ef . HiddenSlides != nil { * _eg . HiddenSlides += * _ef . HiddenSlides ; } ; } else if _ef . HiddenSlides != nil { _eg . HiddenSlides = _ef . HiddenSlides ; } ; if _eg . MMClips != nil { if _ef . MMClips != nil { * _eg . MMClips += * _ef . MMClips ; } ; } else if _ef . MMClips != nil { _eg . MMClips = _ef . MMClips ; } ; if _eg . LinksUpToDate != nil { if _ef . LinksUpToDate != nil { * _eg . LinksUpToDate = * _eg . LinksUpToDate && * _ef . LinksUpToDate ; } ; } else if _ef . LinksUpToDate != nil { _eg . LinksUpToDate = _ef . LinksUpToDate ; } ; if _eg . CharactersWithSpaces != nil { if _ef . CharactersWithSpaces != nil { * _eg . CharactersWithSpaces += * _ef . CharactersWithSpaces ; } ; } else if _ef . CharactersWithSpaces != nil { _eg . CharactersWithSpaces = _ef . CharactersWithSpaces ; } ; if _eg . SharedDoc != nil { if _ef . SharedDoc != nil { * _eg . SharedDoc = * _eg . SharedDoc || * _ef . SharedDoc ; } ; } else if _ef . SharedDoc != nil { _eg . SharedDoc = _ef . SharedDoc ; } ; if _eg . HyperlinksChanged != nil { if _ef . HyperlinksChanged != nil { * _eg . HyperlinksChanged = * _eg . HyperlinksChanged || * _ef . HyperlinksChanged ; } ; } else if _ef . HyperlinksChanged != nil { _eg . HyperlinksChanged = _ef . HyperlinksChanged ; } ; _eg . DigSig = nil ; if _eg . TitlesOfParts == nil && _ef . TitlesOfParts != nil { _eg . TitlesOfParts = _ef . TitlesOfParts ; } ; if _eg . HeadingPairs != nil { if _ef . HeadingPairs != nil { _ed := _eg . HeadingPairs . Vector ; _ga := _ef . HeadingPairs . Vector ; _db := _ed . Variant ; _edg := _ga . Variant ; _ega := [ ] * _dd . Variant { } ; for _gaf := 0 ; _gaf < len ( _edg ) ; _gaf += 2 { _aed := _edg [ _gaf ] . Lpstr ; _gbg := false ; for _eb := 0 ; _eb < len ( _db ) ; _eb += 2 { _de := _db [ _eb ] . Lpstr ; if _de != nil && _aed != nil && * _de == * _aed { * _db [ _eb + 1 ] . I4 = * _db [ _eb + 1 ] . I4 + * _edg [ _gaf + 1 ] . I4 ; _gbg = true ; break ; } ; } ; if ! _gbg { _ega = append ( _ega , & _dd . Variant { CT_Variant : _dd . CT_Variant { Lpstr : _edg [ _gaf ] . Lpstr } } ) ; _ega = append ( _ega , & _dd . Variant { CT_Variant : _dd . CT_Variant { I4 : _edg [ _gaf ] . I4 } } ) ; } ; } ; _db = append ( _db , _ega ... ) ; _ed . SizeAttr = uint32 ( len ( _db ) ) ; } ; } else if _ef . HeadingPairs != nil { _eg . HeadingPairs = _ef . HeadingPairs ; } ; if _eg . HLinks != nil { if _ef . HLinks != nil { _ebd := _eg . HLinks . Vector ; _bge := _ef . HLinks . Vector ; _ad := _ebd . Variant ; _ge := _bge . Variant ; for _ , _eea := range _ge { _ege := true ; for _ , _ede := range _ad { if _d . DeepEqual ( _ede , _eea ) { _ege = false ; break ; } ; } ; if _ege { _ad = append ( _ad , _eea ) ; _ebd . SizeAttr ++ ; } ; } ; } ; } else if _ef . HLinks != nil { _eg . HLinks = _ef . HLinks ; } ; _aea := _fe . GetOrCreateCustomProperties ( ) ; _gea := docBase1 . GetOrCreateCustomProperties ( ) ; for _ , _cf := range _gea . PropertiesList ( ) { _aea . setProperty ( _cf ) ; } ; _fe . CustomProperties = _aea ; _adb := _fe . Rels . X ( ) . Relationship ; for _ , _gee := range docBase1 . Rels . X ( ) . Relationship { _fee := true ; for _ , _eec := range _adb { if _eec . TargetAttr == _gee . TargetAttr && _eec . TypeAttr == _gee . TypeAttr { _fee = false ; break ; } ; } ; if _fee { _fe . Rels . AddRelationship ( _gee . TargetAttr , _gee . Ty
2022-02-25 19:20:45 +00:00
2023-05-26 09:49:04 +00:00
// NewTable makes a new table.
func NewTable ( ) * Table { _eda := _bg . NewTbl ( ) ; _eda . TblPr = _bg . NewCT_TableProperties ( ) ; return & Table { _ddcg : _eda } ; } ;
2023-04-15 17:27:31 +00:00
2023-05-26 09:49:04 +00:00
// AddHyperlink adds an external hyperlink relationship.
func ( _gff Relationships ) AddHyperlink ( target string ) Hyperlink { _bbda := _gff . AddRelationship ( target , _fcf . HyperLinkType ) ; _bbda . _gae . TargetModeAttr = _ag . ST_TargetModeExternal ; return Hyperlink ( _bbda ) ; } ;
// AddOverride adds an override content type for a given path name.
func ( _dag ContentTypes ) AddOverride ( path , contentType string ) { if ! _bbb . HasPrefix ( path , "\u002f" ) { path = "\u002f" + path ; } ; if _bbb . HasPrefix ( contentType , "\u0068\u0074\u0074\u0070" ) { _ca . Log . Debug ( "\u0063\u006f\u006e\u0074\u0065\u006et\u0020\u0074\u0079p\u0065\u0020\u0027%\u0073\u0027\u0020\u0069\u0073\u0020\u0069\u006e\u0063\u006fr\u0072\u0065\u0063\u0074\u002c m\u0075\u0073\u0074\u0020\u006e\u006f\u0074\u0020\u0073\u0074\u0061\u0072\u0074\u0020\u0077\u0069\u0074\u0068\u0020\u0068\u0074\u0074\u0070" , contentType ) ; } ; for _ , _gg := range _dag . _eba . Override { if _gg . PartNameAttr == path && _gg . ContentTypeAttr == contentType { return ; } ; } ; _gad := _bd . NewOverride ( ) ; _gad . PartNameAttr = path ; _gad . ContentTypeAttr = contentType ; _dag . _eba . Override = append ( _dag . _eba . Override , _gad ) ; } ; func init ( ) { _ea . SetAsStorage ( ) } ;
2022-06-27 19:44:23 +00:00
2022-12-06 11:56:49 +00:00
// X returns the inner wrapped XML type.
2023-05-26 09:49:04 +00:00
func ( _cgcf Table ) X ( ) * _bg . Tbl { return _cgcf . _ddcg } ;
2022-06-27 19:44:23 +00:00
2023-05-26 09:49:04 +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 ) { _ffc := Image { } ; _cbec , _agda , _acad := _bba . Decode ( _f . NewReader ( data ) ) ; if _acad != nil { return _ffc , _g . Errorf ( "\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s" , _acad ) ; } ; _ffc . Data = & data ; _ffc . Format = _agda ; _ffc . Size = _cbec . Bounds ( ) . Size ( ) ; return _ffc , nil ; } ; func ( _bdcda CustomProperties ) SetPropertyAsVector ( name string , vector * _dd . Vector ) { _beb := _bdcda . getNewProperty ( name ) ; _beb . Vector = vector ; _bdcda . setOrReplaceProperty ( _beb ) ; } ;
2022-06-27 19:44:23 +00:00
2023-05-26 09:49:04 +00:00
// AddDefault registers a default content type for a given file extension.
func ( _fcgd ContentTypes ) AddDefault ( fileExtension string , contentType string ) { fileExtension = _bbb . ToLower ( fileExtension ) ; for _ , _bdc := range _fcgd . _eba . Default { if _bdc . ExtensionAttr == fileExtension && _bdc . ContentTypeAttr == contentType { return ; } ; } ; _dbd := _bd . NewDefault ( ) ; _dbd . ExtensionAttr = fileExtension ; _dbd . ContentTypeAttr = contentType ; _fcgd . _eba . Default = append ( _fcgd . _eba . Default , _dbd ) ; } ;
2022-09-02 11:46:53 +00:00
2023-05-26 09:49:04 +00:00
// DefAttr returns the DefAttr property.
func ( _eeba TableStyles ) DefAttr ( ) string { return _eeba . _dfgf . DefAttr } ; func ( _cbf CustomProperties ) SetPropertyAsI8 ( name string , i8 int64 ) { _dbad := _cbf . getNewProperty ( name ) ; _dbad . I8 = & i8 ; _cbf . setOrReplaceProperty ( _dbad ) ; } ;
2022-09-02 11:46:53 +00:00
2023-05-26 09:49:04 +00:00
// Relationships represents a .rels file.
type Relationships struct { _dbb * _ag . Relationships } ;
2022-09-02 11:46:53 +00:00
2023-05-26 09:49:04 +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 ( _cad AppProperties ) Company ( ) string { if _cad . _fcg . Company != nil { return * _cad . _fcg . Company ; } ; return "" ; } ;
2022-12-06 11:56:49 +00:00
2023-05-26 09:49:04 +00:00
// GetTargetByRelId returns a target path with the associated relation ID.
func ( _bab Relationships ) GetTargetByRelId ( idAttr string ) string { for _ , _cce := range _bab . _dbb . Relationship { if _cce . IdAttr == idAttr { return _cce . TargetAttr ; } ; } ; return "" ; } ; func ( _ggg CustomProperties ) SetPropertyAsR4 ( name string , r4 float32 ) { _fgf := _ggg . getNewProperty ( name ) ; _fgf . R4 = & r4 ; _ggg . setOrReplaceProperty ( _fgf ) ; } ; func ( _eff CustomProperties ) SetPropertyAsLpwstr ( name string , lpwstr string ) { _acg := _eff . getNewProperty ( name ) ; _acg . Lpwstr = & lpwstr ; _eff . setOrReplaceProperty ( _acg ) ; } ; func _bedd ( _aff * _fcf . XSDAny ) _aa . Time { if _aff == nil { return _aa . Time { } ; } ; _fd , _fce := _aa . Parse ( _cfa , string ( _aff . Data ) ) ; if _fce != nil { _ca . Log . Debug ( "\u0065\u0072\u0072\u006f\u0072\u0020\u0070\u0061\u0072\u0073i\u006e\u0067\u0020\u0074\u0069\u006d\u0065 \u0066\u0072\u006f\u006d\u0020\u0025\u0073\u003a\u0020\u0025\u0073" , string ( _aff . Data ) , _fce ) ; } ; return _fd ; } ;
2022-12-06 11:56:49 +00:00
2023-05-26 09:49:04 +00:00
// TableStyles contains document specific properties.
type TableStyles struct { _dfgf * _bg . TblStyleLst } ;
2022-12-06 11:56:49 +00:00
2023-05-26 09:49:04 +00:00
// Relationship is a relationship within a .rels file.
type Relationship struct { _gae * _ag . Relationship } ;
2023-03-01 18:42:44 +00:00
2023-05-26 09:49:04 +00:00
// SetTitle records the title of the document.
func ( _afg CoreProperties ) SetTitle ( s string ) { if _afg . _bc . Title == nil { _afg . _bc . Title = & _fcf . XSDAny { XMLName : _fa . Name { Local : "\u0064\u0063\u003a\u0074\u0069\u0074\u006c\u0065" } } ; } ; _afg . _bc . Title . Data = [ ] byte ( s ) ; } ;
2023-03-01 18:42:44 +00:00
2023-05-26 09:49:04 +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 ( _cgcb * DocBase ) AddExtraFileFromZip ( f * _e . File ) error { _dcg , _fdb := _fae . ExtractToDiskTmp ( f , _cgcb . TmpPath ) ; if _fdb != nil { return _g . 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" , _fdb ) ; } ; _cgcb . ExtraFiles = append ( _cgcb . ExtraFiles , ExtraFile { ZipPath : f . Name , DiskPath : _dcg } ) ; return nil ; } ; func ( _fbcf Relationship ) String ( ) string { return _g . 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" , _fbcf . ID ( ) , _fbcf . Target ( ) , _fbcf . Type ( ) ) ; } ; const _cdda = 15 ;
2022-12-06 11:56:49 +00:00
2023-05-26 09:49:04 +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 ; } ;
2023-03-01 18:42:44 +00:00
2023-05-26 09:49:04 +00:00
// AddCustomRelationships adds relationships related to custom properties to the document.
func ( _gbab * DocBase ) AddCustomRelationships ( ) { _gbab . 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" ) ; _gbab . Rels . AddRelationship ( "\u0064\u006f\u0063\u0050ro\u0070\u0073\u002f\u0063\u0075\u0073\u0074\u006f\u006d\u002e\u0078\u006d\u006c" , _fcf . CustomPropertiesType ) ; } ;
2023-03-01 18:42:44 +00:00
2023-05-26 09:49:04 +00:00
// X returns the inner wrapped XML type.
func ( _gce TableStyles ) X ( ) * _bg . TblStyleLst { return _gce . _dfgf } ;
// SetDocSecurity sets the document security flag.
func ( _cdb AppProperties ) SetDocSecurity ( v int32 ) { _cdb . _fcg . DocSecurity = _fcf . Int32 ( v ) } ;
// TableCol represents a column in a table.
type TableCol struct { _gada * _bg . CT_TableCol } ;
2023-03-01 18:42:44 +00:00
2023-04-15 17:27:31 +00:00
// GetOrCreateCustomProperties returns the custom properties of the document (and if they not exist yet, creating them first).
2023-05-26 09:49:04 +00:00
func ( _cafd * DocBase ) GetOrCreateCustomProperties ( ) CustomProperties { if _cafd . CustomProperties . X ( ) == nil { _cafd . CreateCustomProperties ( ) ; } ; return _cafd . CustomProperties ; } ;
// NewCustomProperties constructs a new CustomProperties.
func NewCustomProperties ( ) CustomProperties { return CustomProperties { _adg : _c . NewProperties ( ) } } ;
2023-03-01 18:42:44 +00:00
2023-04-15 17:27:31 +00:00
// RelID returns the relationship ID.
2023-05-26 09:49:04 +00:00
func ( _eagg ImageRef ) RelID ( ) string { return _eagg . _gcb } ; func ( _becg CustomProperties ) SetPropertyAsArray ( name string , array * _dd . Array ) { _bbc := _becg . getNewProperty ( name ) ; _bbc . Array = array ; _becg . setOrReplaceProperty ( _bbc ) ; } ;
2023-03-01 18:42:44 +00:00
2023-05-26 09:49:04 +00:00
// SetOffsetX sets horizontal offset of a table in distance units (see measurement package).
func ( _cade Table ) SetOffsetX ( offX float64 ) { if _cade . _edfb . Off == nil { _cade . _edfb . Off = _bg . NewCT_Point2D ( ) ; _gcbba := int64 ( 0 ) ; _cade . _edfb . Off . YAttr = _bg . ST_Coordinate { ST_CoordinateUnqualified : & _gcbba } ; } ; _ccb := _ee . ToEMU ( offX ) ; _cade . _edfb . Off . XAttr = _bg . ST_Coordinate { ST_CoordinateUnqualified : & _ccb } ; } ;
2023-03-01 18:42:44 +00:00
2023-05-26 09:49:04 +00:00
// Properties returns table properties.
func ( _edc Table ) Grid ( ) * _bg . CT_TableGrid { return _edc . _ddcg . TblGrid } ; func ( _bcc CustomProperties ) SetPropertyAsBstr ( name string , bstr string ) { _abg := _bcc . getNewProperty ( name ) ; _abg . Bstr = & bstr ; _bcc . setOrReplaceProperty ( _abg ) ; } ;
2023-03-01 18:42:44 +00:00
2023-05-26 09:49:04 +00:00
// TblStyle returns the TblStyle property.
func ( _egbg TableStyles ) TblStyle ( ) [ ] * _bg . CT_TableStyle { return _egbg . _dfgf . TblStyle } ;
2023-04-15 17:27:31 +00:00
2023-05-26 09:49:04 +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 ( _fed AppProperties ) Pages ( ) int32 { if _fed . _fcg . Pages != nil { return * _fed . _fcg . Pages ; } ; return 0 ; } ; func ( _dbde TableRow ) addCell ( ) * _bg . CT_TableCell { _cab := _bg . NewCT_TableCell ( ) ; _dbde . _dfd . Tc = append ( _dbde . _dfd . Tc , _cab ) ; return _cab ; } ; const _cfa = "2\u00300\u0036\u002d\u0030\u0031\u002d\u0030\u0032\u00541\u0035\u003a\u0030\u0034:0\u0035\u005a" ;
// 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 ( _aeae ImageRef ) RelativeHeight ( w _ee . Distance ) _ee . Distance { _cdbb := float64 ( _aeae . Size ( ) . Y ) / float64 ( _aeae . Size ( ) . X ) ; return w * _ee . Distance ( _cdbb ) ; } ;