//if one of the repeated column want to change something
//then this repeated column have to split to repeated number columns
//the maColumnElement should also be updated according to the original index in the repeated column
void splitRepeatedColumns() {
OdfTable table = getTable();
TableTableElement tableEle = table.getOdfElement();
int repeateNum = getColumnsRepeatedNumber();
if (repeateNum > 1) {
//change this repeated column to several single columns
TableTableColumnElement ownerColumnElement = null;
int repeatedColumnIndex = mnRepeatedIndex;
Node refElement = maColumnElement;
maColumnElement.removeAttributeNS(OdfDocumentNamespace.TABLE.getUri(), "number-columns-repeated");
String originalWidth = maColumnElement.getProperty(OdfTableColumnProperties.ColumnWidth);
String originalRelWidth = maColumnElement.getProperty(OdfTableColumnProperties.RelColumnWidth);
for (int i = repeateNum - 1; i >= 0; i--) {
TableTableColumnElement newColumn = (TableTableColumnElement) OdfXMLFactory.newOdfElement((OdfFileDom) maColumnElement.getOwnerDocument(),
OdfName.newName(OdfDocumentNamespace.TABLE, "table-column"));
if (originalWidth != null && originalWidth.length() > 0) {
newColumn.setProperty(OdfTableColumnProperties.ColumnWidth, originalWidth);
}
if (originalRelWidth != null && originalRelWidth.length() > 0) {
newColumn.setProperty(OdfTableColumnProperties.RelColumnWidth, originalRelWidth);
}
tableEle.insertBefore(newColumn, refElement);
refElement = newColumn;
if (repeatedColumnIndex == i) {
ownerColumnElement = newColumn;
} else {
table.updateColumnRepository(maColumnElement, i, newColumn, 0);
}
}
//remove this column element
tableEle.removeChild(maColumnElement);
if (ownerColumnElement != null) {
table.updateColumnRepository(maColumnElement, mnRepeatedIndex, ownerColumnElement, 0);
}
}