diff --git a/presentation/open.go b/presentation/open.go index 63bc948148..29387fe2f8 100644 --- a/presentation/open.go +++ b/presentation/open.go @@ -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 { diff --git a/presentation/presentation.go b/presentation/presentation.go index d7fe79316f..50f463fa35 100644 --- a/presentation/presentation.go +++ b/presentation/presentation.go @@ -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 diff --git a/presentation/read.go b/presentation/read.go index a7b384efc4..48d6f81821 100644 --- a/presentation/read.go +++ b/presentation/read.go @@ -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 {