Skip to content

Commit

Permalink
presentation: fix use-template example
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaliance committed Mar 13, 2018
1 parent efd47ee commit 8d6c99b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion presentation/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func OpenTemplate(fn string) (*Presentation, error) {
return p, nil
}

// Open opens and reads a document from a file (.docx).
// Open opens and reads a document from a file (.pptx).
func Open(filename string) (*Presentation, error) {
f, err := os.Open(filename)
if err != nil {
Expand Down
16 changes: 9 additions & 7 deletions presentation/presentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,28 @@ type Presentation struct {
themeRels []common.Relationships
}

// New initializes and reurns a new presentation
func New() *Presentation {
func newEmpty() *Presentation {
p := &Presentation{x: pml.NewPresentation()}

p.x.SldIdLst = pml.NewCT_SlideIdList()
p.x.ConformanceAttr = sharedTypes.ST_ConformanceClassTransitional
p.AppProperties = common.NewAppProperties()
p.CoreProperties = common.NewCoreProperties()
p.ContentTypes = common.NewContentTypes()
p.Rels = common.NewRelationships()
p.prels = common.NewRelationships()
return p
}

p.ContentTypes.AddOverride("/ppt/presentation.xml", "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml")
// New initializes and reurns a new presentation
func New() *Presentation {
p := newEmpty()

p.Rels = common.NewRelationships()
p.ContentTypes.AddOverride("/ppt/presentation.xml", "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml")

p.Rels.AddRelationship("docProps/core.xml", "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties")
p.Rels.AddRelationship("docProps/app.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties")
p.Rels.AddRelationship("ppt/presentation.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument")

p.prels = common.NewRelationships()

p.x.SldMasterIdLst = pml.NewCT_SlideMasterIdList()
m := pml.NewSldMaster()
m.ClrMap.Bg1Attr = dml.ST_ColorSchemeIndexLt1
Expand Down
2 changes: 1 addition & 1 deletion presentation/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

// Read reads a document from an io.Reader.
func Read(r io.ReaderAt, size int64) (*Presentation, error) {
doc := New()
doc := newEmpty()

td, err := ioutil.TempDir("", "gooxml-pptx")
if err != nil {
Expand Down

0 comments on commit 8d6c99b

Please sign in to comment.