unioffice/schema/soo/wml/WdWpc.go
Nikita Kryuchkov e65ced8888 Add purl.oclc.org namespace support (#265)
* Regenerate code to handle purl.oclc.org docs correctly
* Make purl.oclc.org docs be opened just as the openxml ones
* Modify opening routine to change strict docs to non-strict
- `CustomXMLType` and `CustomXMLTypeStrict` were added to properly replace
these in strict docs
- `Decode` of `zippkg` was modified to replace the namespace in
relationships
- `TestOpenStrict` was modified to open the strict file, save it as
non-strict, reopen non-strict and validate its correctness
2019-04-29 15:32:26 +00:00

132 lines
5.6 KiB
Go

// Copyright 2017 Baliance. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
//
// 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 wml
import (
"encoding/xml"
"baliance.com/gooxml"
"baliance.com/gooxml/schema/soo/dml"
)
type WdWpc struct {
WdCT_WordprocessingCanvas
}
func NewWdWpc() *WdWpc {
ret := &WdWpc{}
ret.WdCT_WordprocessingCanvas = *NewWdCT_WordprocessingCanvas()
return ret
}
func (m *WdWpc) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"})
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:a"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/main"})
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:pic"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/picture"})
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:r"}, Value: "http://schemas.openxmlformats.org/officeDocument/2006/relationships"})
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:w"}, Value: "http://schemas.openxmlformats.org/wordprocessingml/2006/main"})
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:wp"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"})
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:xml"}, Value: "http://www.w3.org/XML/1998/namespace"})
start.Name.Local = "wp:wpc"
return m.WdCT_WordprocessingCanvas.MarshalXML(e, start)
}
func (m *WdWpc) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
// initialize to default
m.WdCT_WordprocessingCanvas = *NewWdCT_WordprocessingCanvas()
lWdWpc:
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: "bg"},
xml.Name{Space: "http://purl.oclc.org/ooxml/drawingml/wordprocessingDrawing", Local: "bg"}:
m.Bg = dml.NewCT_BackgroundFormatting()
if err := d.DecodeElement(m.Bg, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "whole"},
xml.Name{Space: "http://purl.oclc.org/ooxml/drawingml/wordprocessingDrawing", Local: "whole"}:
m.Whole = dml.NewCT_WholeE2oFormatting()
if err := d.DecodeElement(m.Whole, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "wsp"},
xml.Name{Space: "http://purl.oclc.org/ooxml/drawingml/wordprocessingDrawing", Local: "wsp"}:
tmp := NewWdCT_WordprocessingCanvasChoice()
if err := d.DecodeElement(&tmp.Wsp, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/picture", Local: "pic"},
xml.Name{Space: "http://purl.oclc.org/ooxml/drawingml/picture", Local: "pic"}:
tmp := NewWdCT_WordprocessingCanvasChoice()
if err := d.DecodeElement(&tmp.Pic, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "contentPart"},
xml.Name{Space: "http://purl.oclc.org/ooxml/drawingml/wordprocessingDrawing", Local: "contentPart"}:
tmp := NewWdCT_WordprocessingCanvasChoice()
if err := d.DecodeElement(&tmp.ContentPart, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "wgp"},
xml.Name{Space: "http://purl.oclc.org/ooxml/drawingml/wordprocessingDrawing", Local: "wgp"}:
tmp := NewWdCT_WordprocessingCanvasChoice()
if err := d.DecodeElement(&tmp.Wgp, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "graphicFrame"},
xml.Name{Space: "http://purl.oclc.org/ooxml/drawingml/wordprocessingDrawing", Local: "graphicFrame"}:
tmp := NewWdCT_WordprocessingCanvasChoice()
if err := d.DecodeElement(&tmp.GraphicFrame, &el); err != nil {
return err
}
m.Choice = append(m.Choice, tmp)
case xml.Name{Space: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", Local: "extLst"},
xml.Name{Space: "http://purl.oclc.org/ooxml/drawingml/wordprocessingDrawing", Local: "extLst"}:
m.ExtLst = dml.NewCT_OfficeArtExtensionList()
if err := d.DecodeElement(m.ExtLst, &el); err != nil {
return err
}
default:
gooxml.Log("skipping unsupported element on WdWpc %v", el.Name)
if err := d.Skip(); err != nil {
return err
}
}
case xml.EndElement:
break lWdWpc
case xml.CharData:
}
}
return nil
}
// Validate validates the WdWpc and its children
func (m *WdWpc) Validate() error {
return m.ValidateWithPath("WdWpc")
}
// ValidateWithPath validates the WdWpc and its children, prefixing error messages with path
func (m *WdWpc) ValidateWithPath(path string) error {
if err := m.WdCT_WordprocessingCanvas.ValidateWithPath(path); err != nil {
return err
}
return nil
}