123 lines
3.2 KiB
Go
Raw Normal View History

2017-08-28 20:56:18 -05:00
// 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_Cell3D struct {
PrstMaterialAttr ST_PresetMaterialType
Bevel *CT_Bevel
LightRig *CT_LightRig
ExtLst *CT_OfficeArtExtensionList
}
func NewCT_Cell3D() *CT_Cell3D {
ret := &CT_Cell3D{}
ret.PrstMaterialAttr = ST_PresetMaterialTypePlastic
2017-08-28 20:56:18 -05:00
ret.Bevel = NewCT_Bevel()
return ret
}
2017-08-28 20:56:18 -05:00
func (m *CT_Cell3D) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
if m.PrstMaterialAttr != ST_PresetMaterialTypeUnset {
attr, err := m.PrstMaterialAttr.MarshalXMLAttr(xml.Name{Local: "prstMaterial"})
if err != nil {
return err
}
start.Attr = append(start.Attr, attr)
}
e.EncodeToken(start)
sebevel := xml.StartElement{Name: xml.Name{Local: "a:bevel"}}
e.EncodeElement(m.Bevel, sebevel)
if m.LightRig != nil {
selightRig := xml.StartElement{Name: xml.Name{Local: "a:lightRig"}}
e.EncodeElement(m.LightRig, selightRig)
}
if m.ExtLst != nil {
seextLst := xml.StartElement{Name: xml.Name{Local: "a:extLst"}}
e.EncodeElement(m.ExtLst, seextLst)
}
e.EncodeToken(xml.EndElement{Name: start.Name})
return nil
}
2017-08-28 20:56:18 -05:00
func (m *CT_Cell3D) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
// initialize to default
m.PrstMaterialAttr = ST_PresetMaterialTypePlastic
2017-08-28 20:56:18 -05:00
m.Bevel = NewCT_Bevel()
for _, attr := range start.Attr {
if attr.Name.Local == "prstMaterial" {
m.PrstMaterialAttr.UnmarshalXMLAttr(attr)
}
}
lCT_Cell3D:
for {
tok, err := d.Token()
if err != nil {
return err
}
switch el := tok.(type) {
case xml.StartElement:
switch el.Name.Local {
case "bevel":
if err := d.DecodeElement(m.Bevel, &el); err != nil {
return err
}
case "lightRig":
m.LightRig = NewCT_LightRig()
if err := d.DecodeElement(m.LightRig, &el); err != nil {
return err
}
case "extLst":
m.ExtLst = NewCT_OfficeArtExtensionList()
if err := d.DecodeElement(m.ExtLst, &el); err != nil {
return err
}
default:
log.Printf("skipping unsupported element on CT_Cell3D %v", el.Name)
2017-08-28 20:56:18 -05:00
if err := d.Skip(); err != nil {
return err
}
}
case xml.EndElement:
break lCT_Cell3D
case xml.CharData:
}
}
return nil
}
// Validate validates the CT_Cell3D and its children
2017-08-28 20:56:18 -05:00
func (m *CT_Cell3D) Validate() error {
return m.ValidateWithPath("CT_Cell3D")
}
// ValidateWithPath validates the CT_Cell3D and its children, prefixing error messages with path
2017-08-28 20:56:18 -05:00
func (m *CT_Cell3D) ValidateWithPath(path string) error {
if err := m.PrstMaterialAttr.ValidateWithPath(path + "/PrstMaterialAttr"); err != nil {
return err
}
if err := m.Bevel.ValidateWithPath(path + "/Bevel"); err != nil {
return err
}
if m.LightRig != nil {
if err := m.LightRig.ValidateWithPath(path + "/LightRig"); err != nil {
return err
}
}
if m.ExtLst != nil {
if err := m.ExtLst.ValidateWithPath(path + "/ExtLst"); err != nil {
return err
}
}
return nil
}