}
}
OdfOfficeAutomaticStyles autoStyles = getStylesDom().getAutomaticStyles();
int autoStylesCount = autoStyles.getLength();
OdfStylePageLayout pageLayout = autoStyles.getPageLayout(stylePageLayoutName);
if(pageLayout != null) {
// Clone the OdfStylePageLayout if another master style possesses the same name before modifying its properties
if(pageLayoutNameCount > 1){
Node pageLayoutNew = pageLayout.cloneNode(true);
// Rename the style of the clone before modifying its properties
String oldPageLayoutName = pageLayout.getStyleNameAttribute();
pageLayout.setStyleNameAttribute("Mpm" + (autoStylesCount+1));
// Allocate the new name of the style to the master style (the cloned style)
if (list.getLength() > 0) {
OdfOfficeMasterStyles masterpage = (OdfOfficeMasterStyles) list.item(0);
for (int i = 0; i < masterpage.getLength(); i++) {
StyleMasterPageElement vSyleMasterPage = (StyleMasterPageElement) masterpage.item(i);
if(vSyleMasterPage.getStyleNameAttribute().equals("Standard")){
if(vSyleMasterPage.getStylePageLayoutNameAttribute().equals(oldPageLayoutName)){
vSyleMasterPage.setStylePageLayoutNameAttribute(pageLayout.getStyleNameAttribute());
}
}
}
}
autoStyles.appendChild(pageLayoutNew);
}
NodeList vListStlePageLprop = pageLayout.getElementsByTagName("style:page-layout-properties");
StylePageLayoutPropertiesElement vStlePageLprop = (StylePageLayoutPropertiesElement) vListStlePageLprop.item(0);
StyleColumnsElement vStyleColumnsElement = vStlePageLprop.newStyleColumnsElement(columnsNumber);
vStyleColumnsElement.setFoColumnGapAttribute(vSpacingColumn);
}
} catch (Exception e) {