mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-27 13:48:54 +08:00

These are implied values as they are the defaults in the XSD for optional attributes/elements. However I've noticed that I keep running into issues where Mac Excel/Word fail to open a file unless an optional default is provided. I'll just add them all to hopefully increase compatibility and save painful file format debugging sessions later.
93 lines
2.7 KiB
Go
93 lines
2.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"
|
|
"fmt"
|
|
|
|
"baliance.com/gooxml"
|
|
"baliance.com/gooxml/schema/schemas.openxmlformats.org/officeDocument/2006/sharedTypes"
|
|
)
|
|
|
|
type CT_AnimationDgmElement struct {
|
|
IdAttr *string
|
|
BldStepAttr ST_DgmBuildStep
|
|
}
|
|
|
|
func NewCT_AnimationDgmElement() *CT_AnimationDgmElement {
|
|
ret := &CT_AnimationDgmElement{}
|
|
ret.IdAttr = gooxml.String("{00000000-0000-0000-0000-000000000000}")
|
|
ret.BldStepAttr = ST_DgmBuildStepSp
|
|
return ret
|
|
}
|
|
|
|
func (m *CT_AnimationDgmElement) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
|
if m.IdAttr != nil {
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "id"},
|
|
Value: fmt.Sprintf("%v", *m.IdAttr)})
|
|
}
|
|
if m.BldStepAttr != ST_DgmBuildStepUnset {
|
|
attr, err := m.BldStepAttr.MarshalXMLAttr(xml.Name{Local: "bldStep"})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
start.Attr = append(start.Attr, attr)
|
|
}
|
|
e.EncodeToken(start)
|
|
e.EncodeToken(xml.EndElement{Name: start.Name})
|
|
return nil
|
|
}
|
|
|
|
func (m *CT_AnimationDgmElement) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
|
// initialize to default
|
|
m.IdAttr = gooxml.String("{00000000-0000-0000-0000-000000000000}")
|
|
m.BldStepAttr = ST_DgmBuildStepSp
|
|
for _, attr := range start.Attr {
|
|
if attr.Name.Local == "id" {
|
|
parsed, err := attr.Value, error(nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.IdAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "bldStep" {
|
|
m.BldStepAttr.UnmarshalXMLAttr(attr)
|
|
}
|
|
}
|
|
// skip any extensions we may find, but don't support
|
|
for {
|
|
tok, err := d.Token()
|
|
if err != nil {
|
|
return fmt.Errorf("parsing CT_AnimationDgmElement: %s", err)
|
|
}
|
|
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
|
|
break
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Validate validates the CT_AnimationDgmElement and its children
|
|
func (m *CT_AnimationDgmElement) Validate() error {
|
|
return m.ValidateWithPath("CT_AnimationDgmElement")
|
|
}
|
|
|
|
// ValidateWithPath validates the CT_AnimationDgmElement and its children, prefixing error messages with path
|
|
func (m *CT_AnimationDgmElement) ValidateWithPath(path string) error {
|
|
if m.IdAttr != nil {
|
|
if !sharedTypes.ST_GuidPatternRe.MatchString(*m.IdAttr) {
|
|
return fmt.Errorf(`%s/m.IdAttr must match '%s' (have %v)`, path, sharedTypes.ST_GuidPatternRe, *m.IdAttr)
|
|
}
|
|
}
|
|
if err := m.BldStepAttr.ValidateWithPath(path + "/BldStepAttr"); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|