LayoutContext context, int alignment, int bodyType) {
LinkedList returnList = new LinkedList();
EffRow[] rowGroup = null;
while ((rowGroup = iter.getNextRowGroup()) != null) {
//Check for break-before on the table-row at the start of the row group
TableRow rowFO = rowGroup[0].getTableRow();
if (rowFO != null && rowFO.getBreakBefore() != Constants.EN_AUTO) {
log.info("break-before found");
if (returnList.size() > 0) {
ListElement last = (ListElement)returnList.getLast();
if (last.isPenalty()) {
KnuthPenalty pen = (KnuthPenalty)last;
pen.setP(-KnuthPenalty.INFINITE);
pen.setBreakClass(rowFO.getBreakBefore());
} else if (last instanceof BreakElement) {
BreakElement breakPoss = (BreakElement)last;
breakPoss.setPenaltyValue(-KnuthPenalty.INFINITE);
breakPoss.setBreakClass(rowFO.getBreakBefore());
}
} else {
if (!firstBreakBeforeServed) {
//returnList.add(new KnuthPenalty(0, -KnuthPenalty.INFINITE,
// false, rowFO.getBreakBefore(), new Position(getTableLM()), true));
returnList.add(new BreakElement(new Position(getTableLM()),
0, -KnuthPenalty.INFINITE, rowFO.getBreakBefore(), context));
iter.backToPreviousRow();
firstBreakBeforeServed = true;
break;
}
}
}
firstBreakBeforeServed = true;
//Border resolution
if (!isSeparateBorderModel()) {
resolveNormalBeforeAfterBordersForRowGroup(rowGroup, iter);
}
//Element list creation
createElementsForRowGroup(context, alignment, bodyType,
returnList, rowGroup);
//Handle keeps
if (context.isKeepWithNextPending()) {
log.debug("child LM (row group) signals pending keep-with-next");
}
if (context.isKeepWithPreviousPending()) {
log.debug("child LM (row group) signals pending keep-with-previous");
if (returnList.size() > 0) {
//Modify last penalty
ListElement last = (ListElement)returnList.getLast();
if (last.isPenalty()) {
BreakElement breakPoss = (BreakElement)last;
//Only honor keep if there's no forced break
if (!breakPoss.isForcedBreak()) {
breakPoss.setPenaltyValue(KnuthPenalty.INFINITE);
}
}
}
}
//Check for break-after on the table-row at the end of the row group
rowFO = rowGroup[rowGroup.length - 1].getTableRow();
if (rowFO != null && rowFO.getBreakAfter() != Constants.EN_AUTO) {
log.info("break-after found");
if (returnList.size() > 0) {
ListElement last = (ListElement)returnList.getLast();
if (last instanceof KnuthPenalty) {
KnuthPenalty pen = (KnuthPenalty)last;
pen.setP(-KnuthPenalty.INFINITE);
pen.setBreakClass(rowFO.getBreakAfter());
} else if (last instanceof BreakElement) {
BreakElement breakPoss = (BreakElement)last;
breakPoss.setPenaltyValue(-KnuthPenalty.INFINITE);
breakPoss.setBreakClass(rowFO.getBreakAfter());
}
}
}
}