196 lines
5.6 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"
"fmt"
"strconv"
"baliance.com/gooxml"
2017-08-28 20:56:18 -05:00
)
type AG_Locking struct {
NoGrpAttr *bool
NoSelectAttr *bool
NoRotAttr *bool
NoChangeAspectAttr *bool
NoMoveAttr *bool
NoResizeAttr *bool
NoEditPointsAttr *bool
NoAdjustHandlesAttr *bool
NoChangeArrowheadsAttr *bool
NoChangeShapeTypeAttr *bool
}
func NewAG_Locking() *AG_Locking {
ret := &AG_Locking{}
ret.NoGrpAttr = gooxml.Bool(false)
ret.NoSelectAttr = gooxml.Bool(false)
ret.NoRotAttr = gooxml.Bool(false)
ret.NoChangeAspectAttr = gooxml.Bool(false)
ret.NoMoveAttr = gooxml.Bool(false)
ret.NoResizeAttr = gooxml.Bool(false)
ret.NoEditPointsAttr = gooxml.Bool(false)
ret.NoAdjustHandlesAttr = gooxml.Bool(false)
ret.NoChangeArrowheadsAttr = gooxml.Bool(false)
ret.NoChangeShapeTypeAttr = gooxml.Bool(false)
2017-08-28 20:56:18 -05:00
return ret
}
2017-08-28 20:56:18 -05:00
func (m *AG_Locking) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
if m.NoGrpAttr != nil {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "noGrp"},
Value: fmt.Sprintf("%d", b2i(*m.NoGrpAttr))})
2017-08-28 20:56:18 -05:00
}
if m.NoSelectAttr != nil {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "noSelect"},
Value: fmt.Sprintf("%d", b2i(*m.NoSelectAttr))})
2017-08-28 20:56:18 -05:00
}
if m.NoRotAttr != nil {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "noRot"},
Value: fmt.Sprintf("%d", b2i(*m.NoRotAttr))})
2017-08-28 20:56:18 -05:00
}
if m.NoChangeAspectAttr != nil {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "noChangeAspect"},
Value: fmt.Sprintf("%d", b2i(*m.NoChangeAspectAttr))})
2017-08-28 20:56:18 -05:00
}
if m.NoMoveAttr != nil {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "noMove"},
Value: fmt.Sprintf("%d", b2i(*m.NoMoveAttr))})
2017-08-28 20:56:18 -05:00
}
if m.NoResizeAttr != nil {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "noResize"},
Value: fmt.Sprintf("%d", b2i(*m.NoResizeAttr))})
2017-08-28 20:56:18 -05:00
}
if m.NoEditPointsAttr != nil {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "noEditPoints"},
Value: fmt.Sprintf("%d", b2i(*m.NoEditPointsAttr))})
2017-08-28 20:56:18 -05:00
}
if m.NoAdjustHandlesAttr != nil {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "noAdjustHandles"},
Value: fmt.Sprintf("%d", b2i(*m.NoAdjustHandlesAttr))})
2017-08-28 20:56:18 -05:00
}
if m.NoChangeArrowheadsAttr != nil {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "noChangeArrowheads"},
Value: fmt.Sprintf("%d", b2i(*m.NoChangeArrowheadsAttr))})
2017-08-28 20:56:18 -05:00
}
if m.NoChangeShapeTypeAttr != nil {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "noChangeShapeType"},
Value: fmt.Sprintf("%d", b2i(*m.NoChangeShapeTypeAttr))})
2017-08-28 20:56:18 -05:00
}
return nil
}
2017-08-28 20:56:18 -05:00
func (m *AG_Locking) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
// initialize to default
m.NoGrpAttr = gooxml.Bool(false)
m.NoSelectAttr = gooxml.Bool(false)
m.NoRotAttr = gooxml.Bool(false)
m.NoChangeAspectAttr = gooxml.Bool(false)
m.NoMoveAttr = gooxml.Bool(false)
m.NoResizeAttr = gooxml.Bool(false)
m.NoEditPointsAttr = gooxml.Bool(false)
m.NoAdjustHandlesAttr = gooxml.Bool(false)
m.NoChangeArrowheadsAttr = gooxml.Bool(false)
m.NoChangeShapeTypeAttr = gooxml.Bool(false)
2017-08-28 20:56:18 -05:00
for _, attr := range start.Attr {
if attr.Name.Local == "noGrp" {
parsed, err := strconv.ParseBool(attr.Value)
if err != nil {
return err
}
m.NoGrpAttr = &parsed
}
if attr.Name.Local == "noSelect" {
parsed, err := strconv.ParseBool(attr.Value)
if err != nil {
return err
}
m.NoSelectAttr = &parsed
}
if attr.Name.Local == "noRot" {
parsed, err := strconv.ParseBool(attr.Value)
if err != nil {
return err
}
m.NoRotAttr = &parsed
}
if attr.Name.Local == "noChangeAspect" {
parsed, err := strconv.ParseBool(attr.Value)
if err != nil {
return err
}
m.NoChangeAspectAttr = &parsed
}
if attr.Name.Local == "noMove" {
parsed, err := strconv.ParseBool(attr.Value)
if err != nil {
return err
}
m.NoMoveAttr = &parsed
}
if attr.Name.Local == "noResize" {
parsed, err := strconv.ParseBool(attr.Value)
if err != nil {
return err
}
m.NoResizeAttr = &parsed
}
if attr.Name.Local == "noEditPoints" {
parsed, err := strconv.ParseBool(attr.Value)
if err != nil {
return err
}
m.NoEditPointsAttr = &parsed
}
if attr.Name.Local == "noAdjustHandles" {
parsed, err := strconv.ParseBool(attr.Value)
if err != nil {
return err
}
m.NoAdjustHandlesAttr = &parsed
}
if attr.Name.Local == "noChangeArrowheads" {
parsed, err := strconv.ParseBool(attr.Value)
if err != nil {
return err
}
m.NoChangeArrowheadsAttr = &parsed
}
if attr.Name.Local == "noChangeShapeType" {
parsed, err := strconv.ParseBool(attr.Value)
if err != nil {
return err
}
m.NoChangeShapeTypeAttr = &parsed
}
}
// skip any extensions we may find, but don't support
for {
tok, err := d.Token()
if err != nil {
return fmt.Errorf("parsing AG_Locking: %s", err)
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
break
}
}
return nil
}
// Validate validates the AG_Locking and its children
2017-08-28 20:56:18 -05:00
func (m *AG_Locking) Validate() error {
return m.ValidateWithPath("AG_Locking")
}
// ValidateWithPath validates the AG_Locking and its children, prefixing error messages with path
2017-08-28 20:56:18 -05:00
func (m *AG_Locking) ValidateWithPath(path string) error {
return nil
}