2017-08-28 20:56:18 -05:00
//
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/
2017-08-28 20:56:18 -05:00
2020-08-23 14:15:53 +00:00
/ *
2017-09-01 16:12:59 -05:00
2020-08-23 14:15:53 +00:00
Package document provides creation , reading , and writing of ECMA 376 Open
Office XML documents .
2017-09-01 16:12:59 -05:00
2020-08-23 14:15:53 +00:00
Example :
2018-01-24 18:59:09 -06:00
2020-08-23 14:15:53 +00:00
doc := document . New ( )
para := doc . AddParagraph ( )
run := para . AddRun ( )
run . SetText ( "foo" )
doc . SaveToFile ( "foo.docx" )
* /
2021-01-04 16:11:39 +00:00
package document ; import ( _b "archive/zip" ; _dg "bytes" ; _cd "errors" ; _cfb "fmt" ; _d "github.com/unidoc/unioffice" ; _fb "github.com/unidoc/unioffice/color" ; _bf "github.com/unidoc/unioffice/common" ; _be "github.com/unidoc/unioffice/common/license" ; _ca "github.com/unidoc/unioffice/common/tempstorage" ; _gc "github.com/unidoc/unioffice/measurement" ; _cde "github.com/unidoc/unioffice/schema/soo/dml" ; _bc "github.com/unidoc/unioffice/schema/soo/dml/picture" ; _dc "github.com/unidoc/unioffice/schema/soo/ofc/sharedTypes" ; _df "github.com/unidoc/unioffice/schema/soo/pkg/relationships" ; _ba "github.com/unidoc/unioffice/schema/soo/wml" ; _gg "github.com/unidoc/unioffice/zippkg" ; _ec "image" ; _cf "image/jpeg" ; _ee "io" ; _ga "log" ; _e "math/rand" ; _a "os" ; _gaa "path/filepath" ; _f "strings" ; _c "unicode" ; ) ;
2018-01-24 18:59:09 -06:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _cdgg Settings ) X ( ) * _ba . Settings { return _cdgg . _dbedb } ;
2017-08-28 20:56:18 -05:00
2021-01-04 16:11:39 +00:00
// Borders allows manipulation of the table borders.
func ( _bfaca TableProperties ) Borders ( ) TableBorders { if _bfaca . _efeg . TblBorders == nil { _bfaca . _efeg . TblBorders = _ba . NewCT_TblBorders ( ) ; } ; return TableBorders { _bfaca . _efeg . TblBorders } ; } ;
2017-08-28 20:56:18 -05:00
2021-01-04 16:11:39 +00:00
// SetKeepNext controls if the paragraph is kept with the next paragraph.
func ( _fcca ParagraphStyleProperties ) SetKeepNext ( b bool ) { if ! b { _fcca . _gdb . KeepNext = nil ; } else { _fcca . _gdb . KeepNext = _ba . NewCT_OnOff ( ) ; } ; } ;
2017-08-28 20:56:18 -05:00
2021-01-04 16:11:39 +00:00
// AddHyperLink adds a new hyperlink to a parapgraph.
func ( _gbf Paragraph ) AddHyperLink ( ) HyperLink { _aag := _ba . NewEG_PContent ( ) ; _gbf . _acbc . EG_PContent = append ( _gbf . _acbc . EG_PContent , _aag ) ; _aag . Hyperlink = _ba . NewCT_Hyperlink ( ) ; return HyperLink { _gbf . _dcbe , _aag . Hyperlink } ; } ;
2017-08-28 20:56:18 -05:00
2021-01-04 16:11:39 +00:00
// HasFootnotes returns a bool based on the presence or abscence of footnotes within
// the document.
func ( _afdg * Document ) HasFootnotes ( ) bool { return _afdg . _bgd != nil } ;
2017-08-28 20:56:18 -05:00
2021-01-04 16:11:39 +00:00
// Endnote is an individual endnote reference within the document.
type Endnote struct { _deaa * Document ; _adff * _ba . CT_FtnEdn ; } ;
2017-08-28 20:56:18 -05:00
2021-01-04 16:11:39 +00:00
// SetStyle sets the style of a paragraph and is identical to setting it on the
// paragraph's Properties()
func ( _bgcf Paragraph ) SetStyle ( s string ) { _bgcf . ensurePPr ( ) ; if s == "" { _bgcf . _acbc . PPr . PStyle = nil ; } else { _bgcf . _acbc . PPr . PStyle = _ba . NewCT_String ( ) ; _bgcf . _acbc . PPr . PStyle . ValAttr = s ; } ; } ;
2017-08-28 20:56:18 -05:00
2021-01-04 16:11:39 +00:00
// SetLeft sets the left border to a specified type, color and thickness.
func ( _cfgf CellBorders ) SetLeft ( t _ba . ST_Border , c _fb . Color , thickness _gc . Distance ) { _cfgf . _fbd . Left = _ba . NewCT_Border ( ) ; _deec ( _cfgf . _fbd . Left , t , c , thickness ) ; } ;
2019-10-23 22:06:11 +03:00
2021-01-04 16:11:39 +00:00
// SetTopPct sets the cell top margin
func ( _eaa CellMargins ) SetTopPct ( pct float64 ) { _eaa . _aab . Top = _ba . NewCT_TblWidth ( ) ; _ade ( _eaa . _aab . Top , pct ) ; } ;
2018-01-24 18:59:09 -06:00
2021-01-04 16:11:39 +00:00
// Name returns the name of the style if set.
func ( _cefb Style ) Name ( ) string { if _cefb . _ebcb . Name == nil { return "" ; } ; return _cefb . _ebcb . Name . ValAttr ; } ;
2017-08-28 20:56:18 -05:00
2021-01-04 16:11:39 +00:00
// SetWidth sets the cell width to a specified width.
func ( _abd CellProperties ) SetWidth ( d _gc . Distance ) { _abd . _adg . TcW = _ba . NewCT_TblWidth ( ) ; _abd . _adg . TcW . TypeAttr = _ba . ST_TblWidthDxa ; _abd . _adg . TcW . WAttr = & _ba . ST_MeasurementOrPercent { } ; _abd . _adg . TcW . WAttr . ST_DecimalNumberOrPercent = & _ba . ST_DecimalNumberOrPercent { } ; _abd . _adg . TcW . WAttr . ST_DecimalNumberOrPercent . ST_UnqualifiedPercentage = _d . Int64 ( int64 ( d / _gc . Twips ) ) ; } ;
2017-10-10 17:57:44 -04:00
2021-01-04 16:11:39 +00:00
// SetLineSpacing sets the spacing between lines in a paragraph.
func ( _afcf Paragraph ) SetLineSpacing ( d _gc . Distance , rule _ba . ST_LineSpacingRule ) { _afcf . ensurePPr ( ) ; if _afcf . _acbc . PPr . Spacing == nil { _afcf . _acbc . PPr . Spacing = _ba . NewCT_Spacing ( ) ; } ; _bgfb := _afcf . _acbc . PPr . Spacing ; if rule == _ba . ST_LineSpacingRuleUnset { _bgfb . LineRuleAttr = _ba . ST_LineSpacingRuleUnset ; _bgfb . LineAttr = nil ; } else { _bgfb . LineRuleAttr = rule ; _bgfb . LineAttr = & _ba . ST_SignedTwipsMeasure { } ; _bgfb . LineAttr . Int64 = _d . Int64 ( int64 ( d / _gc . Twips ) ) ; } ; } ;
2017-10-10 17:57:44 -04:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _gga CellProperties ) X ( ) * _ba . CT_TcPr { return _gga . _adg } ;
2018-07-17 00:35:15 +03:00
2021-01-04 16:11:39 +00:00
// Validate validates the structure and in cases where it't possible, the ranges
// of elements within a document. A validation error dones't mean that the
// document won't work in MS Word or LibreOffice, but it's worth checking into.
func ( _adfa * Document ) Validate ( ) error { if _adfa == nil || _adfa . _dadc == nil { return _cd . New ( "\u0064o\u0063\u0075m\u0065\u006e\u0074\u0020n\u006f\u0074\u0020i\u006e\u0069\u0074\u0069\u0061\u006c\u0069\u007a\u0065d \u0063\u006f\u0072r\u0065\u0063t\u006c\u0079\u002c\u0020\u006e\u0069l\u0020\u0062a\u0073\u0065" ) ; } ; for _ , _bbdc := range [ ] func ( ) error { _adfa . validateTableCells , _adfa . validateBookmarks } { if _gbc := _bbdc ( ) ; _gbc != nil { return _gbc ; } ; } ; if _fgag := _adfa . _dadc . Validate ( ) ; _fgag != nil { return _fgag ; } ; return nil ; } ;
2018-07-17 00:35:15 +03:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _bgcg Footer ) X ( ) * _ba . Ftr { return _bgcg . _cged } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetHeight allows controlling the height of a row within a table.
func ( _adcf RowProperties ) SetHeight ( ht _gc . Distance , rule _ba . ST_HeightRule ) { if rule == _ba . ST_HeightRuleUnset { _adcf . _bdefd . TrHeight = nil ; } else { _eeead := _ba . NewCT_Height ( ) ; _eeead . HRuleAttr = rule ; _eeead . ValAttr = & _dc . ST_TwipsMeasure { } ; _eeead . ValAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( ht / _gc . Twips ) ) ; _adcf . _bdefd . TrHeight = [ ] * _ba . CT_Height { _eeead } ; } ; } ; func ( _eegg Paragraph ) ensurePPr ( ) { if _eegg . _acbc . PPr == nil { _eegg . _acbc . PPr = _ba . NewCT_PPr ( ) ; } ; } ; func ( _bgcbd Paragraph ) addInstrText ( _fedc string ) * _ba . CT_Text { _ebece := _bgcbd . AddRun ( ) ; _bdfd := _ebece . X ( ) ; _cfbcf := _ba . NewEG_RunInnerContent ( ) ; _bgfg := _ba . NewCT_Text ( ) ; _acaa := "\u0070\u0072\u0065\u0073\u0065\u0072\u0076\u0065" ; _bgfg . SpaceAttr = & _acaa ; _bgfg . Content = "\u0020" + _fedc + "\u0020" ; _cfbcf . InstrText = _bgfg ; _bdfd . EG_RunInnerContent = append ( _bdfd . EG_RunInnerContent , _cfbcf ) ; return _bgfg ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddRow adds a row to a table.
func ( _gaagf Table ) AddRow ( ) Row { _dgbef := _ba . NewEG_ContentRowContent ( ) ; _gaagf . _fbdg . EG_ContentRowContent = append ( _gaagf . _fbdg . EG_ContentRowContent , _dgbef ) ; _gace := _ba . NewCT_Row ( ) ; _dgbef . Tr = append ( _dgbef . Tr , _gace ) ; return Row { _gaagf . _fgdbd , _gace } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// DrawingInfo is used for keep information about a drawing wrapping a textbox where the text is located.
type DrawingInfo struct { Drawing * _ba . CT_Drawing ; Width int64 ; Height int64 ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetTargetBookmark sets the bookmark target of the hyperlink.
func ( _dccb HyperLink ) SetTargetBookmark ( bm Bookmark ) { _dccb . _edfg . AnchorAttr = _d . String ( bm . Name ( ) ) ; _dccb . _edfg . IdAttr = nil ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Style returns the style for a paragraph, or an empty string if it is unset.
func ( _ebdf Paragraph ) Style ( ) string { if _ebdf . _acbc . PPr != nil && _ebdf . _acbc . PPr . PStyle != nil { return _ebdf . _acbc . PPr . PStyle . ValAttr ; } ; return "" ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the internally wrapped *wml.CT_SectPr.
func ( _cgcd Section ) X ( ) * _ba . CT_SectPr { return _cgcd . _dddg } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetLineSpacing sets the spacing between lines in a paragraph.
func ( _ccbgd ParagraphSpacing ) SetLineSpacing ( d _gc . Distance , rule _ba . ST_LineSpacingRule ) { if rule == _ba . ST_LineSpacingRuleUnset { _ccbgd . _afefd . LineRuleAttr = _ba . ST_LineSpacingRuleUnset ; _ccbgd . _afefd . LineAttr = nil ; } else { _ccbgd . _afefd . LineRuleAttr = rule ; _ccbgd . _afefd . LineAttr = & _ba . ST_SignedTwipsMeasure { } ; _ccbgd . _afefd . LineAttr . Int64 = _d . Int64 ( int64 ( d / _gc . Twips ) ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Clear removes all of the content from within a run.
func ( _gebg Run ) Clear ( ) { _gebg . _afde . EG_RunInnerContent = nil } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// StyleID returns the style ID.
func ( _gbbfb Style ) StyleID ( ) string { if _gbbfb . _ebcb . StyleIdAttr == nil { return "" ; } ; return * _gbbfb . _ebcb . StyleIdAttr ; } ; func _deec ( _fcag * _ba . CT_Border , _afgg _ba . ST_Border , _egeb _fb . Color , _abfcb _gc . Distance ) { _fcag . ValAttr = _afgg ; _fcag . ColorAttr = & _ba . ST_HexColor { } ; if _egeb . IsAuto ( ) { _fcag . ColorAttr . ST_HexColorAuto = _ba . ST_HexColorAutoAuto ; } else { _fcag . ColorAttr . ST_HexColorRGB = _egeb . AsRGBString ( ) ; } ; if _abfcb != _gc . Zero { _fcag . SzAttr = _d . Uint64 ( uint64 ( _abfcb / _gc . Point * 8 ) ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Italic returns true if run font is italic.
func ( _gegg RunProperties ) Italic ( ) bool { _aafg := _gegg . _bdgac ; return _bfbg ( _aafg . I ) || _bfbg ( _aafg . ICs ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _facc Numbering ) X ( ) * _ba . Numbering { return _facc . _cbga } ; func ( _bddc Footnote ) id ( ) int64 { return _bddc . _dabgg . IdAttr } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SizeValue returns the value of run font size in points.
func ( _acbcc RunProperties ) SizeValue ( ) float64 { if _faafg := _acbcc . _bdgac . Sz ; _faafg != nil { _addcg := _faafg . ValAttr ; if _addcg . ST_UnsignedDecimalNumber != nil { return float64 ( * _addcg . ST_UnsignedDecimalNumber ) / 2 ; } ; } ; return 0.0 ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Style returns the style for a paragraph, or an empty string if it is unset.
func ( _dbde ParagraphProperties ) Style ( ) string { if _dbde . _gcdf . PStyle != nil { return _dbde . _gcdf . PStyle . ValAttr ; } ; return "" ; } ;
2020-10-12 13:59:12 +00:00
2021-01-04 16:11:39 +00:00
// IsBold returns true if the run has been set to bold.
func ( _dgbf RunProperties ) IsBold ( ) bool { return _dgbf . BoldValue ( ) == OnOffValueOn } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// Borders allows controlling individual cell borders.
func ( _bbf CellProperties ) Borders ( ) CellBorders { if _bbf . _adg . TcBorders == nil { _bbf . _adg . TcBorders = _ba . NewCT_TcBorders ( ) ; } ; return CellBorders { _bbf . _adg . TcBorders } ; } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// SetBottomPct sets the cell bottom margin
func ( _cb CellMargins ) SetBottomPct ( pct float64 ) { _cb . _aab . Bottom = _ba . NewCT_TblWidth ( ) ; _ade ( _cb . _aab . Bottom , pct ) ; } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// Index returns the index of the footer within the document. This is used to
// form its zip packaged filename as well as to match it with its relationship
// ID.
func ( _abag Footer ) Index ( ) int { for _gbaf , _bbcg := range _abag . _fdea . _ggdc { if _bbcg == _abag . _cged { return _gbaf ; } ; } ; return - 1 ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetTarget sets the URL target of the hyperlink.
func ( _ddga HyperLink ) SetTarget ( url string ) { _bgcge := _ddga . _bgbf . AddHyperlink ( url ) ; _ddga . _edfg . IdAttr = _d . String ( _bf . Relationship ( _bgcge ) . ID ( ) ) ; _ddga . _edfg . AnchorAttr = nil ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// IsEndnote returns a bool based on whether the run has a
// footnote or not. Returns both a bool as to whether it has
// a footnote as well as the ID of the footnote.
func ( _dcee Run ) IsEndnote ( ) ( bool , int64 ) { if _dcee . _afde . EG_RunInnerContent != nil { if _dcee . _afde . EG_RunInnerContent [ 0 ] . EndnoteReference != nil { return true , _dcee . _afde . EG_RunInnerContent [ 0 ] . EndnoteReference . IdAttr ; } ; } ; return false , 0 ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetFirstLineIndent controls the indentation of the first line in a paragraph.
func ( _bbcgb Paragraph ) SetFirstLineIndent ( m _gc . Distance ) { _bbcgb . ensurePPr ( ) ; _geec := _bbcgb . _acbc . PPr ; if _geec . Ind == nil { _geec . Ind = _ba . NewCT_Ind ( ) ; } ; if m == _gc . Zero { _geec . Ind . FirstLineAttr = nil ; } else { _geec . Ind . FirstLineAttr = & _dc . ST_TwipsMeasure { } ; _geec . Ind . FirstLineAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( m / _gc . Twips ) ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddParagraph adds a paragraph to the endnote.
func ( _agbd Endnote ) AddParagraph ( ) Paragraph { _eadag := _ba . NewEG_ContentBlockContent ( ) ; _afc := len ( _agbd . _adff . EG_BlockLevelElts [ 0 ] . EG_ContentBlockContent ) ; _agbd . _adff . EG_BlockLevelElts [ 0 ] . EG_ContentBlockContent = append ( _agbd . _adff . EG_BlockLevelElts [ 0 ] . EG_ContentBlockContent , _eadag ) ; _bgda := _ba . NewCT_P ( ) ; var _cgcg * _ba . CT_String ; if _afc != 0 { _bbge := len ( _agbd . _adff . EG_BlockLevelElts [ 0 ] . EG_ContentBlockContent [ _afc - 1 ] . P ) ; _cgcg = _agbd . _adff . EG_BlockLevelElts [ 0 ] . EG_ContentBlockContent [ _afc - 1 ] . P [ _bbge - 1 ] . PPr . PStyle ; } else { _cgcg = _ba . NewCT_String ( ) ; _cgcg . ValAttr = "\u0045n\u0064\u006e\u006f\u0074\u0065" ; } ; _eadag . P = append ( _eadag . P , _bgda ) ; _eeg := Paragraph { _agbd . _deaa , _bgda } ; _eeg . _acbc . PPr = _ba . NewCT_PPr ( ) ; _eeg . _acbc . PPr . PStyle = _cgcg ; _eeg . _acbc . PPr . RPr = _ba . NewCT_ParaRPr ( ) ; return _eeg ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// PossibleValues returns the possible values for a FormFieldTypeDropDown.
func ( _ddgcc FormField ) PossibleValues ( ) [ ] string { if _ddgcc . _edgb . DdList == nil { return nil ; } ; _ebcae := [ ] string { } ; for _ , _beeg := range _ddgcc . _edgb . DdList . ListEntry { if _beeg == nil { continue ; } ; _ebcae = append ( _ebcae , _beeg . ValAttr ) ; } ; return _ebcae ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _cece RunProperties ) X ( ) * _ba . CT_RPr { return _cece . _bdgac } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// ParagraphProperties are the properties for a paragraph.
type ParagraphProperties struct { _eddg * Document ; _gcdf * _ba . CT_PPr ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetLeft sets the cell left margin
func ( _ge CellMargins ) SetLeft ( d _gc . Distance ) { _ge . _aab . Left = _ba . NewCT_TblWidth ( ) ; _gaag ( _ge . _aab . Left , d ) ; } ; func ( _gdec * Document ) tables ( _fecb * _ba . EG_ContentBlockContent ) [ ] Table { _aed := [ ] Table { } ; for _ , _ecb := range _fecb . Tbl { _aed = append ( _aed , Table { _gdec , _ecb } ) ; for _ , _ccda := range _ecb . EG_ContentRowContent { for _ , _fdda := range _ccda . Tr { for _ , _bbdg := range _fdda . EG_ContentCellContent { for _ , _ced := range _bbdg . Tc { for _ , _afd := range _ced . EG_BlockLevelElts { for _ , _cfbb := range _afd . EG_ContentBlockContent { for _ , _bebe := range _gdec . tables ( _cfbb ) { _aed = append ( _aed , _bebe ) ; } ; } ; } ; } ; } ; } ; } ; } ; return _aed ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// RemoveParagraph removes a paragraph from a document.
func ( _egbb * Document ) RemoveParagraph ( p Paragraph ) { if _egbb . _dadc . Body == nil { return ; } ; for _ , _baca := range _egbb . _dadc . Body . EG_BlockLevelElts { for _ , _agb := range _baca . EG_ContentBlockContent { for _fcf , _bbfd := range _agb . P { if _bbfd == p . _acbc { copy ( _agb . P [ _fcf : ] , _agb . P [ _fcf + 1 : ] ) ; _agb . P = _agb . P [ 0 : len ( _agb . P ) - 1 ] ; return ; } ; } ; if _agb . Sdt != nil && _agb . Sdt . SdtContent != nil && _agb . Sdt . SdtContent . P != nil { for _bfgd , _adc := range _agb . Sdt . SdtContent . P { if _adc == p . _acbc { copy ( _agb . P [ _bfgd : ] , _agb . P [ _bfgd + 1 : ] ) ; _agb . P = _agb . P [ 0 : len ( _agb . P ) - 1 ] ; return ; } ; } ; } ; } ; } ; for _ , _afbb := range _egbb . Tables ( ) { for _ , _ddgc := range _afbb . Rows ( ) { for _ , _dba := range _ddgc . Cells ( ) { for _ , _efge := range _dba . _bd . EG_BlockLevelElts { for _ , _aabe := range _efge . EG_ContentBlockContent { for _bcfce , _dfg := range _aabe . P { if _dfg == p . _acbc { copy ( _aabe . P [ _bcfce : ] , _aabe . P [ _bcfce + 1 : ] ) ; _aabe . P = _aabe . P [ 0 : len ( _aabe . P ) - 1 ] ; return ; } ; } ; } ; } ; } ; } ; } ; for _ , _fdg := range _egbb . Headers ( ) { _fdg . RemoveParagraph ( p ) ; } ; for _ , _dceb := range _egbb . Footers ( ) { _dceb . RemoveParagraph ( p ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Section is the beginning of a new section.
type Section struct { _daag * Document ; _dddg * _ba . CT_SectPr ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetColumnBandSize sets the number of Columns in the column band
func ( _ceeg TableStyleProperties ) SetColumnBandSize ( cols int64 ) { _ceeg . _bggdc . TblStyleColBandSize = _ba . NewCT_DecimalNumber ( ) ; _ceeg . _bggdc . TblStyleColBandSize . ValAttr = cols ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Paragraphs returns the paragraphs defined in a footer.
func ( _aaba Footer ) Paragraphs ( ) [ ] Paragraph { _cafd := [ ] Paragraph { } ; for _ , _ffdc := range _aaba . _cged . EG_ContentBlockContent { for _ , _efeed := range _ffdc . P { _cafd = append ( _cafd , Paragraph { _aaba . _fdea , _efeed } ) ; } ; } ; for _ , _adaac := range _aaba . Tables ( ) { for _ , _ebea := range _adaac . Rows ( ) { for _ , _gfgf := range _ebea . Cells ( ) { _cafd = append ( _cafd , _gfgf . Paragraphs ( ) ... ) ; } ; } ; } ; return _cafd ; } ;
2017-08-28 20:56:18 -05:00
2020-12-17 22:07:08 +00:00
// SetUnderline controls underline for a run style.
2021-01-04 16:11:39 +00:00
func ( _ddea RunProperties ) SetUnderline ( style _ba . ST_Underline , c _fb . Color ) { if style == _ba . ST_UnderlineUnset { _ddea . _bdgac . U = nil ; } else { _ddea . _bdgac . U = _ba . NewCT_Underline ( ) ; _ddea . _bdgac . U . ColorAttr = & _ba . ST_HexColor { } ; _ddea . _bdgac . U . ColorAttr . ST_HexColorRGB = c . AsRGBString ( ) ; _ddea . _bdgac . U . ValAttr = style ; } ; } ;
2017-08-28 20:56:18 -05:00
2021-01-04 16:11:39 +00:00
// SetTextWrapSquare sets the text wrap to square with a given wrap type.
func ( _bcg AnchoredDrawing ) SetTextWrapSquare ( t _ba . WdST_WrapText ) { _bcg . _eg . Choice = & _ba . WdEG_WrapTypeChoice { } ; _bcg . _eg . Choice . WrapSquare = _ba . NewWdCT_WrapSquare ( ) ; _bcg . _eg . Choice . WrapSquare . WrapTextAttr = t ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetAlignment sets the alignment of a table within the page.
func ( _adfceb TableProperties ) SetAlignment ( align _ba . ST_JcTable ) { if align == _ba . ST_JcTableUnset { _adfceb . _efeg . Jc = nil ; } else { _adfceb . _efeg . Jc = _ba . NewCT_JcTable ( ) ; _adfceb . _efeg . Jc . ValAttr = align ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetColor sets the text color.
func ( _fgae RunProperties ) SetColor ( c _fb . Color ) { _fgae . _bdgac . Color = _ba . NewCT_Color ( ) ; _fgae . _bdgac . Color . ValAttr . ST_HexColorRGB = c . AsRGBString ( ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetLeftPct sets the cell left margin
func ( _eff CellMargins ) SetLeftPct ( pct float64 ) { _eff . _aab . Left = _ba . NewCT_TblWidth ( ) ; _ade ( _eff . _aab . Left , pct ) ; } ; func _ecfb ( _aaeg [ ] * _ba . CT_P , _dded * TableInfo , _bfbf * DrawingInfo ) [ ] TextItem { _gffd := [ ] TextItem { } ; for _ , _cfff := range _aaeg { _gffd = append ( _gffd , _ffcg ( _cfff , nil , _dded , _bfbf , _cfff . EG_PContent ) ... ) ; } ; return _gffd ; } ;
2020-08-23 14:15:53 +00:00
2020-12-17 22:07:08 +00:00
// EastAsiaFont returns the name of paragraph font family for East Asia.
2021-01-04 16:11:39 +00:00
func ( _agfb ParagraphProperties ) EastAsiaFont ( ) string { if _fcggg := _agfb . _gcdf . RPr . RFonts ; _fcggg != nil { if _fcggg . EastAsiaAttr != nil { return * _fcggg . EastAsiaAttr ; } ; } ; return "" ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddTable adds a new table to the document body.
func ( _efa * Document ) AddTable ( ) Table { _agg := _ba . NewEG_BlockLevelElts ( ) ; _efa . _dadc . Body . EG_BlockLevelElts = append ( _efa . _dadc . Body . EG_BlockLevelElts , _agg ) ; _dgd := _ba . NewEG_ContentBlockContent ( ) ; _agg . EG_ContentBlockContent = append ( _agg . EG_ContentBlockContent , _dgd ) ; _gd := _ba . NewCT_Tbl ( ) ; _dgd . Tbl = append ( _dgd . Tbl , _gd ) ; return Table { _efa , _gd } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetBottom sets the cell bottom margin
func ( _beg CellMargins ) SetBottom ( d _gc . Distance ) { _beg . _aab . Bottom = _ba . NewCT_TblWidth ( ) ; _gaag ( _beg . _aab . Bottom , d ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetRightPct sets the cell right margin
func ( _bg CellMargins ) SetRightPct ( pct float64 ) { _bg . _aab . Right = _ba . NewCT_TblWidth ( ) ; _ade ( _bg . _aab . Right , pct ) ; } ; func _gaag ( _bfa * _ba . CT_TblWidth , _fdff _gc . Distance ) { _bfa . TypeAttr = _ba . ST_TblWidthDxa ; _bfa . WAttr = & _ba . ST_MeasurementOrPercent { } ; _bfa . WAttr . ST_DecimalNumberOrPercent = & _ba . ST_DecimalNumberOrPercent { } ; _bfa . WAttr . ST_DecimalNumberOrPercent . ST_UnqualifiedPercentage = _d . Int64 ( int64 ( _fdff / _gc . Dxa ) ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// RunProperties controls run styling properties
type RunProperties struct { _bdgac * _ba . CT_RPr } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// GetImage returns the ImageRef associated with an InlineDrawing.
func ( _eafge InlineDrawing ) GetImage ( ) ( _bf . ImageRef , bool ) { _caec := _eafge . _gdece . Graphic . GraphicData . Any ; if len ( _caec ) > 0 { _dbe , _agec := _caec [ 0 ] . ( * _bc . Pic ) ; if _agec { if _dbe . BlipFill != nil && _dbe . BlipFill . Blip != nil && _dbe . BlipFill . Blip . EmbedAttr != nil { return _eafge . _ccadc . GetImageByRelID ( * _dbe . BlipFill . Blip . EmbedAttr ) ; } ; } ; } ; return _bf . ImageRef { } , false ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// GetColor returns the color.Color object representing the run color.
func ( _ecbg RunProperties ) GetColor ( ) _fb . Color { if _fadac := _ecbg . _bdgac . Color ; _fadac != nil { _fcbd := _fadac . ValAttr ; if _fcbd . ST_HexColorRGB != nil { return _fb . FromHex ( * _fcbd . ST_HexColorRGB ) ; } ; } ; return _fb . Color { } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// InitializeDefault constructs the default styles.
func ( _fgcgc Styles ) InitializeDefault ( ) { _fgcgc . initializeDocDefaults ( ) ; _fgcgc . initializeStyleDefaults ( ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Close closes the document, removing any temporary files that might have been
// created when opening a document.
func ( _bdga * Document ) Close ( ) error { if _bdga . TmpPath != "" { return _ca . RemoveAll ( _bdga . TmpPath ) ; } ; return nil ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// TableInfo is used for keep information about a table, a row and a cell where the text is located.
type TableInfo struct { Table * _ba . CT_Tbl ; Row * _ba . CT_Row ; Cell * _ba . CT_Tc ; RowIndex int ; ColIndex int ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddCheckBox adds checkbox form field to the paragraph and returns it.
func ( _gfda Paragraph ) AddCheckBox ( name string ) FormField { _bfdad := _gfda . addFldCharsForField ( name , "\u0046\u004f\u0052M\u0043\u0048\u0045\u0043\u004b\u0042\u004f\u0058" ) ; _bfdad . _edgb . CheckBox = _ba . NewCT_FFCheckBox ( ) ; return _bfdad ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// ComplexSizeMeasure returns font with its measure which can be mm, cm, in, pt, pc or pi.
func ( _ddab RunProperties ) ComplexSizeMeasure ( ) string { if _gfcgb := _ddab . _bdgac . SzCs ; _gfcgb != nil { _ddedc := _gfcgb . ValAttr ; if _ddedc . ST_PositiveUniversalMeasure != nil { return * _ddedc . ST_PositiveUniversalMeasure ; } ; } ; return "" ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetStrikeThrough sets the run to strike-through.
func ( _cabd RunProperties ) SetStrikeThrough ( b bool ) { if ! b { _cabd . _bdgac . Strike = nil ; } else { _cabd . _bdgac . Strike = _ba . NewCT_OnOff ( ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// TableConditionalFormatting controls the conditional formatting within a table
// style.
type TableConditionalFormatting struct { _dddb * _ba . CT_TblStylePr } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Properties returns the numbering level paragraph properties.
func ( _eeaca NumberingLevel ) Properties ( ) ParagraphStyleProperties { if _eeaca . _bbgd . PPr == nil { _eeaca . _bbgd . PPr = _ba . NewCT_PPrGeneral ( ) ; } ; return ParagraphStyleProperties { _eeaca . _bbgd . PPr } ; } ;
2020-10-12 13:59:12 +00:00
2021-01-04 16:11:39 +00:00
// AddFieldWithFormatting adds a field (automatically computed text) to the
// document with field specifc formatting.
func ( _egada Run ) AddFieldWithFormatting ( code string , fmt string , isDirty bool ) { _cecf := _egada . newIC ( ) ; _cecf . FldChar = _ba . NewCT_FldChar ( ) ; _cecf . FldChar . FldCharTypeAttr = _ba . ST_FldCharTypeBegin ; if isDirty { _cecf . FldChar . DirtyAttr = & _dc . ST_OnOff { } ; _cecf . FldChar . DirtyAttr . Bool = _d . Bool ( true ) ; } ; _cecf = _egada . newIC ( ) ; _cecf . InstrText = _ba . NewCT_Text ( ) ; if fmt != "" { _cecf . InstrText . Content = code + "\u0020" + fmt ; } else { _cecf . InstrText . Content = code ; } ; _cecf = _egada . newIC ( ) ; _cecf . FldChar = _ba . NewCT_FldChar ( ) ; _cecf . FldChar . FldCharTypeAttr = _ba . ST_FldCharTypeEnd ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SaveToFile writes the document out to a file.
func ( _dde * Document ) SaveToFile ( path string ) error { _fdc , _bde := _a . Create ( path ) ; if _bde != nil { return _bde ; } ; defer _fdc . Close ( ) ; return _dde . Save ( _fdc ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetKerning sets the run's font kerning.
func ( _bgec RunProperties ) SetKerning ( size _gc . Distance ) { _bgec . _bdgac . Kern = _ba . NewCT_HpsMeasure ( ) ; _bgec . _bdgac . Kern . ValAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( size / _gc . HalfPoint ) ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddCell adds a cell to a row and returns it
func ( _cbgc Row ) AddCell ( ) Cell { _cggfa := _ba . NewEG_ContentCellContent ( ) ; _cbgc . _abdcd . EG_ContentCellContent = append ( _cbgc . _abdcd . EG_ContentCellContent , _cggfa ) ; _dffc := _ba . NewCT_Tc ( ) ; _cggfa . Tc = append ( _cggfa . Tc , _dffc ) ; return Cell { _cbgc . _ebfa , _dffc } ; } ; func _gea ( _bfbfa string ) mergeFieldInfo { _gadb := [ ] string { } ; _fada := _dg . Buffer { } ; _cefe := - 1 ; for _fcfbf , _efbc := range _bfbfa { switch _efbc { case ' ' : if _fada . Len ( ) != 0 { _gadb = append ( _gadb , _fada . String ( ) ) ; } ; _fada . Reset ( ) ; case '"' : if _cefe != - 1 { _gadb = append ( _gadb , _bfbfa [ _cefe + 1 : _fcfbf ] ) ; _cefe = - 1 ; } else { _cefe = _fcfbf ; } ; default : _fada . WriteRune ( _efbc ) ; } ; } ; if _fada . Len ( ) != 0 { _gadb = append ( _gadb , _fada . String ( ) ) ; } ; _gddd := mergeFieldInfo { } ; for _bacg := 0 ; _bacg < len ( _gadb ) - 1 ; _bacg ++ { _cdcb := _gadb [ _bacg ] ; switch _cdcb { case "\u004d\u0045\u0052\u0047\u0045\u0046\u0049\u0045\u004c\u0044" : _gddd . _cfda = _gadb [ _bacg + 1 ] ; _bacg ++ ; case "\u005c\u0066" : _gddd . _cabe = _gadb [ _bacg + 1 ] ; _bacg ++ ; case "\u005c\u0062" : _gddd . _cda = _gadb [ _bacg + 1 ] ; _bacg ++ ; case "\u005c\u002a" : switch _gadb [ _bacg + 1 ] { case "\u0055\u0070\u0070e\u0072" : _gddd . _aafb = true ; case "\u004c\u006f\u0077e\u0072" : _gddd . _gfcae = true ; case "\u0043\u0061\u0070\u0073" : _gddd . _eeac = true ; case "\u0046\u0069\u0072\u0073\u0074\u0043\u0061\u0070" : _gddd . _faaf = true ; } ; _bacg ++ ; } ; } ; return _gddd ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetOrigin sets the origin of the image. It defaults to ST_RelFromHPage and
// ST_RelFromVPage
func ( _cae AnchoredDrawing ) SetOrigin ( h _ba . WdST_RelFromH , v _ba . WdST_RelFromV ) { _cae . _eg . PositionH . RelativeFromAttr = h ; _cae . _eg . PositionV . RelativeFromAttr = v ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// ExtractText returns text from the document as a DocText object.
func ( _fca * Document ) ExtractText ( ) * DocText { _cfbf := [ ] TextItem { } ; for _ , _cafe := range _fca . _dadc . Body . EG_BlockLevelElts { _cfbf = append ( _cfbf , _bgcc ( _cafe , nil ) ... ) ; } ; return & DocText { Items : _cfbf } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// RemoveParagraph removes a paragraph from the footnote.
func ( _fcdc Footnote ) RemoveParagraph ( p Paragraph ) { for _ , _accf := range _fcdc . content ( ) { for _eeef , _dafg := range _accf . P { if _dafg == p . _acbc { copy ( _accf . P [ _eeef : ] , _accf . P [ _eeef + 1 : ] ) ; _accf . P = _accf . P [ 0 : len ( _accf . P ) - 1 ] ; return ; } ; } ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Append appends a document d0 to a document d1. All settings, headers and footers remain the same as in the document d0 if they exist there, otherwise they are taken from the d1.
func ( _ggce * Document ) Append ( d1orig * Document ) error { _efaf , _gfe := d1orig . Copy ( ) ; if _gfe != nil { return _gfe ; } ; _ggce . DocBase = _ggce . DocBase . Append ( _efaf . DocBase ) ; if _efaf . _dadc . ConformanceAttr != _dc . ST_ConformanceClassStrict { _ggce . _dadc . ConformanceAttr = _efaf . _dadc . ConformanceAttr ; } ; _aea := _ggce . _aeg . X ( ) . Relationship ; _edg := _efaf . _aeg . X ( ) . Relationship ; _fdedd := _efaf . _dadc . Body ; _fbeb := map [ string ] string { } ; _edcd := map [ int64 ] int64 { } ; _cgef := map [ int64 ] int64 { } ; for _ , _ebfe := range _edg { _cffeg := true ; _effc := _ebfe . IdAttr ; _bfdb := _ebfe . TargetAttr ; _gfga := _ebfe . TypeAttr ; _eab := _gfga == _d . ImageType ; _cce := _gfga == _d . HyperLinkType ; var _eee string ; for _ , _gce := range _aea { if _gce . TypeAttr == _gfga && _gce . TargetAttr == _bfdb { _cffeg = false ; _eee = _gce . IdAttr ; break ; } ; } ; if _eab { _ddfa := "\u0077\u006f\u0072d\u002f" + _bfdb ; for _ , _cbaf := range _efaf . DocBase . Images { if _cbaf . Target ( ) == _ddfa { _ebee , _agfg := _bf . ImageFromStorage ( _cbaf . Path ( ) ) ; if _agfg != nil { return _agfg ; } ; _gfce , _agfg := _ggce . AddImage ( _ebee ) ; if _agfg != nil { return _agfg ; } ; _eee = _gfce . RelID ( ) ; break ; } ; } ; } else if _cffeg { if _cce { _gegb := _ggce . _aeg . AddHyperlink ( _bfdb ) ; _eee = _bf . Relationship ( _gegb ) . ID ( ) ; } else { _gad := _ggce . _aeg . AddRelationship ( _bfdb , _gfga ) ; _eee = _gad . X ( ) . IdAttr ; } ; } ; if _effc != _eee { _fbeb [ _effc ] = _eee ; } ; } ; if _fdedd . SectPr != nil { for _ , _dged := range _fdedd . SectPr . EG_HdrFtrReferences { if _dged . HeaderReference != nil { if _cdfb , _dfbg := _fbeb [ _dged . HeaderReference . IdAttr ] ; _dfbg { _dged . HeaderReference . IdAttr = _cdfb ; _ggce . _bec = append ( _ggce . _bec , _bf . NewRelationships ( ) ) ; } ; } else if _dged . FooterReference != nil { if _eef , _gedg := _fbeb [ _dged . FooterReference . IdAttr ] ; _gedg { _dged . FooterReference . IdAttr = _eef ; _ggce . _cbb = append ( _ggce . _cbb , _bf . NewRelationships ( ) ) ; } ; } ; } ; } ; _bbc , _agab := _ggce . _bed , _efaf . _bed ; if _bbc != nil { if _agab != nil { if _bbc . Endnote != nil { if _agab . Endnote != nil { _gcbe := int64 ( len ( _bbc . Endnote ) + 1 ) ; for _ , _ecac := range _agab . Endnote { _geba := _ecac . IdAttr ; if _geba > 0 { _ecac . IdAttr = _gcbe ; _bbc . Endnote = append ( _bbc . Endnote , _ecac ) ; _cgef [ _geba ] = _gcbe ; _gcbe ++ ; } ; } ; } ; } else { _bbc . Endnote = _agab . Endnote ; } ; } ; } else if _agab != nil { _bbc = _agab ; } ; _ggce . _bed = _bbc ; _ceec , _abba := _ggce . _bgd , _efaf . _bgd ; if _ceec != nil { if _abba != nil { if _ceec . Footnote != nil { if _abba . Footnote != nil { _eaae := int64 ( len ( _ceec . Footnote ) + 1 ) ; for _ , _dcce := range _abba . Footnote { _fcda := _dcce . IdAttr ; if _fcda > 0 { _dcce . IdAttr = _eaae ; _ceec . Footnote = append ( _ceec . Footnote , _dcce ) ; _edcd [ _fcda ] = _eaae ; _eaae ++ ; } ; } ; } ; } else { _ceec . Footnote = _abba . Footnote ; } ; } ; } else if _abba != nil { _ceec = _abba ; } ; _ggce . _bgd = _ceec ; for _ , _cfae := range _fdedd . EG_BlockLevelElts { for _ , _dfee := range _cfae . EG_ContentBlockContent { for _ , _aabf := range _dfee . P { _bbgg ( _aabf , _fbeb ) ; _fbagb ( _aabf , _fbeb ) ; _addfd ( _aabf , _edcd , _cgef ) ; } ; for _ , _ccea := range _dfee . Tbl { _cbdb ( _ccea , _fbeb ) ; _aedf ( _ccea , _fbeb ) ; _eggc ( _ccea , _edcd , _cgef ) ; } ; } ; } ; _ggce . _dadc . Body . EG_BlockLevelElts = append ( _ggce . _dadc . Body . EG_BlockLevelElts , _efaf . _dadc . Body . EG_BlockLevelElts ... ) ; if _ggce . _dadc . Body . SectPr == nil { _ggce . _dadc . Body . SectPr = _efaf . _dadc . Body . SectPr ; } else { var _cggc , _ccfe bool ; for _ , _dbdd := range _ggce . _dadc . Body . SectPr . EG_HdrFtrReferences { if _dbdd . HeaderReference != nil { _cggc = true ; } else if _dbdd . FooterReference != nil { _ccfe = true ; } ; } ; if ! _cggc { for _ , _becc := range _efaf . _dadc . Body . SectPr . EG_HdrFtrReferences { if _becc . HeaderReference != nil { _ggce . _dadc . Body . SectPr . EG_HdrFtrReferences = append ( _ggce . _dadc . Body . SectPr . EG_HdrFtrReferences , _becc ) ; break ; } ; } ; } ; if ! _ccfe { for _ , _bbb := range _efaf . _dadc . Body . SectPr . EG_HdrFtrReferences { if _bbb . FooterReference != nil { _ggce . _dadc . Body . SectPr . EG_HdrFtrReferences = append ( _ggce . _dadc . Body . SectPr . EG_HdrFtrReferences , _bbb ) ; break ; } ; } ; } ; if _ggce . _dadc . Body . SectPr . Cols == nil && _efaf . _dadc . Body . SectPr . Cols != nil { _ggce . _dadc . Body . SectPr . Cols = _
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddTextInput adds text input form field to the paragraph and returns it.
func ( _ecfbd Paragraph ) AddTextInput ( name string ) FormField { _acbd := _ecfbd . addFldCharsForField ( name , "\u0046\u004f\u0052\u004d\u0054\u0045\u0058\u0054" ) ; _acbd . _edgb . TextInput = _ba . NewCT_FFTextInput ( ) ; return _acbd ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Clear clears all content within a header
func ( _aecaf Header ) Clear ( ) { _aecaf . _gcdbe . EG_ContentBlockContent = nil } ; func ( _cfec Document ) mergeFields ( ) [ ] mergeFieldInfo { _eede := [ ] Paragraph { } ; _dfea := [ ] mergeFieldInfo { } ; for _ , _acag := range _cfec . Tables ( ) { for _ , _cceb := range _acag . Rows ( ) { for _ , _ceaa := range _cceb . Cells ( ) { _eede = append ( _eede , _ceaa . Paragraphs ( ) ... ) ; } ; } ; } ; _eede = append ( _eede , _cfec . Paragraphs ( ) ... ) ; for _ , _geed := range _eede { _gcde := _geed . Runs ( ) ; _cfcc := - 1 ; _aggcd := - 1 ; _bgab := - 1 ; _gefcf := mergeFieldInfo { } ; for _ , _eecdb := range _geed . _acbc . EG_PContent { for _ , _fabbd := range _eecdb . FldSimple { if _f . Contains ( _fabbd . InstrAttr , "\u004d\u0045\u0052\u0047\u0045\u0046\u0049\u0045\u004c\u0044" ) { _gaaa := _gea ( _fabbd . InstrAttr ) ; _gaaa . _gbeb = true ; _gaaa . _deadc = _geed ; _gaaa . _ceca = _eecdb ; _dfea = append ( _dfea , _gaaa ) ; } ; } ; } ; for _fgfbb := 0 ; _fgfbb < len ( _gcde ) ; _fgfbb ++ { _agag := _gcde [ _fgfbb ] ; for _ , _beed := range _agag . X ( ) . EG_RunInnerContent { if _beed . FldChar != nil { switch _beed . FldChar . FldCharTypeAttr { case _ba . ST_FldCharTypeBegin : _cfcc = _fgfbb ; case _ba . ST_FldCharTypeSeparate : _aggcd = _fgfbb ; case _ba . ST_FldCharTypeEnd : _bgab = _fgfbb ; if _gefcf . _cfda != "" { _gefcf . _deadc = _geed ; _gefcf . _dbcg = _cfcc ; _gefcf . _abbf = _bgab ; _gefcf . _cgac = _aggcd ; _dfea = append ( _dfea , _gefcf ) ; } ; _cfcc = - 1 ; _aggcd = - 1 ; _bgab = - 1 ; _gefcf = mergeFieldInfo { } ; } ; } else if _beed . InstrText != nil && _f . Contains ( _beed . InstrText . Content , "\u004d\u0045\u0052\u0047\u0045\u0046\u0049\u0045\u004c\u0044" ) { if _cfcc != - 1 && _bgab == - 1 { _gefcf = _gea ( _beed . InstrText . Content ) ; } ; } ; } ; } ; } ; return _dfea ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// GetFooter gets a section Footer for given type
func ( _fcdae Section ) GetFooter ( t _ba . ST_HdrFtr ) ( Footer , bool ) { for _ , _fbcc := range _fcdae . _dddg . EG_HdrFtrReferences { if _fbcc . FooterReference . TypeAttr == t { for _ , _dfeb := range _fcdae . _daag . Footers ( ) { _bafbe := _fcdae . _daag . _aeg . FindRIDForN ( _dfeb . Index ( ) , _d . FooterType ) ; if _bafbe == _fbcc . FooterReference . IdAttr { return _dfeb , true ; } ; } ; } ; } ; return Footer { } , false ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// OpenTemplate opens a document, removing all content so it can be used as a
// template. Since Word removes unused styles from a document upon save, to
// create a template in Word add a paragraph with every style of interest. When
// opened with OpenTemplate the document's styles will be available but the
// content will be gone.
func OpenTemplate ( filename string ) ( * Document , error ) { _dabe , _agfcg := Open ( filename ) ; if _agfcg != nil { return nil , _agfcg ; } ; _dabe . _dadc . Body = _ba . NewCT_Body ( ) ; return _dabe , nil ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetShading controls the cell shading.
func ( _bcb CellProperties ) SetShading ( shd _ba . ST_Shd , foreground , fill _fb . Color ) { if shd == _ba . ST_ShdUnset { _bcb . _adg . Shd = nil ; } else { _bcb . _adg . Shd = _ba . NewCT_Shd ( ) ; _bcb . _adg . Shd . ValAttr = shd ; _bcb . _adg . Shd . ColorAttr = & _ba . ST_HexColor { } ; if foreground . IsAuto ( ) { _bcb . _adg . Shd . ColorAttr . ST_HexColorAuto = _ba . ST_HexColorAutoAuto ; } else { _bcb . _adg . Shd . ColorAttr . ST_HexColorRGB = foreground . AsRGBString ( ) ; } ; _bcb . _adg . Shd . FillAttr = & _ba . ST_HexColor { } ; if fill . IsAuto ( ) { _bcb . _adg . Shd . FillAttr . ST_HexColorAuto = _ba . ST_HexColorAutoAuto ; } else { _bcb . _adg . Shd . FillAttr . ST_HexColorRGB = fill . AsRGBString ( ) ; } ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddField adds a field (automatically computed text) to the document.
func ( _eefc Run ) AddField ( code string ) { _eefc . AddFieldWithFormatting ( code , "" , true ) } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetInsideHorizontal sets the interior horizontal borders to a specified type, color and thickness.
func ( _eec CellBorders ) SetInsideHorizontal ( t _ba . ST_Border , c _fb . Color , thickness _gc . Distance ) { _eec . _fbd . InsideH = _ba . NewCT_Border ( ) ; _deec ( _eec . _fbd . InsideH , t , c , thickness ) ; } ;
2020-10-12 13:59:12 +00:00
2021-01-04 16:11:39 +00:00
// SetKeepOnOnePage controls if all lines in a paragraph are kept on the same
// page.
func ( _cedf ParagraphStyleProperties ) SetKeepOnOnePage ( b bool ) { if ! b { _cedf . _gdb . KeepLines = nil ; } else { _cedf . _gdb . KeepLines = _ba . NewCT_OnOff ( ) ; } ; } ; func ( _cbdgg Paragraph ) addFldCharsForField ( _dgedf , _bddcb string ) FormField { _fabc := _cbdgg . addBeginFldChar ( _dgedf ) ; _dgde := FormField { _edgb : _fabc } ; _bbga := _cbdgg . _dcbe . Bookmarks ( ) ; _gdfb := int64 ( len ( _bbga ) ) ; if _dgedf != "" { _cbdgg . addStartBookmark ( _gdfb , _dgedf ) ; } ; _cbdgg . addInstrText ( _bddcb ) ; _cbdgg . addSeparateFldChar ( ) ; if _bddcb == "\u0046\u004f\u0052\u004d\u0054\u0045\u0058\u0054" { _feagfg := _cbdgg . AddRun ( ) ; _caga := _ba . NewEG_RunInnerContent ( ) ; _feagfg . _afde . EG_RunInnerContent = [ ] * _ba . EG_RunInnerContent { _caga } ; _dgde . _cggf = _caga ; } ; _cbdgg . addEndFldChar ( ) ; if _dgedf != "" { _cbdgg . addEndBookmark ( _gdfb ) ; } ; return _dgde ; } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// GetDocRelTargetByID returns TargetAttr of document relationship given its IdAttr.
func ( _abfe * Document ) GetDocRelTargetByID ( idAttr string ) string { for _ , _eeaae := range _abfe . _aeg . X ( ) . Relationship { if _eeaae . IdAttr == idAttr { return _eeaae . TargetAttr ; } ; } ; return "" ; } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// ItalicValue returns the precise nature of the italic setting (unset, off or on).
func ( _ffda RunProperties ) ItalicValue ( ) OnOffValue { return _ffge ( _ffda . _bdgac . I ) } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// TableConditionalFormatting returns a conditional formatting object of a given
// type. Calling this method repeatedly will return the same object.
func ( _bagc Style ) TableConditionalFormatting ( typ _ba . ST_TblStyleOverrideType ) TableConditionalFormatting { for _ , _cbgcg := range _bagc . _ebcb . TblStylePr { if _cbgcg . TypeAttr == typ { return TableConditionalFormatting { _cbgcg } ; } ; } ; _caae := _ba . NewCT_TblStylePr ( ) ; _caae . TypeAttr = typ ; _bagc . _ebcb . TblStylePr = append ( _bagc . _ebcb . TblStylePr , _caae ) ; return TableConditionalFormatting { _caae } ; } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _gcef Footnote ) X ( ) * _ba . CT_FtnEdn { return _gcef . _dabgg } ; func ( _febe Paragraph ) addStartBookmark ( _cegd int64 , _dfbef string ) * _ba . CT_Bookmark { _ggca := _ba . NewEG_PContent ( ) ; _febe . _acbc . EG_PContent = append ( _febe . _acbc . EG_PContent , _ggca ) ; _aaag := _ba . NewEG_ContentRunContent ( ) ; _gcfcg := _ba . NewEG_RunLevelElts ( ) ; _gfgb := _ba . NewEG_RangeMarkupElements ( ) ; _fgdd := _ba . NewCT_Bookmark ( ) ; _fgdd . NameAttr = _dfbef ; _fgdd . IdAttr = _cegd ; _gfgb . BookmarkStart = _fgdd ; _ggca . EG_ContentRunContent = append ( _ggca . EG_ContentRunContent , _aaag ) ; _aaag . EG_RunLevelElts = append ( _aaag . EG_RunLevelElts , _gcfcg ) ; _gcfcg . EG_RangeMarkupElements = append ( _gcfcg . EG_RangeMarkupElements , _gfgb ) ; return _fgdd ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Caps returns true if paragraph font is capitalized.
func ( _adfg ParagraphProperties ) Caps ( ) bool { return _bfbg ( _adfg . _gcdf . RPr . Caps ) } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Clear clears the styes.
func ( _cdfe Styles ) Clear ( ) { _cdfe . _eagfa . DocDefaults = nil ; _cdfe . _eagfa . LatentStyles = nil ; _cdfe . _eagfa . Style = nil ; } ; func _bfbg ( _ccc * _ba . CT_OnOff ) bool { return _ccc != nil } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// MailMerge finds mail merge fields and replaces them with the text provided. It also removes
// the mail merge source info from the document settings.
func ( _ccae * Document ) MailMerge ( mergeContent map [ string ] string ) { _acgb := _ccae . mergeFields ( ) ; _cfde := map [ Paragraph ] [ ] Run { } ; for _ , _gdfe := range _acgb { _ffbc , _bdad := mergeContent [ _gdfe . _cfda ] ; if _bdad { if _gdfe . _aafb { _ffbc = _f . ToUpper ( _ffbc ) ; } else if _gdfe . _gfcae { _ffbc = _f . ToLower ( _ffbc ) ; } else if _gdfe . _eeac { _ffbc = _f . Title ( _ffbc ) ; } else if _gdfe . _faaf { _bdba := _dg . Buffer { } ; for _cebe , _gecd := range _ffbc { if _cebe == 0 { _bdba . WriteRune ( _c . ToUpper ( _gecd ) ) ; } else { _bdba . WriteRune ( _gecd ) ; } ; } ; _ffbc = _bdba . String ( ) ; } ; if _ffbc != "" && _gdfe . _cda != "" { _ffbc = _gdfe . _cda + _ffbc ; } ; if _ffbc != "" && _gdfe . _cabe != "" { _ffbc = _ffbc + _gdfe . _cabe ; } ; } ; if _gdfe . _gbeb { if len ( _gdfe . _ceca . FldSimple ) == 1 && len ( _gdfe . _ceca . FldSimple [ 0 ] . EG_PContent ) == 1 && len ( _gdfe . _ceca . FldSimple [ 0 ] . EG_PContent [ 0 ] . EG_ContentRunContent ) == 1 { _aaecc := & _ba . EG_ContentRunContent { } ; _aaecc . R = _gdfe . _ceca . FldSimple [ 0 ] . EG_PContent [ 0 ] . EG_ContentRunContent [ 0 ] . R ; _gdfe . _ceca . FldSimple = nil ; _cbdg := Run { _ccae , _aaecc . R } ; _cbdg . ClearContent ( ) ; _cbdg . AddText ( _ffbc ) ; _gdfe . _ceca . EG_ContentRunContent = append ( _gdfe . _ceca . EG_ContentRunContent , _aaecc ) ; } ; } else { _effd := _gdfe . _deadc . Runs ( ) ; for _fbagg := _gdfe . _dbcg ; _fbagg <= _gdfe . _abbf ; _fbagg ++ { if _fbagg == _gdfe . _cgac + 1 { _effd [ _fbagg ] . ClearContent ( ) ; _effd [ _fbagg ] . AddText ( _ffbc ) ; } else { _cfde [ _gdfe . _deadc ] = append ( _cfde [ _gdfe . _deadc ] , _effd [ _fbagg ] ) ; } ; } ; } ; } ; for _fbg , _baba := range _cfde { for _ , _eabea := range _baba { _fbg . RemoveRun ( _eabea ) ; } ; } ; _ccae . Settings . RemoveMailMerge ( ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// OnOffValue represents an on/off value that can also be unset
type OnOffValue byte ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddFooter creates a Footer associated with the document, but doesn't add it
// to the document for display.
func ( _gge * Document ) AddFooter ( ) Footer { _gac := _ba . NewFtr ( ) ; _gge . _ggdc = append ( _gge . _ggdc , _gac ) ; _fbe := _cfb . Sprintf ( "\u0066\u006f\u006ft\u0065\u0072\u0025\u0064\u002e\u0078\u006d\u006c" , len ( _gge . _ggdc ) ) ; _gge . _aeg . AddRelationship ( _fbe , _d . FooterType ) ; _gge . ContentTypes . AddOverride ( "\u002f\u0077\u006f\u0072\u0064\u002f" + _fbe , "\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u0076\u006e\u0064.\u006f\u0070\u0065\u006ex\u006d\u006c\u0066\u006f\u0072m\u0061\u0074\u0073\u002d\u006f\u0066\u0066\u0069\u0063\u0065\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u002e\u0077\u006f\u0072\u0064\u0070\u0072\u006f\u0063\u0065\u0073\u0073\u0069n\u0067\u006d\u006c\u002e\u0066\u006f\u006f\u0074e\u0072\u002b\u0078\u006d\u006c" ) ; _gge . _cbb = append ( _gge . _cbb , _bf . NewRelationships ( ) ) ; return Footer { _gge , _gac } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// InlineDrawing is an inlined image within a run.
type InlineDrawing struct { _ccadc * Document ; _gdece * _ba . WdInline ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Spacing returns the paragraph spacing settings.
func ( _eeed ParagraphProperties ) Spacing ( ) ParagraphSpacing { if _eeed . _gcdf . Spacing == nil { _eeed . _gcdf . Spacing = _ba . NewCT_Spacing ( ) ; } ; return ParagraphSpacing { _eeed . _gcdf . Spacing } ; } ; const ( FormFieldTypeUnknown FormFieldType = iota ; FormFieldTypeText ; FormFieldTypeCheckBox ; FormFieldTypeDropDown ; ) ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Definitions returns the defined numbering definitions.
func ( _ddagf Numbering ) Definitions ( ) [ ] NumberingDefinition { _efgc := [ ] NumberingDefinition { } ; for _ , _eccc := range _ddagf . _cbga . AbstractNum { _efgc = append ( _efgc , NumberingDefinition { _eccc } ) ; } ; return _efgc ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// InsertRunAfter inserts a run in the paragraph after the relative run.
func ( _fdcf Paragraph ) InsertRunAfter ( relativeTo Run ) Run { return _fdcf . insertRun ( relativeTo , false ) } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Tables returns the tables defined in the footer.
func ( _acec Footer ) Tables ( ) [ ] Table { _ccaa := [ ] Table { } ; if _acec . _cged == nil { return nil ; } ; for _ , _ddd := range _acec . _cged . EG_ContentBlockContent { for _ , _deb := range _acec . _fdea . tables ( _ddd ) { _ccaa = append ( _ccaa , _deb ) ; } ; } ; return _ccaa ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddStyle adds a new empty style.
func ( _efcg Styles ) AddStyle ( styleID string , t _ba . ST_StyleType , isDefault bool ) Style { _cabb := _ba . NewCT_Style ( ) ; _cabb . TypeAttr = t ; if isDefault { _cabb . DefaultAttr = & _dc . ST_OnOff { } ; _cabb . DefaultAttr . Bool = _d . Bool ( isDefault ) ; } ; _cabb . StyleIdAttr = _d . String ( styleID ) ; _efcg . _eagfa . Style = append ( _efcg . _eagfa . Style , _cabb ) ; return Style { _cabb } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _dccg Styles ) X ( ) * _ba . Styles { return _dccg . _eagfa } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _agd * Document ) X ( ) * _ba . Document { return _agd . _dadc } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Footnote is an individual footnote reference within the document.
type Footnote struct { _abfeg * Document ; _dabgg * _ba . CT_FtnEdn ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetStartIndent controls the start indentation.
func ( _aafd ParagraphProperties ) SetStartIndent ( m _gc . Distance ) { if _aafd . _gcdf . Ind == nil { _aafd . _gcdf . Ind = _ba . NewCT_Ind ( ) ; } ; if m == _gc . Zero { _aafd . _gcdf . Ind . StartAttr = nil ; } else { _aafd . _gcdf . Ind . StartAttr = & _ba . ST_SignedTwipsMeasure { } ; _aafd . _gcdf . Ind . StartAttr . Int64 = _d . Int64 ( int64 ( m / _gc . Twips ) ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetEastAsiaTheme sets the font East Asia Theme.
func ( _begc Fonts ) SetEastAsiaTheme ( t _ba . ST_Theme ) { _begc . _ffb . EastAsiaThemeAttr = t } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// GetImage returns the ImageRef associated with an AnchoredDrawing.
func ( _cfg AnchoredDrawing ) GetImage ( ) ( _bf . ImageRef , bool ) { _bb := _cfg . _eg . Graphic . GraphicData . Any ; if len ( _bb ) > 0 { _cg , _dd := _bb [ 0 ] . ( * _bc . Pic ) ; if _dd { if _cg . BlipFill != nil && _cg . BlipFill . Blip != nil && _cg . BlipFill . Blip . EmbedAttr != nil { return _cfg . _af . GetImageByRelID ( * _cg . BlipFill . Blip . EmbedAttr ) ; } ; } ; } ; return _bf . ImageRef { } , false ; } ; const ( FieldCurrentPage = "\u0050\u0041\u0047\u0045" ; FieldNumberOfPages = "\u004e\u0055\u004d\u0050\u0041\u0047\u0045\u0053" ; FieldDate = "\u0044\u0041\u0054\u0045" ; FieldCreateDate = "\u0043\u0052\u0045\u0041\u0054\u0045\u0044\u0041\u0054\u0045" ; FieldEditTime = "\u0045\u0044\u0049\u0054\u0054\u0049\u004d\u0045" ; FieldPrintDate = "\u0050R\u0049\u004e\u0054\u0044\u0041\u0054E" ; FieldSaveDate = "\u0053\u0041\u0056\u0045\u0044\u0041\u0054\u0045" ; FieldTIme = "\u0054\u0049\u004d\u0045" ; FieldTOC = "\u0054\u004f\u0043" ; ) ; func _afe ( _agc * _ba . CT_Tbl , _efb * _ba . CT_P , _ggb bool ) * _ba . CT_Tbl { for _ , _cbd := range _agc . EG_ContentRowContent { for _ , _eadg := range _cbd . Tr { for _ , _ebd := range _eadg . EG_ContentCellContent { for _ , _gfa := range _ebd . Tc { for _aef , _dcd := range _gfa . EG_BlockLevelElts { for _ , _de := range _dcd . EG_ContentBlockContent { for _bdd , _gae := range _de . P { if _gae == _efb { _fgbb := _ba . NewEG_BlockLevelElts ( ) ; _bgc := _ba . NewEG_ContentBlockContent ( ) ; _fgbb . EG_ContentBlockContent = append ( _fgbb . EG_ContentBlockContent , _bgc ) ; _fcc := _ba . NewCT_Tbl ( ) ; _bgc . Tbl = append ( _bgc . Tbl , _fcc ) ; _gfa . EG_BlockLevelElts = append ( _gfa . EG_BlockLevelElts , nil ) ; if _ggb { copy ( _gfa . EG_BlockLevelElts [ _aef + 1 : ] , _gfa . EG_BlockLevelElts [ _aef : ] ) ; _gfa . EG_BlockLevelElts [ _aef ] = _fgbb ; if _bdd != 0 { _fcb := _ba . NewEG_BlockLevelElts ( ) ; _caf := _ba . NewEG_ContentBlockContent ( ) ; _fcb . EG_ContentBlockContent = append ( _fcb . EG_ContentBlockContent , _caf ) ; _caf . P = _de . P [ : _bdd ] ; _gfa . EG_BlockLevelElts = append ( _gfa . EG_BlockLevelElts , nil ) ; copy ( _gfa . EG_BlockLevelElts [ _aef + 1 : ] , _gfa . EG_BlockLevelElts [ _aef : ] ) ; _gfa . EG_BlockLevelElts [ _aef ] = _fcb ; } ; _de . P = _de . P [ _bdd : ] ; } else { copy ( _gfa . EG_BlockLevelElts [ _aef + 2 : ] , _gfa . EG_BlockLevelElts [ _aef + 1 : ] ) ; _gfa . EG_BlockLevelElts [ _aef + 1 ] = _fgbb ; if _bdd != len ( _de . P ) - 1 { _cfad := _ba . NewEG_BlockLevelElts ( ) ; _cebc := _ba . NewEG_ContentBlockContent ( ) ; _cfad . EG_ContentBlockContent = append ( _cfad . EG_ContentBlockContent , _cebc ) ; _cebc . P = _de . P [ _bdd + 1 : ] ; _gfa . EG_BlockLevelElts = append ( _gfa . EG_BlockLevelElts , nil ) ; copy ( _gfa . EG_BlockLevelElts [ _aef + 3 : ] , _gfa . EG_BlockLevelElts [ _aef + 2 : ] ) ; _gfa . EG_BlockLevelElts [ _aef + 2 ] = _cfad ; } else { _dae := _ba . NewEG_BlockLevelElts ( ) ; _fdd := _ba . NewEG_ContentBlockContent ( ) ; _dae . EG_ContentBlockContent = append ( _dae . EG_ContentBlockContent , _fdd ) ; _fdd . P = [ ] * _ba . CT_P { _ba . NewCT_P ( ) } ; _gfa . EG_BlockLevelElts = append ( _gfa . EG_BlockLevelElts , nil ) ; copy ( _gfa . EG_BlockLevelElts [ _aef + 3 : ] , _gfa . EG_BlockLevelElts [ _aef + 2 : ] ) ; _gfa . EG_BlockLevelElts [ _aef + 2 ] = _dae ; } ; _de . P = _de . P [ : _bdd + 1 ] ; } ; return _fcc ; } ; } ; for _ , _gde := range _de . Tbl { _ggea := _afe ( _gde , _efb , _ggb ) ; if _ggea != nil { return _ggea ; } ; } ; } ; } ; } ; } ; } ; } ; return nil ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddImage adds an image to the document package, returning a reference that
// can be used to add the image to a run and place it in the document contents.
func ( _fede * Document ) AddImage ( i _bf . Image ) ( _bf . ImageRef , error ) { _eada := _bf . MakeImageRef ( i , & _fede . DocBase , _fede . _aeg ) ; if i . Data == nil && i . Path == "" { return _eada , _cd . New ( "\u0069\u006d\u0061\u0067\u0065\u0020\u006d\u0075\u0073\u0074 \u0068\u0061\u0076\u0065\u0020\u0064\u0061t\u0061\u0020\u006f\u0072\u0020\u0061\u0020\u0070\u0061\u0074\u0068" ) ; } ; if i . Format == "" { return _eada , _cd . New ( "\u0069\u006d\u0061\u0067\u0065\u0020\u006d\u0075\u0073\u0074 \u0068\u0061\u0076\u0065\u0020\u0061\u0020v\u0061\u006c\u0069\u0064\u0020\u0066\u006f\u0072\u006d\u0061\u0074" ) ; } ; if i . Size . X == 0 || i . Size . Y == 0 { return _eada , _cd . New ( "\u0069\u006d\u0061\u0067e\u0020\u006d\u0075\u0073\u0074\u0020\u0068\u0061\u0076\u0065 \u0061 \u0076\u0061\u006c\u0069\u0064\u0020\u0073i\u007a\u0065" ) ; } ; if i . Path != "" { _bda := _ca . Add ( i . Path ) ; if _bda != nil { return _eada , _bda ; } ; } ; _fede . Images = append ( _fede . Images , _eada ) ; _ddc := _cfb . Sprintf ( "\u006d\u0065d\u0069\u0061\u002fi\u006d\u0061\u0067\u0065\u0025\u0064\u002e\u0025\u0073" , len ( _fede . Images ) , i . Format ) ; _cff := _fede . _aeg . AddRelationship ( _ddc , _d . ImageType ) ; _fede . ContentTypes . EnsureDefault ( "\u0070\u006e\u0067" , "\u0069m\u0061\u0067\u0065\u002f\u0070\u006eg" ) ; _fede . ContentTypes . EnsureDefault ( "\u006a\u0070\u0065\u0067" , "\u0069\u006d\u0061\u0067\u0065\u002f\u006a\u0070\u0065\u0067" ) ; _fede . ContentTypes . EnsureDefault ( "\u006a\u0070\u0067" , "\u0069\u006d\u0061\u0067\u0065\u002f\u006a\u0070\u0065\u0067" ) ; _fede . ContentTypes . EnsureDefault ( "\u0077\u006d\u0066" , "i\u006d\u0061\u0067\u0065\u002f\u0078\u002d\u0077\u006d\u0066" ) ; _fede . ContentTypes . EnsureDefault ( i . Format , "\u0069\u006d\u0061\u0067\u0065\u002f" + i . Format ) ; _eada . SetRelID ( _cff . X ( ) . IdAttr ) ; _eada . SetTarget ( _ddc ) ; return _eada , nil ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// MultiLevelType returns the multilevel type, or ST_MultiLevelTypeUnset if not set.
func ( _eecdd NumberingDefinition ) MultiLevelType ( ) _ba . ST_MultiLevelType { if _eecdd . _ceab . MultiLevelType != nil { return _eecdd . _ceab . MultiLevelType . ValAttr ; } else { return _ba . ST_MultiLevelTypeUnset ; } ; } ; func _ffge ( _aaeca * _ba . CT_OnOff ) OnOffValue { if _aaeca == nil { return OnOffValueUnset ; } ; if _aaeca . ValAttr != nil && _aaeca . ValAttr . Bool != nil && * _aaeca . ValAttr . Bool == false { return OnOffValueOff ; } ; return OnOffValueOn ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetStartIndent controls the start indent of the paragraph.
func ( _gdecg ParagraphStyleProperties ) SetStartIndent ( m _gc . Distance ) { if _gdecg . _gdb . Ind == nil { _gdecg . _gdb . Ind = _ba . NewCT_Ind ( ) ; } ; if m == _gc . Zero { _gdecg . _gdb . Ind . StartAttr = nil ; } else { _gdecg . _gdb . Ind . StartAttr = & _ba . ST_SignedTwipsMeasure { } ; _gdecg . _gdb . Ind . StartAttr . Int64 = _d . Int64 ( int64 ( m / _gc . Twips ) ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// ParagraphSpacing controls the spacing for a paragraph and its lines.
type ParagraphSpacing struct { _afefd * _ba . CT_Spacing } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// CharacterSpacingMeasure returns paragraph characters spacing with its measure which can be mm, cm, in, pt, pc or pi.
func ( _agaga RunProperties ) CharacterSpacingMeasure ( ) string { if _cgbd := _agaga . _bdgac . Spacing ; _cgbd != nil { _eabb := _cgbd . ValAttr ; if _eabb . ST_UniversalMeasure != nil { return * _eabb . ST_UniversalMeasure ; } ; } ; return "" ; } ; func ( _gaaf Paragraph ) addEndFldChar ( ) * _ba . CT_FldChar { _debc := _gaaf . addFldChar ( ) ; _debc . FldCharTypeAttr = _ba . ST_FldCharTypeEnd ; return _debc ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Tables returns the tables defined in the document.
func ( _caea * Document ) Tables ( ) [ ] Table { _cedb := [ ] Table { } ; if _caea . _dadc . Body == nil { return nil ; } ; for _ , _bee := range _caea . _dadc . Body . EG_BlockLevelElts { for _ , _aabb := range _bee . EG_ContentBlockContent { for _ , _egb := range _caea . tables ( _aabb ) { _cedb = append ( _cedb , _egb ) ; } ; } ; } ; return _cedb ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _fdae Row ) X ( ) * _ba . CT_Row { return _fdae . _abdcd } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SizeMeasure returns font with its measure which can be mm, cm, in, pt, pc or pi.
func ( _bffa RunProperties ) SizeMeasure ( ) string { if _cgfc := _bffa . _bdgac . Sz ; _cgfc != nil { _gggcb := _cgfc . ValAttr ; if _gggcb . ST_PositiveUniversalMeasure != nil { return * _gggcb . ST_PositiveUniversalMeasure ; } ; } ; return "" ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// ParagraphStyleProperties is the styling information for a paragraph.
type ParagraphStyleProperties struct { _gdb * _ba . CT_PPrGeneral } ; func _dfef ( _gdgdf * _ba . CT_P , _bdce * _ba . CT_Hyperlink , _gbbf * TableInfo , _afaa * DrawingInfo , _gggd [ ] * _ba . EG_ContentRunContent ) [ ] TextItem { _bgcbe := [ ] TextItem { } ; for _ , _efbf := range _gggd { if _dadg := _efbf . R ; _dadg != nil { _dgad := _dg . NewBuffer ( [ ] byte { } ) ; for _ , _fbagc := range _dadg . EG_RunInnerContent { if _fbagc . T != nil && _fbagc . T . Content != "" { _dgad . WriteString ( _fbagc . T . Content ) ; } ; } ; _bgcbe = append ( _bgcbe , TextItem { Text : _dgad . String ( ) , DrawingInfo : _afaa , Paragraph : _gdgdf , Hyperlink : _bdce , Run : _dadg , TableInfo : _gbbf } ) ; for _ , _bebcg := range _dadg . Extra { if _aaf , _dbff := _bebcg . ( * _ba . AlternateContentRun ) ; _dbff { _fgfc := & DrawingInfo { Drawing : _aaf . Choice . Drawing } ; for _ , _eac := range _fgfc . Drawing . Anchor { for _ , _fcef := range _eac . Graphic . GraphicData . Any { if _afbc , _ebac := _fcef . ( * _ba . WdWsp ) ; _ebac { if _afbc . WChoice != nil { if _cbaea := _afbc . SpPr ; _cbaea != nil { if _agggd := _cbaea . Xfrm ; _agggd != nil { if _ggfd := _agggd . Ext ; _ggfd != nil { _fgfc . Width = _ggfd . CxAttr ; _fgfc . Height = _ggfd . CyAttr ; } ; } ; } ; for _ , _fbcf := range _afbc . WChoice . Txbx . TxbxContent . EG_ContentBlockContent { _bgcbe = append ( _bgcbe , _ecfb ( _fbcf . P , _gbbf , _fgfc ) ... ) ; } ; } ; } ; } ; } ; } ; } ; } ; } ; return _bgcbe ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetBefore sets the spacing that comes before the paragraph.
func ( _gaef ParagraphSpacing ) SetBefore ( before _gc . Distance ) { _gaef . _afefd . BeforeAttr = & _dc . ST_TwipsMeasure { } ; _gaef . _afefd . BeforeAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( before / _gc . Twips ) ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetLeft sets the left border to a specified type, color and thickness.
func ( _ecge TableBorders ) SetLeft ( t _ba . ST_Border , c _fb . Color , thickness _gc . Distance ) { _ecge . _edag . Left = _ba . NewCT_Border ( ) ; _deec ( _ecge . _edag . Left , t , c , thickness ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// InsertRowBefore inserts a row before another row
func ( _dagg Table ) InsertRowBefore ( r Row ) Row { for _dafbf , _ceef := range _dagg . _fbdg . EG_ContentRowContent { if len ( _ceef . Tr ) > 0 && r . X ( ) == _ceef . Tr [ 0 ] { _ggef := _ba . NewEG_ContentRowContent ( ) ; _dagg . _fbdg . EG_ContentRowContent = append ( _dagg . _fbdg . EG_ContentRowContent , nil ) ; copy ( _dagg . _fbdg . EG_ContentRowContent [ _dafbf + 1 : ] , _dagg . _fbdg . EG_ContentRowContent [ _dafbf : ] ) ; _dagg . _fbdg . EG_ContentRowContent [ _dafbf ] = _ggef ; _dffgf := _ba . NewCT_Row ( ) ; _ggef . Tr = append ( _ggef . Tr , _dffgf ) ; return Row { _dagg . _fgdbd , _dffgf } ; } ; } ; return _dagg . AddRow ( ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetText sets the text to be used in bullet mode.
func ( _cdb NumberingLevel ) SetText ( t string ) { if t == "" { _cdb . _bbgd . LvlText = nil ; } else { _cdb . _bbgd . LvlText = _ba . NewCT_LevelText ( ) ; _cdb . _bbgd . LvlText . ValAttr = _d . String ( t ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Type returns the type of the style.
func ( _bedeg Style ) Type ( ) _ba . ST_StyleType { return _bedeg . _ebcb . TypeAttr } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Style is a style within the styles.xml file.
type Style struct { _ebcb * _ba . CT_Style } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// InsertParagraphAfter adds a new empty paragraph after the relativeTo
// paragraph.
func ( _cgd * Document ) InsertParagraphAfter ( relativeTo Paragraph ) Paragraph { return _cgd . insertParagraph ( relativeTo , false ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Text returns text from the document as one string separated with line breaks.
func ( _dggd * DocText ) Text ( ) string { _abgc := _dg . NewBuffer ( [ ] byte { } ) ; for _ , _cadf := range _dggd . Items { if _cadf . Text != "" { _abgc . WriteString ( _cadf . Text ) ; _abgc . WriteString ( "\u000a" ) ; } ; } ; return _abgc . String ( ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddTabStop adds a tab stop to the paragraph. It controls the position of text when using Run.AddTab()
func ( _adeb ParagraphProperties ) AddTabStop ( position _gc . Distance , justificaton _ba . ST_TabJc , leader _ba . ST_TabTlc ) { if _adeb . _gcdf . Tabs == nil { _adeb . _gcdf . Tabs = _ba . NewCT_Tabs ( ) ; } ; _beff := _ba . NewCT_TabStop ( ) ; _beff . LeaderAttr = leader ; _beff . ValAttr = justificaton ; _beff . PosAttr . Int64 = _d . Int64 ( int64 ( position / _gc . Twips ) ) ; _adeb . _gcdf . Tabs . Tab = append ( _adeb . _gcdf . Tabs . Tab , _beff ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetVerticalMerge controls the vertical merging of cells.
func ( _bcd CellProperties ) SetVerticalMerge ( mergeVal _ba . ST_Merge ) { if mergeVal == _ba . ST_MergeUnset { _bcd . _adg . VMerge = nil ; } else { _bcd . _adg . VMerge = _ba . NewCT_VMerge ( ) ; _bcd . _adg . VMerge . ValAttr = mergeVal ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetStyle sets the table style name.
func ( _gaage TableProperties ) SetStyle ( name string ) { if name == "" { _gaage . _efeg . TblStyle = nil ; } else { _gaage . _efeg . TblStyle = _ba . NewCT_String ( ) ; _gaage . _efeg . TblStyle . ValAttr = name ; } ; } ;
2020-11-09 01:00:18 +00:00
2021-01-04 16:11:39 +00:00
// Index returns the index of the header within the document. This is used to
// form its zip packaged filename as well as to match it with its relationship
// ID.
func ( _bdge Header ) Index ( ) int { for _gefg , _defbd := range _bdge . _egded . _adgc { if _defbd == _bdge . _gcdbe { return _gefg ; } ; } ; return - 1 ; } ;
2020-11-09 01:00:18 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _feca NumberingLevel ) X ( ) * _ba . CT_Lvl { return _feca . _bbgd } ;
2020-11-09 01:00:18 +00:00
2021-01-04 16:11:39 +00:00
// SetSemiHidden controls if the style is hidden in the UI.
func ( _feeg Style ) SetSemiHidden ( b bool ) { if b { _feeg . _ebcb . SemiHidden = _ba . NewCT_OnOff ( ) ; } else { _feeg . _ebcb . SemiHidden = nil ; } ; } ;
2020-11-09 01:00:18 +00:00
2021-01-04 16:11:39 +00:00
// Fonts returns the style's Fonts.
func ( _aeee RunProperties ) Fonts ( ) Fonts { if _aeee . _bdgac . RFonts == nil { _aeee . _bdgac . RFonts = _ba . NewCT_Fonts ( ) ; } ; return Fonts { _aeee . _bdgac . RFonts } ; } ; func _efd ( _feagg * _ba . EG_ContentBlockContent ) [ ] Bookmark { _baae := [ ] Bookmark { } ; for _ , _gedd := range _feagg . P { for _ , _fbef := range _gedd . EG_PContent { for _ , _bbg := range _fbef . EG_ContentRunContent { for _ , _ddaf := range _bbg . EG_RunLevelElts { for _ , _bfb := range _ddaf . EG_RangeMarkupElements { if _bfb . BookmarkStart != nil { _baae = append ( _baae , Bookmark { _bfb . BookmarkStart } ) ; } ; } ; } ; } ; } ; } ; for _ , _abbg := range _feagg . EG_RunLevelElts { for _ , _adga := range _abbg . EG_RangeMarkupElements { if _adga . BookmarkStart != nil { _baae = append ( _baae , Bookmark { _adga . BookmarkStart } ) ; } ; } ; } ; for _ , _fee := range _feagg . Tbl { for _ , _acb := range _fee . EG_ContentRowContent { for _ , _ebe := range _acb . Tr { for _ , _afbba := range _ebe . EG_ContentCellContent { for _ , _aeca := range _afbba . Tc { for _ , _cebb := range _aeca . EG_BlockLevelElts { for _ , _aaef := range _cebb . EG_ContentBlockContent { for _ , _abbdc := range _efd ( _aaef ) { _baae = append ( _baae , _abbdc ) ; } ; } ; } ; } ; } ; } ; } ; } ; return _baae ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetCalcOnExit marks if a FormField should be CalcOnExit or not.
func ( _cag FormField ) SetCalcOnExit ( calcOnExit bool ) { _bgb := _ba . NewCT_OnOff ( ) ; _bgb . ValAttr = & _dc . ST_OnOff { Bool : & calcOnExit } ; _cag . _edgb . CalcOnExit = [ ] * _ba . CT_OnOff { _bgb } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetBold sets the run to bold.
func ( _gega RunProperties ) SetBold ( b bool ) { if ! b { _gega . _bdgac . B = nil ; _gega . _bdgac . BCs = nil ; } else { _gega . _bdgac . B = _ba . NewCT_OnOff ( ) ; _gega . _bdgac . BCs = _ba . NewCT_OnOff ( ) ; } ; } ;
2018-03-13 07:24:02 -05:00
2021-01-04 16:11:39 +00:00
// SetEnabled marks a FormField as enabled or disabled.
func ( _bbbg FormField ) SetEnabled ( enabled bool ) { _cadb := _ba . NewCT_OnOff ( ) ; _cadb . ValAttr = & _dc . ST_OnOff { Bool : & enabled } ; _bbbg . _edgb . Enabled = [ ] * _ba . CT_OnOff { _cadb } ; } ;
2017-08-28 20:56:18 -05:00
2021-01-04 16:11:39 +00:00
// CharacterSpacingValue returns the value of run's characters spacing in twips (1/20 of point).
func ( _fdec RunProperties ) CharacterSpacingValue ( ) int64 { if _aaeag := _fdec . _bdgac . Spacing ; _aaeag != nil { _egaadg := _aaeag . ValAttr ; if _egaadg . Int64 != nil { return * _egaadg . Int64 ; } ; } ; return int64 ( 0 ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetEffect sets a text effect on the run.
func ( _ebgd RunProperties ) SetEffect ( e _ba . ST_TextEffect ) { if e == _ba . ST_TextEffectUnset { _ebgd . _bdgac . Effect = nil ; } else { _ebgd . _bdgac . Effect = _ba . NewCT_TextEffect ( ) ; _ebgd . _bdgac . Effect . ValAttr = _ba . ST_TextEffectShimmer ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Bold returns true if run font is bold.
func ( _eefcc RunProperties ) Bold ( ) bool { _bdgd := _eefcc . _bdgac ; return _bfbg ( _bdgd . B ) || _bfbg ( _bdgd . BCs ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetSize sets size attribute for a FormFieldTypeCheckBox in pt.
func ( _efbd FormField ) SetSize ( size uint64 ) { size *= 2 ; if _efbd . _edgb . CheckBox != nil { _efbd . _edgb . CheckBox . Choice = _ba . NewCT_FFCheckBoxChoice ( ) ; _efbd . _edgb . CheckBox . Choice . Size = _ba . NewCT_HpsMeasure ( ) ; _efbd . _edgb . CheckBox . Choice . Size . ValAttr = _ba . ST_HpsMeasure { ST_UnsignedDecimalNumber : & size } ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetBottom sets the bottom border to a specified type, color and thickness.
func ( _da CellBorders ) SetBottom ( t _ba . ST_Border , c _fb . Color , thickness _gc . Distance ) { _da . _fbd . Bottom = _ba . NewCT_Border ( ) ; _deec ( _da . _fbd . Bottom , t , c , thickness ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetDoubleStrikeThrough sets the run to double strike-through.
func ( _adfce RunProperties ) SetDoubleStrikeThrough ( b bool ) { if ! b { _adfce . _bdgac . Dstrike = nil ; } else { _adfce . _bdgac . Dstrike = _ba . NewCT_OnOff ( ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Footers returns the footers defined in the document.
func ( _fa * Document ) Footers ( ) [ ] Footer { _agee := [ ] Footer { } ; for _ , _edc := range _fa . _ggdc { _agee = append ( _agee , Footer { _fa , _edc } ) ; } ; return _agee ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetEndIndent controls the end indentation.
func ( _fdgf ParagraphProperties ) SetEndIndent ( m _gc . Distance ) { if _fdgf . _gcdf . Ind == nil { _fdgf . _gcdf . Ind = _ba . NewCT_Ind ( ) ; } ; if m == _gc . Zero { _fdgf . _gcdf . Ind . EndAttr = nil ; } else { _fdgf . _gcdf . Ind . EndAttr = & _ba . ST_SignedTwipsMeasure { } ; _fdgf . _gcdf . Ind . EndAttr . Int64 = _d . Int64 ( int64 ( m / _gc . Twips ) ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// VerticalAlign returns the value of run vertical align.
func ( _fbcg RunProperties ) VerticalAlignment ( ) _dc . ST_VerticalAlignRun { if _eebg := _fbcg . _bdgac . VertAlign ; _eebg != nil { return _eebg . ValAttr ; } ; return 0 ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// TableProperties returns the table style properties.
func ( _ffgac Style ) TableProperties ( ) TableStyleProperties { if _ffgac . _ebcb . TblPr == nil { _ffgac . _ebcb . TblPr = _ba . NewCT_TblPrBase ( ) ; } ; return TableStyleProperties { _ffgac . _ebcb . TblPr } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetNumberingDefinitionByID sets the numbering definition ID directly, which must
// match an ID defined in numbering.xml
func ( _cbfd Paragraph ) SetNumberingDefinitionByID ( abstractNumberID int64 ) { _cbfd . ensurePPr ( ) ; if _cbfd . _acbc . PPr . NumPr == nil { _cbfd . _acbc . PPr . NumPr = _ba . NewCT_NumPr ( ) ; } ; _ebagb := _ba . NewCT_DecimalNumber ( ) ; _ebagb . ValAttr = int64 ( abstractNumberID ) ; _cbfd . _acbc . PPr . NumPr . NumId = _ebagb ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// VerticalAlign returns the value of paragraph vertical align.
func ( _caab ParagraphProperties ) VerticalAlignment ( ) _dc . ST_VerticalAlignRun { if _adceb := _caab . _gcdf . RPr . VertAlign ; _adceb != nil { return _adceb . ValAttr ; } ; return 0 ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _aacg NumberingDefinition ) X ( ) * _ba . CT_AbstractNum { return _aacg . _ceab } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Endnote returns the endnote based on the ID; this can be used nicely with
// the run.IsEndnote() functionality.
func ( _cdd * Document ) Endnote ( id int64 ) Endnote { for _ , _eag := range _cdd . Endnotes ( ) { if _eag . id ( ) == id { return _eag ; } ; } ; return Endnote { } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wml.CT_TblBorders
func ( _cfge TableBorders ) X ( ) * _ba . CT_TblBorders { return _cfge . _edag } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Bookmarks returns all of the bookmarks defined in the document.
func ( _gfaf Document ) Bookmarks ( ) [ ] Bookmark { if _gfaf . _dadc . Body == nil { return nil ; } ; _bbff := [ ] Bookmark { } ; for _ , _bfd := range _gfaf . _dadc . Body . EG_BlockLevelElts { for _ , _aefe := range _bfd . EG_ContentBlockContent { for _ , _aeba := range _efd ( _aefe ) { _bbff = append ( _bbff , _aeba ) ; } ; } ; } ; return _bbff ; } ; func _eggc ( _abbe * _ba . CT_Tbl , _dggf , _fgdc map [ int64 ] int64 ) { for _ , _afef := range _abbe . EG_ContentRowContent { for _ , _acda := range _afef . Tr { for _ , _gca := range _acda . EG_ContentCellContent { for _ , _baad := range _gca . Tc { for _ , _bgg := range _baad . EG_BlockLevelElts { for _ , _egaa := range _bgg . EG_ContentBlockContent { for _ , _cgaa := range _egaa . P { _addfd ( _cgaa , _dggf , _fgdc ) ; } ; for _ , _fdeb := range _egaa . Tbl { _eggc ( _fdeb , _dggf , _fgdc ) ; } ; } ; } ; } ; } ; } ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetItalic sets the run to italic.
func ( _adgec RunProperties ) SetItalic ( b bool ) { if ! b { _adgec . _bdgac . I = nil ; _adgec . _bdgac . ICs = nil ; } else { _adgec . _bdgac . I = _ba . NewCT_OnOff ( ) ; _adgec . _bdgac . ICs = _ba . NewCT_OnOff ( ) ; } ; } ; func _addfd ( _ccgg * _ba . CT_P , _gfcec , _ccggg map [ int64 ] int64 ) { for _ , _dccf := range _ccgg . EG_PContent { for _ , _dec := range _dccf . EG_ContentRunContent { if _dec . R != nil { for _ , _cfbbc := range _dec . R . EG_RunInnerContent { _dea := _cfbbc . EndnoteReference ; if _dea != nil && _dea . IdAttr > 0 { if _agga , _ggcb := _ccggg [ _dea . IdAttr ] ; _ggcb { _dea . IdAttr = _agga ; } ; } ; _fdcc := _cfbbc . FootnoteReference ; if _fdcc != nil && _fdcc . IdAttr > 0 { if _dabg , _fbfb := _gfcec [ _fdcc . IdAttr ] ; _fbfb { _fdcc . IdAttr = _dabg ; } ; } ; } ; } ; } ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetFirstLineIndent controls the indentation of the first line in a paragraph.
func ( _ccffc ParagraphProperties ) SetFirstLineIndent ( m _gc . Distance ) { if _ccffc . _gcdf . Ind == nil { _ccffc . _gcdf . Ind = _ba . NewCT_Ind ( ) ; } ; if m == _gc . Zero { _ccffc . _gcdf . Ind . FirstLineAttr = nil ; } else { _ccffc . _gcdf . Ind . FirstLineAttr = & _dc . ST_TwipsMeasure { } ; _ccffc . _gcdf . Ind . FirstLineAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( m / _gc . Twips ) ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddDropdownList adds dropdown list form field to the paragraph and returns it.
func ( _afea Paragraph ) AddDropdownList ( name string ) FormField { _dbcc := _afea . addFldCharsForField ( name , "\u0046\u004f\u0052M\u0044\u0052\u004f\u0050\u0044\u004f\u0057\u004e" ) ; _dbcc . _edgb . DdList = _ba . NewCT_FFDDList ( ) ; return _dbcc ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetSpacing sets the spacing that comes before and after the paragraph.
// Deprecated: See Spacing() instead which allows finer control.
func ( _fdgaa ParagraphProperties ) SetSpacing ( before , after _gc . Distance ) { if _fdgaa . _gcdf . Spacing == nil { _fdgaa . _gcdf . Spacing = _ba . NewCT_Spacing ( ) ; } ; _fdgaa . _gcdf . Spacing . BeforeAttr = & _dc . ST_TwipsMeasure { } ; _fdgaa . _gcdf . Spacing . BeforeAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( before / _gc . Twips ) ) ; _fdgaa . _gcdf . Spacing . AfterAttr = & _dc . ST_TwipsMeasure { } ; _fdgaa . _gcdf . Spacing . AfterAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( after / _gc . Twips ) ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetTop sets the cell top margin
func ( _ff CellMargins ) SetTop ( d _gc . Distance ) { _ff . _aab . Top = _ba . NewCT_TblWidth ( ) ; _gaag ( _ff . _aab . Top , d ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetOutline sets the run to outlined text.
func ( _fdccb RunProperties ) SetOutline ( b bool ) { if ! b { _fdccb . _bdgac . Outline = nil ; } else { _fdccb . _bdgac . Outline = _ba . NewCT_OnOff ( ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Paragraphs returns all of the paragraphs in the document body including tables.
func ( _cebcc * Document ) Paragraphs ( ) [ ] Paragraph { _gaacf := [ ] Paragraph { } ; if _cebcc . _dadc . Body == nil { return nil ; } ; for _ , _gcg := range _cebcc . _dadc . Body . EG_BlockLevelElts { for _ , _dcf := range _gcg . EG_ContentBlockContent { for _ , _ffg := range _dcf . P { _gaacf = append ( _gaacf , Paragraph { _cebcc , _ffg } ) ; } ; } ; } ; for _ , _gef := range _cebcc . Tables ( ) { for _ , _caef := range _gef . Rows ( ) { for _ , _gccg := range _caef . Cells ( ) { _gaacf = append ( _gaacf , _gccg . Paragraphs ( ) ... ) ; } ; } ; } ; return _gaacf ; } ;
2020-08-23 14:15:53 +00:00
2020-12-17 22:07:08 +00:00
// X returns the inner wrapped XML type.
2021-01-04 16:11:39 +00:00
func ( _bbde Endnote ) X ( ) * _ba . CT_FtnEdn { return _bbde . _adff } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetHAlignment sets the horizontal alignment for an anchored image.
func ( _cfa AnchoredDrawing ) SetHAlignment ( h _ba . WdST_AlignH ) { _cfa . _eg . PositionH . Choice = & _ba . WdCT_PosHChoice { } ; _cfa . _eg . PositionH . Choice . Align = h ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetAlignment controls the paragraph alignment
func ( _fefba ParagraphStyleProperties ) SetAlignment ( align _ba . ST_Jc ) { if align == _ba . ST_JcUnset { _fefba . _gdb . Jc = nil ; } else { _fefba . _gdb . Jc = _ba . NewCT_Jc ( ) ; _fefba . _gdb . Jc . ValAttr = align ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetVAlignment sets the vertical alignment for an anchored image.
func ( _aa AnchoredDrawing ) SetVAlignment ( v _ba . WdST_AlignV ) { _aa . _eg . PositionV . Choice = & _ba . WdCT_PosVChoice { } ; _aa . _eg . PositionV . Choice . Align = v ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddRun adds a run of text to a hyperlink. This is the text that will be linked.
func ( _faf HyperLink ) AddRun ( ) Run { _ecba := _ba . NewEG_ContentRunContent ( ) ; _faf . _edfg . EG_ContentRunContent = append ( _faf . _edfg . EG_ContentRunContent , _ecba ) ; _effg := _ba . NewCT_R ( ) ; _ecba . R = _effg ; return Run { _faf . _bgbf , _effg } ; } ;
2020-11-09 01:00:18 +00:00
2021-01-04 16:11:39 +00:00
// AddRun adds a run to a paragraph.
func ( _bcef Paragraph ) AddRun ( ) Run { _abgfc := _ba . NewEG_PContent ( ) ; _bcef . _acbc . EG_PContent = append ( _bcef . _acbc . EG_PContent , _abgfc ) ; _abda := _ba . NewEG_ContentRunContent ( ) ; _abgfc . EG_ContentRunContent = append ( _abgfc . EG_ContentRunContent , _abda ) ; _abfbc := _ba . NewCT_R ( ) ; _abda . R = _abfbc ; return Run { _bcef . _dcbe , _abfbc } ; } ;
2020-11-09 01:00:18 +00:00
2021-01-04 16:11:39 +00:00
// Paragraph is a paragraph within a document.
type Paragraph struct { _dcbe * Document ; _acbc * _ba . CT_P ; } ; func ( _ccf * Document ) insertTable ( _gdg Paragraph , _baeg bool ) Table { _gcd := _ccf . _dadc . Body ; if _gcd == nil { return _ccf . AddTable ( ) ; } ; _aecg := _gdg . X ( ) ; for _db , _dcc := range _gcd . EG_BlockLevelElts { for _ , _ebf := range _dcc . EG_ContentBlockContent { for _dgg , _bbeb := range _ebf . P { if _bbeb == _aecg { _cebf := _ba . NewCT_Tbl ( ) ; _ebc := _ba . NewEG_BlockLevelElts ( ) ; _bga := _ba . NewEG_ContentBlockContent ( ) ; _ebc . EG_ContentBlockContent = append ( _ebc . EG_ContentBlockContent , _bga ) ; _bga . Tbl = append ( _bga . Tbl , _cebf ) ; _gcd . EG_BlockLevelElts = append ( _gcd . EG_BlockLevelElts , nil ) ; if _baeg { copy ( _gcd . EG_BlockLevelElts [ _db + 1 : ] , _gcd . EG_BlockLevelElts [ _db : ] ) ; _gcd . EG_BlockLevelElts [ _db ] = _ebc ; if _dgg != 0 { _egdc := _ba . NewEG_BlockLevelElts ( ) ; _aca := _ba . NewEG_ContentBlockContent ( ) ; _egdc . EG_ContentBlockContent = append ( _egdc . EG_ContentBlockContent , _aca ) ; _aca . P = _ebf . P [ : _dgg ] ; _gcd . EG_BlockLevelElts = append ( _gcd . EG_BlockLevelElts , nil ) ; copy ( _gcd . EG_BlockLevelElts [ _db + 1 : ] , _gcd . EG_BlockLevelElts [ _db : ] ) ; _gcd . EG_BlockLevelElts [ _db ] = _egdc ; } ; _ebf . P = _ebf . P [ _dgg : ] ; } else { copy ( _gcd . EG_BlockLevelElts [ _db + 2 : ] , _gcd . EG_BlockLevelElts [ _db + 1 : ] ) ; _gcd . EG_BlockLevelElts [ _db + 1 ] = _ebc ; if _dgg != len ( _ebf . P ) - 1 { _cfgd := _ba . NewEG_BlockLevelElts ( ) ; _abf := _ba . NewEG_ContentBlockContent ( ) ; _cfgd . EG_ContentBlockContent = append ( _cfgd . EG_ContentBlockContent , _abf ) ; _abf . P = _ebf . P [ _dgg + 1 : ] ; _gcd . EG_BlockLevelElts = append ( _gcd . EG_BlockLevelElts , nil ) ; copy ( _gcd . EG_BlockLevelElts [ _db + 3 : ] , _gcd . EG_BlockLevelElts [ _db + 2 : ] ) ; _gcd . EG_BlockLevelElts [ _db + 2 ] = _cfgd ; } ; _ebf . P = _ebf . P [ : _dgg + 1 ] ; } ; return Table { _ccf , _cebf } ; } ; } ; for _ , _bge := range _ebf . Tbl { _bgdg := _afe ( _bge , _aecg , _baeg ) ; if _bgdg != nil { return Table { _ccf , _bgdg } ; } ; } ; } ; } ; return _ccf . AddTable ( ) ; } ;
2020-11-09 01:00:18 +00:00
2021-01-04 16:11:39 +00:00
// RowProperties are the properties for a row within a table
type RowProperties struct { _bdefd * _ba . CT_TrPr } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetFirstColumn controls the conditional formatting for the first column in a table.
func ( _ggddf TableLook ) SetFirstColumn ( on bool ) { if ! on { _ggddf . _acbdf . FirstColumnAttr = & _dc . ST_OnOff { } ; _ggddf . _acbdf . FirstColumnAttr . ST_OnOff1 = _dc . ST_OnOff1Off ; } else { _ggddf . _acbdf . FirstColumnAttr = & _dc . ST_OnOff { } ; _ggddf . _acbdf . FirstColumnAttr . ST_OnOff1 = _dc . ST_OnOff1On ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// NewSettings constructs a new empty Settings
func NewSettings ( ) Settings { _bbaee := _ba . NewSettings ( ) ; _bbaee . Compat = _ba . NewCT_Compat ( ) ; _ddffc := _ba . NewCT_CompatSetting ( ) ; _ddffc . NameAttr = _d . String ( "\u0063\u006f\u006d\u0070\u0061\u0074\u0069\u0062\u0069\u006c\u0069\u0074y\u004d\u006f\u0064\u0065" ) ; _ddffc . UriAttr = _d . String ( "h\u0074\u0074\u0070\u003a\u002f\u002f\u0073\u0063\u0068\u0065\u006d\u0061\u0073\u002e\u006d\u0069\u0063\u0072o\u0073\u006f\u0066\u0074\u002e\u0063\u006f\u006d\u002f\u006fff\u0069\u0063\u0065/\u0077o\u0072\u0064" ) ; _ddffc . ValAttr = _d . String ( "\u0031\u0035" ) ; _bbaee . Compat . CompatSetting = append ( _bbaee . Compat . CompatSetting , _ddffc ) ; return Settings { _bbaee } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Paragraphs returns the paragraphs defined in the cell.
func ( _efg Cell ) Paragraphs ( ) [ ] Paragraph { _ccg := [ ] Paragraph { } ; for _ , _eea := range _efg . _bd . EG_BlockLevelElts { for _ , _ag := range _eea . EG_ContentBlockContent { for _ , _dda := range _ag . P { _ccg = append ( _ccg , Paragraph { _efg . _ad , _dda } ) ; } ; } ; } ; return _ccg ; } ;
2020-08-23 14:15:53 +00:00
2020-12-17 22:07:08 +00:00
// X returns the inner wrapped XML type.
2021-01-04 16:11:39 +00:00
func ( _fd AnchoredDrawing ) X ( ) * _ba . WdAnchor { return _fd . _eg } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetHighlight highlights text in a specified color.
func ( _ccee RunProperties ) SetHighlight ( c _ba . ST_HighlightColor ) { _ccee . _bdgac . Highlight = _ba . NewCT_Highlight ( ) ; _ccee . _bdgac . Highlight . ValAttr = c ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// CellProperties returns the cell properties.
func ( _cgba TableConditionalFormatting ) CellProperties ( ) CellProperties { if _cgba . _dddb . TcPr == nil { _cgba . _dddb . TcPr = _ba . NewCT_TcPr ( ) ; } ; return CellProperties { _cgba . _dddb . TcPr } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetHeadingLevel sets a heading level and style based on the level to a
// paragraph. The default styles for a new unioffice document support headings
// from level 1 to 8.
func ( _cebccf ParagraphProperties ) SetHeadingLevel ( idx int ) { _cebccf . SetStyle ( _cfb . Sprintf ( "\u0048e\u0061\u0064\u0069\u006e\u0067\u0025d" , idx ) ) ; if _cebccf . _gcdf . NumPr == nil { _cebccf . _gcdf . NumPr = _ba . NewCT_NumPr ( ) ; } ; _cebccf . _gcdf . NumPr . Ilvl = _ba . NewCT_DecimalNumber ( ) ; _cebccf . _gcdf . NumPr . Ilvl . ValAttr = int64 ( idx ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetYOffset sets the Y offset for an image relative to the origin.
func ( _dgb AnchoredDrawing ) SetYOffset ( y _gc . Distance ) { _dgb . _eg . PositionV . Choice = & _ba . WdCT_PosVChoice { } ; _dgb . _eg . PositionV . Choice . PosOffset = _d . Int32 ( int32 ( y / _gc . EMU ) ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetChecked marks a FormFieldTypeCheckBox as checked or unchecked.
func ( _aaefe FormField ) SetChecked ( b bool ) { if _aaefe . _edgb . CheckBox == nil { return ; } ; if ! b { _aaefe . _edgb . CheckBox . Checked = nil ; } else { _aaefe . _edgb . CheckBox . Checked = _ba . NewCT_OnOff ( ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AbstractNumberID returns the ID that is unique within all numbering
// definitions that is used to assign the definition to a paragraph.
func ( _ecff NumberingDefinition ) AbstractNumberID ( ) int64 { return _ecff . _ceab . AbstractNumIdAttr } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// TableWidth controls width values in table settings.
type TableWidth struct { _ecbb * _ba . CT_TblWidth } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// RStyle returns the name of character style.
// It is defined here http://officeopenxml.com/WPstyleCharStyles.php
func ( _dabdf ParagraphProperties ) RStyle ( ) string { if _dabdf . _gcdf . RPr . RStyle != nil { return _dabdf . _gcdf . RPr . RStyle . ValAttr ; } ; return "" ; } ; func _dcebb ( _bcad * _cde . CT_Blip , _ege map [ string ] string ) { if _bcad . EmbedAttr != nil { if _bfde , _cfgdf := _ege [ * _bcad . EmbedAttr ] ; _cfgdf { * _bcad . EmbedAttr = _bfde ; } ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Paragraphs returns the paragraphs defined in a header.
func ( _fggg Header ) Paragraphs ( ) [ ] Paragraph { _afbd := [ ] Paragraph { } ; for _ , _aaa := range _fggg . _gcdbe . EG_ContentBlockContent { for _ , _faa := range _aaa . P { _afbd = append ( _afbd , Paragraph { _fggg . _egded , _faa } ) ; } ; } ; for _ , _dfff := range _fggg . Tables ( ) { for _ , _efcb := range _dfff . Rows ( ) { for _ , _fdga := range _efcb . Cells ( ) { _afbd = append ( _afbd , _fdga . Paragraphs ( ) ... ) ; } ; } ; } ; return _afbd ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// CharacterSpacingValue returns the value of characters spacing in twips (1/20 of point).
func ( _fgeca ParagraphProperties ) CharacterSpacingValue ( ) int64 { if _fedd := _fgeca . _gcdf . RPr . Spacing ; _fedd != nil { _bdcb := _fedd . ValAttr ; if _bdcb . Int64 != nil { return * _bdcb . Int64 ; } ; } ; return int64 ( 0 ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SizeMeasure returns font with its measure which can be mm, cm, in, pt, pc or pi.
func ( _bada ParagraphProperties ) SizeMeasure ( ) string { if _adce := _bada . _gcdf . RPr . Sz ; _adce != nil { _gaacb := _adce . ValAttr ; if _gaacb . ST_PositiveUniversalMeasure != nil { return * _gaacb . ST_PositiveUniversalMeasure ; } ; } ; return "" ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetSmallCaps sets the run to small caps.
func ( _bgba RunProperties ) SetSmallCaps ( b bool ) { if ! b { _bgba . _bdgac . SmallCaps = nil ; } else { _bgba . _bdgac . SmallCaps = _ba . NewCT_OnOff ( ) ; } ; } ;
// AddHeader creates a header associated with the document, but doesn't add it
// to the document for display.
func ( _dgbg * Document ) AddHeader ( ) Header { _adf := _ba . NewHdr ( ) ; _dgbg . _adgc = append ( _dgbg . _adgc , _adf ) ; _bcda := _cfb . Sprintf ( "\u0068\u0065\u0061d\u0065\u0072\u0025\u0064\u002e\u0078\u006d\u006c" , len ( _dgbg . _adgc ) ) ; _dgbg . _aeg . AddRelationship ( _bcda , _d . HeaderType ) ; _dgbg . ContentTypes . AddOverride ( "\u002f\u0077\u006f\u0072\u0064\u002f" + _bcda , "\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u0076\u006e\u0064.\u006f\u0070\u0065\u006ex\u006d\u006c\u0066\u006f\u0072m\u0061\u0074\u0073\u002d\u006f\u0066\u0066\u0069\u0063\u0065\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u002e\u0077\u006f\u0072\u0064\u0070\u0072\u006f\u0063\u0065\u0073\u0073\u0069n\u0067\u006d\u006c\u002e\u0068\u0065\u0061\u0064e\u0072\u002b\u0078\u006d\u006c" ) ; _dgbg . _bec = append ( _dgbg . _bec , _bf . NewRelationships ( ) ) ; return Header { _dgbg , _adf } ; } ;
// Paragraphs returns the paragraphs defined in an endnote.
func ( _ffga Endnote ) Paragraphs ( ) [ ] Paragraph { _daff := [ ] Paragraph { } ; for _ , _deg := range _ffga . content ( ) { for _ , _gfafb := range _deg . P { _daff = append ( _daff , Paragraph { _ffga . _deaa , _gfafb } ) ; } ; } ; return _daff ; } ;
// RemoveRun removes a child run from a paragraph.
func ( _gacb Paragraph ) RemoveRun ( r Run ) { for _ , _ddcd := range _gacb . _acbc . EG_PContent { for _gacge , _ccaf := range _ddcd . EG_ContentRunContent { if _ccaf . R == r . _afde { copy ( _ddcd . EG_ContentRunContent [ _gacge : ] , _ddcd . EG_ContentRunContent [ _gacge + 1 : ] ) ; _ddcd . EG_ContentRunContent = _ddcd . EG_ContentRunContent [ 0 : len ( _ddcd . EG_ContentRunContent ) - 1 ] ; } ; if _ccaf . Sdt != nil && _ccaf . Sdt . SdtContent != nil { for _fgc , _cgeg := range _ccaf . Sdt . SdtContent . EG_ContentRunContent { if _cgeg . R == r . _afde { copy ( _ccaf . Sdt . SdtContent . EG_ContentRunContent [ _fgc : ] , _ccaf . Sdt . SdtContent . EG_ContentRunContent [ _fgc + 1 : ] ) ; _ccaf . Sdt . SdtContent . EG_ContentRunContent = _ccaf . Sdt . SdtContent . EG_ContentRunContent [ 0 : len ( _ccaf . Sdt . SdtContent . EG_ContentRunContent ) - 1 ] ; } ; } ; } ; } ; } ; } ;
2020-08-23 14:15:53 +00:00
2020-12-17 22:07:08 +00:00
// SetKeepOnOnePage controls if all lines in a paragraph are kept on the same
// page.
2021-01-04 16:11:39 +00:00
func ( _cdae ParagraphProperties ) SetKeepOnOnePage ( b bool ) { if ! b { _cdae . _gcdf . KeepLines = nil ; } else { _cdae . _gcdf . KeepLines = _ba . NewCT_OnOff ( ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// StructuredDocumentTag are a tagged bit of content in a document.
type StructuredDocumentTag struct { _fbde * Document ; _aad * _ba . CT_SdtBlock ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetCharacterSpacing sets the run's Character Spacing Adjustment.
func ( _dcfe RunProperties ) SetCharacterSpacing ( size _gc . Distance ) { _dcfe . _bdgac . Spacing = _ba . NewCT_SignedTwipsMeasure ( ) ; _dcfe . _bdgac . Spacing . ValAttr . Int64 = _d . Int64 ( int64 ( size / _gc . Twips ) ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// MergeFields returns the list of all mail merge fields found in the document.
func ( _ebg Document ) MergeFields ( ) [ ] string { _abad := map [ string ] struct { } { } ; for _ , _abgd := range _ebg . mergeFields ( ) { _abad [ _abgd . _cfda ] = struct { } { } ; } ; _afeg := [ ] string { } ; for _cggaa := range _abad { _afeg = append ( _afeg , _cggaa ) ; } ; return _afeg ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetSize sets the font size for a run.
func ( _cdac RunProperties ) SetSize ( size _gc . Distance ) { _cdac . _bdgac . Sz = _ba . NewCT_HpsMeasure ( ) ; _cdac . _bdgac . Sz . ValAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( size / _gc . HalfPoint ) ) ; _cdac . _bdgac . SzCs = _ba . NewCT_HpsMeasure ( ) ; _cdac . _bdgac . SzCs . ValAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( size / _gc . HalfPoint ) ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _ecgb TableConditionalFormatting ) X ( ) * _ba . CT_TblStylePr { return _ecgb . _dddb } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetMultiLevelType sets the multilevel type.
func ( _bag NumberingDefinition ) SetMultiLevelType ( t _ba . ST_MultiLevelType ) { if t == _ba . ST_MultiLevelTypeUnset { _bag . _ceab . MultiLevelType = nil ; } else { _bag . _ceab . MultiLevelType = _ba . NewCT_MultiLevelType ( ) ; _bag . _ceab . MultiLevelType . ValAttr = t ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// HyperLink is a link within a document.
type HyperLink struct { _bgbf * Document ; _edfg * _ba . CT_Hyperlink ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddImage adds an image to the document package, returning a reference that
// can be used to add the image to a run and place it in the document contents.
func ( _gfca Header ) AddImage ( i _bf . Image ) ( _bf . ImageRef , error ) { var _ggcg _bf . Relationships ; for _dada , _cdce := range _gfca . _egded . _adgc { if _cdce == _gfca . _gcdbe { _ggcg = _gfca . _egded . _bec [ _dada ] ; } ; } ; _babd := _bf . MakeImageRef ( i , & _gfca . _egded . DocBase , _ggcg ) ; if i . Data == nil && i . Path == "" { return _babd , _cd . New ( "\u0069\u006d\u0061\u0067\u0065\u0020\u006d\u0075\u0073\u0074 \u0068\u0061\u0076\u0065\u0020\u0064\u0061t\u0061\u0020\u006f\u0072\u0020\u0061\u0020\u0070\u0061\u0074\u0068" ) ; } ; if i . Format == "" { return _babd , _cd . New ( "\u0069\u006d\u0061\u0067\u0065\u0020\u006d\u0075\u0073\u0074 \u0068\u0061\u0076\u0065\u0020\u0061\u0020v\u0061\u006c\u0069\u0064\u0020\u0066\u006f\u0072\u006d\u0061\u0074" ) ; } ; if i . Size . X == 0 || i . Size . Y == 0 { return _babd , _cd . New ( "\u0069\u006d\u0061\u0067e\u0020\u006d\u0075\u0073\u0074\u0020\u0068\u0061\u0076\u0065 \u0061 \u0076\u0061\u006c\u0069\u0064\u0020\u0073i\u007a\u0065" ) ; } ; _gfca . _egded . Images = append ( _gfca . _egded . Images , _babd ) ; _edbc := _cfb . Sprintf ( "\u006d\u0065d\u0069\u0061\u002fi\u006d\u0061\u0067\u0065\u0025\u0064\u002e\u0025\u0073" , len ( _gfca . _egded . Images ) , i . Format ) ; _efbe := _ggcg . AddRelationship ( _edbc , _d . ImageType ) ; _babd . SetRelID ( _efbe . X ( ) . IdAttr ) ; return _babd , nil ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetFooter sets a section footer.
func ( _bgfc Section ) SetFooter ( f Footer , t _ba . ST_HdrFtr ) { _feed := _ba . NewEG_HdrFtrReferences ( ) ; _bgfc . _dddg . EG_HdrFtrReferences = append ( _bgfc . _dddg . EG_HdrFtrReferences , _feed ) ; _feed . FooterReference = _ba . NewCT_HdrFtrRef ( ) ; _feed . FooterReference . TypeAttr = t ; _decdd := _bgfc . _daag . _aeg . FindRIDForN ( f . Index ( ) , _d . FooterType ) ; if _decdd == "" { _ga . Print ( "\u0075\u006ea\u0062\u006c\u0065\u0020\u0074\u006f\u0020\u0064\u0065\u0074\u0065\u0072\u006d\u0069\u006e\u0065\u0020\u0066\u006f\u006f\u0074\u0065r \u0049\u0044" ) ; } ; _feed . FooterReference . IdAttr = _decdd ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetNumberingLevel sets the numbering level of a paragraph. If used, then the
// NumberingDefinition must also be set via SetNumberingDefinition or
// SetNumberingDefinitionByID.
func ( _dccbd Paragraph ) SetNumberingLevel ( listLevel int ) { _dccbd . ensurePPr ( ) ; if _dccbd . _acbc . PPr . NumPr == nil { _dccbd . _acbc . PPr . NumPr = _ba . NewCT_NumPr ( ) ; } ; _dgae := _ba . NewCT_DecimalNumber ( ) ; _dgae . ValAttr = int64 ( listLevel ) ; _dccbd . _acbc . PPr . NumPr . Ilvl = _dgae ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetColumnSpan sets the number of Grid Columns Spanned by the Cell. This is used
// to give the appearance of merged cells.
func ( _fde CellProperties ) SetColumnSpan ( cols int ) { if cols == 0 { _fde . _adg . GridSpan = nil ; } else { _fde . _adg . GridSpan = _ba . NewCT_DecimalNumber ( ) ; _fde . _adg . GridSpan . ValAttr = int64 ( cols ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _feg Header ) X ( ) * _ba . Hdr { return _feg . _gcdbe } ; func ( _dac * Document ) insertParagraph ( _gddf Paragraph , _ggfc bool ) Paragraph { if _dac . _dadc . Body == nil { return _dac . AddParagraph ( ) ; } ; _acad := _gddf . X ( ) ; for _ , _aebc := range _dac . _dadc . Body . EG_BlockLevelElts { for _ , _adge := range _aebc . EG_ContentBlockContent { for _fge , _daad := range _adge . P { if _daad == _acad { _fbec := _ba . NewCT_P ( ) ; _adge . P = append ( _adge . P , nil ) ; if _ggfc { copy ( _adge . P [ _fge + 1 : ] , _adge . P [ _fge : ] ) ; _adge . P [ _fge ] = _fbec ; } else { copy ( _adge . P [ _fge + 2 : ] , _adge . P [ _fge + 1 : ] ) ; _adge . P [ _fge + 1 ] = _fbec ; } ; return Paragraph { _dac , _fbec } ; } ; } ; for _ , _gbb := range _adge . Tbl { for _ , _fcba := range _gbb . EG_ContentRowContent { for _ , _fgg := range _fcba . Tr { for _ , _gccd := range _fgg . EG_ContentCellContent { for _ , _gacg := range _gccd . Tc { for _ , _bfab := range _gacg . EG_BlockLevelElts { for _ , _fcbad := range _bfab . EG_ContentBlockContent { for _fag , _dage := range _fcbad . P { if _dage == _acad { _gdgdc := _ba . NewCT_P ( ) ; _fcbad . P = append ( _fcbad . P , nil ) ; if _ggfc { copy ( _fcbad . P [ _fag + 1 : ] , _fcbad . P [ _fag : ] ) ; _fcbad . P [ _fag ] = _gdgdc ; } else { copy ( _fcbad . P [ _fag + 2 : ] , _fcbad . P [ _fag + 1 : ] ) ; _fcbad . P [ _fag + 1 ] = _gdgdc ; } ; return Paragraph { _dac , _gdgdc } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; if _adge . Sdt != nil && _adge . Sdt . SdtContent != nil && _adge . Sdt . SdtContent . P != nil { for _cgdc , _dabf := range _adge . Sdt . SdtContent . P { if _dabf == _acad { _ebdd := _ba . NewCT_P ( ) ; _adge . Sdt . SdtContent . P = append ( _adge . Sdt . SdtContent . P , nil ) ; if _ggfc { copy ( _adge . Sdt . SdtContent . P [ _cgdc + 1 : ] , _adge . Sdt . SdtContent . P [ _cgdc : ] ) ; _adge . Sdt . SdtContent . P [ _cgdc ] = _ebdd ; } else { copy ( _adge . Sdt . SdtContent . P [ _cgdc + 2 : ] , _adge . Sdt . SdtContent . P [ _cgdc + 1 : ] ) ; _adge . Sdt . SdtContent . P [ _cgdc + 1 ] = _ebdd ; } ; return Paragraph { _dac , _ebdd } ; } ; } ; } ; } ; } ; return _dac . AddParagraph ( ) ; } ; func ( _fbag * Document ) InsertTableAfter ( relativeTo Paragraph ) Table { return _fbag . insertTable ( relativeTo , false ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// TableLook returns the table look, or conditional formatting applied to a table style.
func ( _ccbc TableProperties ) TableLook ( ) TableLook { if _ccbc . _efeg . TblLook == nil { _ccbc . _efeg . TblLook = _ba . NewCT_TblLook ( ) ; } ; return TableLook { _ccbc . _efeg . TblLook } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetOffset sets the offset of the image relative to the origin, which by
// default this is the top-left corner of the page. Offset is incompatible with
// SetAlignment, whichever is called last is applied.
func ( _ef AnchoredDrawing ) SetOffset ( x , y _gc . Distance ) { _ef . SetXOffset ( x ) ; _ef . SetYOffset ( y ) } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Properties returns the table properties.
func ( _gcgf Table ) Properties ( ) TableProperties { if _gcgf . _fbdg . TblPr == nil { _gcgf . _fbdg . TblPr = _ba . NewCT_TblPr ( ) ; } ; return TableProperties { _gcgf . _fbdg . TblPr } ; } ;
2017-09-26 18:18:59 -05:00
2021-01-04 16:11:39 +00:00
// SetTextWrapNone unsets text wrapping so the image can float on top of the
// text. When used in conjunction with X/Y Offset relative to the page it can be
// used to place a logo at the top of a page at an absolute position that
// doesn't interfere with text.
func ( _gab AnchoredDrawing ) SetTextWrapNone ( ) { _gab . _eg . Choice = & _ba . WdEG_WrapTypeChoice { } ; _gab . _eg . Choice . WrapNone = _ba . NewWdCT_WrapNone ( ) ; } ;
2017-09-26 18:18:59 -05:00
2021-01-04 16:11:39 +00:00
// Underline returns the type of paragraph underline.
func ( _beege ParagraphProperties ) Underline ( ) _ba . ST_Underline { if _adgd := _beege . _gcdf . RPr . U ; _adgd != nil { return _adgd . ValAttr ; } ; return 0 ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetLeftIndent controls the left indent of the paragraph.
func ( _cdec ParagraphStyleProperties ) SetLeftIndent ( m _gc . Distance ) { if _cdec . _gdb . Ind == nil { _cdec . _gdb . Ind = _ba . NewCT_Ind ( ) ; } ; if m == _gc . Zero { _cdec . _gdb . Ind . LeftAttr = nil ; } else { _cdec . _gdb . Ind . LeftAttr = & _ba . ST_SignedTwipsMeasure { } ; _cdec . _gdb . Ind . LeftAttr . Int64 = _d . Int64 ( int64 ( m / _gc . Twips ) ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddParagraph adds a new paragraph to the document body.
func ( _fab * Document ) AddParagraph ( ) Paragraph { _fgbe := _ba . NewEG_BlockLevelElts ( ) ; _fab . _dadc . Body . EG_BlockLevelElts = append ( _fab . _dadc . Body . EG_BlockLevelElts , _fgbe ) ; _cad := _ba . NewEG_ContentBlockContent ( ) ; _fgbe . EG_ContentBlockContent = append ( _fgbe . EG_ContentBlockContent , _cad ) ; _fabf := _ba . NewCT_P ( ) ; _cad . P = append ( _cad . P , _fabf ) ; return Paragraph { _fab , _fabf } ; } ; func ( _aagf Paragraph ) addBeginFldChar ( _efdea string ) * _ba . CT_FFData { _afebd := _aagf . addFldChar ( ) ; _afebd . FldCharTypeAttr = _ba . ST_FldCharTypeBegin ; _afebd . FfData = _ba . NewCT_FFData ( ) ; _ffa := _ba . NewCT_FFName ( ) ; _ffa . ValAttr = & _efdea ; _afebd . FfData . Name = [ ] * _ba . CT_FFName { _ffa } ; return _afebd . FfData ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// StructuredDocumentTags returns the structured document tags in the document
// which are commonly used in document templates.
func ( _eda * Document ) StructuredDocumentTags ( ) [ ] StructuredDocumentTag { _ecf := [ ] StructuredDocumentTag { } ; for _ , _baf := range _eda . _dadc . Body . EG_BlockLevelElts { for _ , _cgg := range _baf . EG_ContentBlockContent { if _cgg . Sdt != nil { _ecf = append ( _ecf , StructuredDocumentTag { _eda , _cgg . Sdt } ) ; } ; } ; } ; return _ecf ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// FormFieldType is the type of the form field.
//go:generate stringer -type=FormFieldType
type FormFieldType byte ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Properties returns the cell properties.
func ( _dga Cell ) Properties ( ) CellProperties { if _dga . _bd . TcPr == nil { _dga . _bd . TcPr = _ba . NewCT_TcPr ( ) ; } ; return CellProperties { _dga . _bd . TcPr } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// TextItem is used for keeping text with references to a paragraph and run or a table, a row and a cell where it is located.
type TextItem struct { Text string ; DrawingInfo * DrawingInfo ; Paragraph * _ba . CT_P ; Hyperlink * _ba . CT_Hyperlink ; Run * _ba . CT_R ; TableInfo * TableInfo ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetStartPct sets the cell start margin
func ( _bad CellMargins ) SetStartPct ( pct float64 ) { _bad . _aab . Start = _ba . NewCT_TblWidth ( ) ; _ade ( _bad . _aab . Start , pct ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// InsertRunBefore inserts a run in the paragraph before the relative run.
func ( _baga Paragraph ) InsertRunBefore ( relativeTo Run ) Run { return _baga . insertRun ( relativeTo , true ) } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetEmboss sets the run to embossed text.
func ( _aefec RunProperties ) SetEmboss ( b bool ) { if ! b { _aefec . _bdgac . Emboss = nil ; } else { _aefec . _bdgac . Emboss = _ba . NewCT_OnOff ( ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetRight sets the cell right margin
func ( _ae CellMargins ) SetRight ( d _gc . Distance ) { _ae . _aab . Right = _ba . NewCT_TblWidth ( ) ; _gaag ( _ae . _aab . Right , d ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddText adds tet to a run.
func ( _ecfbe Run ) AddText ( s string ) { _ccafg := _ba . NewEG_RunInnerContent ( ) ; _ecfbe . _afde . EG_RunInnerContent = append ( _ecfbe . _afde . EG_RunInnerContent , _ccafg ) ; _ccafg . T = _ba . NewCT_Text ( ) ; if _d . NeedsSpacePreserve ( s ) { _dedge := "\u0070\u0072\u0065\u0073\u0065\u0072\u0076\u0065" ; _ccafg . T . SpaceAttr = & _dedge ; } ; _ccafg . T . Content = s ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Emboss returns true if run emboss is on.
func ( _dbbc RunProperties ) Emboss ( ) bool { return _bfbg ( _dbbc . _bdgac . Emboss ) } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetRowBandSize sets the number of Rows in the row band
func ( _cadfa TableStyleProperties ) SetRowBandSize ( rows int64 ) { _cadfa . _bggdc . TblStyleRowBandSize = _ba . NewCT_DecimalNumber ( ) ; _cadfa . _bggdc . TblStyleRowBandSize . ValAttr = rows ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// FormField is a form within a document. It references the document, so changes
// to the form field wil be reflected in the document if it is saved.
type FormField struct { _edgb * _ba . CT_FFData ; _cggf * _ba . EG_RunInnerContent ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddImage adds an image to the document package, returning a reference that
// can be used to add the image to a run and place it in the document contents.
func ( _ebec Footer ) AddImage ( i _bf . Image ) ( _bf . ImageRef , error ) { var _abgce _bf . Relationships ; for _ggac , _ffe := range _ebec . _fdea . _ggdc { if _ffe == _ebec . _cged { _abgce = _ebec . _fdea . _cbb [ _ggac ] ; } ; } ; _ggge := _bf . MakeImageRef ( i , & _ebec . _fdea . DocBase , _abgce ) ; if i . Data == nil && i . Path == "" { return _ggge , _cd . New ( "\u0069\u006d\u0061\u0067\u0065\u0020\u006d\u0075\u0073\u0074 \u0068\u0061\u0076\u0065\u0020\u0064\u0061t\u0061\u0020\u006f\u0072\u0020\u0061\u0020\u0070\u0061\u0074\u0068" ) ; } ; if i . Format == "" { return _ggge , _cd . New ( "\u0069\u006d\u0061\u0067\u0065\u0020\u006d\u0075\u0073\u0074 \u0068\u0061\u0076\u0065\u0020\u0061\u0020v\u0061\u006c\u0069\u0064\u0020\u0066\u006f\u0072\u006d\u0061\u0074" ) ; } ; if i . Size . X == 0 || i . Size . Y == 0 { return _ggge , _cd . New ( "\u0069\u006d\u0061\u0067e\u0020\u006d\u0075\u0073\u0074\u0020\u0068\u0061\u0076\u0065 \u0061 \u0076\u0061\u006c\u0069\u0064\u0020\u0073i\u007a\u0065" ) ; } ; _ebec . _fdea . Images = append ( _ebec . _fdea . Images , _ggge ) ; _affd := _cfb . Sprintf ( "\u006d\u0065d\u0069\u0061\u002fi\u006d\u0061\u0067\u0065\u0025\u0064\u002e\u0025\u0073" , len ( _ebec . _fdea . Images ) , i . Format ) ; _dead := _abgce . AddRelationship ( _affd , _d . ImageType ) ; _ggge . SetRelID ( _dead . X ( ) . IdAttr ) ; return _ggge , nil ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddTabStop adds a tab stop to the paragraph.
func ( _bafg ParagraphStyleProperties ) AddTabStop ( position _gc . Distance , justificaton _ba . ST_TabJc , leader _ba . ST_TabTlc ) { if _bafg . _gdb . Tabs == nil { _bafg . _gdb . Tabs = _ba . NewCT_Tabs ( ) ; } ; _abe := _ba . NewCT_TabStop ( ) ; _abe . LeaderAttr = leader ; _abe . ValAttr = justificaton ; _abe . PosAttr . Int64 = _d . Int64 ( int64 ( position / _gc . Twips ) ) ; _bafg . _gdb . Tabs . Tab = append ( _bafg . _gdb . Tabs . Tab , _abe ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetFirstRow controls the conditional formatting for the first row in a table.
func ( _cfbd TableLook ) SetFirstRow ( on bool ) { if ! on { _cfbd . _acbdf . FirstRowAttr = & _dc . ST_OnOff { } ; _cfbd . _acbdf . FirstRowAttr . ST_OnOff1 = _dc . ST_OnOff1Off ; } else { _cfbd . _acbdf . FirstRowAttr = & _dc . ST_OnOff { } ; _cfbd . _acbdf . FirstRowAttr . ST_OnOff1 = _dc . ST_OnOff1On ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Strike returns true if paragraph is striked.
func ( _egag ParagraphProperties ) Strike ( ) bool { return _bfbg ( _egag . _gcdf . RPr . Strike ) } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetColor sets a specific color or auto.
func ( _fbc Color ) SetColor ( v _fb . Color ) { if v . IsAuto ( ) { _fbc . _gf . ValAttr . ST_HexColorAuto = _ba . ST_HexColorAutoAuto ; _fbc . _gf . ValAttr . ST_HexColorRGB = nil ; } else { _fbc . _gf . ValAttr . ST_HexColorAuto = _ba . ST_HexColorAutoUnset ; _fbc . _gf . ValAttr . ST_HexColorRGB = v . AsRGBString ( ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// RemoveParagraph removes a paragraph from a footer.
func ( _bff Header ) RemoveParagraph ( p Paragraph ) { for _ , _gabg := range _bff . _gcdbe . EG_ContentBlockContent { for _egga , _ebecc := range _gabg . P { if _ebecc == p . _acbc { copy ( _gabg . P [ _egga : ] , _gabg . P [ _egga + 1 : ] ) ; _gabg . P = _gabg . P [ 0 : len ( _gabg . P ) - 1 ] ; return ; } ; } ; } ; } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// Run is a run of text within a paragraph that shares the same formatting.
type Run struct { _cebg * Document ; _afde * _ba . CT_R ; } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// Borders allows manipulation of the table borders.
func ( _cggd TableStyleProperties ) Borders ( ) TableBorders { if _cggd . _bggdc . TblBorders == nil { _cggd . _bggdc . TblBorders = _ba . NewCT_TblBorders ( ) ; } ; return TableBorders { _cggd . _bggdc . TblBorders } ; } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// EastAsiaFont returns the name of run font family for East Asia.
func ( _gdde RunProperties ) EastAsiaFont ( ) string { if _abfcc := _gdde . _bdgac . RFonts ; _abfcc != nil { if _abfcc . EastAsiaAttr != nil { return * _abfcc . EastAsiaAttr ; } ; } ; return "" ; } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// Text returns the underlying tet in the run.
func ( _ecfc Run ) Text ( ) string { if len ( _ecfc . _afde . EG_RunInnerContent ) == 0 { return "" ; } ; _bgcgb := _dg . Buffer { } ; for _ , _agae := range _ecfc . _afde . EG_RunInnerContent { if _agae . T != nil { _bgcgb . WriteString ( _agae . T . Content ) ; } ; if _agae . Tab != nil { _bgcgb . WriteByte ( '\t' ) ; } ; } ; return _bgcgb . String ( ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetKeepWithNext controls if this paragraph should be kept with the next.
func ( _abgcd ParagraphProperties ) SetKeepWithNext ( b bool ) { if ! b { _abgcd . _gcdf . KeepNext = nil ; } else { _abgcd . _gcdf . KeepNext = _ba . NewCT_OnOff ( ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddParagraph adds a paragraph to the header.
func ( _ecc Header ) AddParagraph ( ) Paragraph { _dcda := _ba . NewEG_ContentBlockContent ( ) ; _ecc . _gcdbe . EG_ContentBlockContent = append ( _ecc . _gcdbe . EG_ContentBlockContent , _dcda ) ; _dbaa := _ba . NewCT_P ( ) ; _dcda . P = append ( _dcda . P , _dbaa ) ; return Paragraph { _ecc . _egded , _dbaa } ; } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// SetPrimaryStyle marks the style as a primary style.
func ( _cgdg Style ) SetPrimaryStyle ( b bool ) { if b { _cgdg . _ebcb . QFormat = _ba . NewCT_OnOff ( ) ; } else { _cgdg . _ebcb . QFormat = nil ; } ; } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// SetWidthAuto sets the the cell width to automatic.
func ( _agf CellProperties ) SetWidthAuto ( ) { _agf . _adg . TcW = _ba . NewCT_TblWidth ( ) ; _agf . _adg . TcW . TypeAttr = _ba . ST_TblWidthAuto ; } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// SetSpacing sets the spacing that comes before and after the paragraph.
func ( _ebeeb ParagraphStyleProperties ) SetSpacing ( before , after _gc . Distance ) { if _ebeeb . _gdb . Spacing == nil { _ebeeb . _gdb . Spacing = _ba . NewCT_Spacing ( ) ; } ; if before == _gc . Zero { _ebeeb . _gdb . Spacing . BeforeAttr = nil ; } else { _ebeeb . _gdb . Spacing . BeforeAttr = & _dc . ST_TwipsMeasure { } ; _ebeeb . _gdb . Spacing . BeforeAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( before / _gc . Twips ) ) ; } ; if after == _gc . Zero { _ebeeb . _gdb . Spacing . AfterAttr = nil ; } else { _ebeeb . _gdb . Spacing . AfterAttr = & _dc . ST_TwipsMeasure { } ; _ebeeb . _gdb . Spacing . AfterAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( after / _gc . Twips ) ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// GetColor returns the color.Color object representing the run color.
func ( _baea ParagraphProperties ) GetColor ( ) _fb . Color { if _eddgd := _baea . _gcdf . RPr . Color ; _eddgd != nil { _bcae := _eddgd . ValAttr ; if _bcae . ST_HexColorRGB != nil { return _fb . FromHex ( * _bcae . ST_HexColorRGB ) ; } ; } ; return _fb . Color { } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Document is a text document that can be written out in the OOXML .docx
// format. It can be opened from a file on disk and modified, or created from
// scratch.
type Document struct { _bf . DocBase ; _dadc * _ba . Document ; Settings Settings ; Numbering Numbering ; Styles Styles ; _adgc [ ] * _ba . Hdr ; _bec [ ] _bf . Relationships ; _ggdc [ ] * _ba . Ftr ; _cbb [ ] _bf . Relationships ; _aeg _bf . Relationships ; _eca [ ] * _cde . Theme ; _bca * _ba . WebSettings ; _add * _ba . Fonts ; _bed * _ba . Endnotes ; _bgd * _ba . Footnotes ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// RunProperties returns the RunProperties controlling numbering level font, etc.
func ( _deca NumberingLevel ) RunProperties ( ) RunProperties { if _deca . _bbgd . RPr == nil { _deca . _bbgd . RPr = _ba . NewCT_RPr ( ) ; } ; return RunProperties { _deca . _bbgd . RPr } ; } ; func ( _fbga Paragraph ) addFldChar ( ) * _ba . CT_FldChar { _dcbb := _fbga . AddRun ( ) ; _ccfc := _dcbb . X ( ) ; _bfbff := _ba . NewEG_RunInnerContent ( ) ; _gggda := _ba . NewCT_FldChar ( ) ; _bfbff . FldChar = _gggda ; _ccfc . EG_RunInnerContent = append ( _ccfc . EG_RunInnerContent , _bfbff ) ; return _gggda ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Fonts allows manipulating a style or run's fonts.
type Fonts struct { _ffb * _ba . CT_Fonts } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetRight sets the right border to a specified type, color and thickness.
func ( _bdff TableBorders ) SetRight ( t _ba . ST_Border , c _fb . Color , thickness _gc . Distance ) { _bdff . _edag . Right = _ba . NewCT_Border ( ) ; _deec ( _bdff . _edag . Right , t , c , thickness ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// ComplexSizeValue returns the value of paragraph font size for complex fonts in points.
func ( _dbg ParagraphProperties ) ComplexSizeValue ( ) float64 { if _gfafg := _dbg . _gcdf . RPr . SzCs ; _gfafg != nil { _cbgg := _gfafg . ValAttr ; if _cbgg . ST_UnsignedDecimalNumber != nil { return float64 ( * _cbgg . ST_UnsignedDecimalNumber ) / 2 ; } ; } ; return 0.0 ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Type returns the type of the field.
func ( _cege FormField ) Type ( ) FormFieldType { if _cege . _edgb . TextInput != nil { return FormFieldTypeText ; } else if _cege . _edgb . CheckBox != nil { return FormFieldTypeCheckBox ; } else if _cege . _edgb . DdList != nil { return FormFieldTypeDropDown ; } ; return FormFieldTypeUnknown ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// ClearColor clears the text color.
func ( _cffcc RunProperties ) ClearColor ( ) { _cffcc . _bdgac . Color = nil } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Open opens and reads a document from a file (.docx).
func Open ( filename string ) ( * Document , error ) { _addf , _abfg := _a . Open ( filename ) ; if _abfg != nil { return nil , _cfb . Errorf ( "e\u0072r\u006f\u0072\u0020\u006f\u0070\u0065\u006e\u0069n\u0067\u0020\u0025\u0073: \u0025\u0073" , filename , _abfg ) ; } ; defer _addf . Close ( ) ; _eedf , _abfg := _a . Stat ( filename ) ; if _abfg != nil { return nil , _cfb . Errorf ( "e\u0072r\u006f\u0072\u0020\u006f\u0070\u0065\u006e\u0069n\u0067\u0020\u0025\u0073: \u0025\u0073" , filename , _abfg ) ; } ; _ = _eedf ; return Read ( _addf , _eedf . Size ( ) ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _bba Bookmark ) X ( ) * _ba . CT_Bookmark { return _bba . _fg } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetOutlineLevel sets the outline level of this style.
func ( _afega ParagraphStyleProperties ) SetOutlineLevel ( lvl int ) { _afega . _gdb . OutlineLvl = _ba . NewCT_DecimalNumber ( ) ; _afega . _gdb . OutlineLvl . ValAttr = int64 ( lvl ) ; } ;
2017-08-28 20:56:18 -05:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _fdcg Run ) X ( ) * _ba . CT_R { return _fdcg . _afde } ;
2020-03-13 09:53:51 +00:00
2021-01-04 16:11:39 +00:00
// NumberingDefinition defines a numbering definition for a list of pragraphs.
type NumberingDefinition struct { _ceab * _ba . CT_AbstractNum } ;
2020-03-13 09:53:51 +00:00
2021-01-04 16:11:39 +00:00
// Underline returns the type of run underline.
func ( _abab RunProperties ) Underline ( ) _ba . ST_Underline { if _eeefd := _abab . _bdgac . U ; _eeefd != nil { return _eeefd . ValAttr ; } ; return 0 ; } ;
2020-03-13 09:53:51 +00:00
2021-01-04 16:11:39 +00:00
// SetTargetByRef sets the URL target of the hyperlink and is more efficient if a link
// destination will be used many times.
func ( _fgfb HyperLink ) SetTargetByRef ( link _bf . Hyperlink ) { _fgfb . _edfg . IdAttr = _d . String ( _bf . Relationship ( link ) . ID ( ) ) ; _fgfb . _edfg . AnchorAttr = nil ; } ;
2020-03-13 09:53:51 +00:00
2021-01-04 16:11:39 +00:00
// SetInsideVertical sets the interior vertical borders to a specified type, color and thickness.
func ( _ab CellBorders ) SetInsideVertical ( t _ba . ST_Border , c _fb . Color , thickness _gc . Distance ) { _ab . _fbd . InsideV = _ba . NewCT_Border ( ) ; _deec ( _ab . _fbd . InsideV , t , c , thickness ) ; } ;
2020-03-13 09:53:51 +00:00
2021-01-04 16:11:39 +00:00
// Rows returns the rows defined in the table.
func ( _abbgc Table ) Rows ( ) [ ] Row { _acga := [ ] Row { } ; for _ , _aged := range _abbgc . _fbdg . EG_ContentRowContent { for _ , _fccf := range _aged . Tr { _acga = append ( _acga , Row { _abbgc . _fgdbd , _fccf } ) ; } ; if _aged . Sdt != nil && _aged . Sdt . SdtContent != nil { for _ , _eddf := range _aged . Sdt . SdtContent . Tr { _acga = append ( _acga , Row { _abbgc . _fgdbd , _eddf } ) ; } ; } ; } ; return _acga ; } ;
2020-03-13 09:53:51 +00:00
2021-01-04 16:11:39 +00:00
// AddParagraph adds a paragraph to the footnote.
func ( _gee Footnote ) AddParagraph ( ) Paragraph { _afg := _ba . NewEG_ContentBlockContent ( ) ; _gcgeg := len ( _gee . _dabgg . EG_BlockLevelElts [ 0 ] . EG_ContentBlockContent ) ; _gee . _dabgg . EG_BlockLevelElts [ 0 ] . EG_ContentBlockContent = append ( _gee . _dabgg . EG_BlockLevelElts [ 0 ] . EG_ContentBlockContent , _afg ) ; _cdca := _ba . NewCT_P ( ) ; var _cdcf * _ba . CT_String ; if _gcgeg != 0 { _dbfe := len ( _gee . _dabgg . EG_BlockLevelElts [ 0 ] . EG_ContentBlockContent [ _gcgeg - 1 ] . P ) ; _cdcf = _gee . _dabgg . EG_BlockLevelElts [ 0 ] . EG_ContentBlockContent [ _gcgeg - 1 ] . P [ _dbfe - 1 ] . PPr . PStyle ; } else { _cdcf = _ba . NewCT_String ( ) ; _cdcf . ValAttr = "\u0046\u006f\u006f\u0074\u006e\u006f\u0074\u0065" ; } ; _afg . P = append ( _afg . P , _cdca ) ; _efeb := Paragraph { _gee . _abfeg , _cdca } ; _efeb . _acbc . PPr = _ba . NewCT_PPr ( ) ; _efeb . _acbc . PPr . PStyle = _cdcf ; _efeb . _acbc . PPr . RPr = _ba . NewCT_ParaRPr ( ) ; return _efeb ; } ;
2017-08-28 20:56:18 -05:00
2021-01-04 16:11:39 +00:00
// DocText is an array of extracted text items which has some methods for representing extracted text.
type DocText struct { Items [ ] TextItem ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetPossibleValues sets possible values for a FormFieldTypeDropDown.
func ( _cdde FormField ) SetPossibleValues ( values [ ] string ) { if _cdde . _edgb . DdList != nil { for _ , _aabfd := range values { _dgea := _ba . NewCT_String ( ) ; _dgea . ValAttr = _aabfd ; _cdde . _edgb . DdList . ListEntry = append ( _cdde . _edgb . DdList . ListEntry , _dgea ) ; } ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetFontFamily sets the Ascii & HAnsi fonly family for a run.
func ( _cbbg RunProperties ) SetFontFamily ( family string ) { if _cbbg . _bdgac . RFonts == nil { _cbbg . _bdgac . RFonts = _ba . NewCT_Fonts ( ) ; } ; _cbbg . _bdgac . RFonts . AsciiAttr = _d . String ( family ) ; _cbbg . _bdgac . RFonts . HAnsiAttr = _d . String ( family ) ; _cbbg . _bdgac . RFonts . EastAsiaAttr = _d . String ( family ) ; } ; func _aedf ( _fecbe * _ba . CT_Tbl , _ccad map [ string ] string ) { for _ , _fddb := range _fecbe . EG_ContentRowContent { for _ , _eafg := range _fddb . Tr { for _ , _bdec := range _eafg . EG_ContentCellContent { for _ , _efbg := range _bdec . Tc { for _ , _eaba := range _efbg . EG_BlockLevelElts { for _ , _ggdd := range _eaba . EG_ContentBlockContent { for _ , _gff := range _ggdd . P { _fbagb ( _gff , _ccad ) ; } ; for _ , _cbae := range _ggdd . Tbl { _aedf ( _cbae , _ccad ) ; } ; } ; } ; } ; } ; } ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetName sets the name of the bookmark. This is the name that is used to
// reference the bookmark from hyperlinks.
func ( _egd Bookmark ) SetName ( name string ) { _egd . _fg . NameAttr = name } ; type mergeFieldInfo struct { _cfda string ; _cabe string ; _cda string ; _aafb bool ; _gfcae bool ; _faaf bool ; _eeac bool ; _deadc Paragraph ; _dbcg , _cgac , _abbf int ; _ceca * _ba . EG_PContent ; _gbeb bool ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetUnhideWhenUsed controls if a semi hidden style becomes visible when used.
func ( _gfbg Style ) SetUnhideWhenUsed ( b bool ) { if b { _gfbg . _ebcb . UnhideWhenUsed = _ba . NewCT_OnOff ( ) ; } else { _gfbg . _ebcb . UnhideWhenUsed = nil ; } ; } ; func ( _aedb Footnote ) content ( ) [ ] * _ba . EG_ContentBlockContent { var _addc [ ] * _ba . EG_ContentBlockContent ; for _ , _daae := range _aedb . _dabgg . EG_BlockLevelElts { _addc = append ( _addc , _daae . EG_ContentBlockContent ... ) ; } ; return _addc ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetStyle sets the font size.
func ( _bccef RunProperties ) SetStyle ( style string ) { if style == "" { _bccef . _bdgac . RStyle = nil ; } else { _bccef . _bdgac . RStyle = _ba . NewCT_String ( ) ; _bccef . _bdgac . RStyle . ValAttr = style ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// DoubleStrike returns true if paragraph is double striked.
func ( _fdbd ParagraphProperties ) DoubleStrike ( ) bool { return _bfbg ( _fdbd . _gcdf . RPr . Dstrike ) } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped type
func ( _bae CellBorders ) X ( ) * _ba . CT_TcBorders { return _bae . _fbd } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// CharacterSpacingMeasure returns paragraph characters spacing with its measure which can be mm, cm, in, pt, pc or pi.
func ( _cgefb ParagraphProperties ) CharacterSpacingMeasure ( ) string { if _gcca := _cgefb . _gcdf . RPr . Spacing ; _gcca != nil { _cffef := _gcca . ValAttr ; if _cffef . ST_UniversalMeasure != nil { return * _cffef . ST_UniversalMeasure ; } ; } ; return "" ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddTab adds tab to a run and can be used with the the Paragraph's tab stops.
func ( _dadf Run ) AddTab ( ) { _ebdb := _dadf . newIC ( ) ; _ebdb . Tab = _ba . NewCT_Empty ( ) } ; func ( _dggff Endnote ) content ( ) [ ] * _ba . EG_ContentBlockContent { var _cfe [ ] * _ba . EG_ContentBlockContent ; for _ , _efdg := range _dggff . _adff . EG_BlockLevelElts { _cfe = append ( _cfe , _efdg . EG_ContentBlockContent ... ) ; } ; return _cfe ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetLinkedStyle sets the style that this style is linked to.
func ( _cgcgf Style ) SetLinkedStyle ( name string ) { if name == "" { _cgcgf . _ebcb . Link = nil ; } else { _cgcgf . _ebcb . Link = _ba . NewCT_String ( ) ; _cgcgf . _ebcb . Link . ValAttr = name ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetASCIITheme sets the font ASCII Theme.
func ( _babc Fonts ) SetASCIITheme ( t _ba . ST_Theme ) { _babc . _ffb . AsciiThemeAttr = t } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Shadow returns true if run shadow is on.
func ( _fdaec RunProperties ) Shadow ( ) bool { return _bfbg ( _fdaec . _bdgac . Shadow ) } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetVerticalAlignment controls the vertical alignment of the run, this is used
// to control if text is superscript/subscript.
func ( _afad RunProperties ) SetVerticalAlignment ( v _dc . ST_VerticalAlignRun ) { if v == _dc . ST_VerticalAlignRunUnset { _afad . _bdgac . VertAlign = nil ; } else { _afad . _bdgac . VertAlign = _ba . NewCT_VerticalAlignRun ( ) ; _afad . _bdgac . VertAlign . ValAttr = v ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// GetHeader gets a section Header for given type t [ST_HdrFtrDefault, ST_HdrFtrEven, ST_HdrFtrFirst]
func ( _fgcg Section ) GetHeader ( t _ba . ST_HdrFtr ) ( Header , bool ) { for _ , _bccc := range _fgcg . _dddg . EG_HdrFtrReferences { if _bccc . HeaderReference . TypeAttr == t { for _ , _abeg := range _fgcg . _daag . Headers ( ) { _fdbe := _fgcg . _daag . _aeg . FindRIDForN ( _abeg . Index ( ) , _d . HeaderType ) ; if _fdbe == _bccc . HeaderReference . IdAttr { return _abeg , true ; } ; } ; } ; } ; return Header { } , false ; } ; func ( _gcf * Document ) InsertTableBefore ( relativeTo Paragraph ) Table { return _gcf . insertTable ( relativeTo , true ) ; } ;
2020-10-12 13:59:12 +00:00
2021-01-04 16:11:39 +00:00
// UnderlineColor returns the hex color value of run underline.
func ( _fgdbf RunProperties ) UnderlineColor ( ) string { if _cgdcb := _fgdbf . _bdgac . U ; _cgdcb != nil { _cccd := _cgdcb . ColorAttr ; if _cccd != nil && _cccd . ST_HexColorRGB != nil { return * _cccd . ST_HexColorRGB ; } ; } ; return "" ; } ;
2020-10-12 13:59:12 +00:00
2021-01-04 16:11:39 +00:00
// RemoveEndnote removes a endnote from both the paragraph and the document
// the requested endnote must be anchored on the paragraph being referenced.
func ( _ecd Paragraph ) RemoveEndnote ( id int64 ) { _bedc := _ecd . _dcbe . _bed ; var _beef int ; for _defd , _aded := range _bedc . CT_Endnotes . Endnote { if _aded . IdAttr == id { _beef = _defd ; } ; } ; _beef = 0 ; _bedc . CT_Endnotes . Endnote [ _beef ] = nil ; _bedc . CT_Endnotes . Endnote [ _beef ] = _bedc . CT_Endnotes . Endnote [ len ( _bedc . CT_Endnotes . Endnote ) - 1 ] ; _bedc . CT_Endnotes . Endnote = _bedc . CT_Endnotes . Endnote [ : len ( _bedc . CT_Endnotes . Endnote ) - 1 ] ; var _dbdbf Run ; for _ , _ggebd := range _ecd . Runs ( ) { if _fcge , _gfcc := _ggebd . IsEndnote ( ) ; _fcge { if _gfcc == id { _dbdbf = _ggebd ; } ; } ; } ; _ecd . RemoveRun ( _dbdbf ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddTable adds a table to the table cell.
func ( _bab Cell ) AddTable ( ) Table { _ea := _ba . NewEG_BlockLevelElts ( ) ; _bab . _bd . EG_BlockLevelElts = append ( _bab . _bd . EG_BlockLevelElts , _ea ) ; _fdf := _ba . NewEG_ContentBlockContent ( ) ; _ea . EG_ContentBlockContent = append ( _ea . EG_ContentBlockContent , _fdf ) ; _ggd := _ba . NewCT_Tbl ( ) ; _fdf . Tbl = append ( _fdf . Tbl , _ggd ) ; return Table { _bab . _ad , _ggd } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetCellSpacingAuto sets the cell spacing within a table to automatic.
func ( _caeaa TableStyleProperties ) SetCellSpacingAuto ( ) { _caeaa . _bggdc . TblCellSpacing = _ba . NewCT_TblWidth ( ) ; _caeaa . _bggdc . TblCellSpacing . TypeAttr = _ba . ST_TblWidthAuto ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// InitializeDefault constructs a default numbering.
func ( _abgf Numbering ) InitializeDefault ( ) { _ccaae := _ba . NewCT_AbstractNum ( ) ; _ccaae . MultiLevelType = _ba . NewCT_MultiLevelType ( ) ; _ccaae . MultiLevelType . ValAttr = _ba . ST_MultiLevelTypeHybridMultilevel ; _abgf . _cbga . AbstractNum = append ( _abgf . _cbga . AbstractNum , _ccaae ) ; _ccaae . AbstractNumIdAttr = 1 ; const _caecd = 720 ; const _ede = 720 ; const _fece = 360 ; for _eeae := 0 ; _eeae < 9 ; _eeae ++ { _bbeg := _ba . NewCT_Lvl ( ) ; _bbeg . IlvlAttr = int64 ( _eeae ) ; _bbeg . Start = _ba . NewCT_DecimalNumber ( ) ; _bbeg . Start . ValAttr = 1 ; _bbeg . NumFmt = _ba . NewCT_NumFmt ( ) ; _bbeg . NumFmt . ValAttr = _ba . ST_NumberFormatBullet ; _bbeg . Suff = _ba . NewCT_LevelSuffix ( ) ; _bbeg . Suff . ValAttr = _ba . ST_LevelSuffixNothing ; _bbeg . LvlText = _ba . NewCT_LevelText ( ) ; _bbeg . LvlText . ValAttr = _d . String ( "\uf0b7" ) ; _bbeg . LvlJc = _ba . NewCT_Jc ( ) ; _bbeg . LvlJc . ValAttr = _ba . ST_JcLeft ; _bbeg . RPr = _ba . NewCT_RPr ( ) ; _bbeg . RPr . RFonts = _ba . NewCT_Fonts ( ) ; _bbeg . RPr . RFonts . AsciiAttr = _d . String ( "\u0053\u0079\u006d\u0062\u006f\u006c" ) ; _bbeg . RPr . RFonts . HAnsiAttr = _d . String ( "\u0053\u0079\u006d\u0062\u006f\u006c" ) ; _bbeg . RPr . RFonts . HintAttr = _ba . ST_HintDefault ; _bbeg . PPr = _ba . NewCT_PPrGeneral ( ) ; _fbbb := int64 ( _eeae * _ede + _caecd ) ; _bbeg . PPr . Ind = _ba . NewCT_Ind ( ) ; _bbeg . PPr . Ind . LeftAttr = & _ba . ST_SignedTwipsMeasure { } ; _bbeg . PPr . Ind . LeftAttr . Int64 = _d . Int64 ( _fbbb ) ; _bbeg . PPr . Ind . HangingAttr = & _dc . ST_TwipsMeasure { } ; _bbeg . PPr . Ind . HangingAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( _fece ) ) ; _ccaae . Lvl = append ( _ccaae . Lvl , _bbeg ) ; } ; _gcad := _ba . NewCT_Num ( ) ; _gcad . NumIdAttr = 1 ; _gcad . AbstractNumId = _ba . NewCT_DecimalNumber ( ) ; _gcad . AbstractNumId . ValAttr = 1 ; _abgf . _cbga . Num = append ( _abgf . _cbga . Num , _gcad ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Bold returns true if paragraph font is bold.
func ( _cddef ParagraphProperties ) Bold ( ) bool { _eeab := _cddef . _gcdf . RPr ; return _bfbg ( _eeab . B ) || _bfbg ( _eeab . BCs ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetAfterAuto controls if spacing after a paragraph is automatically determined.
func ( _cbbf ParagraphSpacing ) SetAfterAuto ( b bool ) { if b { _cbbf . _afefd . AfterAutospacingAttr = & _dc . ST_OnOff { } ; _cbbf . _afefd . AfterAutospacingAttr . Bool = _d . Bool ( true ) ; } else { _cbbf . _afefd . AfterAutospacingAttr = nil ; } ; } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// SetName sets the name of the style.
func ( _fbdfb Style ) SetName ( name string ) { _fbdfb . _ebcb . Name = _ba . NewCT_String ( ) ; _fbdfb . _ebcb . Name . ValAttr = name ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Paragraphs returns the paragraphs within a structured document tag.
func ( _dcag StructuredDocumentTag ) Paragraphs ( ) [ ] Paragraph { if _dcag . _aad . SdtContent == nil { return nil ; } ; _bebcfa := [ ] Paragraph { } ; for _ , _cdef := range _dcag . _aad . SdtContent . P { _bebcfa = append ( _bebcfa , Paragraph { _dcag . _fbde , _cdef } ) ; } ; return _bebcfa ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Tables returns the tables defined in the header.
func ( _bebd Header ) Tables ( ) [ ] Table { _cded := [ ] Table { } ; if _bebd . _gcdbe == nil { return nil ; } ; for _ , _fdefd := range _bebd . _gcdbe . EG_ContentBlockContent { for _ , _dabd := range _bebd . _egded . tables ( _fdefd ) { _cded = append ( _cded , _dabd ) ; } ; } ; return _cded ; } ;
2020-08-23 14:15:53 +00:00
2020-12-17 22:07:08 +00:00
// X returns the inner wrapped XML type.
2021-01-04 16:11:39 +00:00
func ( _gegf Style ) X ( ) * _ba . CT_Style { return _gegf . _ebcb } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// SetBeforeAuto controls if spacing before a paragraph is automatically determined.
func ( _begb ParagraphSpacing ) SetBeforeAuto ( b bool ) { if b { _begb . _afefd . BeforeAutospacingAttr = & _dc . ST_OnOff { } ; _begb . _afefd . BeforeAutospacingAttr . Bool = _d . Bool ( true ) ; } else { _begb . _afefd . BeforeAutospacingAttr = nil ; } ; } ;
2020-12-17 22:07:08 +00:00
// SetInsideHorizontal sets the interior horizontal borders to a specified type, color and thickness.
2021-01-04 16:11:39 +00:00
func ( _effe TableBorders ) SetInsideHorizontal ( t _ba . ST_Border , c _fb . Color , thickness _gc . Distance ) { _effe . _edag . InsideH = _ba . NewCT_Border ( ) ; _deec ( _effe . _edag . InsideH , t , c , thickness ) ; } ; var _cbeb = [ ... ] uint8 { 0 , 20 , 37 , 58 , 79 } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Cell is a table cell within a document (not a spreadsheet)
type Cell struct { _ad * Document ; _bd * _ba . CT_Tc ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Styles returns all styles.
func ( _caffd Styles ) Styles ( ) [ ] Style { _cbfg := [ ] Style { } ; for _ , _fgafd := range _caffd . _eagfa . Style { _cbfg = append ( _cbfg , Style { _fgafd } ) ; } ; return _cbfg ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// ClearContent clears any content in the run (text, tabs, breaks, etc.)
func ( _agce Run ) ClearContent ( ) { _agce . _afde . EG_RunInnerContent = nil } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetDefaultValue sets the default value of a FormFieldTypeDropDown. For
// FormFieldTypeDropDown, the value must be one of the fields possible values.
func ( _gcdb FormField ) SetDefaultValue ( v string ) { if _gcdb . _edgb . DdList != nil { for _abfb , _bfac := range _gcdb . PossibleValues ( ) { if _bfac == v { _gcdb . _edgb . DdList . Default = _ba . NewCT_DecimalNumber ( ) ; _gcdb . _edgb . DdList . Default . ValAttr = int64 ( _abfb ) ; break ; } ; } ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// RightToLeft returns true if run text goes from right to left.
func ( _bcea RunProperties ) RightToLeft ( ) bool { return _bfbg ( _bcea . _bdgac . Rtl ) } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Header is a header for a document section.
type Header struct { _egded * Document ; _gcdbe * _ba . Hdr ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetCellSpacingPercent sets the cell spacing within a table to a percent width.
func ( _ffbcb TableStyleProperties ) SetCellSpacingPercent ( pct float64 ) { _ffbcb . _bggdc . TblCellSpacing = _ba . NewCT_TblWidth ( ) ; _ffbcb . _bggdc . TblCellSpacing . TypeAttr = _ba . ST_TblWidthPct ; _ffbcb . _bggdc . TblCellSpacing . WAttr = & _ba . ST_MeasurementOrPercent { } ; _ffbcb . _bggdc . TblCellSpacing . WAttr . ST_DecimalNumberOrPercent = & _ba . ST_DecimalNumberOrPercent { } ; _ffbcb . _bggdc . TblCellSpacing . WAttr . ST_DecimalNumberOrPercent . ST_UnqualifiedPercentage = _d . Int64 ( int64 ( pct * 50 ) ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// IsFootnote returns a bool based on whether the run has a
// footnote or not. Returns both a bool as to whether it has
// a footnote as well as the ID of the footnote.
func ( _fgfg Run ) IsFootnote ( ) ( bool , int64 ) { if _fgfg . _afde . EG_RunInnerContent != nil { if _fgfg . _afde . EG_RunInnerContent [ 0 ] . FootnoteReference != nil { return true , _fgfg . _afde . EG_RunInnerContent [ 0 ] . FootnoteReference . IdAttr ; } ; } ; return false , 0 ; } ; func ( _ggaca Styles ) initializeDocDefaults ( ) { _ggaca . _eagfa . DocDefaults = _ba . NewCT_DocDefaults ( ) ; _ggaca . _eagfa . DocDefaults . RPrDefault = _ba . NewCT_RPrDefault ( ) ; _ggaca . _eagfa . DocDefaults . RPrDefault . RPr = _ba . NewCT_RPr ( ) ; _adcd := RunProperties { _ggaca . _eagfa . DocDefaults . RPrDefault . RPr } ; _adcd . SetSize ( 12 * _gc . Point ) ; _adcd . Fonts ( ) . SetASCIITheme ( _ba . ST_ThemeMajorAscii ) ; _adcd . Fonts ( ) . SetEastAsiaTheme ( _ba . ST_ThemeMajorEastAsia ) ; _adcd . Fonts ( ) . SetHANSITheme ( _ba . ST_ThemeMajorHAnsi ) ; _adcd . Fonts ( ) . SetCSTheme ( _ba . ST_ThemeMajorBidi ) ; _adcd . X ( ) . Lang = _ba . NewCT_Language ( ) ; _adcd . X ( ) . Lang . ValAttr = _d . String ( "\u0065\u006e\u002dU\u0053" ) ; _adcd . X ( ) . Lang . EastAsiaAttr = _d . String ( "\u0065\u006e\u002dU\u0053" ) ; _adcd . X ( ) . Lang . BidiAttr = _d . String ( "\u0061\u0072\u002dS\u0041" ) ; _ggaca . _eagfa . DocDefaults . PPrDefault = _ba . NewCT_PPrDefault ( ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Outline returns true if run outline is on.
func ( _dgda RunProperties ) Outline ( ) bool { return _bfbg ( _dgda . _bdgac . Outline ) } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetVerticalAlignment sets the vertical alignment of content within a table cell.
func ( _dcb CellProperties ) SetVerticalAlignment ( align _ba . ST_VerticalJc ) { if align == _ba . ST_VerticalJcUnset { _dcb . _adg . VAlign = nil ; } else { _dcb . _adg . VAlign = _ba . NewCT_VerticalJc ( ) ; _dcb . _adg . VAlign . ValAttr = align ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _dgag TableWidth ) X ( ) * _ba . CT_TblWidth { return _dgag . _ecbb } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Numbering is the document wide numbering styles contained in numbering.xml.
type Numbering struct { _cbga * _ba . Numbering } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Endnotes returns the endnotes defined in the document.
func ( _fdfba * Document ) Endnotes ( ) [ ] Endnote { _fea := [ ] Endnote { } ; for _ , _aegf := range _fdfba . _bed . CT_Endnotes . Endnote { _fea = append ( _fea , Endnote { _fdfba , _aegf } ) ; } ; return _fea ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetThemeColor sets the color from the theme.
func ( _eeaa Color ) SetThemeColor ( t _ba . ST_ThemeColor ) { _eeaa . _gf . ThemeColorAttr = t } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddSection adds a new document section with an optional section break. If t
// is ST_SectionMarkUnset, then no break will be inserted.
func ( _eae ParagraphProperties ) AddSection ( t _ba . ST_SectionMark ) Section { _eae . _gcdf . SectPr = _ba . NewCT_SectPr ( ) ; if t != _ba . ST_SectionMarkUnset { _eae . _gcdf . SectPr . Type = _ba . NewCT_SectType ( ) ; _eae . _gcdf . SectPr . Type . ValAttr = t ; } ; return Section { _eae . _eddg , _eae . _gcdf . SectPr } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Levels returns all of the numbering levels defined in the definition.
func ( _ebcad NumberingDefinition ) Levels ( ) [ ] NumberingLevel { _abga := [ ] NumberingLevel { } ; for _ , _dcea := range _ebcad . _ceab . Lvl { _abga = append ( _abga , NumberingLevel { _dcea } ) ; } ; return _abga ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Read reads a document from an io.Reader.
func Read ( r _ee . ReaderAt , size int64 ) ( * Document , error ) { _cca := New ( ) ; _cca . Numbering . _cbga = nil ; _cbed , _ece := _ca . TempDir ( "\u0075\u006e\u0069\u006f\u0066\u0066\u0069\u0063\u0065-\u0064\u006f\u0063\u0078" ) ; if _ece != nil { return nil , _ece ; } ; _cca . TmpPath = _cbed ; _fccd , _ece := _b . NewReader ( r , size ) ; if _ece != nil { return nil , _cfb . Errorf ( "\u0070a\u0072s\u0069\u006e\u0067\u0020\u007a\u0069\u0070\u003a\u0020\u0025\u0073" , _ece ) ; } ; _ged := [ ] * _b . File { } ; _ged = append ( _ged , _fccd . File ... ) ; _aeb := false ; for _ , _dbf := range _ged { if _dbf . FileHeader . Name == "\u0064\u006f\u0063\u0050ro\u0070\u0073\u002f\u0063\u0075\u0073\u0074\u006f\u006d\u002e\u0078\u006d\u006c" { _aeb = true ; break ; } ; } ; if _aeb { _cca . CreateCustomProperties ( ) ; } ; _dcfd := _cca . _dadc . ConformanceAttr ; _cgc := _gg . DecodeMap { } ; _cgc . SetOnNewRelationshipFunc ( _cca . onNewRelationship ) ; _cgc . AddTarget ( _d . ContentTypesFilename , _cca . ContentTypes . X ( ) , "" , 0 ) ; _cgc . AddTarget ( _d . BaseRelsFilename , _cca . Rels . X ( ) , "" , 0 ) ; if _aggg := _cgc . Decode ( _ged ) ; _aggg != nil { return nil , _aggg ; } ; _cca . _dadc . ConformanceAttr = _dcfd ; for _ , _dfc := range _ged { if _dfc == nil { continue ; } ; if _gdd := _cca . AddExtraFileFromZip ( _dfc ) ; _gdd != nil { return nil , _gdd ; } ; } ; if _aeb { _dcba := false ; for _ , _bgf := range _cca . Rels . X ( ) . Relationship { if _bgf . TargetAttr == "\u0064\u006f\u0063\u0050ro\u0070\u0073\u002f\u0063\u0075\u0073\u0074\u006f\u006d\u002e\u0078\u006d\u006c" { _dcba = true ; break ; } ; } ; if ! _dcba { _cca . AddCustomRelationships ( ) ; } ; } ; return _cca , nil ; } ;
2020-08-31 22:58:25 +00:00
2021-01-04 16:11:39 +00:00
// Row is a row within a table within a document.
type Row struct { _ebfa * Document ; _abdcd * _ba . CT_Row ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Color returns the style's Color.
func ( _dbfa RunProperties ) Color ( ) Color { if _dbfa . _bdgac . Color == nil { _dbfa . _bdgac . Color = _ba . NewCT_Color ( ) ; } ; return Color { _dbfa . _bdgac . Color } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Caps returns true if run font is capitalized.
func ( _bdaeg RunProperties ) Caps ( ) bool { return _bfbg ( _bdaeg . _bdgac . Caps ) } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetAlignment sets the paragraph alignment
func ( _bcdc NumberingLevel ) SetAlignment ( j _ba . ST_Jc ) { if j == _ba . ST_JcUnset { _bcdc . _bbgd . LvlJc = nil ; } else { _bcdc . _bbgd . LvlJc = _ba . NewCT_Jc ( ) ; _bcdc . _bbgd . LvlJc . ValAttr = j ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Properties returns the run properties.
func ( _gfbcc Run ) Properties ( ) RunProperties { if _gfbcc . _afde . RPr == nil { _gfbcc . _afde . RPr = _ba . NewCT_RPr ( ) ; } ; return RunProperties { _gfbcc . _afde . RPr } ; } ;
2020-08-23 14:15:53 +00:00
2020-12-17 22:07:08 +00:00
// X returns the inner wrapped XML type.
2021-01-04 16:11:39 +00:00
func ( _dedf Table ) X ( ) * _ba . CT_Tbl { return _dedf . _fbdg } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetFormat sets the numbering format.
func ( _acgbg NumberingLevel ) SetFormat ( f _ba . ST_NumberFormat ) { if _acgbg . _bbgd . NumFmt == nil { _acgbg . _bbgd . NumFmt = _ba . NewCT_NumFmt ( ) ; } ; _acgbg . _bbgd . NumFmt . ValAttr = f ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// BodySection returns the default body section used for all preceding
// paragraphs until the previous Section. If there is no previous sections, the
// body section applies to the entire document.
func ( _cfga * Document ) BodySection ( ) Section { if _cfga . _dadc . Body . SectPr == nil { _cfga . _dadc . Body . SectPr = _ba . NewCT_SectPr ( ) ; } ; return Section { _cfga , _cfga . _dadc . Body . SectPr } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// CellMargins are the margins for an individual cell.
type CellMargins struct { _aab * _ba . CT_TcMar } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetValue sets the width value.
func ( _fccca TableWidth ) SetValue ( m _gc . Distance ) { _fccca . _ecbb . WAttr = & _ba . ST_MeasurementOrPercent { } ; _fccca . _ecbb . WAttr . ST_DecimalNumberOrPercent = & _ba . ST_DecimalNumberOrPercent { } ; _fccca . _ecbb . WAttr . ST_DecimalNumberOrPercent . ST_UnqualifiedPercentage = _d . Int64 ( int64 ( m / _gc . Twips ) ) ; _fccca . _ecbb . TypeAttr = _ba . ST_TblWidthDxa ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddLevel adds a new numbering level to a NumberingDefinition.
func ( _ccde NumberingDefinition ) AddLevel ( ) NumberingLevel { _fdab := _ba . NewCT_Lvl ( ) ; _fdab . Start = & _ba . CT_DecimalNumber { ValAttr : 1 } ; _fdab . IlvlAttr = int64 ( len ( _ccde . _ceab . Lvl ) ) ; _ccde . _ceab . Lvl = append ( _ccde . _ceab . Lvl , _fdab ) ; return NumberingLevel { _fdab } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetCSTheme sets the font complex script theme.
func ( _egad Fonts ) SetCSTheme ( t _ba . ST_Theme ) { _egad . _ffb . CsthemeAttr = t } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetPageMargins sets the page margins for a section
func ( _adedf Section ) SetPageMargins ( top , right , bottom , left , header , footer , gutter _gc . Distance ) { _egagc := _ba . NewCT_PageMar ( ) ; _egagc . TopAttr . Int64 = _d . Int64 ( int64 ( top / _gc . Twips ) ) ; _egagc . BottomAttr . Int64 = _d . Int64 ( int64 ( bottom / _gc . Twips ) ) ; _egagc . RightAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( right / _gc . Twips ) ) ; _egagc . LeftAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( left / _gc . Twips ) ) ; _egagc . HeaderAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( header / _gc . Twips ) ) ; _egagc . FooterAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( footer / _gc . Twips ) ) ; _egagc . GutterAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( gutter / _gc . Twips ) ) ; _adedf . _dddg . PgMar = _egagc ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// CellBorders are the borders for an individual
type CellBorders struct { _fbd * _ba . CT_TcBorders } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// NewStyles constructs a new empty Styles
func NewStyles ( ) Styles { return Styles { _ba . NewStyles ( ) } } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Clear resets the numbering.
func ( _fae Numbering ) Clear ( ) { _fae . _cbga . AbstractNum = nil ; _fae . _cbga . Num = nil ; _fae . _cbga . NumIdMacAtCleanup = nil ; _fae . _cbga . NumPicBullet = nil ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// ComplexSizeValue returns the value of run font size for complex fonts in points.
func ( _fefd RunProperties ) ComplexSizeValue ( ) float64 { if _ceag := _fefd . _bdgac . SzCs ; _ceag != nil { _fcad := _ceag . ValAttr ; if _fcad . ST_UnsignedDecimalNumber != nil { return float64 ( * _fcad . ST_UnsignedDecimalNumber ) / 2 ; } ; } ; return 0.0 ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetWidthAuto sets the the table width to automatic.
func ( _fgfa TableProperties ) SetWidthAuto ( ) { _fgfa . _efeg . TblW = _ba . NewCT_TblWidth ( ) ; _fgfa . _efeg . TblW . TypeAttr = _ba . ST_TblWidthAuto ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// ParagraphProperties returns the paragraph style properties.
func ( _effgc Style ) ParagraphProperties ( ) ParagraphStyleProperties { if _effgc . _ebcb . PPr == nil { _effgc . _ebcb . PPr = _ba . NewCT_PPrGeneral ( ) ; } ; return ParagraphStyleProperties { _effgc . _ebcb . PPr } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// RStyle returns the name of character style.
// It is defined here http://officeopenxml.com/WPstyleCharStyles.php
func ( _bcgf RunProperties ) RStyle ( ) string { if _bcgf . _bdgac . RStyle != nil { return _bcgf . _bdgac . RStyle . ValAttr ; } ; return "" ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// DrawingAnchored returns a slice of AnchoredDrawings.
func ( _fefc Run ) DrawingAnchored ( ) [ ] AnchoredDrawing { _ebaf := [ ] AnchoredDrawing { } ; for _ , _ccaac := range _fefc . _afde . EG_RunInnerContent { if _ccaac . Drawing == nil { continue ; } ; for _ , _bgadb := range _ccaac . Drawing . Anchor { _ebaf = append ( _ebaf , AnchoredDrawing { _fefc . _cebg , _bgadb } ) ; } ; } ; return _ebaf ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetToolTip sets the tooltip text for a hyperlink.
func ( _cfd HyperLink ) SetToolTip ( text string ) { if text == "" { _cfd . _edfg . TooltipAttr = nil ; } else { _cfd . _edfg . TooltipAttr = _d . String ( text ) ; } ; } ;
2017-08-28 20:56:18 -05:00
2021-01-04 16:11:39 +00:00
// Properties returns the paragraph properties.
func ( _cdbd Paragraph ) Properties ( ) ParagraphProperties { _cdbd . ensurePPr ( ) ; return ParagraphProperties { _cdbd . _dcbe , _cdbd . _acbc . PPr } ; } ;
2017-08-30 16:49:57 -05:00
2021-01-04 16:11:39 +00:00
// SetAlignment positions an anchored image via alignment. Offset is
// incompatible with SetOffset, whichever is called last is applied.
func ( _eb AnchoredDrawing ) SetAlignment ( h _ba . WdST_AlignH , v _ba . WdST_AlignV ) { _eb . SetHAlignment ( h ) ; _eb . SetVAlignment ( v ) ; } ;
2017-08-28 20:56:18 -05:00
2021-01-04 16:11:39 +00:00
// Settings controls the document settings.
type Settings struct { _dbedb * _ba . Settings } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Margins allows controlling individual cell margins.
func ( _fgb CellProperties ) Margins ( ) CellMargins { if _fgb . _adg . TcMar == nil { _fgb . _adg . TcMar = _ba . NewCT_TcMar ( ) ; } ; return CellMargins { _fgb . _adg . TcMar } ; } ;
2020-10-12 13:59:12 +00:00
2021-01-04 16:11:39 +00:00
// SetWindowControl controls if the first or last line of the paragraph is
// allowed to dispay on a separate page.
func ( _dgcd ParagraphProperties ) SetWindowControl ( b bool ) { if ! b { _dgcd . _gcdf . WidowControl = nil ; } else { _dgcd . _gcdf . WidowControl = _ba . NewCT_OnOff ( ) ; } ; } ;
2020-10-12 13:59:12 +00:00
2021-01-04 16:11:39 +00:00
// Cells returns the cells defined in the table.
func ( _daea Row ) Cells ( ) [ ] Cell { _bcdd := [ ] Cell { } ; for _ , _gagb := range _daea . _abdcd . EG_ContentCellContent { for _ , _ddgg := range _gagb . Tc { _bcdd = append ( _bcdd , Cell { _daea . _ebfa , _ddgg } ) ; } ; if _gagb . Sdt != nil && _gagb . Sdt . SdtContent != nil { for _ , _faccg := range _gagb . Sdt . SdtContent . Tc { _bcdd = append ( _bcdd , Cell { _daea . _ebfa , _faccg } ) ; } ; } ; } ; return _bcdd ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// TableProperties are the properties for a table within a document
type TableProperties struct { _efeg * _ba . CT_TblPr } ; func ( _daa * Document ) validateTableCells ( ) error { for _ , _feac := range _daa . _dadc . Body . EG_BlockLevelElts { for _ , _afa := range _feac . EG_ContentBlockContent { for _ , _gccf := range _afa . Tbl { for _ , _bfaa := range _gccf . EG_ContentRowContent { for _ , _cea := range _bfaa . Tr { _affb := false ; for _ , _bea := range _cea . EG_ContentCellContent { _cbba := false ; for _ , _fcd := range _bea . Tc { _affb = true ; for _ , _febd := range _fcd . EG_BlockLevelElts { for _ , _fbf := range _febd . EG_ContentBlockContent { if len ( _fbf . P ) > 0 { _cbba = true ; break ; } ; } ; } ; } ; if ! _cbba { return _cd . New ( "t\u0061\u0062\u006c\u0065\u0020\u0063e\u006c\u006c\u0020\u006d\u0075\u0073t\u0020\u0063\u006f\u006e\u0074\u0061\u0069n\u0020\u0061\u0020\u0070\u0061\u0072\u0061\u0067\u0072\u0061p\u0068" ) ; } ; } ; if ! _affb { return _cd . New ( "\u0074\u0061b\u006c\u0065\u0020\u0072\u006f\u0077\u0020\u006d\u0075\u0073\u0074\u0020\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0020\u0061\u0020ce\u006c\u006c" ) ; } ; } ; } ; } ; } ; } ; return nil ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddParagraph adds a paragraph to the table cell.
func ( _gbd Cell ) AddParagraph ( ) Paragraph { _fec := _ba . NewEG_BlockLevelElts ( ) ; _gbd . _bd . EG_BlockLevelElts = append ( _gbd . _bd . EG_BlockLevelElts , _fec ) ; _ddf := _ba . NewEG_ContentBlockContent ( ) ; _fec . EG_ContentBlockContent = append ( _fec . EG_ContentBlockContent , _ddf ) ; _beb := _ba . NewCT_P ( ) ; _ddf . P = append ( _ddf . P , _beb ) ; return Paragraph { _gbd . _ad , _beb } ; } ;
2020-11-09 01:00:18 +00:00
2021-01-04 16:11:39 +00:00
// ComplexSizeMeasure returns font with its measure which can be mm, cm, in, pt, pc or pi.
func ( _afege ParagraphProperties ) ComplexSizeMeasure ( ) string { if _bcgb := _afege . _gcdf . RPr . SzCs ; _bcgb != nil { _dfcfa := _bcgb . ValAttr ; if _dfcfa . ST_PositiveUniversalMeasure != nil { return * _dfcfa . ST_PositiveUniversalMeasure ; } ; } ; return "" ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Value returns the tring value of a FormFieldTypeText or FormFieldTypeDropDown.
func ( _gecc FormField ) Value ( ) string { if _gecc . _edgb . TextInput != nil && _gecc . _cggf . T != nil { return _gecc . _cggf . T . Content ; } else if _gecc . _edgb . DdList != nil && _gecc . _edgb . DdList . Result != nil { _caffa := _gecc . PossibleValues ( ) ; _cbeec := int ( _gecc . _edgb . DdList . Result . ValAttr ) ; if _cbeec < len ( _caffa ) { return _caffa [ _cbeec ] ; } ; } else if _gecc . _edgb . CheckBox != nil { if _gecc . IsChecked ( ) { return "\u0074\u0072\u0075\u0065" ; } ; return "\u0066\u0061\u006cs\u0065" ; } ; return "" ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _bedf HyperLink ) X ( ) * _ba . CT_Hyperlink { return _bedf . _edfg } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetNextStyle sets the style that the next paragraph will use.
func ( _aeag Style ) SetNextStyle ( name string ) { if name == "" { _aeag . _ebcb . Next = nil ; } else { _aeag . _ebcb . Next = _ba . NewCT_String ( ) ; _aeag . _ebcb . Next . ValAttr = name ; } ; } ;
2020-08-23 14:15:53 +00:00
2020-12-17 22:07:08 +00:00
// SetTop sets the top border to a specified type, color and thickness.
2021-01-04 16:11:39 +00:00
func ( _ace CellBorders ) SetTop ( t _ba . ST_Border , c _fb . Color , thickness _gc . Distance ) { _ace . _fbd . Top = _ba . NewCT_Border ( ) ; _deec ( _ace . _fbd . Top , t , c , thickness ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Properties returns the row properties.
func ( _bcge Row ) Properties ( ) RowProperties { if _bcge . _abdcd . TrPr == nil { _bcge . _abdcd . TrPr = _ba . NewCT_TrPr ( ) ; } ; return RowProperties { _bcge . _abdcd . TrPr } ; } ; var _bbd = false ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// RemoveFootnote removes a footnote from both the paragraph and the document
// the requested footnote must be anchored on the paragraph being referenced.
func ( _cddea Paragraph ) RemoveFootnote ( id int64 ) { _faba := _cddea . _dcbe . _bgd ; var _cbfc int ; for _bcegd , _gffa := range _faba . CT_Footnotes . Footnote { if _gffa . IdAttr == id { _cbfc = _bcegd ; } ; } ; _cbfc = 0 ; _faba . CT_Footnotes . Footnote [ _cbfc ] = nil ; _faba . CT_Footnotes . Footnote [ _cbfc ] = _faba . CT_Footnotes . Footnote [ len ( _faba . CT_Footnotes . Footnote ) - 1 ] ; _faba . CT_Footnotes . Footnote = _faba . CT_Footnotes . Footnote [ : len ( _faba . CT_Footnotes . Footnote ) - 1 ] ; var _adbe Run ; for _ , _fcee := range _cddea . Runs ( ) { if _gbdd , _bbae := _fcee . IsFootnote ( ) ; _gbdd { if _bbae == id { _adbe = _fcee ; } ; } ; } ; _cddea . RemoveRun ( _adbe ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _edec Paragraph ) X ( ) * _ba . CT_P { return _edec . _acbc } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetName marks sets a name attribute for a FormField.
func ( _dgcc FormField ) SetName ( name string ) { _dgfd := _ba . NewCT_FFName ( ) ; _dgfd . ValAttr = & name ; _dgcc . _edgb . Name = [ ] * _ba . CT_FFName { _dgfd } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// HasEndnotes returns a bool based on the presence or abscence of endnotes within
// the document.
func ( _begd * Document ) HasEndnotes ( ) bool { return _begd . _bed != nil } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetImprint sets the run to imprinted text.
func ( _beag RunProperties ) SetImprint ( b bool ) { if ! b { _beag . _bdgac . Imprint = nil ; } else { _beag . _bdgac . Imprint = _ba . NewCT_OnOff ( ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetCellSpacingPercent sets the cell spacing within a table to a percent width.
func ( _ggbc TableProperties ) SetCellSpacingPercent ( pct float64 ) { _ggbc . _efeg . TblCellSpacing = _ba . NewCT_TblWidth ( ) ; _ggbc . _efeg . TblCellSpacing . TypeAttr = _ba . ST_TblWidthPct ; _ggbc . _efeg . TblCellSpacing . WAttr = & _ba . ST_MeasurementOrPercent { } ; _ggbc . _efeg . TblCellSpacing . WAttr . ST_DecimalNumberOrPercent = & _ba . ST_DecimalNumberOrPercent { } ; _ggbc . _efeg . TblCellSpacing . WAttr . ST_DecimalNumberOrPercent . ST_UnqualifiedPercentage = _d . Int64 ( int64 ( pct * 50 ) ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetHorizontalBanding controls the conditional formatting for horizontal banding.
func ( _gfgd TableLook ) SetHorizontalBanding ( on bool ) { if ! on { _gfgd . _acbdf . NoHBandAttr = & _dc . ST_OnOff { } ; _gfgd . _acbdf . NoHBandAttr . ST_OnOff1 = _dc . ST_OnOff1On ; } else { _gfgd . _acbdf . NoHBandAttr = & _dc . ST_OnOff { } ; _gfgd . _acbdf . NoHBandAttr . ST_OnOff1 = _dc . ST_OnOff1Off ; } ; } ;
2020-10-12 13:59:12 +00:00
2021-01-04 16:11:39 +00:00
// SetBottom sets the bottom border to a specified type, color and thickness.
func ( _ebdfc TableBorders ) SetBottom ( t _ba . ST_Border , c _fb . Color , thickness _gc . Distance ) { _ebdfc . _edag . Bottom = _ba . NewCT_Border ( ) ; _deec ( _ebdfc . _edag . Bottom , t , c , thickness ) ; } ; func _fbagb ( _gaab * _ba . CT_P , _gafd map [ string ] string ) { for _ , _defe := range _gaab . EG_PContent { if _defe . Hyperlink != nil && _defe . Hyperlink . IdAttr != nil { if _gfgg , _abfc := _gafd [ * _defe . Hyperlink . IdAttr ] ; _abfc { * _defe . Hyperlink . IdAttr = _gfgg ; } ; } ; } ; } ;
2020-10-12 13:59:12 +00:00
2021-01-04 16:11:39 +00:00
// SetAll sets all of the borders to a given value.
func ( _fecdc TableBorders ) SetAll ( t _ba . ST_Border , c _fb . Color , thickness _gc . Distance ) { _fecdc . SetBottom ( t , c , thickness ) ; _fecdc . SetLeft ( t , c , thickness ) ; _fecdc . SetRight ( t , c , thickness ) ; _fecdc . SetTop ( t , c , thickness ) ; _fecdc . SetInsideHorizontal ( t , c , thickness ) ; _fecdc . SetInsideVertical ( t , c , thickness ) ; } ;
2020-10-12 13:59:12 +00:00
2021-01-04 16:11:39 +00:00
// SetContextualSpacing controls whether to Ignore Spacing Above and Below When
// Using Identical Styles
func ( _eaga ParagraphStyleProperties ) SetContextualSpacing ( b bool ) { if ! b { _eaga . _gdb . ContextualSpacing = nil ; } else { _eaga . _gdb . ContextualSpacing = _ba . NewCT_OnOff ( ) ; } ; } ;
2020-10-12 13:59:12 +00:00
2021-01-04 16:11:39 +00:00
// SetStrict is a shortcut for document.SetConformance,
// as one of these values from github.com/unidoc/unioffice/schema/soo/ofc/sharedTypes:
// ST_ConformanceClassUnset, ST_ConformanceClassStrict or ST_ConformanceClassTransitional.
func ( _cgag Document ) SetStrict ( strict bool ) { if strict { _cgag . _dadc . ConformanceAttr = _dc . ST_ConformanceClassStrict ; } else { _cgag . _dadc . ConformanceAttr = _dc . ST_ConformanceClassTransitional ; } ; } ;
2020-10-12 13:59:12 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _cgdca ParagraphProperties ) X ( ) * _ba . CT_PPr { return _cgdca . _gcdf } ; func _ade ( _age * _ba . CT_TblWidth , _ce float64 ) { _age . TypeAttr = _ba . ST_TblWidthPct ; _age . WAttr = & _ba . ST_MeasurementOrPercent { } ; _age . WAttr . ST_DecimalNumberOrPercent = & _ba . ST_DecimalNumberOrPercent { } ; _age . WAttr . ST_DecimalNumberOrPercent . ST_UnqualifiedPercentage = _d . Int64 ( int64 ( _ce * 50 ) ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetVerticalBanding controls the conditional formatting for vertical banding.
func ( _debe TableLook ) SetVerticalBanding ( on bool ) { if ! on { _debe . _acbdf . NoVBandAttr = & _dc . ST_OnOff { } ; _debe . _acbdf . NoVBandAttr . ST_OnOff1 = _dc . ST_OnOff1On ; } else { _debe . _acbdf . NoVBandAttr = & _dc . ST_OnOff { } ; _debe . _acbdf . NoVBandAttr . ST_OnOff1 = _dc . ST_OnOff1Off ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetAll sets all of the borders to a given value.
func ( _fdb CellBorders ) SetAll ( t _ba . ST_Border , c _fb . Color , thickness _gc . Distance ) { _fdb . SetBottom ( t , c , thickness ) ; _fdb . SetLeft ( t , c , thickness ) ; _fdb . SetRight ( t , c , thickness ) ; _fdb . SetTop ( t , c , thickness ) ; _fdb . SetInsideHorizontal ( t , c , thickness ) ; _fdb . SetInsideVertical ( t , c , thickness ) ; } ; func ( _dfdf Styles ) initializeStyleDefaults ( ) { _deae := _dfdf . AddStyle ( "\u004e\u006f\u0072\u006d\u0061\u006c" , _ba . ST_StyleTypeParagraph , true ) ; _deae . SetName ( "\u004e\u006f\u0072\u006d\u0061\u006c" ) ; _deae . SetPrimaryStyle ( true ) ; _cbfdb := _dfdf . AddStyle ( "D\u0065f\u0061\u0075\u006c\u0074\u0050\u0061\u0072\u0061g\u0072\u0061\u0070\u0068Fo\u006e\u0074" , _ba . ST_StyleTypeCharacter , true ) ; _cbfdb . SetName ( "\u0044\u0065\u0066\u0061ul\u0074\u0020\u0050\u0061\u0072\u0061\u0067\u0072\u0061\u0070\u0068\u0020\u0046\u006fn\u0074" ) ; _cbfdb . SetUISortOrder ( 1 ) ; _cbfdb . SetSemiHidden ( true ) ; _cbfdb . SetUnhideWhenUsed ( true ) ; _ebbc := _dfdf . AddStyle ( "\u0054i\u0074\u006c\u0065\u0043\u0068\u0061r" , _ba . ST_StyleTypeCharacter , false ) ; _ebbc . SetName ( "\u0054\u0069\u0074\u006c\u0065\u0020\u0043\u0068\u0061\u0072" ) ; _ebbc . SetBasedOn ( _cbfdb . StyleID ( ) ) ; _ebbc . SetLinkedStyle ( "\u0054\u0069\u0074l\u0065" ) ; _ebbc . SetUISortOrder ( 10 ) ; _ebbc . RunProperties ( ) . Fonts ( ) . SetASCIITheme ( _ba . ST_ThemeMajorAscii ) ; _ebbc . RunProperties ( ) . Fonts ( ) . SetEastAsiaTheme ( _ba . ST_ThemeMajorEastAsia ) ; _ebbc . RunProperties ( ) . Fonts ( ) . SetHANSITheme ( _ba . ST_ThemeMajorHAnsi ) ; _ebbc . RunProperties ( ) . Fonts ( ) . SetCSTheme ( _ba . ST_ThemeMajorBidi ) ; _ebbc . RunProperties ( ) . SetSize ( 28 * _gc . Point ) ; _ebbc . RunProperties ( ) . SetKerning ( 14 * _gc . Point ) ; _ebbc . RunProperties ( ) . SetCharacterSpacing ( - 10 * _gc . Twips ) ; _cebgb := _dfdf . AddStyle ( "\u0054\u0069\u0074l\u0065" , _ba . ST_StyleTypeParagraph , false ) ; _cebgb . SetName ( "\u0054\u0069\u0074l\u0065" ) ; _cebgb . SetBasedOn ( _deae . StyleID ( ) ) ; _cebgb . SetNextStyle ( _deae . StyleID ( ) ) ; _cebgb . SetLinkedStyle ( _ebbc . StyleID ( ) ) ; _cebgb . SetUISortOrder ( 10 ) ; _cebgb . SetPrimaryStyle ( true ) ; _cebgb . ParagraphProperties ( ) . SetContextualSpacing ( true ) ; _cebgb . RunProperties ( ) . Fonts ( ) . SetASCIITheme ( _ba . ST_ThemeMajorAscii ) ; _cebgb . RunProperties ( ) . Fonts ( ) . SetEastAsiaTheme ( _ba . ST_ThemeMajorEastAsia ) ; _cebgb . RunProperties ( ) . Fonts ( ) . SetHANSITheme ( _ba . ST_ThemeMajorHAnsi ) ; _cebgb . RunProperties ( ) . Fonts ( ) . SetCSTheme ( _ba . ST_ThemeMajorBidi ) ; _cebgb . RunProperties ( ) . SetSize ( 28 * _gc . Point ) ; _cebgb . RunProperties ( ) . SetKerning ( 14 * _gc . Point ) ; _cebgb . RunProperties ( ) . SetCharacterSpacing ( - 10 * _gc . Twips ) ; _efceg := _dfdf . AddStyle ( "T\u0061\u0062\u006c\u0065\u004e\u006f\u0072\u006d\u0061\u006c" , _ba . ST_StyleTypeTable , false ) ; _efceg . SetName ( "\u004e\u006f\u0072m\u0061\u006c\u0020\u0054\u0061\u0062\u006c\u0065" ) ; _efceg . SetUISortOrder ( 99 ) ; _efceg . SetSemiHidden ( true ) ; _efceg . SetUnhideWhenUsed ( true ) ; _efceg . X ( ) . TblPr = _ba . NewCT_TblPrBase ( ) ; _eecdbd := NewTableWidth ( ) ; _efceg . X ( ) . TblPr . TblInd = _eecdbd . X ( ) ; _eecdbd . SetValue ( 0 * _gc . Dxa ) ; _efceg . X ( ) . TblPr . TblCellMar = _ba . NewCT_TblCellMar ( ) ; _eecdbd = NewTableWidth ( ) ; _efceg . X ( ) . TblPr . TblCellMar . Top = _eecdbd . X ( ) ; _eecdbd . SetValue ( 0 * _gc . Dxa ) ; _eecdbd = NewTableWidth ( ) ; _efceg . X ( ) . TblPr . TblCellMar . Bottom = _eecdbd . X ( ) ; _eecdbd . SetValue ( 0 * _gc . Dxa ) ; _eecdbd = NewTableWidth ( ) ; _efceg . X ( ) . TblPr . TblCellMar . Left = _eecdbd . X ( ) ; _eecdbd . SetValue ( 108 * _gc . Dxa ) ; _eecdbd = NewTableWidth ( ) ; _efceg . X ( ) . TblPr . TblCellMar . Right = _eecdbd . X ( ) ; _eecdbd . SetValue ( 108 * _gc . Dxa ) ; _fefe := _dfdf . AddStyle ( "\u004e\u006f\u004c\u0069\u0073\u0074" , _ba . ST_StyleTypeNumbering , false ) ; _fefe . SetName ( "\u004eo\u0020\u004c\u0069\u0073\u0074" ) ; _fefe . SetUISortOrder ( 1 ) ; _fefe . SetSemiHidden ( true ) ; _fefe . SetUnhideWhenUsed ( true ) ; _ccac := [ ] _gc . Distance { 16 , 13 , 12 , 11 , 11 , 11 , 11 , 11 , 11 } ; _aafdd := [ ] _gc . Distance { 240 , 40 , 40 , 40 , 40 , 40 , 40 , 40 , 40 } ; for _geda := 0 ; _geda < 9 ; _geda ++ { _efcgg := _cfb . Sprintf ( "\u0048e\u0061\u0064\u0069\u006e\u0067\u0025d" , _geda + 1 ) ; _dabac := _dfdf . AddStyle ( _efcgg + "\u0043\u0068\u0061\u0072" , _ba . ST_StyleTypeCharacter , false ) ; _dabac . SetName ( _cfb . Sprintf (
2020-11-09 01:00:18 +00:00
2021-01-04 16:11:39 +00:00
// Runs returns all of the runs in a paragraph.
func ( _deff Paragraph ) Runs ( ) [ ] Run { _fedec := [ ] Run { } ; for _ , _aacf := range _deff . _acbc . EG_PContent { for _ , _dbb := range _aacf . EG_ContentRunContent { if _dbb . R != nil { _fedec = append ( _fedec , Run { _deff . _dcbe , _dbb . R } ) ; } ; if _dbb . Sdt != nil && _dbb . Sdt . SdtContent != nil { for _ , _dfa := range _dbb . Sdt . SdtContent . EG_ContentRunContent { if _dfa . R != nil { _fedec = append ( _fedec , Run { _deff . _dcbe , _dfa . R } ) ; } ; } ; } ; } ; } ; return _fedec ; } ;
2020-11-09 01:00:18 +00:00
2021-01-04 16:11:39 +00:00
// SetTop sets the top border to a specified type, color and thickness.
func ( _ebdc TableBorders ) SetTop ( t _ba . ST_Border , c _fb . Color , thickness _gc . Distance ) { _ebdc . _edag . Top = _ba . NewCT_Border ( ) ; _deec ( _ebdc . _edag . Top , t , c , thickness ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetTableIndent sets the Table Indent from the Leading Margin
func ( _eggca TableStyleProperties ) SetTableIndent ( ind _gc . Distance ) { _eggca . _bggdc . TblInd = _ba . NewCT_TblWidth ( ) ; _eggca . _bggdc . TblInd . TypeAttr = _ba . ST_TblWidthDxa ; _eggca . _bggdc . TblInd . WAttr = & _ba . ST_MeasurementOrPercent { } ; _eggca . _bggdc . TblInd . WAttr . ST_DecimalNumberOrPercent = & _ba . ST_DecimalNumberOrPercent { } ; _eggca . _bggdc . TblInd . WAttr . ST_DecimalNumberOrPercent . ST_UnqualifiedPercentage = _d . Int64 ( int64 ( ind / _gc . Dxa ) ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetThemeShade sets the shade based off the theme color.
func ( _egg Color ) SetThemeShade ( s uint8 ) { _fcg := _cfb . Sprintf ( "\u0025\u0030\u0032\u0078" , s ) ; _egg . _gf . ThemeShadeAttr = & _fcg ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetHangingIndent controls the indentation of the non-first lines in a paragraph.
func ( _afcg ParagraphProperties ) SetHangingIndent ( m _gc . Distance ) { if _afcg . _gcdf . Ind == nil { _afcg . _gcdf . Ind = _ba . NewCT_Ind ( ) ; } ; if m == _gc . Zero { _afcg . _gcdf . Ind . HangingAttr = nil ; } else { _afcg . _gcdf . Ind . HangingAttr = & _dc . ST_TwipsMeasure { } ; _afcg . _gcdf . Ind . HangingAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( m / _gc . Twips ) ) ; } ; } ;
// SetStart sets the cell start margin
func ( _dad CellMargins ) SetStart ( d _gc . Distance ) { _dad . _aab . Start = _ba . NewCT_TblWidth ( ) ; _gaag ( _dad . _aab . Start , d ) ; } ; const _ddcf = "\u0046\u006f\u0072\u006d\u0046\u0069\u0065l\u0064\u0054\u0079\u0070\u0065\u0055\u006e\u006b\u006e\u006f\u0077\u006e\u0046\u006fr\u006dF\u0069\u0065\u006c\u0064\u0054\u0079p\u0065\u0054\u0065\u0078\u0074\u0046\u006fr\u006d\u0046\u0069\u0065\u006c\u0064\u0054\u0079\u0070\u0065\u0043\u0068\u0065\u0063\u006b\u0042\u006f\u0078\u0046\u006f\u0072\u006d\u0046i\u0065\u006c\u0064\u0054\u0079\u0070\u0065\u0044\u0072\u006f\u0070\u0044\u006fw\u006e" ;
// SetUpdateFieldsOnOpen controls if fields are recalculated upon opening the
// document. This is useful for things like a table of contents as the library
// only adds the field code and relies on Word/LibreOffice to actually compute
// the content.
func ( _eddgc Settings ) SetUpdateFieldsOnOpen ( b bool ) { if ! b { _eddgc . _dbedb . UpdateFields = nil ; } else { _eddgc . _dbedb . UpdateFields = _ba . NewCT_OnOff ( ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2020-08-31 22:58:25 +00:00
// X returns the inner wrapped XML type.
2021-01-04 16:11:39 +00:00
func ( _gbdc Fonts ) X ( ) * _ba . CT_Fonts { return _gbdc . _ffb } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetWidthPercent sets the table to a width percentage.
func ( _dbced TableProperties ) SetWidthPercent ( pct float64 ) { _dbced . _efeg . TblW = _ba . NewCT_TblWidth ( ) ; _dbced . _efeg . TblW . TypeAttr = _ba . ST_TblWidthPct ; _dbced . _efeg . TblW . WAttr = & _ba . ST_MeasurementOrPercent { } ; _dbced . _efeg . TblW . WAttr . ST_DecimalNumberOrPercent = & _ba . ST_DecimalNumberOrPercent { } ; _dbced . _efeg . TblW . WAttr . ST_DecimalNumberOrPercent . ST_UnqualifiedPercentage = _d . Int64 ( int64 ( pct * 50 ) ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetLastColumn controls the conditional formatting for the last column in a table.
func ( _bebec TableLook ) SetLastColumn ( on bool ) { if ! on { _bebec . _acbdf . LastColumnAttr = & _dc . ST_OnOff { } ; _bebec . _acbdf . LastColumnAttr . ST_OnOff1 = _dc . ST_OnOff1Off ; } else { _bebec . _acbdf . LastColumnAttr = & _dc . ST_OnOff { } ; _bebec . _acbdf . LastColumnAttr . ST_OnOff1 = _dc . ST_OnOff1On ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetValue sets the value of a FormFieldTypeText or FormFieldTypeDropDown. For
// FormFieldTypeDropDown, the value must be one of the fields possible values.
func ( _egaad FormField ) SetValue ( v string ) { if _egaad . _edgb . DdList != nil { for _gbe , _ffdcf := range _egaad . PossibleValues ( ) { if _ffdcf == v { _egaad . _edgb . DdList . Result = _ba . NewCT_DecimalNumber ( ) ; _egaad . _edgb . DdList . Result . ValAttr = int64 ( _gbe ) ; break ; } ; } ; } else if _egaad . _edgb . TextInput != nil { _egaad . _cggf . T = _ba . NewCT_Text ( ) ; _egaad . _cggf . T . Content = v ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddPageBreak adds a page break to a run.
func ( _egbg Run ) AddPageBreak ( ) { _gebe := _egbg . newIC ( ) ; _gebe . Br = _ba . NewCT_Br ( ) ; _gebe . Br . TypeAttr = _ba . ST_BrTypePage ; } ; func ( _gbad Paragraph ) addEndBookmark ( _gggc int64 ) * _ba . CT_MarkupRange { _fcbf := _ba . NewEG_PContent ( ) ; _gbad . _acbc . EG_PContent = append ( _gbad . _acbc . EG_PContent , _fcbf ) ; _fbdf := _ba . NewEG_ContentRunContent ( ) ; _cabg := _ba . NewEG_RunLevelElts ( ) ; _ddad := _ba . NewEG_RangeMarkupElements ( ) ; _fdedf := _ba . NewCT_MarkupRange ( ) ; _fdedf . IdAttr = _gggc ; _ddad . BookmarkEnd = _fdedf ; _fcbf . EG_ContentRunContent = append ( _fcbf . EG_ContentRunContent , _fbdf ) ; _fbdf . EG_RunLevelElts = append ( _fbdf . EG_RunLevelElts , _cabg ) ; _cabg . EG_RangeMarkupElements = append ( _cabg . EG_RangeMarkupElements , _ddad ) ; return _fdedf ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddDrawingAnchored adds an anchored (floating) drawing from an ImageRef.
func ( _fdcca Run ) AddDrawingAnchored ( img _bf . ImageRef ) ( AnchoredDrawing , error ) { _bagg := _fdcca . newIC ( ) ; _bagg . Drawing = _ba . NewCT_Drawing ( ) ; _gebf := _ba . NewWdAnchor ( ) ; _fgcc := AnchoredDrawing { _fdcca . _cebg , _gebf } ; _gebf . SimplePosAttr = _d . Bool ( false ) ; _gebf . AllowOverlapAttr = true ; _gebf . CNvGraphicFramePr = _cde . NewCT_NonVisualGraphicFrameProperties ( ) ; _bagg . Drawing . Anchor = append ( _bagg . Drawing . Anchor , _gebf ) ; _gebf . Graphic = _cde . NewGraphic ( ) ; _gebf . Graphic . GraphicData = _cde . NewCT_GraphicalObjectData ( ) ; _gebf . Graphic . GraphicData . UriAttr = "\u0068\u0074\u0074\u0070\u003a\u002f/\u0073\u0063\u0068e\u006d\u0061\u0073.\u006f\u0070\u0065\u006e\u0078\u006d\u006c\u0066\u006f\u0072m\u0061\u0074\u0073\u002e\u006frg\u002f\u0064\u0072\u0061\u0077\u0069\u006e\u0067\u006d\u006c\u002f\u0032\u0030\u0030\u0036\u002f\u0070\u0069\u0063\u0074\u0075\u0072\u0065" ; _gebf . SimplePos . XAttr . ST_CoordinateUnqualified = _d . Int64 ( 0 ) ; _gebf . SimplePos . YAttr . ST_CoordinateUnqualified = _d . Int64 ( 0 ) ; _gebf . PositionH . RelativeFromAttr = _ba . WdST_RelFromHPage ; _gebf . PositionH . Choice = & _ba . WdCT_PosHChoice { } ; _gebf . PositionH . Choice . PosOffset = _d . Int32 ( 0 ) ; _gebf . PositionV . RelativeFromAttr = _ba . WdST_RelFromVPage ; _gebf . PositionV . Choice = & _ba . WdCT_PosVChoice { } ; _gebf . PositionV . Choice . PosOffset = _d . Int32 ( 0 ) ; _gebf . Extent . CxAttr = int64 ( float64 ( img . Size ( ) . X * _gc . Pixel72 ) / _gc . EMU ) ; _gebf . Extent . CyAttr = int64 ( float64 ( img . Size ( ) . Y * _gc . Pixel72 ) / _gc . EMU ) ; _gebf . Choice = & _ba . WdEG_WrapTypeChoice { } ; _gebf . Choice . WrapSquare = _ba . NewWdCT_WrapSquare ( ) ; _gebf . Choice . WrapSquare . WrapTextAttr = _ba . WdST_WrapTextBothSides ; _cbfbd := 0x7FFFFFFF & _e . Uint32 ( ) ; _gebf . DocPr . IdAttr = _cbfbd ; _adede := _bc . NewPic ( ) ; _adede . NvPicPr . CNvPr . IdAttr = _cbfbd ; _bfaef := img . RelID ( ) ; if _bfaef == "" { return _fgcc , _cd . New ( "\u0063\u006f\u0075\u006c\u0064\u006e\u0027\u0074\u0020\u0066\u0069\u006e\u0064\u0020\u0072\u0065\u0066\u0065\u0072\u0065n\u0063\u0065\u0020\u0074\u006f\u0020\u0069\u006d\u0061g\u0065\u0020\u0077\u0069\u0074\u0068\u0069\u006e\u0020\u0064\u006f\u0063\u0075m\u0065\u006e\u0074\u0020\u0072\u0065l\u0061\u0074\u0069o\u006e\u0073" ) ; } ; _gebf . Graphic . GraphicData . Any = append ( _gebf . Graphic . GraphicData . Any , _adede ) ; _adede . BlipFill = _cde . NewCT_BlipFillProperties ( ) ; _adede . BlipFill . Blip = _cde . NewCT_Blip ( ) ; _adede . BlipFill . Blip . EmbedAttr = & _bfaef ; _adede . BlipFill . Stretch = _cde . NewCT_StretchInfoProperties ( ) ; _adede . BlipFill . Stretch . FillRect = _cde . NewCT_RelativeRect ( ) ; _adede . SpPr = _cde . NewCT_ShapeProperties ( ) ; _adede . SpPr . Xfrm = _cde . NewCT_Transform2D ( ) ; _adede . SpPr . Xfrm . Off = _cde . NewCT_Point2D ( ) ; _adede . SpPr . Xfrm . Off . XAttr . ST_CoordinateUnqualified = _d . Int64 ( 0 ) ; _adede . SpPr . Xfrm . Off . YAttr . ST_CoordinateUnqualified = _d . Int64 ( 0 ) ; _adede . SpPr . Xfrm . Ext = _cde . NewCT_PositiveSize2D ( ) ; _adede . SpPr . Xfrm . Ext . CxAttr = int64 ( img . Size ( ) . X * _gc . Point ) ; _adede . SpPr . Xfrm . Ext . CyAttr = int64 ( img . Size ( ) . Y * _gc . Point ) ; _adede . SpPr . PrstGeom = _cde . NewCT_PresetGeometry2D ( ) ; _adede . SpPr . PrstGeom . PrstAttr = _cde . ST_ShapeTypeRect ; return _fgcc , nil ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Font returns the name of paragraph font family.
func ( _eebb ParagraphProperties ) Font ( ) string { if _ffbca := _eebb . _gcdf . RPr . RFonts ; _ffbca != nil { if _ffbca . AsciiAttr != nil { return * _ffbca . AsciiAttr ; } else if _ffbca . HAnsiAttr != nil { return * _ffbca . HAnsiAttr ; } else if _ffbca . CsAttr != nil { return * _ffbca . CsAttr ; } ; } ; return "" ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Table is a table within a document.
type Table struct { _fgdbd * Document ; _fbdg * _ba . CT_Tbl ; } ; func ( _aeaa FormFieldType ) String ( ) string { if _aeaa >= FormFieldType ( len ( _cbeb ) - 1 ) { return _cfb . Sprintf ( "\u0046\u006f\u0072\u006d\u0046\u0069\u0065\u006c\u0064\u0054\u0079\u0070e\u0028\u0025\u0064\u0029" , _aeaa ) ; } ; return _ddcf [ _cbeb [ _aeaa ] : _cbeb [ _aeaa + 1 ] ] ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetAlignment controls the paragraph alignment
func ( _eagf ParagraphProperties ) SetAlignment ( align _ba . ST_Jc ) { if align == _ba . ST_JcUnset { _eagf . _gcdf . Jc = nil ; } else { _eagf . _gcdf . Jc = _ba . NewCT_Jc ( ) ; _eagf . _gcdf . Jc . ValAttr = align ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// TableLook is the conditional formatting associated with a table style that
// has been assigned to a table.
type TableLook struct { _acbdf * _ba . CT_TblLook } ; func _cbdb ( _edgc * _ba . CT_Tbl , _aecae map [ string ] string ) { for _ , _efc := range _edgc . EG_ContentRowContent { for _ , _bggf := range _efc . Tr { for _ , _dgfg := range _bggf . EG_ContentCellContent { for _ , _gdfg := range _dgfg . Tc { for _ , _edb := range _gdfg . EG_BlockLevelElts { for _ , _fcdac := range _edb . EG_ContentBlockContent { for _ , _cbgb := range _fcdac . P { _bbgg ( _cbgb , _aecae ) ; } ; for _ , _bddd := range _fcdac . Tbl { _cbdb ( _bddd , _aecae ) ; } ; } ; } ; } ; } ; } ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetWidth sets the table with to a specified width.
func ( _beefg TableProperties ) SetWidth ( d _gc . Distance ) { _beefg . _efeg . TblW = _ba . NewCT_TblWidth ( ) ; _beefg . _efeg . TblW . TypeAttr = _ba . ST_TblWidthDxa ; _beefg . _efeg . TblW . WAttr = & _ba . ST_MeasurementOrPercent { } ; _beefg . _efeg . TblW . WAttr . ST_DecimalNumberOrPercent = & _ba . ST_DecimalNumberOrPercent { } ; _beefg . _efeg . TblW . WAttr . ST_DecimalNumberOrPercent . ST_UnqualifiedPercentage = _d . Int64 ( int64 ( d / _gc . Twips ) ) ; } ; func ( _begg * Document ) onNewRelationship ( _dfbd * _gg . DecodeMap , _ada , _abbd string , _egdb [ ] * _b . File , _cdf * _df . Relationship , _bcca _gg . Target ) error { _fef := _d . DocTypeDocument ; switch _abbd { case _d . OfficeDocumentType , _d . OfficeDocumentTypeStrict : _begg . _dadc = _ba . NewDocument ( ) ; _dfbd . AddTarget ( _ada , _begg . _dadc , _abbd , 0 ) ; _dfbd . AddTarget ( _gg . RelationsPathFor ( _ada ) , _begg . _aeg . X ( ) , _abbd , 0 ) ; _cdf . TargetAttr = _d . RelativeFilename ( _fef , _bcca . Typ , _abbd , 0 ) ; case _d . CorePropertiesType : _dfbd . AddTarget ( _ada , _begg . CoreProperties . X ( ) , _abbd , 0 ) ; _cdf . TargetAttr = _d . RelativeFilename ( _fef , _bcca . Typ , _abbd , 0 ) ; case _d . CustomPropertiesType : _dfbd . AddTarget ( _ada , _begg . CustomProperties . X ( ) , _abbd , 0 ) ; _cdf . TargetAttr = _d . RelativeFilename ( _fef , _bcca . Typ , _abbd , 0 ) ; case _d . ExtendedPropertiesType , _d . ExtendedPropertiesTypeStrict : _dfbd . AddTarget ( _ada , _begg . AppProperties . X ( ) , _abbd , 0 ) ; _cdf . TargetAttr = _d . RelativeFilename ( _fef , _bcca . Typ , _abbd , 0 ) ; case _d . ThumbnailType , _d . ThumbnailTypeStrict : for _bdae , _cffe := range _egdb { if _cffe == nil { continue ; } ; if _cffe . Name == _ada { _fgde , _efea := _cffe . Open ( ) ; if _efea != nil { return _cfb . Errorf ( "e\u0072\u0072\u006f\u0072\u0020\u0072e\u0061\u0064\u0069\u006e\u0067\u0020\u0074\u0068\u0075m\u0062\u006e\u0061i\u006c:\u0020\u0025\u0073" , _efea ) ; } ; _begg . Thumbnail , _ , _efea = _ec . Decode ( _fgde ) ; _fgde . Close ( ) ; if _efea != nil { return _cfb . Errorf ( "\u0065\u0072\u0072\u006fr\u0020\u0064\u0065\u0063\u006f\u0064\u0069\u006e\u0067\u0020t\u0068u\u006d\u0062\u006e\u0061\u0069\u006c\u003a \u0025\u0073" , _efea ) ; } ; _egdb [ _bdae ] = nil ; } ; } ; case _d . SettingsType , _d . SettingsTypeStrict : _dfbd . AddTarget ( _ada , _begg . Settings . X ( ) , _abbd , 0 ) ; _cdf . TargetAttr = _d . RelativeFilename ( _fef , _bcca . Typ , _abbd , 0 ) ; case _d . NumberingType , _d . NumberingTypeStrict : _begg . Numbering = NewNumbering ( ) ; _dfbd . AddTarget ( _ada , _begg . Numbering . X ( ) , _abbd , 0 ) ; _cdf . TargetAttr = _d . RelativeFilename ( _fef , _bcca . Typ , _abbd , 0 ) ; case _d . StylesType , _d . StylesTypeStrict : _begg . Styles . Clear ( ) ; _dfbd . AddTarget ( _ada , _begg . Styles . X ( ) , _abbd , 0 ) ; _cdf . TargetAttr = _d . RelativeFilename ( _fef , _bcca . Typ , _abbd , 0 ) ; case _d . HeaderType , _d . HeaderTypeStrict : _eba := _ba . NewHdr ( ) ; _dfbd . AddTarget ( _ada , _eba , _abbd , uint32 ( len ( _begg . _adgc ) ) ) ; _begg . _adgc = append ( _begg . _adgc , _eba ) ; _cdf . TargetAttr = _d . RelativeFilename ( _fef , _bcca . Typ , _abbd , len ( _begg . _adgc ) ) ; _aga := _bf . NewRelationships ( ) ; _dfbd . AddTarget ( _gg . RelationsPathFor ( _ada ) , _aga . X ( ) , _abbd , 0 ) ; _begg . _bec = append ( _begg . _bec , _aga ) ; case _d . FooterType , _d . FooterTypeStrict : _fcfb := _ba . NewFtr ( ) ; _dfbd . AddTarget ( _ada , _fcfb , _abbd , uint32 ( len ( _begg . _ggdc ) ) ) ; _begg . _ggdc = append ( _begg . _ggdc , _fcfb ) ; _cdf . TargetAttr = _d . RelativeFilename ( _fef , _bcca . Typ , _abbd , len ( _begg . _ggdc ) ) ; _bbebb := _bf . NewRelationships ( ) ; _dfbd . AddTarget ( _gg . RelationsPathFor ( _ada ) , _bbebb . X ( ) , _abbd , 0 ) ; _begg . _cbb = append ( _begg . _cbb , _bbebb ) ; case _d . ThemeType , _d . ThemeTypeStrict : _gfae := _cde . NewTheme ( ) ; _dfbd . AddTarget ( _ada , _gfae , _abbd , uint32 ( len ( _begg . _eca ) ) ) ; _begg . _eca = append ( _begg . _eca , _gfae ) ; _cdf . TargetAttr = _d . RelativeFilename ( _fef , _bcca . Typ , _abbd , len ( _begg . _eca ) ) ; case _d . WebSettingsType , _d . WebSettingsTypeStrict : _begg . _bca = _ba . NewWebSettings ( ) ; _dfbd . AddTarget ( _ada , _begg . _bca , _abbd , 0 ) ; _cdf . TargetAttr = _d . RelativeFilename ( _fef , _bcca . Typ , _abbd , 0 ) ; case _d . FontTableType , _d . FontTableTypeStrict : _begg . _add = _ba . NewFonts ( ) ; _dfbd . AddTarget ( _ada , _begg . _add , _abbd , 0 ) ; _cdf . TargetAttr = _d . RelativeFilename ( _fef , _bcca . Typ , _abb
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetName sets the name of the image, visible in the properties of the image
// within Word.
func ( _gb AnchoredDrawing ) SetName ( name string ) { _gb . _eg . DocPr . NameAttr = name ; for _ , _cc := range _gb . _eg . Graphic . GraphicData . Any { if _afb , _gaac := _cc . ( * _bc . Pic ) ; _gaac { _afb . NvPicPr . CNvPr . DescrAttr = _d . String ( name ) ; } ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Strike returns true if run is striked.
func ( _ggde RunProperties ) Strike ( ) bool { return _bfbg ( _ggde . _bdgac . Strike ) } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// BoldValue returns the precise nature of the bold setting (unset, off or on).
func ( _agca RunProperties ) BoldValue ( ) OnOffValue { return _ffge ( _agca . _bdgac . B ) } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddParagraph adds a paragraph to the footer.
func ( _agcf Footer ) AddParagraph ( ) Paragraph { _afed := _ba . NewEG_ContentBlockContent ( ) ; _agcf . _cged . EG_ContentBlockContent = append ( _agcf . _cged . EG_ContentBlockContent , _afed ) ; _baed := _ba . NewCT_P ( ) ; _afed . P = append ( _afed . P , _baed ) ; return Paragraph { _agcf . _fdea , _baed } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// TableStyleProperties are table properties as defined in a style.
type TableStyleProperties struct { _bggdc * _ba . CT_TblPrBase } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Name returns the name of the field.
func ( _bbbb FormField ) Name ( ) string { return * _bbbb . _edgb . Name [ 0 ] . ValAttr } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// FormFields extracts all of the fields from a document. They can then be
// manipulated via the methods on the field and the document saved.
func ( _dgbgd * Document ) FormFields ( ) [ ] FormField { _ggcf := [ ] FormField { } ; for _ , _dag := range _dgbgd . Paragraphs ( ) { _cffc := _dag . Runs ( ) ; for _bdfe , _cffce := range _cffc { for _ , _abdc := range _cffce . _afde . EG_RunInnerContent { if _abdc . FldChar == nil || _abdc . FldChar . FfData == nil { continue ; } ; if _abdc . FldChar . FldCharTypeAttr == _ba . ST_FldCharTypeBegin { if len ( _abdc . FldChar . FfData . Name ) == 0 || _abdc . FldChar . FfData . Name [ 0 ] . ValAttr == nil { continue ; } ; _egde := FormField { _edgb : _abdc . FldChar . FfData } ; if _abdc . FldChar . FfData . TextInput != nil { for _dfcd := _bdfe + 1 ; _dfcd < len ( _cffc ) - 1 ; _dfcd ++ { if len ( _cffc [ _dfcd ] . _afde . EG_RunInnerContent ) == 0 { continue ; } ; _bcbc := _cffc [ _dfcd ] . _afde . EG_RunInnerContent [ 0 ] ; if _bcbc . FldChar != nil && _bcbc . FldChar . FldCharTypeAttr == _ba . ST_FldCharTypeSeparate { if len ( _cffc [ _dfcd + 1 ] . _afde . EG_RunInnerContent ) == 0 { continue ; } ; if _cffc [ _dfcd + 1 ] . _afde . EG_RunInnerContent [ 0 ] . FldChar == nil { _egde . _cggf = _cffc [ _dfcd + 1 ] . _afde . EG_RunInnerContent [ 0 ] ; break ; } ; } ; } ; } ; _ggcf = append ( _ggcf , _egde ) ; } ; } ; } ; } ; return _ggcf ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetLayout controls the table layout. wml.ST_TblLayoutTypeAutofit corresponds
// to "Automatically resize to fit contents" being checked, while
// wml.ST_TblLayoutTypeFixed corresponds to it being unchecked.
func ( _gbcec TableProperties ) SetLayout ( l _ba . ST_TblLayoutType ) { if l == _ba . ST_TblLayoutTypeUnset || l == _ba . ST_TblLayoutTypeAutofit { _gbcec . _efeg . TblLayout = nil ; } else { _gbcec . _efeg . TblLayout = _ba . NewCT_TblLayoutType ( ) ; _gbcec . _efeg . TblLayout . TypeAttr = l ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// DoubleStrike returns true if run is double striked.
func ( _aeaee RunProperties ) DoubleStrike ( ) bool { return _bfbg ( _aeaee . _bdgac . Dstrike ) } ; const ( OnOffValueUnset OnOffValue = iota ; OnOffValueOff ; OnOffValueOn ; ) ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// InsertRowAfter inserts a row after another row
func ( _bdbe Table ) InsertRowAfter ( r Row ) Row { for _ebbcf , _ccfd := range _bdbe . _fbdg . EG_ContentRowContent { if len ( _ccfd . Tr ) > 0 && r . X ( ) == _ccfd . Tr [ 0 ] { _egdd := _ba . NewEG_ContentRowContent ( ) ; if len ( _bdbe . _fbdg . EG_ContentRowContent ) < _ebbcf + 2 { return _bdbe . AddRow ( ) ; } ; _bdbe . _fbdg . EG_ContentRowContent = append ( _bdbe . _fbdg . EG_ContentRowContent , nil ) ; copy ( _bdbe . _fbdg . EG_ContentRowContent [ _ebbcf + 2 : ] , _bdbe . _fbdg . EG_ContentRowContent [ _ebbcf + 1 : ] ) ; _bdbe . _fbdg . EG_ContentRowContent [ _ebbcf + 1 ] = _egdd ; _gcgb := _ba . NewCT_Row ( ) ; _egdd . Tr = append ( _egdd . Tr , _gcgb ) ; return Row { _bdbe . _fgdbd , _gcgb } ; } ; } ; return _bdbe . AddRow ( ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetHeader sets a section header.
func ( _deag Section ) SetHeader ( h Header , t _ba . ST_HdrFtr ) { _gccbe := _ba . NewEG_HdrFtrReferences ( ) ; _deag . _dddg . EG_HdrFtrReferences = append ( _deag . _dddg . EG_HdrFtrReferences , _gccbe ) ; _gccbe . HeaderReference = _ba . NewCT_HdrFtrRef ( ) ; _gccbe . HeaderReference . TypeAttr = t ; _dedgb := _deag . _daag . _aeg . FindRIDForN ( h . Index ( ) , _d . HeaderType ) ; if _dedgb == "" { _ga . Print ( "\u0075\u006ea\u0062\u006c\u0065\u0020\u0074\u006f\u0020\u0064\u0065\u0074\u0065\u0072\u006d\u0069\u006e\u0065\u0020\u0068\u0065\u0061\u0064\u0065r \u0049\u0044" ) ; } ; _gccbe . HeaderReference . IdAttr = _dedgb ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Footer is a footer for a document section.
type Footer struct { _fdea * Document ; _cged * _ba . Ftr ; } ; func _bbgg ( _caffc * _ba . CT_P , _bfgda map [ string ] string ) { for _ , _daee := range _caffc . EG_PContent { for _ , _bafa := range _daee . EG_ContentRunContent { if _bafa . R != nil { for _ , _gec := range _bafa . R . EG_RunInnerContent { _ggcee := _gec . Drawing ; if _ggcee != nil { for _ , _cada := range _ggcee . Anchor { for _ , _abg := range _cada . Graphic . GraphicData . Any { switch _daba := _abg . ( type ) { case * _bc . Pic : if _daba . BlipFill != nil && _daba . BlipFill . Blip != nil { _dcebb ( _daba . BlipFill . Blip , _bfgda ) ; } ; default : } ; } ; } ; for _ , _aggc := range _ggcee . Inline { for _ , _beda := range _aggc . Graphic . GraphicData . Any { switch _badd := _beda . ( type ) { case * _bc . Pic : if _badd . BlipFill != nil && _badd . BlipFill . Blip != nil { _dcebb ( _badd . BlipFill . Blip , _bfgda ) ; } ; default : } ; } ; } ; } ; } ; } ; } ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Footnotes returns the footnotes defined in the document.
func ( _dfb * Document ) Footnotes ( ) [ ] Footnote { _acee := [ ] Footnote { } ; for _ , _gccb := range _dfb . _bgd . CT_Footnotes . Footnote { _acee = append ( _acee , Footnote { _dfb , _gccb } ) ; } ; return _acee ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _dadd ParagraphStyleProperties ) X ( ) * _ba . CT_PPrGeneral { return _dadd . _gdb } ; func ( _efeaf Run ) newIC ( ) * _ba . EG_RunInnerContent { _fgad := _ba . NewEG_RunInnerContent ( ) ; _efeaf . _afde . EG_RunInnerContent = append ( _efeaf . _afde . EG_RunInnerContent , _fgad ) ; return _fgad ; } ;
// Footnote returns the footnote based on the ID; this can be used nicely with
// the run.IsFootnote() functionality.
func ( _bceg * Document ) Footnote ( id int64 ) Footnote { for _ , _febc := range _bceg . Footnotes ( ) { if _febc . id ( ) == id { return _febc ; } ; } ; return Footnote { } ; } ; func ( _fafc Paragraph ) insertRun ( _dfcc Run , _ebfeb bool ) Run { for _ , _baef := range _fafc . _acbc . EG_PContent { for _egge , _ecbc := range _baef . EG_ContentRunContent { if _ecbc . R == _dfcc . X ( ) { _dgeg := _ba . NewCT_R ( ) ; _baef . EG_ContentRunContent = append ( _baef . EG_ContentRunContent , nil ) ; if _ebfeb { copy ( _baef . EG_ContentRunContent [ _egge + 1 : ] , _baef . EG_ContentRunContent [ _egge : ] ) ; _baef . EG_ContentRunContent [ _egge ] = _ba . NewEG_ContentRunContent ( ) ; _baef . EG_ContentRunContent [ _egge ] . R = _dgeg ; } else { copy ( _baef . EG_ContentRunContent [ _egge + 2 : ] , _baef . EG_ContentRunContent [ _egge + 1 : ] ) ; _baef . EG_ContentRunContent [ _egge + 1 ] = _ba . NewEG_ContentRunContent ( ) ; _baef . EG_ContentRunContent [ _egge + 1 ] . R = _dgeg ; } ; return Run { _fafc . _dcbe , _dgeg } ; } ; if _ecbc . Sdt != nil && _ecbc . Sdt . SdtContent != nil { for _ , _cefea := range _ecbc . Sdt . SdtContent . EG_ContentRunContent { if _cefea . R == _dfcc . X ( ) { _aafa := _ba . NewCT_R ( ) ; _ecbc . Sdt . SdtContent . EG_ContentRunContent = append ( _ecbc . Sdt . SdtContent . EG_ContentRunContent , nil ) ; if _ebfeb { copy ( _ecbc . Sdt . SdtContent . EG_ContentRunContent [ _egge + 1 : ] , _ecbc . Sdt . SdtContent . EG_ContentRunContent [ _egge : ] ) ; _ecbc . Sdt . SdtContent . EG_ContentRunContent [ _egge ] = _ba . NewEG_ContentRunContent ( ) ; _ecbc . Sdt . SdtContent . EG_ContentRunContent [ _egge ] . R = _aafa ; } else { copy ( _ecbc . Sdt . SdtContent . EG_ContentRunContent [ _egge + 2 : ] , _ecbc . Sdt . SdtContent . EG_ContentRunContent [ _egge + 1 : ] ) ; _ecbc . Sdt . SdtContent . EG_ContentRunContent [ _egge + 1 ] = _ba . NewEG_ContentRunContent ( ) ; _ecbc . Sdt . SdtContent . EG_ContentRunContent [ _egge + 1 ] . R = _aafa ; } ; return Run { _fafc . _dcbe , _aafa } ; } ; } ; } ; } ; } ; return _fafc . AddRun ( ) ; } ;
// SetAfter sets the spacing that comes after the paragraph.
func ( _cgb ParagraphSpacing ) SetAfter ( after _gc . Distance ) { _cgb . _afefd . AfterAttr = & _dc . ST_TwipsMeasure { } ; _cgb . _afefd . AfterAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( after / _gc . Twips ) ) ; } ;
2020-08-23 14:15:53 +00:00
2020-12-17 22:07:08 +00:00
// AddHyperlink adds a hyperlink to a document. Adding the hyperlink to a document
// and setting it on a cell is more efficient than setting hyperlinks directly
// on a cell.
2021-01-04 16:11:39 +00:00
func ( _fce Document ) AddHyperlink ( url string ) _bf . Hyperlink { return _fce . _aeg . AddHyperlink ( url ) } ; func ( _cbdc Endnote ) id ( ) int64 { return _cbdc . _adff . IdAttr } ;
// Emboss returns true if paragraph emboss is on.
func ( _fgec ParagraphProperties ) Emboss ( ) bool { return _bfbg ( _fgec . _gcdf . RPr . Emboss ) } ;
// TableBorders allows manipulation of borders on a table.
type TableBorders struct { _edag * _ba . CT_TblBorders } ;
// RemoveParagraph removes a paragraph from the endnote.
func ( _bgcb Endnote ) RemoveParagraph ( p Paragraph ) { for _ , _dcff := range _bgcb . content ( ) { for _fgf , _dgc := range _dcff . P { if _dgc == p . _acbc { copy ( _dcff . P [ _fgf : ] , _dcff . P [ _fgf + 1 : ] ) ; _dcff . P = _dcff . P [ 0 : len ( _dcff . P ) - 1 ] ; return ; } ; } ; } ; } ;
2020-08-23 14:15:53 +00:00
2020-10-12 13:59:12 +00:00
// X returns the inner wrapped XML type.
2021-01-04 16:11:39 +00:00
func ( _bega TableStyleProperties ) X ( ) * _ba . CT_TblPrBase { return _bega . _bggdc } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// RemoveMailMerge removes any mail merge settings
func ( _abdcf Settings ) RemoveMailMerge ( ) { _abdcf . _dbedb . MailMerge = nil } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Copy makes a deep copy of the document by saving and reading it back.
// It can be useful to avoid sharing common data between two documents.
func ( _defb * Document ) Copy ( ) ( * Document , error ) { _cffcb := _dg . NewBuffer ( [ ] byte { } ) ; _cafc := _defb . Save ( _cffcb ) ; if _cafc != nil { return nil , _cafc ; } ; _gcfa := _cffcb . Bytes ( ) ; _ffgd := _dg . NewReader ( _gcfa ) ; return Read ( _ffgd , int64 ( _ffgd . Len ( ) ) ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// NewNumbering constructs a new numbering.
func NewNumbering ( ) Numbering { _bdef := _ba . NewNumbering ( ) ; return Numbering { _bdef } } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetWidthPercent sets the cell to a width percentage.
func ( _fgd CellProperties ) SetWidthPercent ( pct float64 ) { _fgd . _adg . TcW = _ba . NewCT_TblWidth ( ) ; _fgd . _adg . TcW . TypeAttr = _ba . ST_TblWidthPct ; _fgd . _adg . TcW . WAttr = & _ba . ST_MeasurementOrPercent { } ; _fgd . _adg . TcW . WAttr . ST_DecimalNumberOrPercent = & _ba . ST_DecimalNumberOrPercent { } ; _fgd . _adg . TcW . WAttr . ST_DecimalNumberOrPercent . ST_UnqualifiedPercentage = _d . Int64 ( int64 ( pct * 50 ) ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// RunProperties returns the run properties controlling text formatting within the table.
func ( _cfdac TableConditionalFormatting ) RunProperties ( ) RunProperties { if _cfdac . _dddb . RPr == nil { _cfdac . _dddb . RPr = _ba . NewCT_RPr ( ) ; } ; return RunProperties { _cfdac . _dddb . RPr } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetShadow sets the run to shadowed text.
func ( _dgcg RunProperties ) SetShadow ( b bool ) { if ! b { _dgcg . _bdgac . Shadow = nil ; } else { _dgcg . _bdgac . Shadow = _ba . NewCT_OnOff ( ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _fgaff TableProperties ) X ( ) * _ba . CT_TblPr { return _fgaff . _efeg } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// RemoveParagraph removes a paragraph from a footer.
func ( _fac Footer ) RemoveParagraph ( p Paragraph ) { for _ , _abfef := range _fac . _cged . EG_ContentBlockContent { for _bbfe , _gcdd := range _abfef . P { if _gcdd == p . _acbc { copy ( _abfef . P [ _bbfe : ] , _abfef . P [ _bbfe + 1 : ] ) ; _abfef . P = _abfef . P [ 0 : len ( _abfef . P ) - 1 ] ; return ; } ; } ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// NewTableWidth returns a newly intialized TableWidth
func NewTableWidth ( ) TableWidth { return TableWidth { _ba . NewCT_TblWidth ( ) } } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// NumberingLevel is the definition for numbering for a particular level within
// a NumberingDefinition.
type NumberingLevel struct { _bbgd * _ba . CT_Lvl } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddEndnote will create a new endnote and attach it to the Paragraph in the
// location at the end of the previous run (endnotes create their own run within
// the paragraph. The text given to the function is simply a convenience helper,
// paragraphs and runs can always be added to the text of the endnote later.
func ( _dgbe Paragraph ) AddEndnote ( text string ) Endnote { var _aead int64 ; if _dgbe . _dcbe . HasEndnotes ( ) { for _ , _eeea := range _dgbe . _dcbe . Endnotes ( ) { if _eeea . id ( ) > _aead { _aead = _eeea . id ( ) ; } ; } ; _aead ++ ; } else { _aead = 0 ; _dgbe . _dcbe . _bed = & _ba . Endnotes { } ; } ; _eded := _ba . NewCT_FtnEdn ( ) ; _ebge := _ba . NewCT_FtnEdnRef ( ) ; _ebge . IdAttr = _aead ; _dgbe . _dcbe . _bed . CT_Endnotes . Endnote = append ( _dgbe . _dcbe . _bed . CT_Endnotes . Endnote , _eded ) ; _dgge := _dgbe . AddRun ( ) ; _edga := _dgge . Properties ( ) ; _edga . SetStyle ( "\u0045\u006e\u0064\u006e\u006f\u0074\u0065\u0041\u006e\u0063\u0068\u006f\u0072" ) ; _dgge . _afde . EG_RunInnerContent = [ ] * _ba . EG_RunInnerContent { _ba . NewEG_RunInnerContent ( ) } ; _dgge . _afde . EG_RunInnerContent [ 0 ] . EndnoteReference = _ebge ; _gceg := Endnote { _dgbe . _dcbe , _eded } ; _gceg . _adff . IdAttr = _aead ; _gceg . _adff . EG_BlockLevelElts = [ ] * _ba . EG_BlockLevelElts { _ba . NewEG_BlockLevelElts ( ) } ; _gdcc := _gceg . AddParagraph ( ) ; _gdcc . Properties ( ) . SetStyle ( "\u0045n\u0064\u006e\u006f\u0074\u0065" ) ; _gdcc . _acbc . PPr . RPr = _ba . NewCT_ParaRPr ( ) ; _bcgc := _gdcc . AddRun ( ) ; _bcgc . AddTab ( ) ; _bcgc . AddText ( text ) ; return _gceg ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Color controls the run or styles color.
type Color struct { _gf * _ba . CT_Color } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Styles is the document wide styles contained in styles.xml.
type Styles struct { _eagfa * _ba . Styles } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AddDefinition adds a new numbering definition.
func ( _cfca Numbering ) AddDefinition ( ) NumberingDefinition { _cgfa := _ba . NewCT_Num ( ) ; _adec := int64 ( 1 ) ; for _ , _cfcgg := range _cfca . Definitions ( ) { if _cfcgg . AbstractNumberID ( ) >= _adec { _adec = _cfcgg . AbstractNumberID ( ) + 1 ; } ; } ; _fbdd := int64 ( 1 ) ; for _ , _ddagb := range _cfca . X ( ) . Num { if _ddagb . NumIdAttr >= _fbdd { _fbdd = _ddagb . NumIdAttr + 1 ; } ; } ; _cgfa . NumIdAttr = _fbdd ; _cgfa . AbstractNumId = _ba . NewCT_DecimalNumber ( ) ; _cgfa . AbstractNumId . ValAttr = _adec ; _dcaf := _ba . NewCT_AbstractNum ( ) ; _dcaf . AbstractNumIdAttr = _adec ; _cfca . _cbga . AbstractNum = append ( _cfca . _cbga . AbstractNum , _dcaf ) ; _cfca . _cbga . Num = append ( _cfca . _cbga . Num , _cgfa ) ; return NumberingDefinition { _dcaf } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetInsideVertical sets the interior vertical borders to a specified type, color and thickness.
func ( _bcfca TableBorders ) SetInsideVertical ( t _ba . ST_Border , c _fb . Color , thickness _gc . Distance ) { _bcfca . _edag . InsideV = _ba . NewCT_Border ( ) ; _deec ( _bcfca . _edag . InsideV , t , c , thickness ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetSize sets the size of the displayed image on the page.
func ( _ega AnchoredDrawing ) SetSize ( w , h _gc . Distance ) { _ega . _eg . Extent . CxAttr = int64 ( float64 ( w * _gc . Pixel72 ) / _gc . EMU ) ; _ega . _eg . Extent . CyAttr = int64 ( float64 ( h * _gc . Pixel72 ) / _gc . EMU ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Italic returns true if paragraph font is italic.
func ( _bafe ParagraphProperties ) Italic ( ) bool { _effge := _bafe . _gcdf . RPr ; return _bfbg ( _effge . I ) || _bfbg ( _effge . ICs ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Font returns the name of run font family.
func ( _fbcb RunProperties ) Font ( ) string { if _dbag := _fbcb . _bdgac . RFonts ; _dbag != nil { if _dbag . AsciiAttr != nil { return * _dbag . AsciiAttr ; } else if _dbag . HAnsiAttr != nil { return * _dbag . HAnsiAttr ; } else if _dbag . CsAttr != nil { return * _dbag . CsAttr ; } ; } ; return "" ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// IsItalic returns true if the run has been set to italics.
func ( _gagd RunProperties ) IsItalic ( ) bool { return _gagd . ItalicValue ( ) == OnOffValueOn } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Clear clears all content within a footer
func ( _afag Footer ) Clear ( ) { _afag . _cged . EG_ContentBlockContent = nil } ;
2017-10-03 08:03:24 -05:00
2021-01-04 16:11:39 +00:00
// GetImageByRelID returns an ImageRef with the associated relation ID in the
// document.
func ( _dbd * Document ) GetImageByRelID ( relID string ) ( _bf . ImageRef , bool ) { for _ , _dgf := range _dbd . Images { if _dgf . RelID ( ) == relID { return _dgf , true ; } ; } ; return _bf . ImageRef { } , false ; } ;
2017-08-30 21:00:24 -05:00
2021-01-04 16:11:39 +00:00
// SetHANSITheme sets the font H ANSI Theme.
func ( _bdceb Fonts ) SetHANSITheme ( t _ba . ST_Theme ) { _bdceb . _ffb . HAnsiThemeAttr = t } ;
2017-09-01 18:42:02 -05:00
2021-01-04 16:11:39 +00:00
// SizeValue returns the value of paragraph font size in points.
func ( _gda ParagraphProperties ) SizeValue ( ) float64 { if _adfcd := _gda . _gcdf . RPr . Sz ; _adfcd != nil { _bccad := _adfcd . ValAttr ; if _bccad . ST_UnsignedDecimalNumber != nil { return float64 ( * _bccad . ST_UnsignedDecimalNumber ) / 2 ; } ; } ; return 0.0 ; } ;
2017-09-28 18:12:22 -05:00
2021-01-04 16:11:39 +00:00
// RightToLeft returns true if paragraph text goes from right to left.
func ( _gbcc ParagraphProperties ) RightToLeft ( ) bool { return _bfbg ( _gbcc . _gcdf . RPr . Rtl ) } ;
2017-09-28 18:12:22 -05:00
2021-01-04 16:11:39 +00:00
// Bookmark is a bookmarked location within a document that can be referenced
// with a hyperlink.
type Bookmark struct { _fg * _ba . CT_Bookmark } ;
2020-08-31 22:58:25 +00:00
2021-01-04 16:11:39 +00:00
// CellProperties are a table cells properties within a document.
type CellProperties struct { _adg * _ba . CT_TcPr } ; func _ffcg ( _gffdb * _ba . CT_P , _ggeg * _ba . CT_Hyperlink , _fgbd * TableInfo , _deaf * DrawingInfo , _efca [ ] * _ba . EG_PContent ) [ ] TextItem { _decd := [ ] TextItem { } ; for _ , _acdf := range _efca { for _ , _bddg := range _acdf . FldSimple { if _bddg != nil { _decd = append ( _decd , _ffcg ( _gffdb , _ggeg , _fgbd , _deaf , _bddg . EG_PContent ) ... ) ; } ; } ; if _gabc := _acdf . Hyperlink ; _gabc != nil { _decd = append ( _decd , _dfef ( _gffdb , _gabc , _fgbd , _deaf , _gabc . EG_ContentRunContent ) ... ) ; } ; _decd = append ( _decd , _dfef ( _gffdb , nil , _fgbd , _deaf , _acdf . EG_ContentRunContent ) ... ) ; } ; return _decd ; } ;
2020-08-31 22:58:25 +00:00
2021-01-04 16:11:39 +00:00
// ParagraphProperties returns the paragraph properties controlling text formatting within the table.
func ( _egcba TableConditionalFormatting ) ParagraphProperties ( ) ParagraphStyleProperties { if _egcba . _dddb . PPr == nil { _egcba . _dddb . PPr = _ba . NewCT_PPrGeneral ( ) ; } ; return ParagraphStyleProperties { _egcba . _dddb . PPr } ; } ;
2017-10-10 12:40:02 -05:00
2021-01-04 16:11:39 +00:00
// Paragraphs returns the paragraphs defined in a footnote.
func ( _fgaga Footnote ) Paragraphs ( ) [ ] Paragraph { _eeb := [ ] Paragraph { } ; for _ , _cbc := range _fgaga . content ( ) { for _ , _bafb := range _cbc . P { _eeb = append ( _eeb , Paragraph { _fgaga . _abfeg , _bafb } ) ; } ; } ; return _eeb ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _eace InlineDrawing ) X ( ) * _ba . WdInline { return _eace . _gdece } ;
2020-12-17 22:07:08 +00:00
2021-01-04 16:11:39 +00:00
// SetAllCaps sets the run to all caps.
func ( _befa RunProperties ) SetAllCaps ( b bool ) { if ! b { _befa . _bdgac . Caps = nil ; } else { _befa . _bdgac . Caps = _ba . NewCT_OnOff ( ) ; } ; } ; func ( _ccfa Paragraph ) addSeparateFldChar ( ) * _ba . CT_FldChar { _edee := _ccfa . addFldChar ( ) ; _edee . FldCharTypeAttr = _ba . ST_FldCharTypeSeparate ; return _edee ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetNumberingDefinition sets the numbering definition ID via a NumberingDefinition
// defined in numbering.xml
func ( _dfge Paragraph ) SetNumberingDefinition ( nd NumberingDefinition ) { _dfge . ensurePPr ( ) ; if _dfge . _acbc . PPr . NumPr == nil { _dfge . _acbc . PPr . NumPr = _ba . NewCT_NumPr ( ) ; } ; _agge := _ba . NewCT_DecimalNumber ( ) ; _aabeg := int64 ( - 1 ) ; for _ , _bgfe := range _dfge . _dcbe . Numbering . _cbga . Num { if _bgfe . AbstractNumId != nil && _bgfe . AbstractNumId . ValAttr == nd . AbstractNumberID ( ) { _aabeg = _bgfe . NumIdAttr ; } ; } ; if _aabeg == - 1 { _adfd := _ba . NewCT_Num ( ) ; _dfge . _dcbe . Numbering . _cbga . Num = append ( _dfge . _dcbe . Numbering . _cbga . Num , _adfd ) ; _adfd . NumIdAttr = int64 ( len ( _dfge . _dcbe . Numbering . _cbga . Num ) ) ; _adfd . AbstractNumId = _ba . NewCT_DecimalNumber ( ) ; _adfd . AbstractNumId . ValAttr = nd . AbstractNumberID ( ) ; } ; _agge . ValAttr = _aabeg ; _dfge . _acbc . PPr . NumPr . NumId = _agge ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetBasedOn sets the style that this style is based on.
func ( _dgdd Style ) SetBasedOn ( name string ) { if name == "" { _dgdd . _ebcb . BasedOn = nil ; } else { _dgdd . _ebcb . BasedOn = _ba . NewCT_String ( ) ; _dgdd . _ebcb . BasedOn . ValAttr = name ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// UnderlineColor returns the hex color value of paragraph underline.
func ( _fega ParagraphProperties ) UnderlineColor ( ) string { if _dfd := _fega . _gcdf . RPr . U ; _dfd != nil { _dafb := _dfd . ColorAttr ; if _dafb != nil && _dafb . ST_HexColorRGB != nil { return * _dafb . ST_HexColorRGB ; } ; } ; return "" ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetCellSpacingAuto sets the cell spacing within a table to automatic.
func ( _dcad TableProperties ) SetCellSpacingAuto ( ) { _dcad . _efeg . TblCellSpacing = _ba . NewCT_TblWidth ( ) ; _dcad . _efeg . TblCellSpacing . TypeAttr = _ba . ST_TblWidthAuto ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// New constructs an empty document that content can be added to.
func New ( ) * Document { _ddg := & Document { _dadc : _ba . NewDocument ( ) } ; _ddg . ContentTypes = _bf . NewContentTypes ( ) ; _ddg . _dadc . Body = _ba . NewCT_Body ( ) ; _ddg . _dadc . ConformanceAttr = _dc . ST_ConformanceClassTransitional ; _ddg . _aeg = _bf . NewRelationships ( ) ; _ddg . AppProperties = _bf . NewAppProperties ( ) ; _ddg . CoreProperties = _bf . NewCoreProperties ( ) ; _ddg . ContentTypes . AddOverride ( "\u002fw\u006fr\u0064\u002f\u0064\u006f\u0063u\u006d\u0065n\u0074\u002e\u0078\u006d\u006c" , "\u0061p\u0070\u006c\u0069c\u0061\u0074\u0069o\u006e/v\u006e\u0064\u002e\u006f\u0070\u0065\u006ex\u006d\u006c\u0066\u006f\u0072\u006d\u0061\u0074\u0073\u002d\u006f\u0066\u0066\u0069\u0063\u0065\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u002e\u0077\u006f\u0072dp\u0072o\u0063\u0065\u0073\u0073\u0069\u006eg\u006d\u006c\u002e\u0064\u006fc\u0075\u006d\u0065\u006e\u0074\u002e\u006d\u0061\u0069\u006e\u002bx\u006d\u006c" ) ; _ddg . Settings = NewSettings ( ) ; _ddg . _aeg . AddRelationship ( "\u0073\u0065\u0074t\u0069\u006e\u0067\u0073\u002e\u0078\u006d\u006c" , _d . SettingsType ) ; _ddg . ContentTypes . AddOverride ( "\u002fw\u006fr\u0064\u002f\u0073\u0065\u0074t\u0069\u006eg\u0073\u002e\u0078\u006d\u006c" , "\u0061\u0070\u0070\u006c\u0069\u0063\u0061\u0074\u0069o\u006e\u002fv\u006e\u0064\u002e\u006f\u0070\u0065\u006e\u0078\u006dl\u0066\u006f\u0072\u006da\u0074\u0073\u002d\u006f\u0066\u0066\u0069\u0063\u0065\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u002e\u0077\u006f\u0072\u0064\u0070\u0072\u006f\u0063\u0065\u0073\u0073\u0069n\u0067\u006d\u006c.\u0073\u0065\u0074\u0074\u0069\u006e\u0067\u0073\u002b\u0078\u006d\u006c" ) ; _ddg . Rels = _bf . NewRelationships ( ) ; _ddg . Rels . AddRelationship ( _d . RelativeFilename ( _d . DocTypeDocument , "" , _d . CorePropertiesType , 0 ) , _d . CorePropertiesType ) ; _ddg . Rels . AddRelationship ( "\u0064\u006fc\u0050\u0072\u006fp\u0073\u002f\u0061\u0070\u0070\u002e\u0078\u006d\u006c" , _d . ExtendedPropertiesType ) ; _ddg . Rels . AddRelationship ( "\u0077\u006f\u0072\u0064\u002f\u0064\u006f\u0063\u0075\u006d\u0065\u006et\u002e\u0078\u006d\u006c" , _d . OfficeDocumentType ) ; _ddg . Numbering = NewNumbering ( ) ; _ddg . Numbering . InitializeDefault ( ) ; _ddg . ContentTypes . AddOverride ( "\u002f\u0077\u006f\u0072d/\u006e\u0075\u006d\u0062\u0065\u0072\u0069\u006e\u0067\u002e\u0078\u006d\u006c" , "\u0061\u0070\u0070\u006c\u0069c\u0061\u0074\u0069\u006f\u006e\u002f\u0076n\u0064\u002e\u006f\u0070\u0065\u006e\u0078\u006d\u006c\u0066\u006f\u0072\u006d\u0061\u0074\u0073\u002d\u006f\u0066\u0066\u0069\u0063\u0065\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u002e\u0077\u006f\u0072\u0064\u0070\u0072\u006f\u0063e\u0073\u0073\u0069\u006e\u0067\u006d\u006c\u002e\u006e\u0075\u006d\u0062e\u0072\u0069\u006e\u0067\u002b\u0078m\u006c" ) ; _ddg . _aeg . AddRelationship ( "\u006e\u0075\u006d\u0062\u0065\u0072\u0069\u006e\u0067\u002e\u0078\u006d\u006c" , _d . NumberingType ) ; _ddg . Styles = NewStyles ( ) ; _ddg . Styles . InitializeDefault ( ) ; _ddg . ContentTypes . AddOverride ( "\u002f\u0077o\u0072\u0064\u002fs\u0074\u0079\u006c\u0065\u0073\u002e\u0078\u006d\u006c" , "\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u0076\u006e\u0064.\u006f\u0070\u0065\u006ex\u006d\u006c\u0066\u006f\u0072m\u0061\u0074\u0073\u002d\u006f\u0066\u0066\u0069\u0063\u0065\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u002e\u0077\u006f\u0072\u0064\u0070\u0072\u006f\u0063\u0065\u0073\u0073\u0069n\u0067\u006d\u006c\u002e\u0073\u0074\u0079\u006ce\u0073\u002b\u0078\u006d\u006c" ) ; _ddg . _aeg . AddRelationship ( "\u0073\u0074\u0079\u006c\u0065\u0073\u002e\u0078\u006d\u006c" , _d . StylesType ) ; _ddg . _dadc . Body = _ba . NewCT_Body ( ) ; return _ddg ; } ; func ( _aba * Document ) validateBookmarks ( ) error { _afdd := make ( map [ string ] struct { } ) ; for _ , _cfcg := range _aba . Bookmarks ( ) { if _ , _edfc := _afdd [ _cfcg . Name ( ) ] ; _edfc { return _cfb . Errorf ( "d\u0075\u0070\u006c\u0069\u0063\u0061t\u0065\u0020\u0062\u006f\u006f\u006b\u006d\u0061\u0072k\u0020\u0025\u0073 \u0066o\u0075\u006e\u0064" , _cfcg . Name ( ) ) ; } ; _afdd [ _cfcg . Name ( ) ] = struct { } { } ; } ; return nil ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetXOffset sets the X offset for an image relative to the origin.
func ( _bcc AnchoredDrawing ) SetXOffset ( x _gc . Distance ) { _bcc . _eg . PositionH . Choice = & _ba . WdCT_PosHChoice { } ; _bcc . _eg . PositionH . Choice . PosOffset = _d . Int32 ( int32 ( x / _gc . EMU ) ) ; } ;
2019-04-03 03:02:32 -07:00
2021-01-04 16:11:39 +00:00
// AddFootnote will create a new footnote and attach it to the Paragraph in the
// location at the end of the previous run (footnotes create their own run within
// the paragraph). The text given to the function is simply a convenience helper,
// paragraphs and runs can always be added to the text of the footnote later.
func ( _ffea Paragraph ) AddFootnote ( text string ) Footnote { var _cdg int64 ; if _ffea . _dcbe . HasFootnotes ( ) { for _ , _deba := range _ffea . _dcbe . Footnotes ( ) { if _deba . id ( ) > _cdg { _cdg = _deba . id ( ) ; } ; } ; _cdg ++ ; } else { _cdg = 0 ; _ffea . _dcbe . _bgd = & _ba . Footnotes { } ; _ffea . _dcbe . _bgd . CT_Footnotes = _ba . CT_Footnotes { } ; _ffea . _dcbe . _bgd . Footnote = make ( [ ] * _ba . CT_FtnEdn , 0 ) ; } ; _dgfa := _ba . NewCT_FtnEdn ( ) ; _eafc := _ba . NewCT_FtnEdnRef ( ) ; _eafc . IdAttr = _cdg ; _ffea . _dcbe . _bgd . CT_Footnotes . Footnote = append ( _ffea . _dcbe . _bgd . CT_Footnotes . Footnote , _dgfa ) ; _ebfee := _ffea . AddRun ( ) ; _fggfd := _ebfee . Properties ( ) ; _fggfd . SetStyle ( "\u0046\u006f\u006f\u0074\u006e\u006f\u0074\u0065\u0041n\u0063\u0068\u006f\u0072" ) ; _ebfee . _afde . EG_RunInnerContent = [ ] * _ba . EG_RunInnerContent { _ba . NewEG_RunInnerContent ( ) } ; _ebfee . _afde . EG_RunInnerContent [ 0 ] . FootnoteReference = _eafc ; _edd := Footnote { _ffea . _dcbe , _dgfa } ; _edd . _dabgg . IdAttr = _cdg ; _edd . _dabgg . EG_BlockLevelElts = [ ] * _ba . EG_BlockLevelElts { _ba . NewEG_BlockLevelElts ( ) } ; _efae := _edd . AddParagraph ( ) ; _efae . Properties ( ) . SetStyle ( "\u0046\u006f\u006f\u0074\u006e\u006f\u0074\u0065" ) ; _efae . _acbc . PPr . RPr = _ba . NewCT_ParaRPr ( ) ; _cbdd := _efae . AddRun ( ) ; _cbdd . AddTab ( ) ; _cbdd . AddText ( text ) ; return _edd ; } ;
2020-05-12 19:07:52 +03:00
2021-01-04 16:11:39 +00:00
// SetCellSpacing sets the cell spacing within a table.
func ( _babb TableProperties ) SetCellSpacing ( m _gc . Distance ) { _babb . _efeg . TblCellSpacing = _ba . NewCT_TblWidth ( ) ; _babb . _efeg . TblCellSpacing . TypeAttr = _ba . ST_TblWidthDxa ; _babb . _efeg . TblCellSpacing . WAttr = & _ba . ST_MeasurementOrPercent { } ; _babb . _efeg . TblCellSpacing . WAttr . ST_DecimalNumberOrPercent = & _ba . ST_DecimalNumberOrPercent { } ; _babb . _efeg . TblCellSpacing . WAttr . ST_DecimalNumberOrPercent . ST_UnqualifiedPercentage = _d . Int64 ( int64 ( m / _gc . Dxa ) ) ; } ;
2020-06-05 23:38:29 +07:00
2021-01-04 16:11:39 +00:00
// SetConformance sets conformance attribute of the document
// as one of these values from github.com/unidoc/unioffice/schema/soo/ofc/sharedTypes:
// ST_ConformanceClassUnset, ST_ConformanceClassStrict or ST_ConformanceClassTransitional.
func ( _ffcf Document ) SetConformance ( conformanceAttr _dc . ST_ConformanceClass ) { _ffcf . _dadc . ConformanceAttr = conformanceAttr ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// RunProperties returns the run style properties.
func ( _egbbf Style ) RunProperties ( ) RunProperties { if _egbbf . _ebcb . RPr == nil { _egbbf . _ebcb . RPr = _ba . NewCT_RPr ( ) ; } ; return RunProperties { _egbbf . _ebcb . RPr } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Headers returns the headers defined in the document.
func ( _acd * Document ) Headers ( ) [ ] Header { _fded := [ ] Header { } ; for _ , _feb := range _acd . _adgc { _fded = append ( _fded , Header { _acd , _feb } ) ; } ; return _fded ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Save writes the document to an io.Writer in the Zip package format.
func ( _fedb * Document ) Save ( w _ee . Writer ) error { if _dce := _fedb . _dadc . Validate ( ) ; _dce != nil { _d . Log ( "\u0076\u0061\u006c\u0069\u0064\u0061\u0074\u0069\u006f\u006e\u0020\u0065\u0072\u0072\u006fr\u0020i\u006e\u0020\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u003a\u0020\u0025\u0073" , _dce ) ; } ; _ceb := _d . DocTypeDocument ; if ! _be . GetLicenseKey ( ) . IsLicensed ( ) && ! _bbd { _cfb . Println ( "\u0055\u006e\u006ci\u0063\u0065\u006e\u0073e\u0064\u0020\u0076\u0065\u0072\u0073\u0069o\u006e\u0020\u006f\u0066\u0020\u0055\u006e\u0069\u004f\u0066\u0066\u0069\u0063\u0065" ) ; _cfb . Println ( "\u002d\u0020\u0047e\u0074\u0020\u0061\u0020\u0074\u0072\u0069\u0061\u006c\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0020\u006f\u006e\u0020\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002fu\u006e\u0069\u0064\u006f\u0063\u002e\u0069\u006f" ) ; return _cd . New ( "\u0075\u006e\u0069\u006f\u0066\u0066\u0069\u0063\u0065\u0020\u006ci\u0063\u0065\u006e\u0073\u0065\u0020\u0072\u0065\u0071\u0075i\u0072\u0065\u0064" ) ; } ; _bebc := _b . NewWriter ( w ) ; defer _bebc . Close ( ) ; if _aae := _gg . MarshalXML ( _bebc , _d . BaseRelsFilename , _fedb . Rels . X ( ) ) ; _aae != nil { return _aae ; } ; if _gaf := _gg . MarshalXMLByType ( _bebc , _ceb , _d . ExtendedPropertiesType , _fedb . AppProperties . X ( ) ) ; _gaf != nil { return _gaf ; } ; if _ccd := _gg . MarshalXMLByType ( _bebc , _ceb , _d . CorePropertiesType , _fedb . CoreProperties . X ( ) ) ; _ccd != nil { return _ccd ; } ; if _fedb . CustomProperties . X ( ) != nil { if _fcgg := _gg . MarshalXMLByType ( _bebc , _ceb , _d . CustomPropertiesType , _fedb . CustomProperties . X ( ) ) ; _fcgg != nil { return _fcgg ; } ; } ; if _fedb . Thumbnail != nil { _ead , _dab := _bebc . Create ( "\u0064\u006f\u0063Pr\u006f\u0070\u0073\u002f\u0074\u0068\u0075\u006d\u0062\u006e\u0061\u0069\u006c\u002e\u006a\u0070\u0065\u0067" ) ; if _dab != nil { return _dab ; } ; if _fcgd := _cf . Encode ( _ead , _fedb . Thumbnail , nil ) ; _fcgd != nil { return _fcgd ; } ; } ; if _gfc := _gg . MarshalXMLByType ( _bebc , _ceb , _d . SettingsType , _fedb . Settings . X ( ) ) ; _gfc != nil { return _gfc ; } ; _eadb := _d . AbsoluteFilename ( _ceb , _d . OfficeDocumentType , 0 ) ; if _cfbe := _gg . MarshalXML ( _bebc , _eadb , _fedb . _dadc ) ; _cfbe != nil { return _cfbe ; } ; if _cfc := _gg . MarshalXML ( _bebc , _gg . RelationsPathFor ( _eadb ) , _fedb . _aeg . X ( ) ) ; _cfc != nil { return _cfc ; } ; if _fedb . Numbering . X ( ) != nil { if _fba := _gg . MarshalXMLByType ( _bebc , _ceb , _d . NumberingType , _fedb . Numbering . X ( ) ) ; _fba != nil { return _fba ; } ; } ; if _fbb := _gg . MarshalXMLByType ( _bebc , _ceb , _d . StylesType , _fedb . Styles . X ( ) ) ; _fbb != nil { return _fbb ; } ; if _fedb . _bca != nil { if _bfg := _gg . MarshalXMLByType ( _bebc , _ceb , _d . WebSettingsType , _fedb . _bca ) ; _bfg != nil { return _bfg ; } ; } ; if _fedb . _add != nil { if _cbe := _gg . MarshalXMLByType ( _bebc , _ceb , _d . FontTableType , _fedb . _add ) ; _cbe != nil { return _cbe ; } ; } ; if _fedb . _bed != nil { if _ccgf := _gg . MarshalXMLByType ( _bebc , _ceb , _d . EndNotesType , _fedb . _bed ) ; _ccgf != nil { return _ccgf ; } ; } ; if _fedb . _bgd != nil { if _bac := _gg . MarshalXMLByType ( _bebc , _ceb , _d . FootNotesType , _fedb . _bgd ) ; _bac != nil { return _bac ; } ; } ; for _efe , _bbaba := range _fedb . _eca { if _bgdf := _gg . MarshalXMLByTypeIndex ( _bebc , _ceb , _d . ThemeType , _efe + 1 , _bbaba ) ; _bgdf != nil { return _bgdf ; } ; } ; for _bdf , _bef := range _fedb . _adgc { _edf := _d . AbsoluteFilename ( _ceb , _d . HeaderType , _bdf + 1 ) ; if _eaf := _gg . MarshalXML ( _bebc , _edf , _bef ) ; _eaf != nil { return _eaf ; } ; if ! _fedb . _bec [ _bdf ] . IsEmpty ( ) { _gg . MarshalXML ( _bebc , _gg . RelationsPathFor ( _edf ) , _fedb . _bec [ _bdf ] . X ( ) ) ; } ; } ; for _bbe , _aec := range _fedb . _ggdc { _ageb := _d . AbsoluteFilename ( _ceb , _d . FooterType , _bbe + 1 ) ; if _acc := _gg . MarshalXMLByTypeIndex ( _bebc , _ceb , _d . FooterType , _bbe + 1 , _aec ) ; _acc != nil { return _acc ; } ; if ! _fedb . _cbb [ _bbe ] . IsEmpty ( ) { _gg . MarshalXML ( _bebc , _gg . RelationsPathFor ( _ageb ) , _fedb . _cbb [ _bbe ] . X ( ) ) ; } ; } ; for _efee , _agfc := range _fedb . Images { if _ffd := _bf . AddImageToZip ( _bebc , _agfc , _efee + 1 , _d . DocTypeDocument ) ; _ffd != nil { return _ffd ; } ; } ; if _fdef := _gg . MarshalXML ( _bebc , _d . ContentTypesFilename , _fedb . ContentTypes . X ( ) ) ; _fdef != nil { return _fdef ; } ; if _bfc := _fedb . WriteExtr
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetStyle sets the style of a paragraph.
func ( _fcga ParagraphProperties ) SetStyle ( s string ) { if s == "" { _fcga . _gcdf . PStyle = nil ; } else { _fcga . _gcdf . PStyle = _ba . NewCT_String ( ) ; _fcga . _gcdf . PStyle . ValAttr = s ; } ; } ; func _bgcc ( _gacd * _ba . EG_BlockLevelElts , _ceg * TableInfo ) [ ] TextItem { _gcge := [ ] TextItem { } ; for _ , _fad := range _gacd . EG_ContentBlockContent { if _dgca := _fad . Sdt ; _dgca != nil { if _bcfa := _dgca . SdtContent ; _bcfa != nil { _gcge = append ( _gcge , _ecfb ( _bcfa . P , _ceg , nil ) ... ) ; } ; } ; _gcge = append ( _gcge , _ecfb ( _fad . P , _ceg , nil ) ... ) ; for _ , _efgde := range _fad . Tbl { for _ccba , _ebb := range _efgde . EG_ContentRowContent { for _ , _bgeg := range _ebb . Tr { for _gfad , _gbbb := range _bgeg . EG_ContentCellContent { for _ , _eecd := range _gbbb . Tc { _bebg := & TableInfo { Table : _efgde , Row : _bgeg , Cell : _eecd , RowIndex : _ccba , ColIndex : _gfad } ; for _ , _bbca := range _eecd . EG_BlockLevelElts { _gcge = append ( _gcge , _bgcc ( _bbca , _bebg ) ... ) ; } ; } ; } ; } ; } ; } ; } ; return _gcge ; } ;
2020-08-31 22:58:25 +00:00
2021-01-04 16:11:39 +00:00
// IsChecked returns true if a FormFieldTypeCheckBox is checked.
func ( _bcce FormField ) IsChecked ( ) bool { if _bcce . _edgb . CheckBox == nil { return false ; } ; if _bcce . _edgb . CheckBox . Checked != nil { return true ; } ; return false ; } ;
2020-08-31 22:58:25 +00:00
2021-01-04 16:11:39 +00:00
// SetSize sets the size of the displayed image on the page.
func ( _daca InlineDrawing ) SetSize ( w , h _gc . Distance ) { _daca . _gdece . Extent . CxAttr = int64 ( float64 ( w * _gc . Pixel72 ) / _gc . EMU ) ; _daca . _gdece . Extent . CyAttr = int64 ( float64 ( h * _gc . Pixel72 ) / _gc . EMU ) ; } ;
2020-08-31 22:58:25 +00:00
2021-01-04 16:11:39 +00:00
// Name returns the name of the bookmark whcih is the document unique ID that
// identifies the bookmark.
func ( _ed Bookmark ) Name ( ) string { return _ed . _fg . NameAttr } ;
2020-08-31 22:58:25 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _fe Cell ) X ( ) * _ba . CT_Tc { return _fe . _bd } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// X returns the inner wrapped XML type.
func ( _ddbe TableLook ) X ( ) * _ba . CT_TblLook { return _ddbe . _acbdf } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// ParagraphStyles returns only the paragraph styles.
func ( _dfgee Styles ) ParagraphStyles ( ) [ ] Style { _cgfd := [ ] Style { } ; for _ , _efgb := range _dfgee . _eagfa . Style { if _efgb . TypeAttr != _ba . ST_StyleTypeParagraph { continue ; } ; _cgfd = append ( _cgfd , Style { _efgb } ) ; } ; return _cgfd ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// Outline returns true if paragraph outline is on.
func ( _ddaeg ParagraphProperties ) Outline ( ) bool { return _bfbg ( _ddaeg . _gcdf . RPr . Outline ) } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetPageBreakBefore controls if there is a page break before this paragraph.
func ( _ggae ParagraphProperties ) SetPageBreakBefore ( b bool ) { if ! b { _ggae . _gcdf . PageBreakBefore = nil ; } else { _ggae . _gcdf . PageBreakBefore = _ba . NewCT_OnOff ( ) ; } ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// InsertParagraphBefore adds a new empty paragraph before the relativeTo
// paragraph.
func ( _dbad * Document ) InsertParagraphBefore ( relativeTo Paragraph ) Paragraph { return _dbad . insertParagraph ( relativeTo , true ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// AnchoredDrawing is an absolutely positioned image within a document page.
type AnchoredDrawing struct { _af * Document ; _eg * _ba . WdAnchor ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetRight sets the right border to a specified type, color and thickness.
func ( _bbab CellBorders ) SetRight ( t _ba . ST_Border , c _fb . Color , thickness _gc . Distance ) { _bbab . _fbd . Right = _ba . NewCT_Border ( ) ; _deec ( _bbab . _fbd . Right , t , c , thickness ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetUISortOrder controls the order the style is displayed in the UI.
func ( _efga Style ) SetUISortOrder ( order int ) { _efga . _ebcb . UiPriority = _ba . NewCT_DecimalNumber ( ) ; _efga . _ebcb . UiPriority . ValAttr = int64 ( order ) ; } ;
2020-08-23 14:15:53 +00:00
2021-01-04 16:11:39 +00:00
// SetHangingIndent controls the hanging indent of the paragraph.
func ( _adgb ParagraphStyleProperties ) SetHangingIndent ( m _gc . Distance ) { if _adgb . _gdb . Ind == nil { _adgb . _gdb . Ind = _ba . NewCT_Ind ( ) ; } ; if m == _gc . Zero { _adgb . _gdb . Ind . HangingAttr = nil ; } else { _adgb . _gdb . Ind . HangingAttr = & _dc . ST_TwipsMeasure { } ; _adgb . _gdb . Ind . HangingAttr . ST_UnsignedDecimalNumber = _d . Uint64 ( uint64 ( m / _gc . Twips ) ) ; } ; } ;
2020-08-31 22:58:25 +00:00
2021-01-04 16:11:39 +00:00
// Shadow returns true if paragraph shadow is on.
func ( _bfga ParagraphProperties ) Shadow ( ) bool { return _bfbg ( _bfga . _gcdf . RPr . Shadow ) } ;
2020-11-09 01:00:18 +00:00
2021-01-04 16:11:39 +00:00
// SetLastRow controls the conditional formatting for the last row in a table.
// This is called the 'Total' row within Word.
func ( _gdfd TableLook ) SetLastRow ( on bool ) { if ! on { _gdfd . _acbdf . LastRowAttr = & _dc . ST_OnOff { } ; _gdfd . _acbdf . LastRowAttr . ST_OnOff1 = _dc . ST_OnOff1Off ; } else { _gdfd . _acbdf . LastRowAttr = & _dc . ST_OnOff { } ; _gdfd . _acbdf . LastRowAttr . ST_OnOff1 = _dc . ST_OnOff1On ; } ; } ;
// AddBreak adds a line break to a run.
func ( _fbbd Run ) AddBreak ( ) { _gage := _fbbd . newIC ( ) ; _gage . Br = _ba . NewCT_Br ( ) } ;
// AddBookmark adds a bookmark to a document that can then be used from a hyperlink. Name is a document
// unique name that identifies the bookmark so it can be referenced from hyperlinks.
func ( _edae Paragraph ) AddBookmark ( name string ) Bookmark { _cafa := _ba . NewEG_PContent ( ) ; _eage := _ba . NewEG_ContentRunContent ( ) ; _cafa . EG_ContentRunContent = append ( _cafa . EG_ContentRunContent , _eage ) ; _aeaac := _ba . NewEG_RunLevelElts ( ) ; _eage . EG_RunLevelElts = append ( _eage . EG_RunLevelElts , _aeaac ) ; _ddee := _ba . NewEG_RangeMarkupElements ( ) ; _gbce := _ba . NewCT_Bookmark ( ) ; _ddee . BookmarkStart = _gbce ; _aeaac . EG_RangeMarkupElements = append ( _aeaac . EG_RangeMarkupElements , _ddee ) ; _ddee = _ba . NewEG_RangeMarkupElements ( ) ; _ddee . BookmarkEnd = _ba . NewCT_MarkupRange ( ) ; _aeaac . EG_RangeMarkupElements = append ( _aeaac . EG_RangeMarkupElements , _ddee ) ; _edae . _acbc . EG_PContent = append ( _edae . _acbc . EG_PContent , _cafa ) ; _dbce := Bookmark { _gbce } ; _dbce . SetName ( name ) ; return _dbce ; } ;
// AddDrawingInline adds an inline drawing from an ImageRef.
func ( _ebcf Run ) AddDrawingInline ( img _bf . ImageRef ) ( InlineDrawing , error ) { _cdab := _ebcf . newIC ( ) ; _cdab . Drawing = _ba . NewCT_Drawing ( ) ; _ggfdf := _ba . NewWdInline ( ) ; _aaea := InlineDrawing { _ebcf . _cebg , _ggfdf } ; _ggfdf . CNvGraphicFramePr = _cde . NewCT_NonVisualGraphicFrameProperties ( ) ; _cdab . Drawing . Inline = append ( _cdab . Drawing . Inline , _ggfdf ) ; _ggfdf . Graphic = _cde . NewGraphic ( ) ; _ggfdf . Graphic . GraphicData = _cde . NewCT_GraphicalObjectData ( ) ; _ggfdf . Graphic . GraphicData . UriAttr = "\u0068\u0074\u0074\u0070\u003a\u002f/\u0073\u0063\u0068e\u006d\u0061\u0073.\u006f\u0070\u0065\u006e\u0078\u006d\u006c\u0066\u006f\u0072m\u0061\u0074\u0073\u002e\u006frg\u002f\u0064\u0072\u0061\u0077\u0069\u006e\u0067\u006d\u006c\u002f\u0032\u0030\u0030\u0036\u002f\u0070\u0069\u0063\u0074\u0075\u0072\u0065" ; _ggfdf . DistTAttr = _d . Uint32 ( 0 ) ; _ggfdf . DistLAttr = _d . Uint32 ( 0 ) ; _ggfdf . DistBAttr = _d . Uint32 ( 0 ) ; _ggfdf . DistRAttr = _d . Uint32 ( 0 ) ; _ggfdf . Extent . CxAttr = int64 ( float64 ( img . Size ( ) . X * _gc . Pixel72 ) / _gc . EMU ) ; _ggfdf . Extent . CyAttr = int64 ( float64 ( img . Size ( ) . Y * _gc . Pixel72 ) / _gc . EMU ) ; _becba := 0x7FFFFFFF & _e . Uint32 ( ) ; _ggfdf . DocPr . IdAttr = _becba ; _efafc := _bc . NewPic ( ) ; _efafc . NvPicPr . CNvPr . IdAttr = _becba ; _fgfde := img . RelID ( ) ; if _fgfde == "" { return _aaea , _cd . New ( "\u0063\u006f\u0075\u006c\u0064\u006e\u0027\u0074\u0020\u0066\u0069\u006e\u0064\u0020\u0072\u0065\u0066\u0065\u0072\u0065n\u0063\u0065\u0020\u0074\u006f\u0020\u0069\u006d\u0061g\u0065\u0020\u0077\u0069\u0074\u0068\u0069\u006e\u0020\u0064\u006f\u0063\u0075m\u0065\u006e\u0074\u0020\u0072\u0065l\u0061\u0074\u0069o\u006e\u0073" ) ; } ; _ggfdf . Graphic . GraphicData . Any = append ( _ggfdf . Graphic . GraphicData . Any , _efafc ) ; _efafc . BlipFill = _cde . NewCT_BlipFillProperties ( ) ; _efafc . BlipFill . Blip = _cde . NewCT_Blip ( ) ; _efafc . BlipFill . Blip . EmbedAttr = & _fgfde ; _efafc . BlipFill . Stretch = _cde . NewCT_StretchInfoProperties ( ) ; _efafc . BlipFill . Stretch . FillRect = _cde . NewCT_RelativeRect ( ) ; _efafc . SpPr = _cde . NewCT_ShapeProperties ( ) ; _efafc . SpPr . Xfrm = _cde . NewCT_Transform2D ( ) ; _efafc . SpPr . Xfrm . Off = _cde . NewCT_Point2D ( ) ; _efafc . SpPr . Xfrm . Off . XAttr . ST_CoordinateUnqualified = _d . Int64 ( 0 ) ; _efafc . SpPr . Xfrm . Off . YAttr . ST_CoordinateUnqualified = _d . Int64 ( 0 ) ; _efafc . SpPr . Xfrm . Ext = _cde . NewCT_PositiveSize2D ( ) ; _efafc . SpPr . Xfrm . Ext . CxAttr = int64 ( img . Size ( ) . X * _gc . Point ) ; _efafc . SpPr . Xfrm . Ext . CyAttr = int64 ( img . Size ( ) . Y * _gc . Point ) ; _efafc . SpPr . PrstGeom = _cde . NewCT_PresetGeometry2D ( ) ; _efafc . SpPr . PrstGeom . PrstAttr = _cde . ST_ShapeTypeRect ; return _aaea , nil ; } ;
// X returns the inner wrapped XML type.
func ( _fc Color ) X ( ) * _ba . CT_Color { return _fc . _gf } ;