Skip to content

Commit

Permalink
Merge pull request unidoc#416 from gunnsth/release/v1.4.0
Browse files Browse the repository at this point in the history
Prepare unioffice release v1.4.0
  • Loading branch information
gunnsth authored Jun 30, 2020
2 parents f2e9441 + 2671067 commit 7bee805
Show file tree
Hide file tree
Showing 3,570 changed files with 7,283 additions and 7,141 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
7 changes: 5 additions & 2 deletions .travis/dotnet_run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/bin/bash
output=$(dotnet ./openxml-validator/bin/Debug/netcoreapp3.0/Program.dll --$2 $1)
echo $output
echo ""
if [[ $output == *"is not valid"* ]]; then
if [[ $output != *"main:sz"* ]] && [[ $output != *"main:family"* ]]; then
>&2 echo $output\\n
if [[ $output != *"main:sz"* ]] && [[ $output != *"main:family"* ]] && [[ $output != *"Attribute 'si' should be present when the value of attribute 't' is 'shared'"* ]] ; then
echo $output >> errors
echo "" >> errors
fi
fi
7 changes: 7 additions & 0 deletions .travis/validate-examples.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/bin/bash
find ../_examples -maxdepth 2 -mindepth 2 -exec sh -c "cd {}; echo running {}; ./main" \;
export PATH=$PATH:$HOME/dotnet
:> errors
find ../_examples -name "*.docx" $(printf "! -name %s " $(cat skip_files)) -exec ./dotnet_run.sh {} docx \;
find ../_examples -name "*.xlsx" $(printf "! -name %s " $(cat skip_files)) -exec ./dotnet_run.sh {} xlsx \;
find ../_examples -name "*.pptx" $(printf "! -name %s " $(cat skip_files)) -exec ./dotnet_run.sh {} pptx \;
if [[ $(wc -l errors) == "0 errors" ]]; then
exit 0
fi
echo "there are errors"
exit 1
1 change: 0 additions & 1 deletion _examples/document/set-strict/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package main

