forked from unidoc/unioffice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CT_CoreProperties.go
226 lines (217 loc) · 7.74 KB
/
CT_CoreProperties.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
// 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 core_properties
import (
"encoding/xml"
"time"
"baliance.com/gooxml"
)
type CT_CoreProperties struct {
Category *string
ContentStatus *string
Created *gooxml.XSDAny
Creator *gooxml.XSDAny
Description *gooxml.XSDAny
Identifier *gooxml.XSDAny
Keywords *CT_Keywords
Language *gooxml.XSDAny
LastModifiedBy *string
LastPrinted *time.Time
Modified *gooxml.XSDAny
Revision *string
Subject *gooxml.XSDAny
Title *gooxml.XSDAny
Version *string
}
func NewCT_CoreProperties() *CT_CoreProperties {
ret := &CT_CoreProperties{}
return ret
}
func (m *CT_CoreProperties) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
e.EncodeToken(start)
if m.Category != nil {
secategory := xml.StartElement{Name: xml.Name{Local: "cp:category"}}
gooxml.AddPreserveSpaceAttr(&secategory, *m.Category)
e.EncodeElement(m.Category, secategory)
}
if m.ContentStatus != nil {
secontentStatus := xml.StartElement{Name: xml.Name{Local: "cp:contentStatus"}}
gooxml.AddPreserveSpaceAttr(&secontentStatus, *m.ContentStatus)
e.EncodeElement(m.ContentStatus, secontentStatus)
}
if m.Created != nil {
secreated := xml.StartElement{Name: xml.Name{Local: "dcterms:created"}}
e.EncodeElement(m.Created, secreated)
}
if m.Creator != nil {
secreator := xml.StartElement{Name: xml.Name{Local: "dc:creator"}}
e.EncodeElement(m.Creator, secreator)
}
if m.Description != nil {
sedescription := xml.StartElement{Name: xml.Name{Local: "dc:description"}}
e.EncodeElement(m.Description, sedescription)
}
if m.Identifier != nil {
seidentifier := xml.StartElement{Name: xml.Name{Local: "dc:identifier"}}
e.EncodeElement(m.Identifier, seidentifier)
}
if m.Keywords != nil {
sekeywords := xml.StartElement{Name: xml.Name{Local: "cp:keywords"}}
e.EncodeElement(m.Keywords, sekeywords)
}
if m.Language != nil {
selanguage := xml.StartElement{Name: xml.Name{Local: "dc:language"}}
e.EncodeElement(m.Language, selanguage)
}
if m.LastModifiedBy != nil {
selastModifiedBy := xml.StartElement{Name: xml.Name{Local: "cp:lastModifiedBy"}}
gooxml.AddPreserveSpaceAttr(&selastModifiedBy, *m.LastModifiedBy)
e.EncodeElement(m.LastModifiedBy, selastModifiedBy)
}
if m.LastPrinted != nil {
selastPrinted := xml.StartElement{Name: xml.Name{Local: "cp:lastPrinted"}}
e.EncodeElement(m.LastPrinted, selastPrinted)
}
if m.Modified != nil {
semodified := xml.StartElement{Name: xml.Name{Local: "dcterms:modified"}}
e.EncodeElement(m.Modified, semodified)
}
if m.Revision != nil {
serevision := xml.StartElement{Name: xml.Name{Local: "cp:revision"}}
gooxml.AddPreserveSpaceAttr(&serevision, *m.Revision)
e.EncodeElement(m.Revision, serevision)
}
if m.Subject != nil {
sesubject := xml.StartElement{Name: xml.Name{Local: "dc:subject"}}
e.EncodeElement(m.Subject, sesubject)
}
if m.Title != nil {
setitle := xml.StartElement{Name: xml.Name{Local: "dc:title"}}
e.EncodeElement(m.Title, setitle)
}
if m.Version != nil {
seversion := xml.StartElement{Name: xml.Name{Local: "cp:version"}}
gooxml.AddPreserveSpaceAttr(&seversion, *m.Version)
e.EncodeElement(m.Version, seversion)
}
e.EncodeToken(xml.EndElement{Name: start.Name})
return nil
}
func (m *CT_CoreProperties) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
// initialize to default
lCT_CoreProperties:
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/package/2006/metadata/core-properties", Local: "category"}:
m.Category = new(string)
if err := d.DecodeElement(m.Category, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", Local: "contentStatus"}:
m.ContentStatus = new(string)
if err := d.DecodeElement(m.ContentStatus, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/terms/", Local: "created"}:
m.Created = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Created, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/elements/1.1/", Local: "creator"}:
m.Creator = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Creator, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/elements/1.1/", Local: "description"}:
m.Description = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Description, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/elements/1.1/", Local: "identifier"}:
m.Identifier = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Identifier, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", Local: "keywords"}:
m.Keywords = NewCT_Keywords()
if err := d.DecodeElement(m.Keywords, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/elements/1.1/", Local: "language"}:
m.Language = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Language, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", Local: "lastModifiedBy"}:
m.LastModifiedBy = new(string)
if err := d.DecodeElement(m.LastModifiedBy, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", Local: "lastPrinted"}:
m.LastPrinted = new(time.Time)
if err := d.DecodeElement(m.LastPrinted, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/terms/", Local: "modified"}:
m.Modified = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Modified, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", Local: "revision"}:
m.Revision = new(string)
if err := d.DecodeElement(m.Revision, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/elements/1.1/", Local: "subject"}:
m.Subject = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Subject, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/elements/1.1/", Local: "title"}:
m.Title = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Title, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", Local: "version"}:
m.Version = new(string)
if err := d.DecodeElement(m.Version, &el); err != nil {
return err
}
default:
gooxml.Log("skipping unsupported element on CT_CoreProperties %v", el.Name)
if err := d.Skip(); err != nil {
return err
}
}
case xml.EndElement:
break lCT_CoreProperties
case xml.CharData:
}
}
return nil
}
// Validate validates the CT_CoreProperties and its children
func (m *CT_CoreProperties) Validate() error {
return m.ValidateWithPath("CT_CoreProperties")
}
// ValidateWithPath validates the CT_CoreProperties and its children, prefixing error messages with path
func (m *CT_CoreProperties) ValidateWithPath(path string) error {
if m.Keywords != nil {
if err := m.Keywords.ValidateWithPath(path + "/Keywords"); err != nil {
return err
}
}
return nil
}