mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-29 13:49:10 +08:00

This caused problems with Libre. This reverts commit 59b2711e1b87be534c9cd3d155710d13cfe7743b.
135 lines
3.7 KiB
Go
135 lines
3.7 KiB
Go
// 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 presentationml
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"fmt"
|
|
"log"
|
|
"strconv"
|
|
)
|
|
|
|
type CT_CommonSlideViewProperties struct {
|
|
// Snap Objects to Grid
|
|
SnapToGridAttr *bool
|
|
// Snap Objects to Objects
|
|
SnapToObjectsAttr *bool
|
|
// Show Guides in View
|
|
ShowGuidesAttr *bool
|
|
// Base properties for Slide View
|
|
CViewPr *CT_CommonViewProperties
|
|
// List of Guides
|
|
GuideLst *CT_GuideList
|
|
}
|
|
|
|
func NewCT_CommonSlideViewProperties() *CT_CommonSlideViewProperties {
|
|
ret := &CT_CommonSlideViewProperties{}
|
|
ret.CViewPr = NewCT_CommonViewProperties()
|
|
return ret
|
|
}
|
|
|
|
func (m *CT_CommonSlideViewProperties) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
|
if m.SnapToGridAttr != nil {
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "snapToGrid"},
|
|
Value: fmt.Sprintf("%d", b2i(*m.SnapToGridAttr))})
|
|
}
|
|
if m.SnapToObjectsAttr != nil {
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "snapToObjects"},
|
|
Value: fmt.Sprintf("%d", b2i(*m.SnapToObjectsAttr))})
|
|
}
|
|
if m.ShowGuidesAttr != nil {
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "showGuides"},
|
|
Value: fmt.Sprintf("%d", b2i(*m.ShowGuidesAttr))})
|
|
}
|
|
e.EncodeToken(start)
|
|
secViewPr := xml.StartElement{Name: xml.Name{Local: "p:cViewPr"}}
|
|
e.EncodeElement(m.CViewPr, secViewPr)
|
|
if m.GuideLst != nil {
|
|
seguideLst := xml.StartElement{Name: xml.Name{Local: "p:guideLst"}}
|
|
e.EncodeElement(m.GuideLst, seguideLst)
|
|
}
|
|
e.EncodeToken(xml.EndElement{Name: start.Name})
|
|
return nil
|
|
}
|
|
|
|
func (m *CT_CommonSlideViewProperties) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
|
// initialize to default
|
|
m.CViewPr = NewCT_CommonViewProperties()
|
|
for _, attr := range start.Attr {
|
|
if attr.Name.Local == "snapToGrid" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.SnapToGridAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "snapToObjects" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.SnapToObjectsAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "showGuides" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.ShowGuidesAttr = &parsed
|
|
}
|
|
}
|
|
lCT_CommonSlideViewProperties:
|
|
for {
|
|
tok, err := d.Token()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
switch el := tok.(type) {
|
|
case xml.StartElement:
|
|
switch el.Name.Local {
|
|
case "cViewPr":
|
|
if err := d.DecodeElement(m.CViewPr, &el); err != nil {
|
|
return err
|
|
}
|
|
case "guideLst":
|
|
m.GuideLst = NewCT_GuideList()
|
|
if err := d.DecodeElement(m.GuideLst, &el); err != nil {
|
|
return err
|
|
}
|
|
default:
|
|
log.Printf("skipping unsupported element on CT_CommonSlideViewProperties %v", el.Name)
|
|
if err := d.Skip(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
case xml.EndElement:
|
|
break lCT_CommonSlideViewProperties
|
|
case xml.CharData:
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Validate validates the CT_CommonSlideViewProperties and its children
|
|
func (m *CT_CommonSlideViewProperties) Validate() error {
|
|
return m.ValidateWithPath("CT_CommonSlideViewProperties")
|
|
}
|
|
|
|
// ValidateWithPath validates the CT_CommonSlideViewProperties and its children, prefixing error messages with path
|
|
func (m *CT_CommonSlideViewProperties) ValidateWithPath(path string) error {
|
|
if err := m.CViewPr.ValidateWithPath(path + "/CViewPr"); err != nil {
|
|
return err
|
|
}
|
|
if m.GuideLst != nil {
|
|
if err := m.GuideLst.ValidateWithPath(path + "/GuideLst"); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|