ConversionSectionWrapper section = null;
for(int i=0; i<sections.size(); i++) {
section = sections.get(i);
HeaderFooterPolicy hf = section.getHeaderFooterPolicy();
String sectionName = "s" + Integer.toString(i + 1);
// FIRST, create simple-page-masters
// has first header or footer?
if (hf.getFirstHeader()!=null || hf.getFirstFooter()!=null) {
// per spec, HeaderFooterPolicy checks the titlePg elememt
lms.getSimplePageMasterOrPageSequenceMaster().add(
createSimplePageMaster(sectionName + "-firstpage",
section.getPageDimensions(),
"firstpage",
(hf.getFirstHeader()!=null),
(hf.getFirstFooter()!=null) ));
}
// has even or odd header or footer?
/*
* <w:headerReference w:type="even" r:id="rId12"/>
* <w:headerReference w:type="default" r:id="rId13"/>
*
* the default one is treated as odd.
*/
if (hf.getEvenHeader()!=null || hf.getEvenFooter()!=null) {
lms.getSimplePageMasterOrPageSequenceMaster().add(
createSimplePageMaster(sectionName + "-evenpage",
section.getPageDimensions(),
"evenpage",
(hf.getEvenHeader()!=null),
(hf.getEvenFooter()!=null) ));
// the xslt outputs a "-default" page as the odd-page
}
if (hf.getDefaultHeader()!=null
|| hf.getDefaultFooter()!=null) {
lms.getSimplePageMasterOrPageSequenceMaster().add(
createSimplePageMaster(sectionName + "-default",
section.getPageDimensions(),
"default",
(hf.getDefaultHeader()!=null),
(hf.getDefaultFooter()!=null) ));
}
// simple: no headers and footers - after the first page anyway/
// We still need this where there is just a first page header/footer,
// since otherwise there'd be no page sequence for any content
// after the first page, and you'd get:
// org.apache.fop.fo.pagination.PageProductionException:
// Subsequences exhausted in page-sequence-master ..., cannot recover.
//
// <w:sectPr>
// <w:headerReference w:type="first" r:id="rId7"/>
// </w:sectPr>
if (
(hf.getDefaultHeader() == null) && (hf.getDefaultFooter() == null)) {
lms.getSimplePageMasterOrPageSequenceMaster().add(
createSimplePageMaster(sectionName + "-simple",
section.getPageDimensions(),
"simple",
true, true));