j += coverCellEle.getTableNumberColumnsRepeatedAttribute();
}
}
// find the cover cell, now start cell clone.
if (coverCellEle instanceof TableTableCellElement) {
TableTableCellElement newCellEle = (TableTableCellElement) (coverCellEle.cloneNode(true));
cleanCell(newCellEle);
newCellEle.removeAttributeNS(tableNameSpace, "number-rows-spanned");
newRow.appendChild(newCellEle);
// deal with the following covered cell, spread
// sheet need change these covered cell to cell.
if (mIsSpreadsheet) {
// update column repeated number.
int columnsSpannedNumber = newCellEle.getTableNumberColumnsSpannedAttribute();
newCellEle.removeAttributeNS(tableNameSpace, "number-columns-spanned");
int newColumnRepeatedNumber = newCellEle.getTableNumberColumnsRepeatedAttribute()
* columnsSpannedNumber;
if (newColumnRepeatedNumber > 1) {
newCellEle.setTableNumberColumnsRepeatedAttribute(newColumnRepeatedNumber);
} else {
newCellEle.removeAttributeNS(tableNameSpace, "number-columns-repeated");
}
// ignore the following covered cell of
// reference row.
// added by Daisy because of a bug in demo4
// cellElement is a covered cell. coverCellEle
// is its cover cell.
// below codes will count
// newColumnRepeatedNumber covered cell.
int tempi = newColumnRepeatedNumber;
while (tempi > 0) {
int iColumnRepeatedNumber = cellElement.getTableNumberColumnsRepeatedAttribute();
if (iColumnRepeatedNumber > tempi) {
// split covered cell
if (cellElement instanceof TableCoveredTableCellElement) {
cellElement.setTableNumberColumnsRepeatedAttribute(iColumnRepeatedNumber
- tempi);
TableTableCellElementBase newCoveredCellEle = (TableTableCellElementBase) cellElement
.cloneNode(true);
cleanCell(newCoveredCellEle);
if (tempi > 1) {
newCoveredCellEle.setTableNumberColumnsRepeatedAttribute(tempi);
} else {
newCoveredCellEle.removeAttributeNS(
OdfDocumentNamespace.TABLE.getUri(), "number-columns-repeated");
}
refRowElement.insertBefore(newCoveredCellEle, cellElement);
cellElement = newCoveredCellEle;
}
}
tempi = tempi - cellElement.getTableNumberColumnsRepeatedAttribute();
i = i + cellElement.getTableNumberColumnsRepeatedAttribute();
if (!(cellElement instanceof TableCoveredTableCellElement) && (tempi > 0)){
Logger.getLogger(Table.class.getName()).log(Level.FINE, "Not covered cell was ignored");
}
cellElement = (TableTableCellElementBase) (cellElement.getNextSibling());
// while ((cellElement != null) &&
// (cellElement instanceof
// TableCoveredTableCellElement)) {
// cellElement = (TableTableCellElementBase)
// (cellElement.getNextSibling());
// }
}
// i += newColumnRepeatedNumber;
} else {
// clone the following covered cell of reference
// row.
// added by Daisy because of a bug in demo4
cellElement = (TableTableCellElementBase) cellElement.getNextSibling();
i += cellElement.getTableNumberColumnsRepeatedAttribute();
int newColumnSpanNumber = newCellEle.getTableNumberColumnsSpannedAttribute();
while ((cellElement != null) && (cellElement instanceof TableCoveredTableCellElement)
&& (newColumnSpanNumber > 1)) {
TableCoveredTableCellElement newCoveredCellElement = (TableCoveredTableCellElement) cellElement
.cloneNode(true);
cleanCell(newCoveredCellElement);
newRow.appendChild(newCoveredCellElement);
i += cellElement.getTableNumberColumnsRepeatedAttribute();
cellElement = (TableTableCellElementBase) cellElement.getNextSibling();
newColumnSpanNumber--;
}
}
break;
}
// continue find cover cell
Node preNode = aRowEle.getPreviousSibling();
if (preNode instanceof TableTableRowElement) {
aRowEle = (TableTableRowElement) preNode;
} else {
// </table:table-header-rows>
aRowEle = (TableTableRowElement) (preNode.getLastChild());
}
}
} else {
TableTableCellElement newCellEle = (TableTableCellElement) cellElement.cloneNode(true);
cleanCell(newCellEle);
newRow.appendChild(newCellEle);
Integer tableNumberColumnsRepeated = newCellEle.getTableNumberColumnsRepeatedAttribute();
Integer tableNumberColumnsSpanned = newCellEle.getTableNumberColumnsSpannedAttribute();
i += tableNumberColumnsRepeated * tableNumberColumnsSpanned;
cellElement = (TableTableCellElementBase) cellElement.getNextSibling();
if (tableNumberColumnsSpanned > 1) {
int j = 1;
if (mIsSpreadsheet) {
newCellEle.removeAttributeNS(tableNameSpace, "number-columns-spanned");
int newColumnRepeatedNumber = tableNumberColumnsRepeated * tableNumberColumnsSpanned;
if (newColumnRepeatedNumber > 1) {
newCellEle.setTableNumberColumnsRepeatedAttribute(newColumnRepeatedNumber);
} else {
newCellEle.removeAttributeNS(tableNameSpace, "number-columns-repeated");
}
// cellElement is not a covered cell.
// below codes will count
// (newColumnRepeatedNumber-1) covered cell.
int tempi = newColumnRepeatedNumber;