2017-08-28 20:56:18 -05:00
|
|
|
// Copyright 2017 Baliance. All rights reserved.
|
|
|
|
//
|
2017-09-09 10:21:47 -05:00
|
|
|
// 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-10 10:02:39 -05:00
|
|
|
package wordprocessingml
|
2017-08-28 20:56:18 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/xml"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
"baliance.com/gooxml/schema/schemas.openxmlformats.org/drawingml"
|
|
|
|
)
|
|
|
|
|
2017-09-10 10:02:39 -05:00
|
|
|
type WdCT_Anchor struct {
|
2017-08-28 20:56:18 -05:00
|
|
|
DistTAttr *uint32
|
|
|
|
DistBAttr *uint32
|
|
|
|
DistLAttr *uint32
|
|
|
|
DistRAttr *uint32
|
|
|
|
SimplePosAttr *bool
|
|
|
|
RelativeHeightAttr uint32
|
|
|
|
BehindDocAttr bool
|
|
|
|
LockedAttr bool
|
|
|
|
LayoutInCellAttr bool
|
|
|
|
HiddenAttr *bool
|
|
|
|
AllowOverlapAttr bool
|
|
|
|
SimplePos *drawingml.CT_Point2D
|
2017-09-10 10:02:39 -05:00
|
|
|
PositionH *WdCT_PosH
|
|
|
|
PositionV *WdCT_PosV
|
2017-08-28 20:56:18 -05:00
|
|
|
Extent *drawingml.CT_PositiveSize2D
|
2017-09-10 10:02:39 -05:00
|
|
|
EffectExtent *WdCT_EffectExtent
|
|
|
|
Choice *WdEG_WrapTypeChoice
|
2017-08-28 20:56:18 -05:00
|
|
|
DocPr *drawingml.CT_NonVisualDrawingProps
|
|
|
|
CNvGraphicFramePr *drawingml.CT_NonVisualGraphicFrameProperties
|
|
|
|
Graphic *drawingml.Graphic
|
|
|
|
}
|
|
|
|
|
2017-09-10 10:02:39 -05:00
|
|
|
func NewWdCT_Anchor() *WdCT_Anchor {
|
|
|
|
ret := &WdCT_Anchor{}
|
2017-08-28 20:56:18 -05:00
|
|
|
ret.SimplePos = drawingml.NewCT_Point2D()
|
2017-09-10 10:02:39 -05:00
|
|
|
ret.PositionH = NewWdCT_PosH()
|
|
|
|
ret.PositionV = NewWdCT_PosV()
|
2017-08-28 20:56:18 -05:00
|
|
|
ret.Extent = drawingml.NewCT_PositiveSize2D()
|
|
|
|
ret.DocPr = drawingml.NewCT_NonVisualDrawingProps()
|
|
|
|
ret.Graphic = drawingml.NewGraphic()
|
|
|
|
return ret
|
|
|
|
}
|
2017-09-01 15:19:23 -05:00
|
|
|
|
2017-09-10 10:02:39 -05:00
|
|
|
func (m *WdCT_Anchor) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
2017-08-28 20:56:18 -05:00
|
|
|
if m.DistTAttr != nil {
|
|
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "distT"},
|
|
|
|
Value: fmt.Sprintf("%v", *m.DistTAttr)})
|
|
|
|
}
|
|
|
|
if m.DistBAttr != nil {
|
|
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "distB"},
|
|
|
|
Value: fmt.Sprintf("%v", *m.DistBAttr)})
|
|
|
|
}
|
|
|
|
if m.DistLAttr != nil {
|
|
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "distL"},
|
|
|
|
Value: fmt.Sprintf("%v", *m.DistLAttr)})
|
|
|
|
}
|
|
|
|
if m.DistRAttr != nil {
|
|
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "distR"},
|
|
|
|
Value: fmt.Sprintf("%v", *m.DistRAttr)})
|
|
|
|
}
|
|
|
|
if m.SimplePosAttr != nil {
|
|
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "simplePos"},
|
2017-09-03 21:00:35 -05:00
|
|
|
Value: fmt.Sprintf("%d", b2i(*m.SimplePosAttr))})
|
2017-08-28 20:56:18 -05:00
|
|
|
}
|
|
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "relativeHeight"},
|
|
|
|
Value: fmt.Sprintf("%v", m.RelativeHeightAttr)})
|
|
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "behindDoc"},
|
2017-09-03 21:00:35 -05:00
|
|
|
Value: fmt.Sprintf("%d", b2i(m.BehindDocAttr))})
|
2017-08-28 20:56:18 -05:00
|
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "locked"},
|
2017-09-03 21:00:35 -05:00
|
|
|
Value: fmt.Sprintf("%d", b2i(m.LockedAttr))})
|
2017-08-28 20:56:18 -05:00
|
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "layoutInCell"},
|
2017-09-03 21:00:35 -05:00
|
|
|
Value: fmt.Sprintf("%d", b2i(m.LayoutInCellAttr))})
|
2017-08-28 20:56:18 -05:00
|
|
|
if m.HiddenAttr != nil {
|
|
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "hidden"},
|
2017-09-03 21:00:35 -05:00
|
|
|
Value: fmt.Sprintf("%d", b2i(*m.HiddenAttr))})
|
2017-08-28 20:56:18 -05:00
|
|
|
}
|
|
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "allowOverlap"},
|
2017-09-03 21:00:35 -05:00
|
|
|
Value: fmt.Sprintf("%d", b2i(m.AllowOverlapAttr))})
|
2017-08-28 20:56:18 -05:00
|
|
|
e.EncodeToken(start)
|
|
|
|
sesimplePos := xml.StartElement{Name: xml.Name{Local: "wp:simplePos"}}
|
|
|
|
e.EncodeElement(m.SimplePos, sesimplePos)
|
|
|
|
sepositionH := xml.StartElement{Name: xml.Name{Local: "wp:positionH"}}
|
|
|
|
e.EncodeElement(m.PositionH, sepositionH)
|
|
|
|
sepositionV := xml.StartElement{Name: xml.Name{Local: "wp:positionV"}}
|
|
|
|
e.EncodeElement(m.PositionV, sepositionV)
|
|
|
|
seextent := xml.StartElement{Name: xml.Name{Local: "wp:extent"}}
|
|
|
|
e.EncodeElement(m.Extent, seextent)
|
|
|
|
if m.EffectExtent != nil {
|
|
|
|
seeffectExtent := xml.StartElement{Name: xml.Name{Local: "wp:effectExtent"}}
|
|
|
|
e.EncodeElement(m.EffectExtent, seeffectExtent)
|
|
|
|
}
|
|
|
|
if m.Choice != nil {
|
2017-09-04 13:47:32 -05:00
|
|
|
m.Choice.MarshalXML(e, xml.StartElement{})
|
2017-08-28 20:56:18 -05:00
|
|
|
}
|
|
|
|
sedocPr := xml.StartElement{Name: xml.Name{Local: "wp:docPr"}}
|
|
|
|
e.EncodeElement(m.DocPr, sedocPr)
|
|
|
|
if m.CNvGraphicFramePr != nil {
|
|
|
|
secNvGraphicFramePr := xml.StartElement{Name: xml.Name{Local: "wp:cNvGraphicFramePr"}}
|
|
|
|
e.EncodeElement(m.CNvGraphicFramePr, secNvGraphicFramePr)
|
|
|
|
}
|
|
|
|
segraphic := xml.StartElement{Name: xml.Name{Local: "a:graphic"}}
|
|
|
|
e.EncodeElement(m.Graphic, segraphic)
|
|
|
|
e.EncodeToken(xml.EndElement{Name: start.Name})
|
|
|
|
return nil
|
|
|
|
}
|
2017-09-01 15:19:23 -05:00
|
|
|
|
2017-09-10 10:02:39 -05:00
|
|
|
func (m *WdCT_Anchor) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
2017-08-28 20:56:18 -05:00
|
|
|
// initialize to default
|
|
|
|
m.SimplePos = drawingml.NewCT_Point2D()
|
2017-09-10 10:02:39 -05:00
|
|
|
m.PositionH = NewWdCT_PosH()
|
|
|
|
m.PositionV = NewWdCT_PosV()
|
2017-08-28 20:56:18 -05:00
|
|
|
m.Extent = drawingml.NewCT_PositiveSize2D()
|
|
|
|
m.DocPr = drawingml.NewCT_NonVisualDrawingProps()
|
|
|
|
m.Graphic = drawingml.NewGraphic()
|
|
|
|
for _, attr := range start.Attr {
|
|
|
|
if attr.Name.Local == "distT" {
|
|
|
|
parsed, err := strconv.ParseUint(attr.Value, 10, 32)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
pt := uint32(parsed)
|
|
|
|
m.DistTAttr = &pt
|
|
|
|
}
|
|
|
|
if attr.Name.Local == "distB" {
|
|
|
|
parsed, err := strconv.ParseUint(attr.Value, 10, 32)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
pt := uint32(parsed)
|
|
|
|
m.DistBAttr = &pt
|
|
|
|
}
|
|
|
|
if attr.Name.Local == "distL" {
|
|
|
|
parsed, err := strconv.ParseUint(attr.Value, 10, 32)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
pt := uint32(parsed)
|
|
|
|
m.DistLAttr = &pt
|
|
|
|
}
|
|
|
|
if attr.Name.Local == "distR" {
|
|
|
|
parsed, err := strconv.ParseUint(attr.Value, 10, 32)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
pt := uint32(parsed)
|
|
|
|
m.DistRAttr = &pt
|
|
|
|
}
|
|
|
|
if attr.Name.Local == "simplePos" {
|
|
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
m.SimplePosAttr = &parsed
|
|
|
|
}
|
|
|
|
if attr.Name.Local == "relativeHeight" {
|
|
|
|
parsed, err := strconv.ParseUint(attr.Value, 10, 32)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
m.RelativeHeightAttr = uint32(parsed)
|
|
|
|
}
|
|
|
|
if attr.Name.Local == "behindDoc" {
|
|
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
m.BehindDocAttr = parsed
|
|
|
|
}
|
|
|
|
if attr.Name.Local == "locked" {
|
|
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
m.LockedAttr = parsed
|
|
|
|
}
|
|
|
|
if attr.Name.Local == "layoutInCell" {
|
|
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
m.LayoutInCellAttr = parsed
|
|
|
|
}
|
|
|
|
if attr.Name.Local == "hidden" {
|
|
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
m.HiddenAttr = &parsed
|
|
|
|
}
|
|
|
|
if attr.Name.Local == "allowOverlap" {
|
|
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
m.AllowOverlapAttr = parsed
|
|
|
|
}
|
|
|
|
}
|
2017-09-10 10:02:39 -05:00
|
|
|
lWdCT_Anchor:
|
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:
|
2017-09-10 10:02:39 -05:00
|
|
|
switch el.Name {
|
|
|
|
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "simplePos"}:
|
2017-08-28 20:56:18 -05:00
|
|
|
if err := d.DecodeElement(m.SimplePos, &el); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-10 10:02:39 -05:00
|
|
|
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "positionH"}:
|
2017-08-28 20:56:18 -05:00
|
|
|
if err := d.DecodeElement(m.PositionH, &el); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-10 10:02:39 -05:00
|
|
|
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "positionV"}:
|
2017-08-28 20:56:18 -05:00
|
|
|
if err := d.DecodeElement(m.PositionV, &el); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-10 10:02:39 -05:00
|
|
|
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "extent"}:
|
2017-08-28 20:56:18 -05:00
|
|
|
if err := d.DecodeElement(m.Extent, &el); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-10 10:02:39 -05:00
|
|
|
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "effectExtent"}:
|
|
|
|
m.EffectExtent = NewWdCT_EffectExtent()
|
2017-08-28 20:56:18 -05:00
|
|
|
if err := d.DecodeElement(m.EffectExtent, &el); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-10 10:02:39 -05:00
|
|
|
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "wrapNone"}:
|
|
|
|
m.Choice = NewWdEG_WrapTypeChoice()
|
2017-08-28 20:56:18 -05:00
|
|
|
if err := d.DecodeElement(&m.Choice.WrapNone, &el); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-10 10:02:39 -05:00
|
|
|
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "wrapSquare"}:
|
|
|
|
m.Choice = NewWdEG_WrapTypeChoice()
|
2017-08-28 20:56:18 -05:00
|
|
|
if err := d.DecodeElement(&m.Choice.WrapSquare, &el); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-10 10:02:39 -05:00
|
|
|
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "wrapTight"}:
|
|
|
|
m.Choice = NewWdEG_WrapTypeChoice()
|
2017-08-28 20:56:18 -05:00
|
|
|
if err := d.DecodeElement(&m.Choice.WrapTight, &el); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-10 10:02:39 -05:00
|
|
|
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "wrapThrough"}:
|
|
|
|
m.Choice = NewWdEG_WrapTypeChoice()
|
2017-08-28 20:56:18 -05:00
|
|
|
if err := d.DecodeElement(&m.Choice.WrapThrough, &el); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-10 10:02:39 -05:00
|
|
|
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "wrapTopAndBottom"}:
|
|
|
|
m.Choice = NewWdEG_WrapTypeChoice()
|
2017-08-28 20:56:18 -05:00
|
|
|
if err := d.DecodeElement(&m.Choice.WrapTopAndBottom, &el); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-10 10:02:39 -05:00
|
|
|
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "docPr"}:
|
2017-08-28 20:56:18 -05:00
|
|
|
if err := d.DecodeElement(m.DocPr, &el); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-10 10:02:39 -05:00
|
|
|
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "cNvGraphicFramePr"}:
|
2017-08-28 20:56:18 -05:00
|
|
|
m.CNvGraphicFramePr = drawingml.NewCT_NonVisualGraphicFrameProperties()
|
|
|
|
if err := d.DecodeElement(m.CNvGraphicFramePr, &el); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-10 10:02:39 -05:00
|
|
|
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/main", Local: "graphic"}:
|
2017-08-28 20:56:18 -05:00
|
|
|
if err := d.DecodeElement(m.Graphic, &el); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
default:
|
2017-09-10 10:02:39 -05:00
|
|
|
log.Printf("skipping unsupported element on WdCT_Anchor %v", el.Name)
|
2017-08-28 20:56:18 -05:00
|
|
|
if err := d.Skip(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case xml.EndElement:
|
2017-09-10 10:02:39 -05:00
|
|
|
break lWdCT_Anchor
|
2017-08-28 20:56:18 -05:00
|
|
|
case xml.CharData:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2017-09-01 15:19:23 -05:00
|
|
|
|
2017-09-10 10:02:39 -05:00
|
|
|
// Validate validates the WdCT_Anchor and its children
|
|
|
|
func (m *WdCT_Anchor) Validate() error {
|
|
|
|
return m.ValidateWithPath("WdCT_Anchor")
|
2017-08-28 20:56:18 -05:00
|
|
|
}
|
2017-09-01 15:19:23 -05:00
|
|
|
|
2017-09-10 10:02:39 -05:00
|
|
|
// ValidateWithPath validates the WdCT_Anchor and its children, prefixing error messages with path
|
|
|
|
func (m *WdCT_Anchor) ValidateWithPath(path string) error {
|
2017-08-28 20:56:18 -05:00
|
|
|
if err := m.SimplePos.ValidateWithPath(path + "/SimplePos"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := m.PositionH.ValidateWithPath(path + "/PositionH"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := m.PositionV.ValidateWithPath(path + "/PositionV"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := m.Extent.ValidateWithPath(path + "/Extent"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if m.EffectExtent != nil {
|
|
|
|
if err := m.EffectExtent.ValidateWithPath(path + "/EffectExtent"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if m.Choice != nil {
|
|
|
|
if err := m.Choice.ValidateWithPath(path + "/Choice"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := m.DocPr.ValidateWithPath(path + "/DocPr"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if m.CNvGraphicFramePr != nil {
|
|
|
|
if err := m.CNvGraphicFramePr.ValidateWithPath(path + "/CNvGraphicFramePr"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := m.Graphic.ValidateWithPath(path + "/Graphic"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|