unioffice/document/section.go

53 lines
1.5 KiB
Go
Raw Normal View History

2017-08-28 20:56:18 -05:00
// Copyright 2017 Baliance. All rights reserved.
//
// 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
// appearing in the file LICENSE included in the packaging of this file. A
// commercial license can be purchased by contacting sales@baliance.com.
package document
import (
"log"
"baliance.com/gooxml"
2017-09-23 08:28:52 -05:00
"baliance.com/gooxml/schema/soo/wml"
2017-08-28 20:56:18 -05:00
)
2017-09-08 09:59:23 +08:00
// Section is the beginning of a new section.
2017-08-28 20:56:18 -05:00
type Section struct {
d *Document
x *wml.CT_SectPr
}
// X returns the internally wrapped *wml.CT_SectPr.
func (s Section) X() *wml.CT_SectPr {
return s.x
}
// SetHeader sets a section header.
func (s Section) SetHeader(h Header, t wml.ST_HdrFtr) {
hdrRef := wml.NewEG_HdrFtrReferences()
s.x.EG_HdrFtrReferences = append(s.x.EG_HdrFtrReferences, hdrRef)
hdrRef.HeaderReference = wml.NewCT_HdrFtrRef()
hdrRef.HeaderReference.TypeAttr = t
hdrID := s.d.docRels.FindRIDForN(h.Index(), gooxml.HeaderType)
2017-08-28 20:56:18 -05:00
if hdrID == "" {
log.Print("unable to determine header ID")
}
hdrRef.HeaderReference.IdAttr = hdrID
}
// SetFooter sets a section footer.
func (s Section) SetFooter(f Footer, t wml.ST_HdrFtr) {
ftrRef := wml.NewEG_HdrFtrReferences()
s.x.EG_HdrFtrReferences = append(s.x.EG_HdrFtrReferences, ftrRef)
ftrRef.FooterReference = wml.NewCT_HdrFtrRef()
ftrRef.FooterReference.TypeAttr = t
hdrID := s.d.docRels.FindRIDForN(f.Index(), gooxml.FooterType)
2017-08-28 20:56:18 -05:00
if hdrID == "" {
log.Print("unable to determine footer ID")
}
ftrRef.FooterReference.IdAttr = hdrID
}