Skip to content

Commit

Permalink
feat: A3PageSize4
Browse files Browse the repository at this point in the history
  • Loading branch information
mabiao0525 committed Mar 19, 2024
1 parent 1da342c commit 19ad5a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions structdoc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func TestUnmarshalPlainStructure(t *testing.T) {
content string
numParagraphs int
}{
{decoded_doc_1, 5},
{decoded_doc_2, 14},
{decoded_doc_1, 6},
{decoded_doc_2, 15},
}
for _, tc := range testCases {
doc := Document{
Expand All @@ -46,7 +46,7 @@ func TestUnmarshalPlainStructure(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if len(doc.Body.Items) != tc.numParagraphs+1 { // the 1 is the sectPr
if len(doc.Body.Items) != tc.numParagraphs {
t.Fatalf("We expected %d paragraphs, we got %d", tc.numParagraphs, len(doc.Body.Items))
}
for i, it := range doc.Body.Items {
Expand Down
11 changes: 7 additions & 4 deletions structsect.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Copyright (c) 2020 gingfrederik
Copyright (c) 2021 Gonzalo Fernandez-Victorio
Copyright (c) 2021 Basement Crowd Ltd (https://www.basementcrowd.com)
Copyright (c) 2023 Fumiama Minamoto (源文雨)
Copyright (c) 2023 mabiao0525 (马飚)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
Expand Down Expand Up @@ -71,12 +71,15 @@ func (sect *SectPr) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error {
// UnmarshalXML ...
func (pgsz *PgSz) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var err error

for _, attr := range start.Attr {
if attr.Name.Local == "w" {
switch attr.Name.Local {
case "w":
pgsz.W = xml.Attr{Name: xml.Name{Local: "w:w"}, Value: attr.Value}
}
if attr.Name.Local == "h" {
case "h":
pgsz.H = xml.Attr{Name: xml.Name{Local: "w:w"}, Value: attr.Value}
default:
//ignore other attributes now
}
}
// Consume the end element
Expand Down

0 comments on commit 19ad5a7

Please sign in to comment.