forked from fumiama/go-docx
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstructnumbering.go
98 lines (84 loc) · 2.08 KB
/
structnumbering.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
package docx
import (
"encoding/xml"
"io"
)
type Numbering struct {
XMLName xml.Name `xml:"w:numbering"`
XMLW string `xml:"xmlns:w,attr"` // cannot be unmarshalled in
XMLR string `xml:"xmlns:r,attr,omitempty"` // cannot be unmarshalled in
XMLWP string `xml:"xmlns:wp,attr,omitempty"` // cannot be unmarshalled in
XMLWPS string `xml:"xmlns:wps,attr,omitempty"` // cannot be unmarshalled in
XMLWPC string `xml:"xmlns:wpc,attr,omitempty"` // cannot be unmarshalled in
XMLWPG string `xml:"xmlns:wpg,attr,omitempty"` // cannot be unmarshalled in
AbstractNum []*AbstractNum
file *Docx
}
type AbstractNum struct {
XMLName xml.Name `xml:"w:abstractNum,omitempty"`
AbstractNumId string `xml:"w:abstractNumId"`
Nsid *Nsid
MultiLevelType *MultiLevelType
Tmpl *Tmpl
}
type Nsid struct {
XMLName xml.Name `xml:"w:nsid"`
Val string `xml:"w:val"`
}
type MultiLevelType struct {
XMLName xml.Name `xml:"w:multiLevelType"`
Val string `xml:"w:val"`
}
type Tmpl struct {
XMLName xml.Name `xml:"w:tmpl"`
Val string `xml:"w:val"`
}
type Lvl struct {
XMLName xml.Name `xml:"w:lvl"`
Ilvl string `xml:"w:ilvl"`
Tentative string `xml:"w:tentative"`
Start *Start
NumFmt *NumFmt
LvlText *LvlText
LvlJc *LvlJc
PPr *ParagraphProperties
RPr *RunProperties
}
type Start struct {
XMLName xml.Name `xml:"w:start"`
Val string `xml:"w:val"`
}
type NumFmt struct {
XMLName xml.Name `xml:"w:numFmt"`
Val string `xml:"w:val"`
}
type LvlText struct {
XMLName xml.Name `xml:"w:lvlText"`
Val string `xml:"w:val"`
}
type LvlJc struct {
XMLName xml.Name `xml:"w:lvlJc"`
Val string `xml:"w:val"`
}
func (p *Numbering) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error {
for {
t, err := d.Token()
if err == io.EOF {
break
}
if err != nil {
return err
}
if tt, ok := t.(xml.StartElement); ok {
switch tt.Name.Local {
default:
err = d.Skip() // skip unsupported tags
if err != nil {
return err
}
continue
}
}
}
return nil
}