mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-27 13:48:54 +08:00
413 lines
48 KiB
Go
413 lines
48 KiB
Go
//
|
|
// 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.
|
|
package common ;import (_da "archive/zip";_be "bytes";_cd "encoding/xml";_g "errors";_ea "fmt";_gg "github.com/unidoc/unioffice";_ebd "github.com/unidoc/unioffice/common/logger";_daf "github.com/unidoc/unioffice/common/tempstorage";_ge "github.com/unidoc/unioffice/common/tempstorage/diskstore";_eb "github.com/unidoc/unioffice/measurement";_cg "github.com/unidoc/unioffice/schema/soo/dml";_aeb "github.com/unidoc/unioffice/schema/soo/ofc/custom_properties";_gd "github.com/unidoc/unioffice/schema/soo/ofc/docPropsVTypes";_ec "github.com/unidoc/unioffice/schema/soo/ofc/extended_properties";_ag "github.com/unidoc/unioffice/schema/soo/pkg/content_types";_fc "github.com/unidoc/unioffice/schema/soo/pkg/metadata/core_properties";_agb "github.com/unidoc/unioffice/schema/soo/pkg/relationships";_fg "github.com/unidoc/unioffice/zippkg";_f "image";_ "image/gif";_ "image/jpeg";_ "image/png";_ae "os";_c "reflect";_bg "regexp";_de "strconv";_gf "strings";_ba "time";);
|
|
|
|
// Hyperlink is just an appropriately configured relationship.
|
|
type Hyperlink Relationship ;
|
|
|
|
// SetCategory records the category of the document.
|
|
func (_fdfa CoreProperties )SetCategory (s string ){_fdfa ._ggf .Category =&s };
|
|
|
|
// Description returns the description of the document
|
|
func (_cca CoreProperties )Description ()string {if _cca ._ggf .Description !=nil {return string (_cca ._ggf .Description .Data );};return "";};
|
|
|
|
// SetTarget set the target (path) of a relationship.
|
|
func (_eab Relationship )SetTarget (s string ){_eab ._egfa .TargetAttr =s };
|
|
|
|
// 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 ){_fdda ,_dfbf :=_ae .Open (path );_bbg :=Image {};if _dfbf !=nil {return _bbg ,_ea .Errorf ("\u0065\u0072\u0072or\u0020\u0072\u0065\u0061\u0064\u0069\u006e\u0067\u0020\u0069\u006d\u0061\u0067\u0065\u003a\u0020\u0025\u0073",_dfbf );};defer _fdda .Close ();_ddba ,_edd ,_dfbf :=_f .Decode (_fdda );if _dfbf !=nil {return _bbg ,_ea .Errorf ("\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s",_dfbf );};_bbg .Path =path ;_bbg .Format =_edd ;_bbg .Size =_ddba .Bounds ().Size ();return _bbg ,nil ;};
|
|
|
|
// SetOffsetY sets vertical offset of a table in distance units (see measurement package).
|
|
func (_fbcd Table )SetOffsetY (offY float64 ){if _fbcd ._cff .Off ==nil {_fbcd ._cff .Off =_cg .NewCT_Point2D ();_bgd :=int64 (0);_fbcd ._cff .Off .XAttr =_cg .ST_Coordinate {ST_CoordinateUnqualified :&_bgd };};_dbgg :=_eb .ToEMU (offY );_fbcd ._cff .Off .YAttr =_cg .ST_Coordinate {ST_CoordinateUnqualified :&_dbgg };};func (_cfc CustomProperties )SetPropertyAsR8 (name string ,r8 float64 ){_feg :=_cfc .getNewProperty (name );_feg .R8 =&r8 ;_cfc .setOrReplaceProperty (_feg );};
|
|
|
|
// RelID returns the relationship ID.
|
|
func (_cee ImageRef )RelID ()string {return _cee ._ddb };
|
|
|
|
// ContentTypes is the top level "[Content_Types].xml" in a zip package.
|
|
type ContentTypes struct{_cc *_ag .Types };func (_gcd CustomProperties )SetPropertyAsUi1 (name string ,ui1 uint8 ){_cbdga :=_gcd .getNewProperty (name );_cbdga .Ui1 =&ui1 ;_gcd .setOrReplaceProperty (_cbdga );};
|
|
|
|
// Data returns the data of an image file, if any.
|
|
func (_edf ImageRef )Data ()*[]byte {return _edf ._cea .Data };
|
|
|
|
// NewTable makes a new table.
|
|
func NewTable ()*Table {_adb :=_cg .NewTbl ();_adb .TblPr =_cg .NewCT_TableProperties ();return &Table {_dfd :_adb };};
|
|
|
|
// SetAuthor records the author of the document.
|
|
func (_gae CoreProperties )SetAuthor (s string ){if _gae ._ggf .Creator ==nil {_gae ._ggf .Creator =&_gg .XSDAny {XMLName :_cd .Name {Local :"\u0064\u0063\u003a\u0063\u0072\u0065\u0061\u0074\u006f\u0072"}};};_gae ._ggf .Creator .Data =[]byte (s );};
|
|
|
|
// NewAppProperties constructs a new AppProperties.
|
|
func NewAppProperties ()AppProperties {_fb :=AppProperties {_fgg :_ec .NewProperties ()};_fb .SetCompany ("\u0046\u006f\u0078\u0079\u0055\u0074\u0069\u006c\u0073\u0020\u0065\u0068\u0066");_fb .SetApplication ("g\u0069\u0074\u0068\u0075\u0062\u002ec\u006f\u006d\u002f\u0075\u006e\u0069\u0064\u006f\u0063/\u0075\u006e\u0069o\u0066f\u0069\u0063\u0065");_fb .SetDocSecurity (0);_fb .SetLinksUpToDate (false );var _cdd ,_fbb ,_ggc int64 ;_ea .Sscanf (Version ,"\u0025\u0064\u002e\u0025\u0064\u002e\u0025\u0064",&_cdd ,&_fbb ,&_ggc );_gaf :=float64 (_cdd )+float64 (_fbb )/10000.0;_fb .SetApplicationVersion (_ea .Sprintf ("\u0025\u0030\u0037\u002e\u0034\u0066",_gaf ));return _fb ;};
|
|
|
|
// GetPropertyByName returns a custom property selected by it's name.
|
|
func (_gba CustomProperties )GetPropertyByName (name string )CustomProperty {_cbac :=_gba ._ebe .Property ;for _ ,_gbf :=range _cbac {if *_gbf .NameAttr ==name {return CustomProperty {_cbd :_gbf };};};return CustomProperty {};};func (_agd CustomProperties )SetPropertyAsVstream (name string ,vstream *_gd .Vstream ){_egfg :=_agd .getNewProperty (name );_egfg .Vstream =vstream ;_agd .setOrReplaceProperty (_egfg );};func (_gbd CustomProperties )SetPropertyAsDate (name string ,date _ba .Time ){date =date .UTC ();_fea ,_fddfe ,_agg :=date .Date ();_fgaa ,_dbgb ,_gbc :=date .Clock ();_gbec :=_ba .Date (_fea ,_fddfe ,_agg ,_fgaa ,_dbgb ,_gbc ,0,_ba .UTC );_cbab :=_gbd .getNewProperty (name );_cbab .Filetime =&_gbec ;_gbd .setOrReplaceProperty (_cbab );};const _ffbg ="\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034";
|
|
|
|
// Size returns the size of an image
|
|
func (_caff ImageRef )Size ()_f .Point {return _caff ._cea .Size };
|
|
|
|
// NewTableStyles constructs a new TableStyles.
|
|
func NewTableStyles ()TableStyles {return TableStyles {_def :_cg .NewTblStyleLst ()}};
|
|
|
|
// Cells returns an array of row cells.
|
|
func (_dgb TableRow )Cells ()[]*_cg .CT_TableCell {return _dgb ._fccb .Tc };
|
|
|
|
// SetOffsetX sets horizontal offset of a table in distance units (see measurement package).
|
|
func (_bege Table )SetOffsetX (offX float64 ){if _bege ._cff .Off ==nil {_bege ._cff .Off =_cg .NewCT_Point2D ();_daed :=int64 (0);_bege ._cff .Off .YAttr =_cg .ST_Coordinate {ST_CoordinateUnqualified :&_daed };};_aagf :=_eb .ToEMU (offX );_bege ._cff .Off .XAttr =_cg .ST_Coordinate {ST_CoordinateUnqualified :&_aagf };};func (_eebf CustomProperties )getNewProperty (_bebb string )*_aeb .CT_Property {_bca :=_eebf ._ebe .Property ;_cfa :=int32 (1);for _ ,_gdee :=range _bca {if _gdee .PidAttr > _cfa {_cfa =_gdee .PidAttr ;};};_dec :=_aeb .NewCT_Property ();_dec .NameAttr =&_bebb ;_dec .PidAttr =_cfa +1;_dec .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 _dec ;};
|
|
|
|
// Type returns the type of a relationship.
|
|
func (_ddf Relationship )Type ()string {return _ddf ._egfa .TypeAttr };func (_aed CustomProperties )SetPropertyAsInt (name string ,i int ){_cbaa :=_aed .getNewProperty (name );_ccac :=int32 (i );_cbaa .Int =&_ccac ;_aed .setOrReplaceProperty (_cbaa );};
|
|
|
|
// 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 (_fcg ImageRef )RelativeHeight (w _eb .Distance )_eb .Distance {_bfa :=float64 (_fcg .Size ().Y )/float64 (_fcg .Size ().X );return w *_eb .Distance (_bfa );};func (_fa CustomProperties )SetPropertyAsDecimal (name string ,decimal float64 ){_adf :=_fa .getNewProperty (name );_adf .Decimal =&decimal ;_fa .setOrReplaceProperty (_adf );};func (_fbf CustomProperties )SetPropertyAsUi8 (name string ,ui8 uint64 ){_dbd :=_fbf .getNewProperty (name );_dbd .Ui8 =&ui8 ;_fbf .setOrReplaceProperty (_dbd );};
|
|
|
|
// 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 (_ced AppProperties )Pages ()int32 {if _ced ._fgg .Pages !=nil {return *_ced ._fgg .Pages ;};return 0;};
|
|
|
|
// CustomProperty contains document specific property.
|
|
// Using of this type is deprecated.
|
|
type CustomProperty struct{_cbd *_aeb .CT_Property };func (_gbad CustomProperties )SetPropertyAsUint (name string ,ui uint ){_bcf :=_gbad .getNewProperty (name );_bgf :=uint32 (ui );_bcf .Uint =&_bgf ;_gbad .setOrReplaceProperty (_bcf );};
|
|
|
|
// GetOrCreateCustomProperties returns the custom properties of the document (and if they not exist yet, creating them first).
|
|
func (_ccg *DocBase )GetOrCreateCustomProperties ()CustomProperties {if _ccg .CustomProperties .X ()==nil {_ccg .CreateCustomProperties ();};return _ccg .CustomProperties ;};func (_dcg CustomProperties )SetPropertyAsUi2 (name string ,ui2 uint16 ){_bcdb :=_dcg .getNewProperty (name );_bcdb .Ui2 =&ui2 ;_dcg .setOrReplaceProperty (_bcdb );};
|
|
|
|
// SetLastModifiedBy records the last person to modify the document.
|
|
func (_bbff CoreProperties )SetLastModifiedBy (s string ){_bbff ._ggf .LastModifiedBy =&s };
|
|
|
|
// Properties returns table properties.
|
|
func (_dfbc Table )Grid ()*_cg .CT_TableGrid {return _dfbc ._dfd .TblGrid };
|
|
|
|
// AddRelationship adds a relationship.
|
|
func (_fbc Relationships )AddRelationship (target ,ctype string )Relationship {if !_gf .HasPrefix (ctype ,"\u0068t\u0074\u0070\u003a\u002f\u002f"){_ebd .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 );};_bbffc :=_agb .NewRelationship ();_ddc :=len (_fbc ._adc .Relationship )+1;_dga :=map[string ]struct{}{};for _ ,_fafg :=range _fbc ._adc .Relationship {_dga [_fafg .IdAttr ]=struct{}{};};for _ ,_aaff :=_dga [_ea .Sprintf ("\u0072\u0049\u0064%\u0064",_ddc )];_aaff ;_ ,_aaff =_dga [_ea .Sprintf ("\u0072\u0049\u0064%\u0064",_ddc )]{_ddc ++;};_bbffc .IdAttr =_ea .Sprintf ("\u0072\u0049\u0064%\u0064",_ddc );_bbffc .TargetAttr =target ;_bbffc .TypeAttr =ctype ;_fbc ._adc .Relationship =append (_fbc ._adc .Relationship ,_bbffc );return Relationship {_egfa :_bbffc };};func (_cbdg CustomProperties )setOrReplaceProperty (_agbc *_aeb .CT_Property ){_cbdg .setPropertyHelper (_agbc ,true );};
|
|
|
|
// PropertiesList returns the list of all custom properties of the document.
|
|
func (_bdb CustomProperties )PropertiesList ()[]*_aeb .CT_Property {return _bdb ._ebe .Property };
|
|
|
|
// SetHeight sets row height, see measurement package.
|
|
func (_gdd TableRow )SetHeight (m _eb .Distance ){_gec :=_eb .ToEMU (float64 (m ));_gdd ._fccb .HAttr =_cg .ST_Coordinate {ST_CoordinateUnqualified :&_gec };};
|
|
|
|
// DefAttr returns the DefAttr property.
|
|
func (_fgd TableStyles )DefAttr ()string {return _fgd ._def .DefAttr };
|
|
|
|
// ContentStatus returns the content status of the document (e.g. "Final", "Draft")
|
|
func (_gfc CoreProperties )ContentStatus ()string {if _gfc ._ggf .ContentStatus !=nil {return *_gfc ._ggf .ContentStatus ;};return "";};func (_ffb CustomProperties )setProperty (_fbbb *_aeb .CT_Property ){_ffb .setPropertyHelper (_fbbb ,false );};
|
|
|
|
// CopyRelationship copies the relationship.
|
|
func (_eda Relationships )CopyRelationship (idAttr string )(Relationship ,bool ){for _dbb :=range _eda ._adc .Relationship {if _eda ._adc .Relationship [_dbb ].IdAttr ==idAttr {_eefc :=*_eda ._adc .Relationship [_dbb ];_gab :=len (_eda ._adc .Relationship )+1;_aafd :=map[string ]struct{}{};for _ ,_egee :=range _eda ._adc .Relationship {_aafd [_egee .IdAttr ]=struct{}{};};for _ ,_dcb :=_aafd [_ea .Sprintf ("\u0072\u0049\u0064%\u0064",_gab )];_dcb ;_ ,_dcb =_aafd [_ea .Sprintf ("\u0072\u0049\u0064%\u0064",_gab )]{_gab ++;};_eefc .IdAttr =_ea .Sprintf ("\u0072\u0049\u0064%\u0064",_gab );_eda ._adc .Relationship =append (_eda ._adc .Relationship ,&_eefc );return Relationship {_egfa :&_eefc },true ;};};return Relationship {},false ;};
|
|
|
|
// 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 (_eaaa *ImageRef )SetTarget (target string ){_eaaa ._eafb =target };func (_cece Relationship )String ()string {return _ea .Sprintf ("\u007b\u0049\u0044\u003a \u0025\u0073\u0020\u0054\u0061\u0072\u0067\u0065\u0074\u003a \u0025s\u0020\u0054\u0079\u0070\u0065\u003a\u0020%\u0073\u007d",_cece .ID (),_cece .Target (),_cece .Type ());};
|
|
|
|
// X returns the inner raw content types.
|
|
func (_ed ContentTypes )X ()*_ag .Types {return _ed ._cc };
|
|
|
|
// Format returns the format of the underlying image
|
|
func (_eebd ImageRef )Format ()string {return _eebd ._cea .Format };
|
|
|
|
// CopyOverride copies override content type for a given `path` and puts it with a path `newPath`.
|
|
func (_gc ContentTypes )CopyOverride (path ,newPath string ){if !_gf .HasPrefix (path ,"\u002f"){path ="\u002f"+path ;};if !_gf .HasPrefix (newPath ,"\u002f"){newPath ="\u002f"+newPath ;};for _dfe :=range _gc ._cc .Override {if _gc ._cc .Override [_dfe ].PartNameAttr ==path {_dgg :=*_gc ._cc .Override [_dfe ];_dgg .PartNameAttr =newPath ;_gc ._cc .Override =append (_gc ._cc .Override ,&_dgg );};};};
|
|
|
|
// Title returns the Title of the document
|
|
func (_gaeb CoreProperties )Title ()string {if _gaeb ._ggf .Title !=nil {return string (_gaeb ._ggf .Title .Data );};return "";};
|
|
|
|
// CoreProperties contains document specific properties.
|
|
type CoreProperties struct{_ggf *_fc .CoreProperties };func (_aae CustomProperties )SetPropertyAsI4 (name string ,i4 int32 ){_ccaf :=_aae .getNewProperty (name );_ccaf .I4 =&i4 ;_aae .setOrReplaceProperty (_ccaf );};func (_afdd CustomProperties )SetPropertyAsOblob (name ,oblob string ){_ac :=_afdd .getNewProperty (name );_ac .Oblob =&oblob ;_afdd .setOrReplaceProperty (_ac );};func (_fddf CustomProperties )SetPropertyAsCy (name string ,cy string ){_cbed :=_fddf .getNewProperty (name );_cbed .Cy =&cy ;_fddf .setOrReplaceProperty (_cbed );};
|
|
|
|
// X returns the inner wrapped XML type.
|
|
func (_eeb CoreProperties )X ()*_fc .CoreProperties {return _eeb ._ggf };const _dgeef =15;
|
|
|
|
// X returns the inner wrapped XML type.
|
|
func (_fec AppProperties )X ()*_ec .Properties {return _fec ._fgg };func (_egc CustomProperties )SetPropertyAsI1 (name string ,i1 int8 ){_fdd :=_egc .getNewProperty (name );_fdd .I1 =&i1 ;_egc .setOrReplaceProperty (_fdd );};
|
|
|
|
// X returns the inner wrapped XML type.
|
|
func (_bgag Theme )X ()*_cg .Theme {return _bgag ._fca };
|
|
|
|
// X returns the underlying raw XML data.
|
|
func (_fddd Relationships )X ()*_agb .Relationships {return _fddd ._adc };
|
|
|
|
// AddImageToZip adds an image (either from bytes or from disk) and adds it to the zip file.
|
|
func AddImageToZip (z *_da .Writer ,img ImageRef ,imageNum int ,dt _gg .DocType )error {_dce :=_gg .AbsoluteImageFilename (dt ,imageNum ,_gf .ToLower (img .Format ()));if img .Data ()!=nil &&len (*img .Data ())> 0{if _ecbe :=_fg .AddFileFromBytes (z ,_dce ,*img .Data ());_ecbe !=nil {return _ecbe ;};}else if img .Path ()!=""{if _cec :=_fg .AddFileFromDisk (z ,_dce ,img .Path ());_cec !=nil {return _cec ;};}else {return _ea .Errorf ("\u0075\u006es\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0069\u006d\u0061\u0067\u0065\u0020\u0073\u006f\u0075\u0072\u0063\u0065\u003a %\u002b\u0076",img );};return nil ;};
|
|
|
|
// Relationships represents a .rels file.
|
|
type Relationships struct{_adc *_agb .Relationships };
|
|
|
|
// TblStyle returns the TblStyle property.
|
|
func (_bbd TableStyles )TblStyle ()[]*_cg .CT_TableStyle {return _bbd ._def .TblStyle };var _ede =_g .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");
|
|
|
|
// LastModifiedBy returns the name of the last person to modify the document
|
|
func (_dge CoreProperties )LastModifiedBy ()string {if _dge ._ggf .LastModifiedBy !=nil {return *_dge ._ggf .LastModifiedBy ;};return "";};
|
|
|
|
// TableCol represents a column in a table.
|
|
type TableCol struct{_gfbc *_cg .CT_TableCol };func (_bcc CustomProperties )SetPropertyAsI8 (name string ,i8 int64 ){_bgc :=_bcc .getNewProperty (name );_bgc .I8 =&i8 ;_bcc .setOrReplaceProperty (_bgc );};
|
|
|
|
// Modified returns the time that the document was modified.
|
|
func (_fcc CoreProperties )Modified ()_ba .Time {return _geee (_fcc ._ggf .Modified )};func (_gbb CustomProperties )SetPropertyAsUi4 (name string ,ui4 uint32 ){_bce :=_gbb .getNewProperty (name );_bce .Ui4 =&ui4 ;_gbb .setOrReplaceProperty (_bce );};
|
|
|
|
// 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 ){_bba :=Image {};_bgbd ,_ddaf ,_dbe :=_f .Decode (_be .NewReader (data ));if _dbe !=nil {return _bba ,_ea .Errorf ("\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s",_dbe );};_bba .Data =&data ;_bba .Format =_ddaf ;_bba .Size =_bgbd .Bounds ().Size ();return _bba ,nil ;};func (_ecb CustomProperties )SetPropertyAsLpwstr (name string ,lpwstr string ){_dcd :=_ecb .getNewProperty (name );_dcd .Lpwstr =&lpwstr ;_ecb .setOrReplaceProperty (_dcd );};
|
|
|
|
// AddOverride adds an override content type for a given path name.
|
|
func (_geea ContentTypes )AddOverride (path ,contentType string ){if !_gf .HasPrefix (path ,"\u002f"){path ="\u002f"+path ;};if _gf .HasPrefix (contentType ,"\u0068\u0074\u0074\u0070"){_ebd .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 _ ,_ffge :=range _geea ._cc .Override {if _ffge .PartNameAttr ==path &&_ffge .ContentTypeAttr ==contentType {return ;};};_eee :=_ag .NewOverride ();_eee .PartNameAttr =path ;_eee .ContentTypeAttr =contentType ;_geea ._cc .Override =append (_geea ._cc .Override ,_eee );};
|
|
|
|
// Relationship is a relationship within a .rels file.
|
|
type Relationship struct{_egfa *_agb .Relationship };func (_dfea CustomProperties )SetPropertyAsOstorage (name string ,ostorage string ){_gedb :=_dfea .getNewProperty (name );_gedb .Ostorage =&ostorage ;_dfea .setOrReplaceProperty (_gedb );};
|
|
|
|
// 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 _f .Image ;Images []ImageRef ;ExtraFiles []ExtraFile ;TmpPath string ;};
|
|
|
|
// Company returns the name of the company that created the document.
|
|
// For unioffice created documents, it defaults to github.com/unidoc/unioffice
|
|
func (_bga AppProperties )Company ()string {if _bga ._fgg .Company !=nil {return *_bga ._fgg .Company ;};return "";};func (_edc CustomProperties )SetPropertyAsStorage (name string ,storage string ){_egfb :=_edc .getNewProperty (name );_egfb .Storage =&storage ;_edc .setOrReplaceProperty (_egfb );};const Version ="\u0031\u002e\u0031\u0037\u002e\u0030";
|
|
|
|
// X returns the inner wrapped XML type of CustomProperty.
|
|
func (_eefg CustomProperty )X ()*_aeb .CT_Property {return _eefg ._cbd };
|
|
|
|
// ID returns the ID of a relationship.
|
|
func (_dag Relationship )ID ()string {return _dag ._egfa .IdAttr };
|
|
|
|
// Target returns the target (path) of a relationship.
|
|
func (_fcb Relationship )Target ()string {return _fcb ._egfa .TargetAttr };
|
|
|
|
// 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 ){_ggbf :=Image {};_dceb ,_aag :=_daf .Open (path );if _aag !=nil {return _ggbf ,_ea .Errorf ("\u0065\u0072\u0072or\u0020\u0072\u0065\u0061\u0064\u0069\u006e\u0067\u0020\u0069\u006d\u0061\u0067\u0065\u003a\u0020\u0025\u0073",_aag );};defer _dceb .Close ();_abg ,_fdb ,_aag :=_f .Decode (_dceb );if _aag !=nil {return _ggbf ,_ea .Errorf ("\u0075n\u0061\u0062\u006c\u0065 \u0074\u006f\u0020\u0070\u0061r\u0073e\u0020i\u006d\u0061\u0067\u0065\u003a\u0020\u0025s",_aag );};_ggbf .Path =path ;_ggbf .Format =_fdb ;_ggbf .Size =_abg .Bounds ().Size ();return _ggbf ,nil ;};
|
|
|
|
// TableStyles contains document specific properties.
|
|
type TableStyles struct{_def *_cg .TblStyleLst };
|
|
|
|
// X returns the inner wrapped XML type.
|
|
func (_fae Table )X ()*_cg .Tbl {return _fae ._dfd };func (_cfaa CustomProperties )SetPropertyAsBstr (name string ,bstr string ){_bbfd :=_cfaa .getNewProperty (name );_bbfd .Bstr =&bstr ;_cfaa .setOrReplaceProperty (_bbfd );};
|
|
|
|
// GetByRelId returns a relationship with the associated relation ID.
|
|
func (_bdgc Relationships )GetByRelId (idAttr string )Relationship {for _ ,_caffc :=range _bdgc ._adc .Relationship {if _caffc .IdAttr ==idAttr {return Relationship {_egfa :_caffc };};};return Relationship {};};func (_gfa CustomProperties )SetPropertyAsI2 (name string ,i2 int16 ){_gfb :=_gfa .getNewProperty (name );_gfb .I2 =&i2 ;_gfa .setOrReplaceProperty (_gfb );};
|
|
|
|
// EnsureOverride ensures that an override for the given path exists, adding it if necessary
|
|
func (_bd ContentTypes )EnsureOverride (path ,contentType string ){for _ ,_ccb :=range _bd ._cc .Override {if _ccb .PartNameAttr ==path {if _gf .HasPrefix (contentType ,"\u0068\u0074\u0074\u0070"){_ebd .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 );};_ccb .ContentTypeAttr =contentType ;return ;};};_bd .AddOverride (path ,contentType );};func _geee (_aa *_gg .XSDAny )_ba .Time {if _aa ==nil {return _ba .Time {};};_ef ,_efc :=_ba .Parse (_ab ,string (_aa .Data ));if _efc !=nil {_ebd .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 (_aa .Data ),_efc );};return _ef ;};
|
|
|
|
// Clear removes any existing relationships.
|
|
func (_abc Relationships )Clear (){_abc ._adc .Relationship =nil };
|
|
|
|
// X returns the inner wrapped XML type.
|
|
func (_dbfa TableStyles )X ()*_cg .TblStyleLst {return _dbfa ._def };func (_ccc CustomProperties )SetPropertyAsEmpty (name string ){_gegf :=_ccc .getNewProperty (name );_gegf .Empty =_gd .NewEmpty ();_ccc .setOrReplaceProperty (_gegf );};
|
|
|
|
// NewTheme constructs a new theme.
|
|
func NewTheme ()Theme {return Theme {_cg .NewTheme ()}};
|
|
|
|
// X returns the inner wrapped XML type.
|
|
func (_gad Relationship )X ()*_agb .Relationship {return _gad ._egfa };
|
|
|
|
// 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 {_cea :img ,_acd :d ,_aeg :rels };};
|
|
|
|
// SetApplicationVersion sets the version of the application that created the
|
|
// document. Per MS, the verison string mut be in the form 'XX.YYYY'.
|
|
func (_dd AppProperties )SetApplicationVersion (s string ){_dd ._fgg .AppVersion =&s };
|
|
|
|
// Author returns the author of the document
|
|
func (_bbe CoreProperties )Author ()string {if _bbe ._ggf .Creator !=nil {return string (_bbe ._ggf .Creator .Data );};return "";};
|
|
|
|
// SetCreated sets the time that the document was created.
|
|
func (_egaa CoreProperties )SetCreated (t _ba .Time ){_egaa ._ggf .Created =_gce (t ,"\u0064c\u0074e\u0072\u006d\u0073\u003a\u0063\u0072\u0065\u0061\u0074\u0065\u0064");};func _gce (_ffef _ba .Time ,_abf string )*_gg .XSDAny {_ged :=&_gg .XSDAny {XMLName :_cd .Name {Local :_abf }};_ged .Attrs =append (_ged .Attrs ,_cd .Attr {Name :_cd .Name {Local :"\u0078\u0073\u0069\u003a\u0074\u0079\u0070\u0065"},Value :"\u0064\u0063\u0074\u0065\u0072\u006d\u0073\u003a\u00573\u0043\u0044\u0054\u0046"});_ged .Attrs =append (_ged .Attrs ,_cd .Attr {Name :_cd .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"});_ged .Attrs =append (_ged .Attrs ,_cd .Attr {Name :_cd .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/"});_ged .Data =[]byte (_ffef .Format (_ab ));return _ged ;};func (_bcb CustomProperties )SetPropertyAsBool (name string ,b bool ){_fegc :=_bcb .getNewProperty (name );_fegc .Bool =&b ;_bcb .setOrReplaceProperty (_fegc );};func (_bfg CustomProperties )SetPropertyAsBlob (name ,blob string ){_feff :=_bfg .getNewProperty (name );_feff .Blob =&blob ;_bfg .setOrReplaceProperty (_feff );};
|
|
|
|
// SetLinksUpToDate sets the links up to date flag.
|
|
func (_caf AppProperties )SetLinksUpToDate (v bool ){_caf ._fgg .LinksUpToDate =_gg .Bool (v )};func (_egcf CustomProperties )SetPropertyAsClsid (name string ,clsid string ){_gbbd :=_egcf .getNewProperty (name );_gbbd .Clsid =&clsid ;_egcf .setOrReplaceProperty (_gbbd );};
|
|
|
|
// NewContentTypes returns a wrapper around a newly constructed content-types.
|
|
func NewContentTypes ()ContentTypes {_dda :=ContentTypes {_cc :_ag .NewTypes ()};_dda .AddDefault ("\u0078\u006d\u006c","\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u0078\u006d\u006c");_dda .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");_dda .AddDefault ("\u0070\u006e\u0067","\u0069m\u0061\u0067\u0065\u002f\u0070\u006eg");_dda .AddDefault ("\u006a\u0070\u0065\u0067","\u0069\u006d\u0061\u0067\u0065\u002f\u006a\u0070\u0065\u0067");_dda .AddDefault ("\u006a\u0070\u0067","\u0069m\u0061\u0067\u0065\u002f\u006a\u0070g");_dda .AddDefault ("\u0077\u006d\u0066","i\u006d\u0061\u0067\u0065\u002f\u0078\u002d\u0077\u006d\u0066");_dda .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");_dda .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 _dda ;};func (_aebg CustomProperties )SetPropertyAsNull (name string ){_aaf :=_aebg .getNewProperty (name );_aaf .Null =_gd .NewNull ();_aebg .setOrReplaceProperty (_aaf );};
|
|
|
|
// NewRelationship constructs a new relationship.
|
|
func NewRelationship ()Relationship {return Relationship {_egfa :_agb .NewRelationship ()}};
|
|
|
|
// AddRow adds a row to a table.
|
|
func (_bde Table )AddRow ()*TableRow {_gfab :=_cg .NewCT_TableRow ();for _agfa :=0;_agfa < len (_bde ._dfd .TblGrid .GridCol );_agfa ++{_gfab .Tc =append (_gfab .Tc ,_cg .NewCT_TableCell ());};_bde ._dfd .Tr =append (_bde ._dfd .Tr ,_gfab );return &TableRow {_fccb :_gfab };};
|
|
|
|
// TableRow represents a row in a table.
|
|
type TableRow struct{_fccb *_cg .CT_TableRow };func (_bdf CustomProperties )SetPropertyAsOstream (name string ,ostream string ){_dfa :=_bdf .getNewProperty (name );_dfa .Ostream =&ostream ;_bdf .setOrReplaceProperty (_dfa );};func (_dbbe TableRow )addCell ()*_cg .CT_TableCell {_agc :=_cg .NewCT_TableCell ();_dbbe ._fccb .Tc =append (_dbbe ._fccb .Tc ,_agc );return _agc ;};
|
|
|
|
// CustomProperties contains document specific properties.
|
|
type CustomProperties struct{_ebe *_aeb .Properties };
|
|
|
|
// IsEmpty returns true if there are no relationships.
|
|
func (_faf Relationships )IsEmpty ()bool {return _faf ._adc ==nil ||len (_faf ._adc .Relationship )==0};func (_bdg CustomProperties )SetPropertyAsLpstr (name string ,lpstr string ){_dcgg :=_bdg .getNewProperty (name );_dcgg .Lpstr =&lpstr ;_bdg .setOrReplaceProperty (_dcgg );};
|
|
|
|
// AddCustomRelationships adds relationships related to custom properties to the document.
|
|
func (_ffd *DocBase )AddCustomRelationships (){_ffd .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");_ffd .Rels .AddRelationship ("\u0064\u006f\u0063\u0050ro\u0070\u0073\u002f\u0063\u0075\u0073\u0074\u006f\u006d\u002e\u0078\u006d\u006c",_gg .CustomPropertiesType );};
|
|
|
|
// SetWidth sets column width, see measurement package.
|
|
func (_gfbcd TableCol )SetWidth (m _eb .Distance ){_ceeg :=_eb .ToEMU (float64 (m ));_gfbcd ._gfbc .WAttr =_cg .ST_Coordinate {ST_CoordinateUnqualified :&_ceeg };};const _ab ="2\u00300\u0036\u002d\u0030\u0031\u002d\u0030\u0032\u00541\u0035\u003a\u0030\u0034:0\u0035\u005a";
|
|
|
|
// AddHyperlink adds an external hyperlink relationship.
|
|
func (_ggae Relationships )AddHyperlink (target string )Hyperlink {_eacf :=_ggae .AddRelationship (target ,_gg .HyperLinkType );_eacf ._egfa .TargetModeAttr =_agb .ST_TargetModeExternal ;return Hyperlink (_eacf );};
|
|
|
|
// 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 (_dgf *DocBase )AddExtraFileFromZip (f *_da .File )error {_bae ,_ccd :=_fg .ExtractToDiskTmp (f ,_dgf .TmpPath );if _ccd !=nil {return _ea .Errorf ("\u0065\u0072r\u006f\u0072\u0020\u0065x\u0074\u0072a\u0063\u0074\u0069\u006e\u0067\u0020\u0075\u006es\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0066\u0069\u006ce\u003a\u0020\u0025\u0073",_ccd );};_dgf .ExtraFiles =append (_dgf .ExtraFiles ,ExtraFile {ZipPath :f .Name ,DiskPath :_bae });return nil ;};
|
|
|
|
// NewCustomProperties constructs a new CustomProperties.
|
|
func NewCustomProperties ()CustomProperties {return CustomProperties {_ebe :_aeb .NewProperties ()}};const _bef =2022;
|
|
|
|
// Category returns the category of the document
|
|
func (_egd CoreProperties )Category ()string {if _egd ._ggf .Category !=nil {return *_egd ._ggf .Category ;};return "";};
|
|
|
|
// Created returns the time that the document was created.
|
|
func (_egdb CoreProperties )Created ()_ba .Time {return _geee (_egdb ._ggf .Created )};
|
|
|
|
// NewRelationshipsCopy creates a new relationships wrapper as a copy of passed in instance.
|
|
func NewRelationshipsCopy (rels Relationships )Relationships {_bgbg :=*rels ._adc ;return Relationships {_adc :&_bgbg };};
|
|
|
|
// Application returns the name of the application that created the document.
|
|
// For unioffice created documents, it defaults to github.com/unidoc/unioffice
|
|
func (_bafc AppProperties )Application ()string {if _bafc ._fgg .Application !=nil {return *_bafc ._fgg .Application ;};return "";};func (_bfe CustomProperties )setPropertyHelper (_bfc *_aeb .CT_Property ,_dba bool ){_cbfa :=_bfe .GetPropertyByName (*_bfc .NameAttr );if (_cbfa ==CustomProperty {}){_bfe ._ebe .Property =append (_bfe ._ebe .Property ,_bfc );}else if _dba {_bfc .FmtidAttr =_cbfa ._cbd .FmtidAttr ;if _cbfa ._cbd .PidAttr ==0{_bfc .PidAttr =_cbfa ._cbd .PidAttr ;};_bfc .LinkTargetAttr =_cbfa ._cbd .LinkTargetAttr ;*_cbfa ._cbd =*_bfc ;};};
|
|
|
|
// 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 (_aggc ImageRef )RelativeWidth (h _eb .Distance )_eb .Distance {_fgfe :=float64 (_aggc .Size ().X )/float64 (_aggc .Size ().Y );return h *_eb .Distance (_fgfe );};func (_fef CustomProperties )SetPropertyAsArray (name string ,array *_gd .Array ){_cdb :=_fef .getNewProperty (name );_cdb .Array =array ;_fef .setOrReplaceProperty (_cdb );};
|
|
|
|
// FindRIDForN returns the relationship ID for the i'th relationship of type t.
|
|
func (_fcce Relationships )FindRIDForN (i int ,t string )string {for _ ,_cgfg :=range _fcce ._adc .CT_Relationships .Relationship {if _cgfg .TypeAttr ==t {if i ==0{return _cgfg .IdAttr ;};i --;};};return "";};
|
|
|
|
// Table represents a table in the document.
|
|
type Table struct{_dfd *_cg .Tbl ;_cff *_cg .CT_Transform2D ;};
|
|
|
|
// AddDefault registers a default content type for a given file extension.
|
|
func (_dc ContentTypes )AddDefault (fileExtension string ,contentType string ){fileExtension =_gf .ToLower (fileExtension );for _ ,_ad :=range _dc ._cc .Default {if _ad .ExtensionAttr ==fileExtension &&_ad .ContentTypeAttr ==contentType {return ;};};_gfd :=_ag .NewDefault ();_gfd .ExtensionAttr =fileExtension ;_gfd .ContentTypeAttr =contentType ;_dc ._cc .Default =append (_dc ._cc .Default ,_gfd );};func (_ggbe CustomProperties )SetPropertyAsStream (name string ,stream string ){_dee :=_ggbe .getNewProperty (name );_dee .Stream =&stream ;_ggbe .setOrReplaceProperty (_dee );};
|
|
|
|
// 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 (_fddg Relationships )AddAutoRelationship (dt _gg .DocType ,src string ,idx int ,ctype string )Relationship {return _fddg .AddRelationship (_gg .RelativeFilename (dt ,src ,ctype ,idx ),ctype );};
|
|
|
|
// Append appends DocBase part of an office document to another DocBase.
|
|
func (_db DocBase )Append (docBase1 DocBase )DocBase {_ff :=docBase1 .ContentTypes .X ();for _ ,_cdg :=range _ff .Default {_db .ContentTypes .AddDefault (_cdg .ExtensionAttr ,_cdg .ContentTypeAttr );};for _ ,_cb :=range _ff .Override {_db .ContentTypes .AddOverride (_cb .PartNameAttr ,_cb .ContentTypeAttr );};_ffe :=_db .AppProperties .X ();_ee :=docBase1 .AppProperties .X ();if _ffe .Pages !=nil {if _ee .Pages !=nil {*_ffe .Pages +=*_ee .Pages ;};}else if _ee .Pages !=nil {_ffe .Pages =_ee .Pages ;};if _ffe .Words !=nil {if _ee .Words !=nil {*_ffe .Words +=*_ee .Words ;};}else if _ee .Words !=nil {_ffe .Words =_ee .Words ;};if _ffe .Characters !=nil {if _ee .Characters !=nil {*_ffe .Characters +=*_ee .Characters ;};}else if _ee .Characters !=nil {_ffe .Characters =_ee .Characters ;};if _ffe .Lines !=nil {if _ee .Lines !=nil {*_ffe .Lines +=*_ee .Lines ;};}else if _ee .Lines !=nil {_ffe .Lines =_ee .Lines ;};if _ffe .Paragraphs !=nil {if _ee .Paragraphs !=nil {*_ffe .Paragraphs +=*_ee .Paragraphs ;};}else if _ee .Paragraphs !=nil {_ffe .Paragraphs =_ee .Paragraphs ;};if _ffe .Notes !=nil {if _ee .Notes !=nil {*_ffe .Notes +=*_ee .Notes ;};}else if _ee .Notes !=nil {_ffe .Notes =_ee .Notes ;};if _ffe .HiddenSlides !=nil {if _ee .HiddenSlides !=nil {*_ffe .HiddenSlides +=*_ee .HiddenSlides ;};}else if _ee .HiddenSlides !=nil {_ffe .HiddenSlides =_ee .HiddenSlides ;};if _ffe .MMClips !=nil {if _ee .MMClips !=nil {*_ffe .MMClips +=*_ee .MMClips ;};}else if _ee .MMClips !=nil {_ffe .MMClips =_ee .MMClips ;};if _ffe .LinksUpToDate !=nil {if _ee .LinksUpToDate !=nil {*_ffe .LinksUpToDate =*_ffe .LinksUpToDate &&*_ee .LinksUpToDate ;};}else if _ee .LinksUpToDate !=nil {_ffe .LinksUpToDate =_ee .LinksUpToDate ;};if _ffe .CharactersWithSpaces !=nil {if _ee .CharactersWithSpaces !=nil {*_ffe .CharactersWithSpaces +=*_ee .CharactersWithSpaces ;};}else if _ee .CharactersWithSpaces !=nil {_ffe .CharactersWithSpaces =_ee .CharactersWithSpaces ;};if _ffe .SharedDoc !=nil {if _ee .SharedDoc !=nil {*_ffe .SharedDoc =*_ffe .SharedDoc ||*_ee .SharedDoc ;};}else if _ee .SharedDoc !=nil {_ffe .SharedDoc =_ee .SharedDoc ;};if _ffe .HyperlinksChanged !=nil {if _ee .HyperlinksChanged !=nil {*_ffe .HyperlinksChanged =*_ffe .HyperlinksChanged ||*_ee .HyperlinksChanged ;};}else if _ee .HyperlinksChanged !=nil {_ffe .HyperlinksChanged =_ee .HyperlinksChanged ;};_ffe .DigSig =nil ;if _ffe .TitlesOfParts ==nil &&_ee .TitlesOfParts !=nil {_ffe .TitlesOfParts =_ee .TitlesOfParts ;};if _ffe .HeadingPairs !=nil {if _ee .HeadingPairs !=nil {_dac :=_ffe .HeadingPairs .Vector ;_cdf :=_ee .HeadingPairs .Vector ;_cbc :=_dac .Variant ;_fff :=_cdf .Variant ;_ffg :=[]*_gd .Variant {};for _baf :=0;_baf < len (_fff );_baf +=2{_df :=_fff [_baf ].Lpstr ;_fd :=false ;for _eg :=0;_eg < len (_cbc );_eg +=2{_eaa :=_cbc [_eg ].Lpstr ;if _eaa !=nil &&_df !=nil &&*_eaa ==*_df {*_cbc [_eg +1].I4 =*_cbc [_eg +1].I4 +*_fff [_baf +1].I4 ;_fd =true ;break ;};};if !_fd {_ffg =append (_ffg ,&_gd .Variant {CT_Variant :_gd .CT_Variant {Lpstr :_fff [_baf ].Lpstr }});_ffg =append (_ffg ,&_gd .Variant {CT_Variant :_gd .CT_Variant {I4 :_fff [_baf ].I4 }});};};_cbc =append (_cbc ,_ffg ...);_dac .SizeAttr =uint32 (len (_cbc ));};}else if _ee .HeadingPairs !=nil {_ffe .HeadingPairs =_ee .HeadingPairs ;};if _ffe .HLinks !=nil {if _ee .HLinks !=nil {_dg :=_ffe .HLinks .Vector ;_gb :=_ee .HLinks .Vector ;_dbf :=_dg .Variant ;_ce :=_gb .Variant ;for _ ,_cbf :=range _ce {_dace :=true ;for _ ,_gde :=range _dbf {if _c .DeepEqual (_gde ,_cbf ){_dace =false ;break ;};};if _dace {_dbf =append (_dbf ,_cbf );_dg .SizeAttr ++;};};};}else if _ee .HLinks !=nil {_ffe .HLinks =_ee .HLinks ;};_gee :=_db .GetOrCreateCustomProperties ();_ebc :=docBase1 .GetOrCreateCustomProperties ();for _ ,_bb :=range _ebc .PropertiesList (){_gee .setProperty (_bb );};_db .CustomProperties =_gee ;_fgf :=_db .Rels .X ().Relationship ;for _ ,_age :=range docBase1 .Rels .X ().Relationship {_fe :=true ;for _ ,_ded :=range _fgf {if _ded .TargetAttr ==_age .TargetAttr &&_ded .TypeAttr ==_age .TypeAttr {_fe =false ;break ;};};if _fe {_db .Rels .AddRelationship (_age .TargetAttr ,_age .TypeAttr );};};for _ ,_ege :=range docBase1 .ExtraFiles {_agbd :=_ege .ZipPath ;_fdf :=true ;for _ ,_af :=range _db .ExtraFiles {if _af .ZipPath ==_agbd {_fdf =false ;break ;};};if _fdf {_db .ExtraFiles =append (_db .ExtraFiles ,_ege );};};return _db ;};func UtcTimeFormat (t _ba .Time )string {return t .Format (_ffbg )+"\u0020\u0055\u0054\u0043"};
|
|
|
|
// Relationships returns a slice of all of the relationships.
|
|
func (_fcde Relationships )Relationships ()[]Relationship {_ade :=[]Relationship {};for _ ,_fgba :=range _fcde ._adc .Relationship {_ade =append (_ade ,Relationship {_egfa :_fgba });};return _ade ;};
|
|
|
|
// SetApplication sets the name of the application that created the document.
|
|
func (_gbe AppProperties )SetApplication (s string ){_gbe ._fgg .Application =&s };
|
|
|
|
// RemoveOverride removes an override given a path.
|
|
func (_eef ContentTypes )RemoveOverride (path string ){if !_gf .HasPrefix (path ,"\u002f"){path ="\u002f"+path ;};for _eacd ,_fffb :=range _eef ._cc .Override {if _fffb .PartNameAttr ==path {copy (_eef ._cc .Override [_eacd :],_eef ._cc .Override [_eacd +1:]);_eef ._cc .Override =_eef ._cc .Override [0:len (_eef ._cc .Override )-1];};};};func (_eaf CustomProperties )SetPropertyAsFiletime (name string ,filetime _ba .Time ){_feb :=_eaf .getNewProperty (name );_feb .Filetime =&filetime ;_eaf .setOrReplaceProperty (_feb );};
|
|
|
|
// AppProperties contains properties specific to the document and the
|
|
// application that created it.
|
|
type AppProperties struct{_fgg *_ec .Properties };
|
|
|
|
// WriteExtraFiles writes the extra files to the zip package.
|
|
func (_dbda *DocBase )WriteExtraFiles (z *_da .Writer )error {for _ ,_fdfb :=range _dbda .ExtraFiles {if _adff :=_fg .AddFileFromDisk (z ,_fdfb .ZipPath ,_fdfb .DiskPath );_adff !=nil {return _adff ;};};return nil ;};
|
|
|
|
// SetTitle records the title of the document.
|
|
func (_cfb CoreProperties )SetTitle (s string ){if _cfb ._ggf .Title ==nil {_cfb ._ggf .Title =&_gg .XSDAny {XMLName :_cd .Name {Local :"\u0064\u0063\u003a\u0074\u0069\u0074\u006c\u0065"}};};_cfb ._ggf .Title .Data =[]byte (s );};
|
|
|
|
// Target returns the target attrubute of the image reference (a path where the image file is located in the document structure).
|
|
func (_dff *ImageRef )Target ()string {return _dff ._eafb };func init (){_ge .SetAsStorage ()};
|
|
|
|
// ImageRef is a reference to an image within a document.
|
|
type ImageRef struct{_acd *DocBase ;_aeg Relationships ;_cea Image ;_ddb string ;_eafb string ;};
|
|
|
|
// SetCompany sets the name of the company that created the document.
|
|
func (_dafa AppProperties )SetCompany (s string ){_dafa ._fgg .Company =&s };
|
|
|
|
// SetModified sets the time that the document was modified.
|
|
func (_baa CoreProperties )SetModified (t _ba .Time ){_baa ._ggf .Modified =_gce (t ,"\u0064\u0063t\u0065\u0072\u006ds\u003a\u006d\u006f\u0064\u0069\u0066\u0069\u0065\u0064");};
|
|
|
|
// SetContentStatus records the content status of the document.
|
|
func (_cba CoreProperties )SetContentStatus (s string ){_cba ._ggf .ContentStatus =&s };
|
|
|
|
// EnsureDefault esnures that an extension and default content type exist,
|
|
// adding it if necessary.
|
|
func (_fbbd ContentTypes )EnsureDefault (ext ,contentType string ){ext =_gf .ToLower (ext );for _ ,_bc :=range _fbbd ._cc .Default {if _bc .ExtensionAttr ==ext {_bc .ContentTypeAttr =contentType ;return ;};};_cbe :=&_ag .Default {};_cbe .ContentTypeAttr =contentType ;_cbe .ExtensionAttr =ext ;_fbbd ._cc .Default =append (_fbbd ._cc .Default ,_cbe );};
|
|
|
|
// AddCol adds a column to a table.
|
|
func (_ddg Table )AddCol ()*TableCol {_agac :=_cg .NewCT_TableCol ();_ddg ._dfd .TblGrid .GridCol =append (_ddg ._dfd .TblGrid .GridCol ,_agac );for _ ,_aff :=range _ddg ._dfd .Tr {_gff :=_cg .NewCT_TableCell ();_aff .Tc =append (_aff .Tc ,_gff );};return &TableCol {_gfbc :_agac };};
|
|
|
|
// X returns the inner wrapped XML type.
|
|
func (_beg CustomProperties )X ()*_aeb .Properties {return _beg ._ebe };func (_eaab *ImageRef )SetRelID (id string ){_eaab ._ddb =id };const _efd =15;
|
|
|
|
// CreateCustomProperties creates the custom properties of the document.
|
|
func (_ecc *DocBase )CreateCustomProperties (){_ecc .CustomProperties =NewCustomProperties ();_ecc .AddCustomRelationships ();};const _edg =1;
|
|
|
|
// RemoveOverrideByIndex removes an override given a path and override index.
|
|
func (_fga ContentTypes )RemoveOverrideByIndex (path string ,indexToFind int )error {_egf :=path [0:len (path )-5];if !_gf .HasPrefix (_egf ,"\u002f"){_egf ="\u002f"+_egf ;};_dbfd ,_fda :=_bg .Compile (_egf +"\u0028\u005b\u0030-\u0039\u005d\u002b\u0029\u002e\u0078\u006d\u006c");if _fda !=nil {return _fda ;};_dfba :=0;_deb :=-1;for _fbe ,_beb :=range _fga ._cc .Override {if _aga :=_dbfd .FindStringSubmatch (_beb .PartNameAttr );len (_aga )> 1{if _dfba ==indexToFind {_deb =_fbe ;}else if _dfba > indexToFind {_bf ,_ :=_de .Atoi (_aga [1]);_bf --;_beb .PartNameAttr =_ea .Sprintf ("\u0025\u0073\u0025\u0064\u002e\u0078\u006d\u006c",_egf ,_bf );};_dfba ++;};};if _deb > -1{copy (_fga ._cc .Override [_deb :],_fga ._cc .Override [_deb +1:]);_fga ._cc .Override =_fga ._cc .Override [0:len (_fga ._cc .Override )-1];};return nil ;};
|
|
|
|
// Remove removes an existing relationship.
|
|
func (_cafe Relationships )Remove (rel Relationship )bool {for _cgga ,_dgee :=range _cafe ._adc .Relationship {if _dgee ==rel ._egfa {copy (_cafe ._adc .Relationship [_cgga :],_cafe ._adc .Relationship [_cgga +1:]);_cafe ._adc .Relationship =_cafe ._adc .Relationship [0:len (_cafe ._adc .Relationship )-1];return true ;};};return false ;};func (_bgb CustomProperties )SetPropertyAsR4 (name string ,r4 float32 ){_adg :=_bgb .getNewProperty (name );_adg .R4 =&r4 ;_bgb .setOrReplaceProperty (_adg );};
|
|
|
|
// Rows returns all table rows.
|
|
func (_ecd Table )Rows ()[]*TableRow {_egb :=_ecd ._dfd .Tr ;_gceg :=[]*TableRow {};for _ ,_fdc :=range _egb {_gceg =append (_gceg ,&TableRow {_fccb :_fdc });};return _gceg ;};
|
|
|
|
// SetID set the ID of a relationship.
|
|
func (_gfe Relationship )SetID (ID string ){_gfe ._egfa .IdAttr =ID ;};
|
|
|
|
// SetStyle assigns TableStyle to a table.
|
|
func (_eccf Table )SetStyle (style *_cg .CT_TableStyle ){if _eccf ._dfd .TblPr ==nil {_eccf ._dfd .TblPr =_cg .NewCT_TableProperties ();};if _eccf ._dfd .TblPr .Choice ==nil {_eccf ._dfd .TblPr .Choice =_cg .NewCT_TablePropertiesChoice ();};_eccf ._dfd .TblPr .Choice .TableStyle =style ;};const _bcec =30;
|
|
|
|
// Path returns the path to an image file, if any.
|
|
func (_dae ImageRef )Path ()string {return _dae ._cea .Path };
|
|
|
|
// ExtraFile is an unsupported file type extracted from, or to be written to a
|
|
// zip package
|
|
type ExtraFile struct{ZipPath string ;DiskPath string ;};
|
|
|
|
// Theme is a drawingml theme.
|
|
type Theme struct{_fca *_cg .Theme };
|
|
|
|
// NewTableWithXfrm makes a new table with a pointer to its parent Xfrm for changing its offset and size.
|
|
func NewTableWithXfrm (xfrm *_cg .CT_Transform2D )*Table {_fecc :=_cg .NewTbl ();_fecc .TblPr =_cg .NewCT_TableProperties ();return &Table {_dfd :_fecc ,_cff :xfrm };};
|
|
|
|
// SetLanguage records the language of the document.
|
|
func (_agee CoreProperties )SetLanguage (s string ){_agee ._ggf .Language =&_gg .XSDAny {XMLName :_cd .Name {Local :"d\u0063\u003a\u006c\u0061\u006e\u0067\u0075\u0061\u0067\u0065"}};_agee ._ggf .Language .Data =[]byte (s );};
|
|
|
|
// 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 _f .Point ;Format string ;Path string ;Data *[]byte ;};func (_bcd CustomProperties )SetPropertyAsVector (name string ,vector *_gd .Vector ){_dbg :=_bcd .getNewProperty (name );_dbg .Vector =vector ;_bcd .setOrReplaceProperty (_dbg );};
|
|
|
|
// SetDescription records the description of the document.
|
|
func (_geg CoreProperties )SetDescription (s string ){if _geg ._ggf .Description ==nil {_geg ._ggf .Description =&_gg .XSDAny {XMLName :_cd .Name {Local :"\u0064\u0063\u003a\u0064\u0065\u0073\u0063\u0072\u0069p\u0074\u0069\u006f\u006e"}};};_geg ._ggf .Description .Data =[]byte (s );};
|
|
|
|
// NewRelationships creates a new relationship wrapper.
|
|
func NewRelationships ()Relationships {return Relationships {_adc :_agb .NewRelationships ()}};
|
|
|
|
// ApplicationVersion returns the version of the application that created the
|
|
// document.
|
|
func (_cf AppProperties )ApplicationVersion ()string {if _cf ._fgg .AppVersion !=nil {return *_cf ._fgg .AppVersion ;};return "";};
|
|
|
|
// SetDocSecurity sets the document security flag.
|
|
func (_ead AppProperties )SetDocSecurity (v int32 ){_ead ._fgg .DocSecurity =_gg .Int32 (v )};func (_gcdf CustomProperties )SetPropertyAsError (name string ,error string ){_dfg :=_gcdf .getNewProperty (name );_dfg .Error =&error ;_gcdf .setOrReplaceProperty (_dfg );};
|
|
|
|
// Properties returns table properties.
|
|
func (_aee Table )Properties ()*_cg .CT_TableProperties {return _aee ._dfd .TblPr };var ReleasedAt =_ba .Date (_bef ,_edg ,_efd ,_dgeef ,_bcec ,0,0,_ba .UTC );
|
|
|
|
// GetImageBytesByTarget returns Image object with Data bytes read from its target.
|
|
func (_gge *DocBase )GetImageBytesByTarget (target string )(Image ,error ){if target !=""{target ="\u0077\u006f\u0072d\u002f"+target ;for _ ,_gdg :=range _gge .Images {if _gdg .Target ()==target {return ImageFromStorage (_gdg .Path ());};};};return Image {},_ede ;};
|
|
|
|
// NewCoreProperties constructs a new CoreProperties.
|
|
func NewCoreProperties ()CoreProperties {return CoreProperties {_ggf :_fc .NewCoreProperties ()}};
|
|
|
|
// GetTargetByRelId returns a target path with the associated relation ID.
|
|
func (_bdfg Relationships )GetTargetByRelId (idAttr string )string {for _ ,_dcgc :=range _bdfg ._adc .Relationship {if _dcgc .IdAttr ==idAttr {return _dcgc .TargetAttr ;};};return "";}; |