forked from fumiama/go-docx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # structsect.go
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package docx | ||
|
||
import ( | ||
"encoding/xml" | ||
"io" | ||
) | ||
|
||
// NumProperties show the number properties | ||
type NumProperties struct { | ||
XMLName xml.Name `xml:"w:numPr,omitempty"` | ||
NumId *NumId | ||
Ilvl *Ilevel | ||
} | ||
|
||
// NumId show the number id | ||
type NumId struct { | ||
XMLName xml.Name `xml:"w:numId,omitempty"` | ||
Val string `xml:"w:val,attr"` | ||
} | ||
|
||
// Ilevel show the level | ||
type Ilevel struct { | ||
XMLName xml.Name `xml:"w:ilvl,omitempty"` | ||
Val string `xml:"w:val,attr"` | ||
} | ||
|
||
// UnmarshalXML ... | ||
func (n *NumProperties) 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 { | ||
case "numId": | ||
var value NumId | ||
value.Val = getAtt(tt.Attr, "val") | ||
n.NumId = &value | ||
case "ilvl": | ||
var value Ilevel | ||
value.Val = getAtt(tt.Attr, "val") | ||
n.Ilvl = &value | ||
default: | ||
err = d.Skip() // skip unsupported tags | ||
if err != nil { | ||
return err | ||
} | ||
continue | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters