mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-29 13:49:10 +08:00
72 lines
1.7 KiB
Go
72 lines
1.7 KiB
Go
// Copyright 2017 Baliance. All rights reserved.
|
|
//
|
|
// 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 drawingml
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"log"
|
|
)
|
|
|
|
type CT_Headers struct {
|
|
Header []string
|
|
}
|
|
|
|
func NewCT_Headers() *CT_Headers {
|
|
ret := &CT_Headers{}
|
|
return ret
|
|
}
|
|
|
|
func (m *CT_Headers) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
|
e.EncodeToken(start)
|
|
seheader := xml.StartElement{Name: xml.Name{Local: "a:header"}}
|
|
e.EncodeElement(m.Header, seheader)
|
|
e.EncodeToken(xml.EndElement{Name: start.Name})
|
|
return nil
|
|
}
|
|
|
|
func (m *CT_Headers) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
|
// initialize to default
|
|
lCT_Headers:
|
|
for {
|
|
tok, err := d.Token()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
switch el := tok.(type) {
|
|
case xml.StartElement:
|
|
switch el.Name.Local {
|
|
case "header":
|
|
var tmp string
|
|
if err := d.DecodeElement(&tmp, &el); err != nil {
|
|
return err
|
|
}
|
|
m.Header = append(m.Header, tmp)
|
|
default:
|
|
log.Printf("skipping unsupported element on CT_Headers %v", el.Name)
|
|
if err := d.Skip(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
case xml.EndElement:
|
|
break lCT_Headers
|
|
case xml.CharData:
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Validate validates the CT_Headers and its children
|
|
func (m *CT_Headers) Validate() error {
|
|
return m.ValidateWithPath("CT_Headers")
|
|
}
|
|
|
|
// ValidateWithPath validates the CT_Headers and its children, prefixing error messages with path
|
|
func (m *CT_Headers) ValidateWithPath(path string) error {
|
|
return nil
|
|
}
|