2019-07-25 19:43:46 +03:00
|
|
|
// Copyright 2017 FoxyUtils ehf. All rights reserved.
|
2017-08-28 20:56:18 -05:00
|
|
|
//
|
2020-08-08 01:01:05 +00:00
|
|
|
// Use of this software package and source code is governed by the terms of the
|
|
|
|
// UniDoc End User License Agreement (EULA) that is available at:
|
|
|
|
// https://unidoc.io/eula/
|
|
|
|
// A trial license code for evaluation can be obtained at https://unidoc.io.
|
2017-08-28 20:56:18 -05:00
|
|
|
|
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
2018-01-18 12:15:53 -05:00
|
|
|
"fmt"
|
2017-10-03 07:21:57 -05:00
|
|
|
|
2019-05-04 11:18:06 +03:00
|
|
|
"github.com/unidoc/unioffice"
|
|
|
|
"github.com/unidoc/unioffice/schema/soo/ofc/extended_properties"
|
2017-08-28 20:56:18 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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()}
|
2019-06-09 11:56:06 +00:00
|
|
|
p.SetCompany("FoxyUtils ehf")
|
2019-05-04 11:18:06 +03:00
|
|
|
p.SetApplication("github.com/unidoc/unioffice")
|
2018-01-18 11:48:37 -05:00
|
|
|
p.SetDocSecurity(0)
|
|
|
|
p.SetLinksUpToDate(false)
|
2019-06-09 11:56:06 +00:00
|
|
|
|
|
|
|
var major, minor, patch int64
|
|
|
|
fmt.Sscanf(Version, "%d.%d.%d", &major, &minor, &patch)
|
|
|
|
f := float64(major) + float64(minor)/10000.0
|
2018-01-18 12:15:53 -05:00
|
|
|
p.SetApplicationVersion(fmt.Sprintf("%07.4f", f))
|
2017-08-28 20:56:18 -05:00
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
2017-09-02 13:45:42 -05:00
|
|
|
// Application returns the name of the application that created the document.
|
2019-05-04 11:18:06 +03:00
|
|
|
// For gooxml created documents, it defaults to github.com/unidoc/unioffice
|
2017-09-02 13:45:42 -05:00
|
|
|
func (a AppProperties) Application() string {
|
|
|
|
if a.x.Application != nil {
|
|
|
|
return *a.x.Application
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2018-01-18 11:48:37 -05:00
|
|
|
// SetLinksUpToDate sets the links up to date flag.
|
|
|
|
func (a AppProperties) SetLinksUpToDate(v bool) {
|
2019-05-04 13:54:29 +00:00
|
|
|
a.x.LinksUpToDate = unioffice.Bool(v)
|
2018-01-18 11:48:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetDocSecurity sets the document security flag.
|
|
|
|
func (a AppProperties) SetDocSecurity(v int32) {
|
2019-05-04 13:54:29 +00:00
|
|
|
a.x.DocSecurity = unioffice.Int32(v)
|
2018-01-18 11:48:37 -05:00
|
|
|
}
|
|
|
|
|
2017-09-02 13:45:42 -05:00
|
|
|
// 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 ""
|
|
|
|
}
|
|
|
|
|
2018-01-18 12:15:53 -05:00
|
|
|
// SetApplicationVersion sets the version of the application that created the
|
|
|
|
// document. Per MS, the verison string mut be in the form 'XX.YYYY'.
|
2017-09-02 13:45:42 -05:00
|
|
|
func (a AppProperties) SetApplicationVersion(s string) {
|
|
|
|
a.x.AppVersion = &s
|
|
|
|
}
|
|
|
|
|
2017-08-28 20:56:18 -05:00
|
|
|
// X returns the inner wrapped XML type.
|
|
|
|
func (a AppProperties) X() *extended_properties.Properties {
|
|
|
|
return a.x
|
|
|
|
}
|
2017-09-02 13:45:42 -05:00
|
|
|
|
|
|
|
// Company returns the name of the company that created the document.
|
2019-05-04 11:18:06 +03:00
|
|
|
// For gooxml created documents, it defaults to github.com/unidoc/unioffice
|
2017-09-02 13:45:42 -05:00
|
|
|
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
|
|
|
|
}
|