mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-27 13:48:54 +08:00

This caused problems with Libre. This reverts commit 59b2711e1b87be534c9cd3d155710d13cfe7743b.
248 lines
6.4 KiB
Go
248 lines
6.4 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"
|
|
|
|
"baliance.com/gooxml/schema/schemas.openxmlformats.org/drawingml"
|
|
)
|
|
|
|
type CT_ShowProperties struct {
|
|
// Loop Slide Show
|
|
LoopAttr *bool
|
|
// Show Narration in Slide Show
|
|
ShowNarrationAttr *bool
|
|
// Show Animation in Slide Show
|
|
ShowAnimationAttr *bool
|
|
// Use Timings in Slide Show
|
|
UseTimingsAttr *bool
|
|
// Presenter Slide Show Mode
|
|
Present *CT_Empty
|
|
// Browse Slide Show Mode
|
|
Browse *CT_ShowInfoBrowse
|
|
// Kiosk Slide Show Mode
|
|
Kiosk *CT_ShowInfoKiosk
|
|
// All Slides
|
|
SldAll *CT_Empty
|
|
// Slide Range
|
|
SldRg *CT_IndexRange
|
|
// Custom Show
|
|
CustShow *CT_CustomShowId
|
|
// Pen Color for Slide Show
|
|
PenClr *drawingml.CT_Color
|
|
ExtLst *CT_ExtensionList
|
|
}
|
|
|
|
func NewCT_ShowProperties() *CT_ShowProperties {
|
|
ret := &CT_ShowProperties{}
|
|
return ret
|
|
}
|
|
|
|
func (m *CT_ShowProperties) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
|
if m.LoopAttr != nil {
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "loop"},
|
|
Value: fmt.Sprintf("%d", b2i(*m.LoopAttr))})
|
|
}
|
|
if m.ShowNarrationAttr != nil {
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "showNarration"},
|
|
Value: fmt.Sprintf("%d", b2i(*m.ShowNarrationAttr))})
|
|
}
|
|
if m.ShowAnimationAttr != nil {
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "showAnimation"},
|
|
Value: fmt.Sprintf("%d", b2i(*m.ShowAnimationAttr))})
|
|
}
|
|
if m.UseTimingsAttr != nil {
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "useTimings"},
|
|
Value: fmt.Sprintf("%d", b2i(*m.UseTimingsAttr))})
|
|
}
|
|
e.EncodeToken(start)
|
|
if m.Present != nil {
|
|
sepresent := xml.StartElement{Name: xml.Name{Local: "p:present"}}
|
|
e.EncodeElement(m.Present, sepresent)
|
|
}
|
|
if m.Browse != nil {
|
|
sebrowse := xml.StartElement{Name: xml.Name{Local: "p:browse"}}
|
|
e.EncodeElement(m.Browse, sebrowse)
|
|
}
|
|
if m.Kiosk != nil {
|
|
sekiosk := xml.StartElement{Name: xml.Name{Local: "p:kiosk"}}
|
|
e.EncodeElement(m.Kiosk, sekiosk)
|
|
}
|
|
if m.SldAll != nil {
|
|
sesldAll := xml.StartElement{Name: xml.Name{Local: "p:sldAll"}}
|
|
e.EncodeElement(m.SldAll, sesldAll)
|
|
}
|
|
if m.SldRg != nil {
|
|
sesldRg := xml.StartElement{Name: xml.Name{Local: "p:sldRg"}}
|
|
e.EncodeElement(m.SldRg, sesldRg)
|
|
}
|
|
if m.CustShow != nil {
|
|
secustShow := xml.StartElement{Name: xml.Name{Local: "p:custShow"}}
|
|
e.EncodeElement(m.CustShow, secustShow)
|
|
}
|
|
if m.PenClr != nil {
|
|
sepenClr := xml.StartElement{Name: xml.Name{Local: "p:penClr"}}
|
|
e.EncodeElement(m.PenClr, sepenClr)
|
|
}
|
|
if m.ExtLst != nil {
|
|
seextLst := xml.StartElement{Name: xml.Name{Local: "p:extLst"}}
|
|
e.EncodeElement(m.ExtLst, seextLst)
|
|
}
|
|
e.EncodeToken(xml.EndElement{Name: start.Name})
|
|
return nil
|
|
}
|
|
|
|
func (m *CT_ShowProperties) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
|
// initialize to default
|
|
for _, attr := range start.Attr {
|
|
if attr.Name.Local == "loop" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.LoopAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "showNarration" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.ShowNarrationAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "showAnimation" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.ShowAnimationAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "useTimings" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.UseTimingsAttr = &parsed
|
|
}
|
|
}
|
|
lCT_ShowProperties:
|
|
for {
|
|
tok, err := d.Token()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
switch el := tok.(type) {
|
|
case xml.StartElement:
|
|
switch el.Name.Local {
|
|
case "present":
|
|
m.Present = NewCT_Empty()
|
|
if err := d.DecodeElement(m.Present, &el); err != nil {
|
|
return err
|
|
}
|
|
case "browse":
|
|
m.Browse = NewCT_ShowInfoBrowse()
|
|
if err := d.DecodeElement(m.Browse, &el); err != nil {
|
|
return err
|
|
}
|
|
case "kiosk":
|
|
m.Kiosk = NewCT_ShowInfoKiosk()
|
|
if err := d.DecodeElement(m.Kiosk, &el); err != nil {
|
|
return err
|
|
}
|
|
case "sldAll":
|
|
m.SldAll = NewCT_Empty()
|
|
if err := d.DecodeElement(m.SldAll, &el); err != nil {
|
|
return err
|
|
}
|
|
case "sldRg":
|
|
m.SldRg = NewCT_IndexRange()
|
|
if err := d.DecodeElement(m.SldRg, &el); err != nil {
|
|
return err
|
|
}
|
|
case "custShow":
|
|
m.CustShow = NewCT_CustomShowId()
|
|
if err := d.DecodeElement(m.CustShow, &el); err != nil {
|
|
return err
|
|
}
|
|
case "penClr":
|
|
m.PenClr = drawingml.NewCT_Color()
|
|
if err := d.DecodeElement(m.PenClr, &el); err != nil {
|
|
return err
|
|
}
|
|
case "extLst":
|
|
m.ExtLst = NewCT_ExtensionList()
|
|
if err := d.DecodeElement(m.ExtLst, &el); err != nil {
|
|
return err
|
|
}
|
|
default:
|
|
log.Printf("skipping unsupported element on CT_ShowProperties %v", el.Name)
|
|
if err := d.Skip(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
case xml.EndElement:
|
|
break lCT_ShowProperties
|
|
case xml.CharData:
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Validate validates the CT_ShowProperties and its children
|
|
func (m *CT_ShowProperties) Validate() error {
|
|
return m.ValidateWithPath("CT_ShowProperties")
|
|
}
|
|
|
|
// ValidateWithPath validates the CT_ShowProperties and its children, prefixing error messages with path
|
|
func (m *CT_ShowProperties) ValidateWithPath(path string) error {
|
|
if m.Present != nil {
|
|
if err := m.Present.ValidateWithPath(path + "/Present"); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if m.Browse != nil {
|
|
if err := m.Browse.ValidateWithPath(path + "/Browse"); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if m.Kiosk != nil {
|
|
if err := m.Kiosk.ValidateWithPath(path + "/Kiosk"); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if m.SldAll != nil {
|
|
if err := m.SldAll.ValidateWithPath(path + "/SldAll"); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if m.SldRg != nil {
|
|
if err := m.SldRg.ValidateWithPath(path + "/SldRg"); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if m.CustShow != nil {
|
|
if err := m.CustShow.ValidateWithPath(path + "/CustShow"); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if m.PenClr != nil {
|
|
if err := m.PenClr.ValidateWithPath(path + "/PenClr"); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if m.ExtLst != nil {
|
|
if err := m.ExtLst.ValidateWithPath(path + "/ExtLst"); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|