188 lines
6.4 KiB
Go
Raw Normal View History

2017-08-28 20:56:18 -05:00
// Copyright 2017 Baliance. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
//
2017-08-28 20:56:18 -05:00
// 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 wordprocessingml
2017-08-28 20:56:18 -05:00
import (
"encoding/xml"
"fmt"
"log"
"strconv"
"baliance.com/gooxml/schema/schemas.openxmlformats.org/drawingml"
)
type WdCT_WordprocessingShape struct {
2017-08-28 20:56:18 -05:00
NormalEastAsianFlowAttr *bool
CNvPr *drawingml.CT_NonVisualDrawingProps
Choice *WdCT_WordprocessingShapeChoice
2017-08-28 20:56:18 -05:00
SpPr *drawingml.CT_ShapeProperties
Style *drawingml.CT_ShapeStyle
ExtLst *drawingml.CT_OfficeArtExtensionList
WChoice *WdCT_WordprocessingShapeChoice1
2017-08-28 20:56:18 -05:00
BodyPr *drawingml.CT_TextBodyProperties
}
func NewWdCT_WordprocessingShape() *WdCT_WordprocessingShape {
ret := &WdCT_WordprocessingShape{}
ret.Choice = NewWdCT_WordprocessingShapeChoice()
2017-08-28 20:56:18 -05:00
ret.SpPr = drawingml.NewCT_ShapeProperties()
ret.BodyPr = drawingml.NewCT_TextBodyProperties()
return ret
}
func (m *WdCT_WordprocessingShape) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
2017-08-28 20:56:18 -05:00
if m.NormalEastAsianFlowAttr != nil {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "normalEastAsianFlow"},
Value: fmt.Sprintf("%d", b2i(*m.NormalEastAsianFlowAttr))})
2017-08-28 20:56:18 -05:00
}
e.EncodeToken(start)
if m.CNvPr != nil {
secNvPr := xml.StartElement{Name: xml.Name{Local: "wp:cNvPr"}}
e.EncodeElement(m.CNvPr, secNvPr)
}
m.Choice.MarshalXML(e, xml.StartElement{})
2017-08-28 20:56:18 -05:00
sespPr := xml.StartElement{Name: xml.Name{Local: "wp:spPr"}}
e.EncodeElement(m.SpPr, sespPr)
if m.Style != nil {
sestyle := xml.StartElement{Name: xml.Name{Local: "wp:style"}}
e.EncodeElement(m.Style, sestyle)
}
if m.ExtLst != nil {
seextLst := xml.StartElement{Name: xml.Name{Local: "wp:extLst"}}
e.EncodeElement(m.ExtLst, seextLst)
}
if m.WChoice != nil {
m.WChoice.MarshalXML(e, xml.StartElement{})
2017-08-28 20:56:18 -05:00
}
sebodyPr := xml.StartElement{Name: xml.Name{Local: "wp:bodyPr"}}
e.EncodeElement(m.BodyPr, sebodyPr)
e.EncodeToken(xml.EndElement{Name: start.Name})
return nil
}
func (m *WdCT_WordprocessingShape) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
2017-08-28 20:56:18 -05:00
// initialize to default
m.Choice = NewWdCT_WordprocessingShapeChoice()
2017-08-28 20:56:18 -05:00
m.SpPr = drawingml.NewCT_ShapeProperties()
m.BodyPr = drawingml.NewCT_TextBodyProperties()
for _, attr := range start.Attr {
if attr.Name.Local == "normalEastAsianFlow" {
parsed, err := strconv.ParseBool(attr.Value)
if err != nil {
return err
}
m.NormalEastAsianFlowAttr = &parsed
}
}
lWdCT_WordprocessingShape:
2017-08-28 20:56:18 -05:00
for {
tok, err := d.Token()
if err != nil {
return err
}
switch el := tok.(type) {
case xml.StartElement:
switch el.Name {
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "cNvPr"}:
2017-08-28 20:56:18 -05:00
m.CNvPr = drawingml.NewCT_NonVisualDrawingProps()
if err := d.DecodeElement(m.CNvPr, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "cNvSpPr"}:
m.Choice = NewWdCT_WordprocessingShapeChoice()
2017-08-28 20:56:18 -05:00
if err := d.DecodeElement(&m.Choice.CNvSpPr, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "cNvCnPr"}:
m.Choice = NewWdCT_WordprocessingShapeChoice()
2017-08-28 20:56:18 -05:00
if err := d.DecodeElement(&m.Choice.CNvCnPr, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "spPr"}:
2017-08-28 20:56:18 -05:00
if err := d.DecodeElement(m.SpPr, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "style"}:
2017-08-28 20:56:18 -05:00
m.Style = drawingml.NewCT_ShapeStyle()
if err := d.DecodeElement(m.Style, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "extLst"}:
2017-08-28 20:56:18 -05:00
m.ExtLst = drawingml.NewCT_OfficeArtExtensionList()
if err := d.DecodeElement(m.ExtLst, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "txbx"}:
m.WChoice = NewWdCT_WordprocessingShapeChoice1()
if err := d.DecodeElement(&m.WChoice.Txbx, &el); err != nil {
2017-08-28 20:56:18 -05:00
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "linkedTxbx"}:
m.WChoice = NewWdCT_WordprocessingShapeChoice1()
if err := d.DecodeElement(&m.WChoice.LinkedTxbx, &el); err != nil {
2017-08-28 20:56:18 -05:00
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "bodyPr"}:
2017-08-28 20:56:18 -05:00
if err := d.DecodeElement(m.BodyPr, &el); err != nil {
return err
}
default:
log.Printf("skipping unsupported element on WdCT_WordprocessingShape %v", el.Name)
2017-08-28 20:56:18 -05:00
if err := d.Skip(); err != nil {
return err
}
}
case xml.EndElement:
break lWdCT_WordprocessingShape
2017-08-28 20:56:18 -05:00
case xml.CharData:
}
}
return nil
}
// Validate validates the WdCT_WordprocessingShape and its children
func (m *WdCT_WordprocessingShape) Validate() error {
return m.ValidateWithPath("WdCT_WordprocessingShape")
2017-08-28 20:56:18 -05:00
}
// ValidateWithPath validates the WdCT_WordprocessingShape and its children, prefixing error messages with path
func (m *WdCT_WordprocessingShape) ValidateWithPath(path string) error {
2017-08-28 20:56:18 -05:00
if m.CNvPr != nil {
if err := m.CNvPr.ValidateWithPath(path + "/CNvPr"); err != nil {
return err
}
}
if err := m.Choice.ValidateWithPath(path + "/Choice"); err != nil {
return err
}
if err := m.SpPr.ValidateWithPath(path + "/SpPr"); err != nil {
return err
}
if m.Style != nil {
if err := m.Style.ValidateWithPath(path + "/Style"); err != nil {
return err
}
}
if m.ExtLst != nil {
if err := m.ExtLst.ValidateWithPath(path + "/ExtLst"); err != nil {
return err
}
}
if m.WChoice != nil {
if err := m.WChoice.ValidateWithPath(path + "/WChoice"); err != nil {
2017-08-28 20:56:18 -05:00
return err
}
}
if err := m.BodyPr.ValidateWithPath(path + "/BodyPr"); err != nil {
return err
}
return nil
}