Skip to content

Commit

Permalink
Resolve UO-27, UO-28, UO-31 (unidoc#407)
Browse files Browse the repository at this point in the history
* Fixes in CI (unidoc#406)

* Create .gitattributes

* Update .travis.yml

* Update .travis.yml

* travis fix

* only errors are printed in travis log

* spreadsheet errors fixed: duplicate ID in non-visual properties and lack of third axis in an example

* set-strict example fix

* build-examples.sh exits with error status in the case of build error

* redundant command deleted from script

* unneeded image relationships removed

* pptx validation errors fixes

* all output to travis

Co-authored-by: Gunnsteinn Hall <[email protected]>
  • Loading branch information
zgordan-vv and gunnsth authored Jun 23, 2020
1 parent 37e4905 commit 0f98a7e
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 15 deletions.
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
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
1 change: 0 additions & 1 deletion schema/soo/dml/CT_ColorMappingOverride.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func NewCT_ColorMappingOverride() *CT_ColorMappingOverride {
}

func (m *CT_ColorMappingOverride) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
start.Name.Local = "a:CT_ColorMappingOverride"
e.EncodeToken(start)
m.Choice.MarshalXML(e, xml.StartElement{})
e.EncodeToken(xml.EndElement{Name: start.Name})
Expand Down
4 changes: 2 additions & 2 deletions spreadsheet/drawing.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (d Drawing) AddChart(at AnchorType) (chart.Chart, Anchor) {

// required by Mac Excel
gf.NvGraphicFramePr = sd.NewCT_GraphicalObjectFrameNonVisual()
gf.NvGraphicFramePr.CNvPr.IdAttr = 2
gf.NvGraphicFramePr.CNvPr.IdAttr = uint32(len(d.x.EG_Anchor))
gf.NvGraphicFramePr.CNvPr.NameAttr = "Chart"

gf.Graphic = dml.NewGraphic()
Expand Down Expand Up @@ -149,7 +149,7 @@ func (d Drawing) AddImage(img common.ImageRef, at AnchorType) Anchor {
anc = TwoCellAnchor{tca}
}

pic.NvPicPr.CNvPr.IdAttr = 0
pic.NvPicPr.CNvPr.IdAttr = uint32(len(d.x.EG_Anchor))
pic.NvPicPr.CNvPr.NameAttr = "Image"
pic.BlipFill.Blip = dml.NewCT_Blip()
pic.BlipFill.Blip.EmbedAttr = unioffice.String(imgID)
Expand Down
2 changes: 0 additions & 2 deletions spreadsheet/workbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,6 @@ func (wb *Workbook) AddImage(i common.Image) (common.ImageRef, error) {
}

wb.Images = append(wb.Images, r)
fn := fmt.Sprintf("media/image%d.%s", len(wb.Images), i.Format)
wb.wbRels.AddRelationship(fn, unioffice.ImageType)
return r, nil
}

Expand Down

0 comments on commit 0f98a7e

Please sign in to comment.