(TableFooter) node, graftingPoint);
}
List<TableRow> keepWith = new ArrayList<TableRow>();
final int numChildren = node.getChildCount();
TableRow lastRow = null;
boolean endKeepGroup = true;
for (int i = getProgress(); i < numChildren; i++) {
final Fo child = node.getChildAt(i);
if (child instanceof Marker) {
final MarkerPL markerPL = (MarkerPL) getLayoutProxy(child);
markerPL.layout(tableArea, graftingPoint);
continue;
}
/* FOTree is normalized so that all children are TableRows. */
final TableRow row = (TableRow) child;
final TableRowPL rowPL = (TableRowPL) getLayoutProxy(row);
if (row.traitKeepWithPreviousWithinColumn(tableArea) > 0
&& lastRow != null
&& keepWith.indexOf(lastRow) == -1) {
keepWith.add(lastRow);
} else {
/* This row has no keep-with-previous, or it is the first
* row in this area.
*/
if (endKeepGroup && keepWith.size() > 0) {
keepWith = new ArrayList<TableRow>();
}
/* If we have composed at least one complete row which is not
* part of a keep set, we can take following keeps into
* account again */
if (endKeepGroup && i > getProgress()) {
this.rowSpanMgr.setIgnoreKeeps(false);
}
}
/* Tell the row whether it is at the top of this area: if so, the
* row should not honor keep-together. */
boolean bRowStartsArea = i == getProgress();
if (bRowStartsArea == false && keepWith.size() > 0) {
final TableRow firstKeepWith = keepWith.get(0);
if (node.getIndex(firstKeepWith) == getProgress()) {
bRowStartsArea = true;
}
}
rowPL.setIgnoreKeepTogether(bRowStartsArea);
Status status = rowPL.layout(areaContainer, graftingPoint);
if (status.isIncomplete()) {
// BUG!!! don't distinguish between break-before and after!
if (status.isPageBreak()) {
setProgress(i);
// areaContainer.end();
if (i == numChildren - 1) {
setProgress(FONodePL.BREAK_AFTER);
}
return status;
}
if ((keepWith.size() > 0)
&& (! this.rowSpanMgr.ignoreKeeps())) {
// && status.getCode() == Status.AREA_FULL_NONE
// FIXME!!! Handle rows spans!!!
removeTableRowLayout(row);
for (int j = 0; j < keepWith.size(); j++) {
final TableRow tr = keepWith.get(j);
removeTableRowLayout(tr);
i--;
}
if (i == 0) {
resetProgress();