// The page layouts are derived from a common template, but as the
// header-heights differ, we have to derive these beasts instead
// of copying them
final OfficeStylesCollection officeStylesCollection = getGlobalStylesCollection();
final OfficeMasterStyles officeMasterStyles = officeStylesCollection.getMasterStyles();
final String pageLayoutTemplate = currentMasterPage.getPageLayout();
if (pageLayoutTemplate == null)
{
// there is no pagelayout. Create one ..
final String derivedLayout = masterPageFactory.createPageStyle(getGlobalStylesCollection().getAutomaticStyles(), headerSize, footerSize);
currentMasterPage.setPageLayout(derivedLayout);
}
else
{
final String derivedLayout = masterPageFactory.derivePageStyle(pageLayoutTemplate,
getPredefinedStylesCollection().getAutomaticStyles(),
getGlobalStylesCollection().getAutomaticStyles(), headerSize, footerSize);
currentMasterPage.setPageLayout(derivedLayout);
}
officeMasterStyles.addMasterPage(currentMasterPage);
masterPageName = currentMasterPage.getStyleName();
}
else
{
// retrieve the master-page.