-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CT_DocPartPr.go
172 lines (164 loc) · 5.26 KB
/
CT_DocPartPr.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
package wml
import (
"encoding/xml"
"go.devnw.com/ooxml"
)
type CT_DocPartPr struct {
// Entry Name
Name *CT_DocPartName
// Associated Paragraph Style Name
Style *CT_String
// Entry Categorization
Category *CT_DocPartCategory
// Entry Types
Types *CT_DocPartTypes
// Entry Insertion Behaviors
Behaviors *CT_DocPartBehaviors
// Description for Entry
Description *CT_String
// Entry ID
Guid *CT_Guid
}
func NewCT_DocPartPr() *CT_DocPartPr {
ret := &CT_DocPartPr{}
ret.Name = NewCT_DocPartName()
return ret
}
func (m *CT_DocPartPr) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
e.EncodeToken(start)
sename := xml.StartElement{Name: xml.Name{Local: "w:name"}}
e.EncodeElement(m.Name, sename)
if m.Style != nil {
sestyle := xml.StartElement{Name: xml.Name{Local: "w:style"}}
e.EncodeElement(m.Style, sestyle)
}
if m.Category != nil {
secategory := xml.StartElement{Name: xml.Name{Local: "w:category"}}
e.EncodeElement(m.Category, secategory)
}
if m.Types != nil {
setypes := xml.StartElement{Name: xml.Name{Local: "w:types"}}
e.EncodeElement(m.Types, setypes)
}
if m.Behaviors != nil {
sebehaviors := xml.StartElement{Name: xml.Name{Local: "w:behaviors"}}
e.EncodeElement(m.Behaviors, sebehaviors)
}
if m.Description != nil {
sedescription := xml.StartElement{Name: xml.Name{Local: "w:description"}}
e.EncodeElement(m.Description, sedescription)
}
if m.Guid != nil {
seguid := xml.StartElement{Name: xml.Name{Local: "w:guid"}}
e.EncodeElement(m.Guid, seguid)
}
e.EncodeToken(xml.EndElement{Name: start.Name})
return nil
}
func (m *CT_DocPartPr) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
// initialize to default
m.Name = NewCT_DocPartName()
lCT_DocPartPr:
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/wordprocessingml/2006/main", Local: "name"},
xml.Name{Space: "http://purl.oclc.org/ooxml/wordprocessingml/main", Local: "name"}:
if err := d.DecodeElement(m.Name, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/wordprocessingml/2006/main", Local: "style"},
xml.Name{Space: "http://purl.oclc.org/ooxml/wordprocessingml/main", Local: "style"}:
m.Style = NewCT_String()
if err := d.DecodeElement(m.Style, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/wordprocessingml/2006/main", Local: "category"},
xml.Name{Space: "http://purl.oclc.org/ooxml/wordprocessingml/main", Local: "category"}:
m.Category = NewCT_DocPartCategory()
if err := d.DecodeElement(m.Category, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/wordprocessingml/2006/main", Local: "types"},
xml.Name{Space: "http://purl.oclc.org/ooxml/wordprocessingml/main", Local: "types"}:
m.Types = NewCT_DocPartTypes()
if err := d.DecodeElement(m.Types, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/wordprocessingml/2006/main", Local: "behaviors"},
xml.Name{Space: "http://purl.oclc.org/ooxml/wordprocessingml/main", Local: "behaviors"}:
m.Behaviors = NewCT_DocPartBehaviors()
if err := d.DecodeElement(m.Behaviors, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/wordprocessingml/2006/main", Local: "description"},
xml.Name{Space: "http://purl.oclc.org/ooxml/wordprocessingml/main", Local: "description"}:
m.Description = NewCT_String()
if err := d.DecodeElement(m.Description, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/wordprocessingml/2006/main", Local: "guid"},
xml.Name{Space: "http://purl.oclc.org/ooxml/wordprocessingml/main", Local: "guid"}:
m.Guid = NewCT_Guid()
if err := d.DecodeElement(m.Guid, &el); err != nil {
return err
}
default:
office.Log("skipping unsupported element on CT_DocPartPr %v", el.Name)
if err := d.Skip(); err != nil {
return err
}
}
case xml.EndElement:
break lCT_DocPartPr
case xml.CharData:
}
}
return nil
}
// Validate validates the CT_DocPartPr and its children
func (m *CT_DocPartPr) Validate() error {
return m.ValidateWithPath("CT_DocPartPr")
}
// ValidateWithPath validates the CT_DocPartPr and its children, prefixing error messages with path
func (m *CT_DocPartPr) ValidateWithPath(path string) error {
if err := m.Name.ValidateWithPath(path + "/Name"); err != nil {
return err
}
if m.Style != nil {
if err := m.Style.ValidateWithPath(path + "/Style"); err != nil {
return err
}
}
if m.Category != nil {
if err := m.Category.ValidateWithPath(path + "/Category"); err != nil {
return err
}
}
if m.Types != nil {
if err := m.Types.ValidateWithPath(path + "/Types"); err != nil {
return err
}
}
if m.Behaviors != nil {
if err := m.Behaviors.ValidateWithPath(path + "/Behaviors"); err != nil {
return err
}
}
if m.Description != nil {
if err := m.Description.ValidateWithPath(path + "/Description"); err != nil {
return err
}
}
if m.Guid != nil {
if err := m.Guid.ValidateWithPath(path + "/Guid"); err != nil {
return err
}
}
return nil
}