forked from zxzgl/unioffice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlip.go
204 lines (195 loc) · 7.29 KB
/
Blip.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
// 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 dml
import (
"encoding/xml"
"baliance.com/gooxml"
)
type Blip struct {
CT_Blip
}
func NewBlip() *Blip {
ret := &Blip{}
ret.CT_Blip = *NewCT_Blip()
return ret
}
func (m *Blip) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/main"})
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:a"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/main"})
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:r"}, Value: "http://schemas.openxmlformats.org/officeDocument/2006/relationships"})
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:sh"}, Value: "http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes"})
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:xml"}, Value: "http://www.w3.org/XML/1998/namespace"})
start.Name.Local = "a:blip"
return m.CT_Blip.MarshalXML(e, start)
}
func (m *Blip) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
// initialize to default
m.CT_Blip = *NewCT_Blip()
for _, attr := range start.Attr {
if attr.Name.Space == "http://schemas.openxmlformats.org/officeDocument/2006/relationships" && attr.Name.Local == "embed" {
parsed, err := attr.Value, error(nil)
if err != nil {
return err
}
m.EmbedAttr = &parsed
continue
}
if attr.Name.Space == "http://schemas.openxmlformats.org/officeDocument/2006/relationships" && attr.Name.Local == "link" {
parsed, err := attr.Value, error(nil)
if err != nil {
return err
}
m.LinkAttr = &parsed
continue
}
if attr.Name.Local == "cstate" {
m.CstateAttr.UnmarshalXMLAttr(attr)
continue
}
}
lBlip:
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/drawingml/2006/main", Local: "alphaBiLevel"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.AlphaBiLevel, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "alphaCeiling"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.AlphaCeiling, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "alphaFloor"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.AlphaFloor, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "alphaInv"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.AlphaInv, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "alphaMod"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.AlphaMod, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "alphaModFix"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.AlphaModFix, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "alphaRepl"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.AlphaRepl, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "biLevel"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.BiLevel, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "blur"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.Blur, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "clrChange"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.ClrChange, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "clrRepl"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.ClrRepl, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "duotone"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.Duotone, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "fillOverlay"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.FillOverlay, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "grayscl"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.Grayscl, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "hsl"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.Hsl, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "lum"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.Lum, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "tint"}:
tmp := NewCT_BlipChoice()
if err := d.DecodeElement(&tmp.Tint, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "extLst"}:
m.ExtLst = NewCT_OfficeArtExtensionList()
if err := d.DecodeElement(m.ExtLst, &el); err != nil {
return err
}
default:
gooxml.Log("skipping unsupported element on Blip %v", el.Name)
if err := d.Skip(); err != nil {
return err
}
}
case xml.EndElement:
break lBlip
case xml.CharData:
}
}
return nil
}
// Validate validates the Blip and its children
func (m *Blip) Validate() error {
return m.ValidateWithPath("Blip")
}
// ValidateWithPath validates the Blip and its children, prefixing error messages with path
func (m *Blip) ValidateWithPath(path string) error {
if err := m.CT_Blip.ValidateWithPath(path); err != nil {
return err
}
return nil
}