forked from srinathh/gooxml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CT_Stylesheet.go
241 lines (232 loc) · 7.06 KB
/
CT_Stylesheet.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
// Copyright 2017 Baliance. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
//
// Use of this source code is governed by the terms of the Affero GNU General
// Public License version 3.0 as published by the Free Software Foundation and
// appearing in the file LICENSE included in the packaging of this file. A
// commercial license can be purchased by contacting sales@baliance.com.
package sml
import (
"encoding/xml"
"github.com/qnfnypen/gooxml"
)
type CT_Stylesheet struct {
// Number Formats
NumFmts *CT_NumFmts
// Fonts
Fonts *CT_Fonts
// Fills
Fills *CT_Fills
// Borders
Borders *CT_Borders
// Formatting Records
CellStyleXfs *CT_CellStyleXfs
// Cell Formats
CellXfs *CT_CellXfs
// Cell Styles
CellStyles *CT_CellStyles
// Formats
Dxfs *CT_Dxfs
// Table Styles
TableStyles *CT_TableStyles
// Colors
Colors *CT_Colors
// Future Feature Data Storage Area
ExtLst *CT_ExtensionList
}
func NewCT_Stylesheet() *CT_Stylesheet {
ret := &CT_Stylesheet{}
return ret
}
func (m *CT_Stylesheet) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
e.EncodeToken(start)
if m.NumFmts != nil {
senumFmts := xml.StartElement{Name: xml.Name{Local: "ma:numFmts"}}
e.EncodeElement(m.NumFmts, senumFmts)
}
if m.Fonts != nil {
sefonts := xml.StartElement{Name: xml.Name{Local: "ma:fonts"}}
e.EncodeElement(m.Fonts, sefonts)
}
if m.Fills != nil {
sefills := xml.StartElement{Name: xml.Name{Local: "ma:fills"}}
e.EncodeElement(m.Fills, sefills)
}
if m.Borders != nil {
seborders := xml.StartElement{Name: xml.Name{Local: "ma:borders"}}
e.EncodeElement(m.Borders, seborders)
}
if m.CellStyleXfs != nil {
secellStyleXfs := xml.StartElement{Name: xml.Name{Local: "ma:cellStyleXfs"}}
e.EncodeElement(m.CellStyleXfs, secellStyleXfs)
}
if m.CellXfs != nil {
secellXfs := xml.StartElement{Name: xml.Name{Local: "ma:cellXfs"}}
e.EncodeElement(m.CellXfs, secellXfs)
}
if m.CellStyles != nil {
secellStyles := xml.StartElement{Name: xml.Name{Local: "ma:cellStyles"}}
e.EncodeElement(m.CellStyles, secellStyles)
}
if m.Dxfs != nil {
sedxfs := xml.StartElement{Name: xml.Name{Local: "ma:dxfs"}}
e.EncodeElement(m.Dxfs, sedxfs)
}
if m.TableStyles != nil {
setableStyles := xml.StartElement{Name: xml.Name{Local: "ma:tableStyles"}}
e.EncodeElement(m.TableStyles, setableStyles)
}
if m.Colors != nil {
secolors := xml.StartElement{Name: xml.Name{Local: "ma:colors"}}
e.EncodeElement(m.Colors, secolors)
}
if m.ExtLst != nil {
seextLst := xml.StartElement{Name: xml.Name{Local: "ma:extLst"}}
e.EncodeElement(m.ExtLst, seextLst)
}
e.EncodeToken(xml.EndElement{Name: start.Name})
return nil
}
func (m *CT_Stylesheet) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
// initialize to default
lCT_Stylesheet:
for {
tok, err := d.Token()
if err != nil {
return err
}
switch el := tok.(type) {
case xml.StartElement:
switch el.Name {
case xml.Name{Space: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", Local: "numFmts"}:
m.NumFmts = NewCT_NumFmts()
if err := d.DecodeElement(m.NumFmts, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", Local: "fonts"}:
m.Fonts = NewCT_Fonts()
if err := d.DecodeElement(m.Fonts, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", Local: "fills"}:
m.Fills = NewCT_Fills()
if err := d.DecodeElement(m.Fills, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", Local: "borders"}:
m.Borders = NewCT_Borders()
if err := d.DecodeElement(m.Borders, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", Local: "cellStyleXfs"}:
m.CellStyleXfs = NewCT_CellStyleXfs()
if err := d.DecodeElement(m.CellStyleXfs, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", Local: "cellXfs"}:
m.CellXfs = NewCT_CellXfs()
if err := d.DecodeElement(m.CellXfs, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", Local: "cellStyles"}:
m.CellStyles = NewCT_CellStyles()
if err := d.DecodeElement(m.CellStyles, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", Local: "dxfs"}:
m.Dxfs = NewCT_Dxfs()
if err := d.DecodeElement(m.Dxfs, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", Local: "tableStyles"}:
m.TableStyles = NewCT_TableStyles()
if err := d.DecodeElement(m.TableStyles, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", Local: "colors"}:
m.Colors = NewCT_Colors()
if err := d.DecodeElement(m.Colors, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", Local: "extLst"}:
m.ExtLst = NewCT_ExtensionList()
if err := d.DecodeElement(m.ExtLst, &el); err != nil {
return err
}
default:
gooxml.Log("skipping unsupported element on CT_Stylesheet %v", el.Name)
if err := d.Skip(); err != nil {
return err
}
}
case xml.EndElement:
break lCT_Stylesheet
case xml.CharData:
}
}
return nil
}
// Validate validates the CT_Stylesheet and its children
func (m *CT_Stylesheet) Validate() error {
return m.ValidateWithPath("CT_Stylesheet")
}
// ValidateWithPath validates the CT_Stylesheet and its children, prefixing error messages with path
func (m *CT_Stylesheet) ValidateWithPath(path string) error {
if m.NumFmts != nil {
if err := m.NumFmts.ValidateWithPath(path + "/NumFmts"); err != nil {
return err
}
}
if m.Fonts != nil {
if err := m.Fonts.ValidateWithPath(path + "/Fonts"); err != nil {
return err
}
}
if m.Fills != nil {
if err := m.Fills.ValidateWithPath(path + "/Fills"); err != nil {
return err
}
}
if m.Borders != nil {
if err := m.Borders.ValidateWithPath(path + "/Borders"); err != nil {
return err
}
}
if m.CellStyleXfs != nil {
if err := m.CellStyleXfs.ValidateWithPath(path + "/CellStyleXfs"); err != nil {
return err
}
}
if m.CellXfs != nil {
if err := m.CellXfs.ValidateWithPath(path + "/CellXfs"); err != nil {
return err
}
}
if m.CellStyles != nil {
if err := m.CellStyles.ValidateWithPath(path + "/CellStyles"); err != nil {
return err
}
}
if m.Dxfs != nil {
if err := m.Dxfs.ValidateWithPath(path + "/Dxfs"); err != nil {
return err
}
}
if m.TableStyles != nil {
if err := m.TableStyles.ValidateWithPath(path + "/TableStyles"); err != nil {
return err
}
}
if m.Colors != nil {
if err := m.Colors.ValidateWithPath(path + "/Colors"); err != nil {
return err
}
}
if m.ExtLst != nil {
if err := m.ExtLst.ValidateWithPath(path + "/ExtLst"); err != nil {
return err
}
}
return nil
}