import (
"github.com/unidoc/unioffice/document"
st "github.com/unidoc/unioffice/schema/soo/ofc/sharedTypes"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion _examples/presentation/use-template-with-image/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func main() {
fmt.Println("ppt.Validate err ", err)
}

if err := ppt.SaveToFile("success.pptx"); err != nil {
if err := ppt.SaveToFile("mod.pptx"); err != nil {
fmt.Println("ppt.SaveToFile err ", err)
}

Expand Down
3 changes: 2 additions & 1 deletion _examples/spreadsheet/complex/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ func addLineChart(chrt chart.Chart) {
totalSeries.SetText("Total")
totalSeries.Values().SetReference(`'Sheet 1'!D2:D6`)

// the line chart accepts up to two axes
// the 3d line chart accepts three axes
ca := chrt.AddCategoryAxis()
va := chrt.AddValueAxis()
lc.AddAxis(ca)
lc.AddAxis(va)
lc.AddAxis(chart.NullAxis)

ca.SetCrosses(va)
va.SetCrosses(ca)
Expand Down
7 changes: 6 additions & 1 deletion build-examples.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/bash

go get -u github.com/go-ole/go-ole/oleutil
find _examples/ -maxdepth 2 -mindepth 2 -exec sh -c "cd {}; echo building {}; go build -i main.go" \;
:> build_errors
find _examples/ -maxdepth 2 -mindepth 2 -exec sh -c "cd {}; echo building {}; go build -i main.go" 2>>build_errors \;
if [[ $(wc -l build_errors | awk '{print $1}') == "0" ]]; then
exit 0
fi
exit 1
10 changes: 5 additions & 5 deletions common/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"time"
)

const releaseYear = 2019
const releaseYear = 2020
const releaseMonth = 6
const releaseDay = 6
const releaseHour = 11
const releaseMin = 30
const releaseDay = 30
const releaseHour = 16
const releaseMin = 10

// Version holds version information, when bumping this make sure to bump the released at stamp also.
const Version = "1.2.0"
const Version = "1.4.0"

var ReleasedAt = time.Date(releaseYear, releaseMonth, releaseDay, releaseHour, releaseMin, 0, 0, time.UTC)
7 changes: 3 additions & 4 deletions presentation/presentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,9 @@ func (p *Presentation) AddSlideWithLayout(l SlideLayout) (Slide, error) {
if lout == l.X() {
lrels := p.layoutRels[i]
for _, lrel := range lrels.X().Relationship {
p.slideRels[slrLen].X().Relationship = append(p.slideRels[slrLen].X().Relationship, lrel)
if lrel.TypeAttr != unioffice.SlideMasterType {
p.slideRels[slrLen].X().Relationship = append(p.slideRels[slrLen].X().Relationship, lrel)
}
}
srel.AddAutoRelationship(unioffice.DocTypePresentation, unioffice.SlideType,
i+1, unioffice.SlideLayoutType)
Expand Down Expand Up @@ -851,9 +853,6 @@ func (p *Presentation) AddImage(i common.Image) (common.ImageRef, error) {
return r, errors.New("image must have a valid size")
}

fn := fmt.Sprintf("media/image%d.%s", len(p.Images)+1, i.Format)
rel := p.prels.AddRelationship(fn, unioffice.ImageType)
r.SetRelID(rel.X().IdAttr)
p.Images = append(p.Images, r)
p.ContentTypes.EnsureDefault("png", "image/png")
p.ContentTypes.EnsureDefault("jpeg", "image/jpeg")
Expand Down
138 changes: 138 additions & 0 deletions presentation/presentation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package presentation
import (
"testing"

"github.com/unidoc/unioffice/common"
"github.com/unidoc/unioffice/schema/soo/dml"
"github.com/unidoc/unioffice/schema/soo/pml"
)

Expand All @@ -26,3 +28,139 @@ func TestRemoveChoicesWithPics(t *testing.T) {
}
}
}

// Filling in placeholder fields: both text and images and check that it is as expected

// Saving slides and checking if valid

// anything else we can think of?

func TestFillPlaceholderText(t *testing.T) {
ppt, err := loadTemplateHelper()
if err != nil {
t.Fatal(err)
}

// Add new slide from template
layout, err := ppt.GetLayoutByName("Picture with Caption")
if err != nil {
t.Fatal(err)
}

slide, err := ppt.AddDefaultSlideWithLayout(layout)
if err != nil {
t.Fatal(err)
}

// Inject content into placeholders
title, _ := slide.GetPlaceholder(pml.ST_PlaceholderTypeTitle)
title.SetText("New title")

body, _ := slide.GetPlaceholder(pml.ST_PlaceholderTypeBody)
body.SetText("New body text")

titleExpected := "New title"
titleGot := slide.X().CSld.SpTree.Choice[0].Sp[0].TxBody.P[0].EG_TextRun[0].R.T
if titleExpected != titleGot {
t.Errorf("Expected title to be %s, got %s", titleExpected, titleGot)
}

bodyTextExpected := "New body text"
bodyTextGot := slide.X().CSld.SpTree.Choice[2].Sp[0].TxBody.P[0].EG_TextRun[0].R.T
if bodyTextExpected != bodyTextGot {
t.Errorf("Expected body text to be %s, got %s", bodyTextExpected, bodyTextGot)
}
}

func TestFillPlaceholderImage(t *testing.T) {
ppt, err := loadTemplateHelper()
if err != nil {
t.Fatal(err)
}

// Add local image to pptx
image, err := common.ImageFromFile("testdata/gophercolor.png")
if err != nil {
t.Fatal(err)
}

iRef, err := ppt.AddImage(image)
if err != nil {
t.Fatal(err)
}

// Add new slide from template
layout, err := ppt.GetLayoutByName("Picture with Caption")
if err != nil {
t.Fatal(err)
}

slide, err := ppt.AddDefaultSlideWithLayout(layout)
if err != nil {
t.Fatal(err)
}

imageRelID := slide.AddImageToRels(iRef)

pic, err := slide.GetPlaceholder(pml.ST_PlaceholderTypePic)
if err != nil {
t.Fatal(err)
}

spPr := dml.NewCT_ShapeProperties()
spPr.BlipFill = dml.NewCT_BlipFillProperties()
spPr.BlipFill.Blip = dml.NewCT_Blip()
spPr.BlipFill.Blip.EmbedAttr = &imageRelID
spPr.BlipFill.Stretch = dml.NewCT_StretchInfoProperties() // stretch to parent block with default values

pic.X().SpPr = spPr

imageRelIDGot := *slide.X().CSld.SpTree.Choice[1].Sp[0].SpPr.BlipFill.Blip.EmbedAttr
if imageRelIDGot != imageRelID {
t.Errorf("Expected image relationship id to be %s, got %s", imageRelID, imageRelIDGot)
}
if len(ppt.Images) != 1 {
t.Fatalf("Expected number of images id to be %d, got %d", 1, len(ppt.Images))
}

img := ppt.Images[0]

formatExpected := "png"
formatGot := img.Format()
if formatExpected != formatGot {
t.Errorf("Expected image format to be %s, got %s", formatExpected, formatGot)
}

pathExpected := "testdata/gophercolor.png"
pathGot := img.Path()
if pathExpected != pathGot {
t.Errorf("Expected image path to be %s, got %s", pathExpected, pathGot)
}

sizeXExpected := 400
sizeXGot := img.Size().X
if sizeXExpected != sizeXGot {
t.Errorf("Expected image sizeX to be %d, got %d", sizeXExpected, sizeXGot)
}

sizeYExpected := 400
sizeYGot := img.Size().Y
if sizeYExpected != sizeYGot {
t.Errorf("Expected image sizeY to be %d, got %d", sizeYExpected, sizeYGot)
}
}

func loadTemplateHelper() (*Presentation, error) {
ppt, err := OpenTemplate("testdata/template.potx")
if err != nil {
return nil, err
}

for _, s := range ppt.Slides() {
if err = ppt.RemoveSlide(s); err != nil {
return nil, err
}
}

return ppt, nil
}
Binary file added presentation/testdata/gophercolor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added presentation/testdata/template.potx
Binary file not shown.
4 changes: 2 additions & 2 deletions schema/purl.org/dc/elements/Any.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 FoxyUtils ehf. All rights reserved.
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
// DO NOT EDIT: generated by unioffice 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
Expand Down
4 changes: 2 additions & 2 deletions schema/purl.org/dc/elements/Any_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 FoxyUtils ehf. All rights reserved.
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
// DO NOT EDIT: generated by unioffice 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
Expand Down
4 changes: 2 additions & 2 deletions schema/purl.org/dc/elements/ElementContainer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 FoxyUtils ehf. All rights reserved.
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
// DO NOT EDIT: generated by unioffice 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
Expand Down
4 changes: 2 additions & 2 deletions schema/purl.org/dc/elements/ElementContainer_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 FoxyUtils ehf. All rights reserved.
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
// DO NOT EDIT: generated by unioffice 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
Expand Down
4 changes: 2 additions & 2 deletions schema/purl.org/dc/elements/ElementsGroup.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 FoxyUtils ehf. All rights reserved.
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
// DO NOT EDIT: generated by unioffice 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
Expand Down
4 changes: 2 additions & 2 deletions schema/purl.org/dc/elements/ElementsGroupChoice.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 FoxyUtils ehf. All rights reserved.
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
// DO NOT EDIT: generated by unioffice 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
Expand Down
4 changes: 2 additions & 2 deletions schema/purl.org/dc/elements/ElementsGroupChoice_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 FoxyUtils ehf. All rights reserved.
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
// DO NOT EDIT: generated by unioffice 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
Expand Down
4 changes: 2 additions & 2 deletions schema/purl.org/dc/elements/ElementsGroup_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 FoxyUtils ehf. All rights reserved.
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
// DO NOT EDIT: generated by unioffice 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
Expand Down
4 changes: 2 additions & 2 deletions schema/purl.org/dc/elements/SimpleLiteral.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 FoxyUtils ehf. All rights reserved.
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
// DO NOT EDIT: generated by unioffice 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
Expand Down
4 changes: 2 additions & 2 deletions schema/purl.org/dc/elements/SimpleLiteral_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 FoxyUtils ehf. All rights reserved.
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
// DO NOT EDIT: generated by unioffice 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
Expand Down
4 changes: 2 additions & 2 deletions schema/purl.org/dc/elements/common.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 FoxyUtils ehf. All rights reserved.
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
// DO NOT EDIT: generated by unioffice 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
Expand Down
4 changes: 2 additions & 2 deletions schema/purl.org/dc/terms/Box.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 FoxyUtils ehf. All rights reserved.
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
// DO NOT EDIT: generated by unioffice 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
Expand Down
4 changes: 2 additions & 2 deletions schema/purl.org/dc/terms/Box_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 FoxyUtils ehf. All rights reserved.
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
// DO NOT EDIT: generated by unioffice 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
Expand Down
4 changes: 2 additions & 2 deletions schema/purl.org/dc/terms/DCMIType.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 FoxyUtils ehf. All rights reserved.
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
// DO NOT EDIT: generated by unioffice 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
Expand Down
4 changes: 2 additions & 2 deletions schema/purl.org/dc/terms/DCMIType_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 FoxyUtils ehf. All rights reserved.
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
// DO NOT EDIT: generated by unioffice 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
Expand Down
Loading

0 comments on commit 7bee805

Please sign in to comment.