return cellPosition;
}
private void validatePredefinedColumns()
{
final TableRenderBox table = currentTable.getTable();
if (table.isPredefinedColumnsValidated())
{
// all work as been done already ...
return;
}
final TableColumnModel columnModel = table.getColumnModel();
int colCount = 0;
RenderNode node = table.getFirstChild();
while (node != null)
{
if (node instanceof TableColumnNode)
{
TableColumnNode columnNode = (TableColumnNode) node;
if (colCount >= columnModel.getColumnCount())
{
// No column exists at that position ..
final BoxDefinition boxDefinition = columnNode.getBoxDefinition();
final Border border = boxDefinition.getBorder();
final RenderLength width = boxDefinition.getPreferredWidth();
final TableColumn column = new TableColumn(border, width, false);
final TableColumnGroup group = new TableColumnGroup();
group.addColumn(column);
columnModel.addColumnGroup(group);
colCount += 1;
}
else
{
// We do not change existing columns. That validation should be the
// first that checks column definitions, so that state should always
// be correct.
}
}
else if (node instanceof TableColumnGroupNode)
{
TableColumnGroupNode groupNode = (TableColumnGroupNode) node;
final boolean newGroupGenerated;
final TableColumnGroup group;
if (colCount >= columnModel.getColumnCount())
{
group = new TableColumnGroup(groupNode.getBorder());
newGroupGenerated = true;
}
else
{
group = columnModel.getGroupForIndex(colCount);
newGroupGenerated = false;
}
RenderNode groupColNode = groupNode.getFirstChild();
while (groupColNode != null)
{
if (groupColNode instanceof TableColumnNode)
{
final TableColumnNode columnNode = (TableColumnNode) groupColNode;
if (colCount >= columnModel.getColumnCount())
{
final BoxDefinition boxDefinition = columnNode.getBoxDefinition();
final Border border = boxDefinition.getBorder();
final RenderLength width = boxDefinition.getPreferredWidth();
final TableColumn column = new TableColumn(border, width, false);
group.addColumn(column);
}
else
{
colCount += 1;
}
}
else
{
// ignore silently ..
}
groupColNode = groupColNode.getNext();
}
if (newGroupGenerated)
{
columnModel.addColumnGroup(group);
colCount += group.getColumnCount();
}
}
else if (node instanceof TableSectionRenderBox)
{
// OK; nice we are done. All other column definitions will be ignored
table.setPredefinedColumnsValidated(true);
}
else
{
// ignore ...
}