CloneException cloneException = new CloneException(
"No destination selected..");
throw cloneException;
}
} else if (TextTableCell.class.isAssignableFrom(position.getType())) {
TextTableCell textTableCell = ((TextTableCell) position
.getDestinationObject());
newTable = textTableCell.getTextTable();
ITextTableCellName cellName = textTableCell.getName();
columnStart = cellName.getColumnIndex();
rowStart = cellName.getRowIndex();
int newTableColumnCount = newTable.getColumnCount();
int newTableRowCount = newTable.getRowCount();
if (columnStart + columnArrayLength > newTableColumnCount) {
CloneException cloneException = new CloneException(
"Too much columns selected.");
throw cloneException;
}
if ((rowStart + rowCount) * newTableColumnCount > ITextTable.MAX_CELLS_IN_TABLE) {
CloneException cloneException = new CloneException(
"The sumbitted range is too big.");
throw cloneException;
}
if (rowStart + rowCount > newTableRowCount) {
newTable.addRow(rowStart, (rowStart + rowCount)
- newTableRowCount);
}
} else if (TextTableCellRange.class.isAssignableFrom(position
.getType())) {
TextTableCellRange tableCellRange = ((TextTableCellRange) position
.getDestinationObject());
int tmpColumnCount = tableCellRange.getColumnCount();
int tmpRowCount = tableCellRange.getRowCount();
if (tmpColumnCount == 0 || tmpRowCount == 0) {
CloneException cloneException = new CloneException(
"No range selected.");
throw cloneException;
}
newTable = tableCellRange.getCell(0, 0).getTextTable();
;
ITextTableCellRangeName rangeName = tableCellRange
.getRangeName();
columnStart = rangeName.getRangeStartColumnIndex();
rowStart = rangeName.getRangeStartRowIndex();
if (tmpColumnCount != columnCount || tmpRowCount != rowCount) {
CloneException cloneException = new CloneException(
"The selected range is not valid.");
throw cloneException;
}
} else if (TextTableRow.class.isAssignableFrom(position.getType())) {
TextTableRow textTableRow = ((TextTableRow) position
.getDestinationObject());
ITextTableCellRange tableCellRange = textTableRow
.getCellRange();
int tmpColumnCount = tableCellRange.getColumnCount();
int tmpRowCount = tableCellRange.getRowCount();
if (tmpColumnCount == 0 || tmpRowCount == 0) {
CloneException cloneException = new CloneException(
"No range selected.");
throw cloneException;
}
newTable = tableCellRange.getCell(0, 0).getTextTable();
;
ITextTableCellRangeName rangeName = tableCellRange
.getRangeName();
columnStart = rangeName.getRangeStartColumnIndex();
rowStart = rangeName.getRangeStartRowIndex();
if (tmpColumnCount != columnCount || tmpRowCount != rowCount) {
CloneException cloneException = new CloneException(
"The selected range is not valid.");
throw cloneException;
}
} else if (TextTableColumn.class.isAssignableFrom(position
.getType())) {
// TODO fill with logic
} else {
CloneException cloneException = new CloneException(
"No range selected.");
throw cloneException;
}
if (newTable != null) {
int rowArrayLength = cellCloneServices.length;
for (int rows = 0; rows < rowArrayLength; rows++) {
for (int columns = 0; columns < columnArrayLength; columns++) {
ICloneService cellClone = cellCloneServices[rows][columns];
ITextTableCell textTableCell = newTable.getCell(
columnStart + columns, rowStart + rows);
CloneDestinationPosition destinationCell = new CloneDestinationPosition(
textTableCell, textTableCell.getClass());
cellClone.cloneToPositionNoReturn(destinationCell,
adoptContent, propertyKeysContainer);
}
}
if (generateReturnValue) {