{
// there's already a suitable version included.
return pageLayoutName;
}
final PageLayout original = predefined.getPageStyle(pageStyleTemplate);
if (original == null)
{
throw new ReportProcessingException("Invalid page-layout '" + pageStyleTemplate + "', will not continue.");
}
try
{
final PageLayout derived = (PageLayout) original.clone();
final String name = pageLayoutNameGenerator.generateName(
pageStyleTemplate);
derived.setStyleName(name);
commonStyles.addPageStyle(derived);
if (headerHeight != null)
{
Section headerStyle = derived.getHeaderStyle();
if (headerStyle == null)
{
headerStyle = new Section();
headerStyle.setNamespace(OfficeNamespaces.STYLE_NS);
headerStyle.setType("header-style");
derived.addNode(headerStyle);
}
MasterPageFactory.applyHeaderFooterHeight(headerStyle, headerHeight);
}
if (footerHeight != null)
{
Section footerStyle = derived.getFooterStyle();
if (footerStyle == null)
{
footerStyle = new Section();
footerStyle.setNamespace(OfficeNamespaces.STYLE_NS);
footerStyle.setType("footer-style");
derived.addNode(footerStyle);
}
MasterPageFactory.applyHeaderFooterHeight(footerStyle, footerHeight);
}
pageLayouts.put(key, name);