Skip to content

Commit

Permalink
common: fix app version
Browse files Browse the repository at this point in the history
Our app version wasn't correct per MS's spec.  Modify it
to match the XX.YYYY format.
  • Loading branch information
tbaliance committed Jan 18, 2018
1 parent 01883a5 commit 33a8645
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 5 deletions.
Binary file modified _examples/document/simple/simple.docx
Binary file not shown.
10 changes: 8 additions & 2 deletions common/appproperties.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
package common

import (
"fmt"
"strconv"
"strings"

"baliance.com/gooxml"
Expand All @@ -27,7 +29,10 @@ func NewAppProperties() AppProperties {
p.SetApplication("baliance.com/gooxml")
p.SetDocSecurity(0)
p.SetLinksUpToDate(false)
p.SetApplicationVersion(strings.Replace(gooxml.ReleaseVersion, "v", "", -1))
// trim the 'v'
ver := strings.Replace(gooxml.ReleaseVersion, "v", "", -1)
f, _ := strconv.ParseFloat(ver, 64)
p.SetApplicationVersion(fmt.Sprintf("%07.4f", f))
return p
}

Expand Down Expand Up @@ -64,7 +69,8 @@ func (a AppProperties) ApplicationVersion() string {
return ""
}

// SetApplicationVersion sets the version of the application that created the document.
// 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
}
Expand Down
5 changes: 4 additions & 1 deletion common/appproperties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
package common_test

import (
"fmt"
"strconv"
"strings"
"testing"

Expand All @@ -30,7 +32,8 @@ func TestNewAppDefaultProperties(t *testing.T) {
t.Errorf("unexpected application: %s", got)
}

if got := ap.ApplicationVersion(); got != strings.Replace(gooxml.ReleaseVersion, "v", "", -1) {
fv, _ := strconv.ParseFloat(strings.Replace(gooxml.ReleaseVersion, "v", "", -1), 64)
if got := ap.ApplicationVersion(); got != fmt.Sprintf("%07.4f", fv) {
t.Errorf("unexpected application version: %s", got)
}
ap.X().AppVersion = nil
Expand Down
Binary file modified document/testdata/header-footer-multiple.docx
Binary file not shown.
Binary file modified document/testdata/simple-1.docx
Binary file not shown.
Binary file modified spreadsheet/testdata/simple-1.xlsx
Binary file not shown.
Binary file modified spreadsheet/testdata/simple-2.xlsx
Binary file not shown.
5 changes: 3 additions & 2 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ package gooxml

import "time"

// Release is the last release version of the software.
var ReleaseVersion = "v0.4.0"
// ReleaseVersion is the last release version of the software and must be in the
// format x.y
var ReleaseVersion = "v0.5000"

// ReleaseDate is the release date of the source code for licensing purposes.
var ReleaseDate = time.Date(2018, 1, 4, 0, 0, 0, 0, time.UTC)

0 comments on commit 33a8645

Please sign in to comment.