Skip to content

Commit

Permalink
schema: round trip extra content on Workbook
Browse files Browse the repository at this point in the history
Excel occasionally drops some alternate content with
path information here.
  • Loading branch information
tbaliance committed Oct 2, 2017
1 parent 99ed487 commit 56e9890
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 9 additions & 2 deletions schema/soo/sml/CT_Workbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type CT_Workbook struct {
WebPublishObjects *CT_WebPublishObjects
// Future Feature Data Storage Area
ExtLst *CT_ExtensionList
Extra []gooxml.Any
}

func NewCT_Workbook() *CT_Workbook {
Expand Down Expand Up @@ -151,6 +152,11 @@ func (m *CT_Workbook) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
seextLst := xml.StartElement{Name: xml.Name{Local: "ma:extLst"}}
e.EncodeElement(m.ExtLst, seextLst)
}
for _, any := range m.Extra {
if err := any.MarshalXML(e, xml.StartElement{}); err != nil {
return err
}
}
e.EncodeToken(xml.EndElement{Name: start.Name})
return nil
}
Expand Down Expand Up @@ -268,10 +274,11 @@ lCT_Workbook:
return err
}
default:
gooxml.Log("skipping unsupported element on CT_Workbook %v", el.Name)
if err := d.Skip(); err != nil {
any := &gooxml.XSDAny{}
if err := d.DecodeElement(any, &el); err != nil {
return err
}
m.Extra = append(m.Extra, any)
}
case xml.EndElement:
break lCT_Workbook
Expand Down
5 changes: 3 additions & 2 deletions schema/soo/sml/Workbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,11 @@ lWorkbook:
return err
}
default:
gooxml.Log("skipping unsupported element on Workbook %v", el.Name)
if err := d.Skip(); err != nil {
any := &gooxml.XSDAny{}
if err := d.DecodeElement(any, &el); err != nil {
return err
}
m.Extra = append(m.Extra, any)
}
case xml.EndElement:
break lWorkbook
Expand Down

0 comments on commit 56e9890

Please sign in to comment.