forked from unidoc/unioffice
/
appproperties.go
95 lines (81 loc) · 2.69 KB
/
appproperties.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// 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 common
import (
"fmt"
"strconv"
"strings"
"baliance.com/gooxml"
"baliance.com/gooxml/schema/soo/ofc/extended_properties"
)
// AppProperties contains properties specific to the document and the
// application that created it.
type AppProperties struct {
x *extended_properties.Properties
}
// NewAppProperties constructs a new AppProperties.
func NewAppProperties() AppProperties {
p := AppProperties{x: extended_properties.NewProperties()}
p.SetCompany("Baliance LLC")
p.SetApplication("baliance.com/gooxml")
p.SetDocSecurity(0)
p.SetLinksUpToDate(false)
// trim the 'v'
ver := strings.Replace(gooxml.ReleaseVersion, "v", "", -1)
f, _ := strconv.ParseFloat(ver, 64)
p.SetApplicationVersion(fmt.Sprintf("%07.4f", f))
return p
}
// Application returns the name of the application that created the document.
// For gooxml created documents, it defaults to baliance.com/gooxml
func (a AppProperties) Application() string {
if a.x.Application != nil {
return *a.x.Application
}
return ""
}
// SetLinksUpToDate sets the links up to date flag.
func (a AppProperties) SetLinksUpToDate(v bool) {
a.x.LinksUpToDate = gooxml.Bool(v)
}
// SetDocSecurity sets the document security flag.
func (a AppProperties) SetDocSecurity(v int32) {
a.x.DocSecurity = gooxml.Int32(v)
}
// SetApplication sets the name of the application that created the document.
func (a AppProperties) SetApplication(s string) {
a.x.Application = &s
}
// ApplicationVersion returns the version of the application that created the
// document.
func (a AppProperties) ApplicationVersion() string {
if a.x.AppVersion != nil {
return *a.x.AppVersion
}
return ""
}
// SetApplicationVersion sets the version of the application that created the
// document. Per MS, the verison string mut be in the form 'XX.YYYY'.
func (a AppProperties) SetApplicationVersion(s string) {
a.x.AppVersion = &s
}
// X returns the inner wrapped XML type.
func (a AppProperties) X() *extended_properties.Properties {
return a.x
}
// Company returns the name of the company that created the document.
// For gooxml created documents, it defaults to baliance.com/gooxml
func (a AppProperties) Company() string {
if a.x.Company != nil {
return *a.x.Company
}
return ""
}
// SetCompany sets the name of the company that created the document.
func (a AppProperties) SetCompany(s string) {
a.x.Company = &s
}