unioffice/schema/soo/wml/WdCT_WrapPath.go

111 lines
3.0 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.
2017-09-23 08:28:52 -05:00
package wml
2017-08-28 20:56:18 -05:00
import (
"encoding/xml"
"fmt"
"log"
"strconv"
2017-09-23 08:39:08 -05:00
"baliance.com/gooxml/schema/soo/dml"
2017-08-28 20:56:18 -05:00
)
type WdCT_WrapPath struct {
2017-08-28 20:56:18 -05:00
EditedAttr *bool
2017-09-23 08:39:08 -05:00
Start *dml.CT_Point2D
LineTo []*dml.CT_Point2D
2017-08-28 20:56:18 -05:00
}
func NewWdCT_WrapPath() *WdCT_WrapPath {
ret := &WdCT_WrapPath{}
2017-09-23 08:39:08 -05:00
ret.Start = dml.NewCT_Point2D()
2017-08-28 20:56:18 -05:00
return ret
}
func (m *WdCT_WrapPath) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
2017-08-28 20:56:18 -05:00
if m.EditedAttr != nil {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "edited"},
Value: fmt.Sprintf("%d", b2i(*m.EditedAttr))})
2017-08-28 20:56:18 -05:00
}
e.EncodeToken(start)
sestart := xml.StartElement{Name: xml.Name{Local: "wp:start"}}
e.EncodeElement(m.Start, sestart)
selineTo := xml.StartElement{Name: xml.Name{Local: "wp:lineTo"}}
for _, c := range m.LineTo {
e.EncodeElement(c, selineTo)
}
2017-08-28 20:56:18 -05:00
e.EncodeToken(xml.EndElement{Name: start.Name})
return nil
}
func (m *WdCT_WrapPath) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
2017-08-28 20:56:18 -05:00
// initialize to default
2017-09-23 08:39:08 -05:00
m.Start = dml.NewCT_Point2D()
2017-08-28 20:56:18 -05:00
for _, attr := range start.Attr {
if attr.Name.Local == "edited" {
parsed, err := strconv.ParseBool(attr.Value)
if err != nil {
return err
}
m.EditedAttr = &parsed
}
}
lWdCT_WrapPath:
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: "start"}:
2017-08-28 20:56:18 -05:00
if err := d.DecodeElement(m.Start, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "lineTo"}:
2017-09-23 08:39:08 -05:00
tmp := dml.NewCT_Point2D()
2017-08-28 20:56:18 -05:00
if err := d.DecodeElement(tmp, &el); err != nil {
return err
}
m.LineTo = append(m.LineTo, tmp)
default:
log.Printf("skipping unsupported element on WdCT_WrapPath %v", el.Name)
2017-08-28 20:56:18 -05:00
if err := d.Skip(); err != nil {
return err
}
}
case xml.EndElement:
break lWdCT_WrapPath
2017-08-28 20:56:18 -05:00
case xml.CharData:
}
}
return nil
}
// Validate validates the WdCT_WrapPath and its children
func (m *WdCT_WrapPath) Validate() error {
return m.ValidateWithPath("WdCT_WrapPath")
2017-08-28 20:56:18 -05:00
}
// ValidateWithPath validates the WdCT_WrapPath and its children, prefixing error messages with path
func (m *WdCT_WrapPath) ValidateWithPath(path string) error {
2017-08-28 20:56:18 -05:00
if err := m.Start.ValidateWithPath(path + "/Start"); err != nil {
return err
}
for i, v := range m.LineTo {
if err := v.ValidateWithPath(fmt.Sprintf("%s/LineTo[%d]", path, i)); err != nil {
return err
}
}
return nil
}