mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-27 13:48:54 +08:00
236 lines
6.3 KiB
Go
236 lines
6.3 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 spreadsheetml
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"log"
|
|
"strconv"
|
|
)
|
|
|
|
type QueryTable struct {
|
|
CT_QueryTable
|
|
}
|
|
|
|
func NewQueryTable() *QueryTable {
|
|
ret := &QueryTable{}
|
|
ret.CT_QueryTable = *NewCT_QueryTable()
|
|
return ret
|
|
}
|
|
func (m *QueryTable) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns"}, Value: "http://schemas.openxmlformats.org/spreadsheetml/2006/main"})
|
|
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:sh"}, Value: "http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes"})
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:x"}, Value: "http://schemas.openxmlformats.org/spreadsheetml/2006/main"})
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:xdr"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"})
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:xml"}, Value: "http://www.w3.org/XML/1998/namespace"})
|
|
start.Name.Local = "x:queryTable"
|
|
return m.CT_QueryTable.MarshalXML(e, start)
|
|
}
|
|
func (m *QueryTable) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
|
// initialize to default
|
|
m.CT_QueryTable = *NewCT_QueryTable()
|
|
for _, attr := range start.Attr {
|
|
if attr.Name.Local == "name" {
|
|
parsed, err := attr.Value, error(nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.NameAttr = parsed
|
|
}
|
|
if attr.Name.Local == "headers" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.HeadersAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "rowNumbers" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.RowNumbersAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "disableRefresh" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.DisableRefreshAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "backgroundRefresh" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.BackgroundRefreshAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "firstBackgroundRefresh" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.FirstBackgroundRefreshAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "refreshOnLoad" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.RefreshOnLoadAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "growShrinkType" {
|
|
m.GrowShrinkTypeAttr.UnmarshalXMLAttr(attr)
|
|
}
|
|
if attr.Name.Local == "fillFormulas" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.FillFormulasAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "removeDataOnSave" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.RemoveDataOnSaveAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "disableEdit" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.DisableEditAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "preserveFormatting" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.PreserveFormattingAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "adjustColumnWidth" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.AdjustColumnWidthAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "intermediate" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.IntermediateAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "connectionId" {
|
|
parsed, err := strconv.ParseUint(attr.Value, 10, 32)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.ConnectionIdAttr = uint32(parsed)
|
|
}
|
|
if attr.Name.Local == "autoFormatId" {
|
|
parsed, err := strconv.ParseUint(attr.Value, 10, 32)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// SPECIAL
|
|
pt := uint32(parsed)
|
|
m.AutoFormatIdAttr = &pt
|
|
}
|
|
if attr.Name.Local == "applyNumberFormats" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.ApplyNumberFormatsAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "applyBorderFormats" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.ApplyBorderFormatsAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "applyFontFormats" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.ApplyFontFormatsAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "applyPatternFormats" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.ApplyPatternFormatsAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "applyAlignmentFormats" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.ApplyAlignmentFormatsAttr = &parsed
|
|
}
|
|
if attr.Name.Local == "applyWidthHeightFormats" {
|
|
parsed, err := strconv.ParseBool(attr.Value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
m.ApplyWidthHeightFormatsAttr = &parsed
|
|
}
|
|
}
|
|
lQueryTable:
|
|
for {
|
|
tok, err := d.Token()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
switch el := tok.(type) {
|
|
case xml.StartElement:
|
|
switch el.Name.Local {
|
|
case "queryTableRefresh":
|
|
m.QueryTableRefresh = NewCT_QueryTableRefresh()
|
|
if err := d.DecodeElement(m.QueryTableRefresh, &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 %v", el.Name)
|
|
if err := d.Skip(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
case xml.EndElement:
|
|
break lQueryTable
|
|
case xml.CharData:
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
func (m *QueryTable) Validate() error {
|
|
return m.ValidateWithPath("QueryTable")
|
|
}
|
|
func (m *QueryTable) ValidateWithPath(path string) error {
|
|
if err := m.CT_QueryTable.ValidateWithPath(path); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|