LayoutContext layoutContext) {
getParentArea(null);
getPSLM().addIDToPage(getListItemFO().getId());
LayoutContext lc = new LayoutContext(0);
Position firstPos = null;
Position lastPos = null;
// "unwrap" the NonLeafPositions stored in parentIter
LinkedList positionList = new LinkedList();
Position pos;
while (parentIter.hasNext()) {
pos = (Position) parentIter.next();
if (pos.getIndex() >= 0) {
if (firstPos == null) {
firstPos = pos;
}
lastPos = pos;
}
if (pos instanceof NonLeafPosition && pos.getPosition() != null) {
// pos contains a ListItemPosition created by this ListBlockLM
positionList.add(((NonLeafPosition) pos).getPosition());
}
}
addMarkersToPage(true, isFirst(firstPos), isLast(lastPos));
// use the first and the last ListItemPosition to determine the
// corresponding indexes in the original labelList and bodyList
int labelFirstIndex = ((ListItemPosition) positionList.getFirst()).getLabelFirstIndex();
int labelLastIndex = ((ListItemPosition) positionList.getLast()).getLabelLastIndex();
int bodyFirstIndex = ((ListItemPosition) positionList.getFirst()).getBodyFirstIndex();
int bodyLastIndex = ((ListItemPosition) positionList.getLast()).getBodyLastIndex();
//Determine previous break if any
int previousBreak = ElementListUtils.determinePreviousBreak(labelList, labelFirstIndex);
SpaceResolver.performConditionalsNotification(labelList,
labelFirstIndex, labelLastIndex, previousBreak);
//Determine previous break if any
previousBreak = ElementListUtils.determinePreviousBreak(bodyList, bodyFirstIndex);
SpaceResolver.performConditionalsNotification(bodyList,
bodyFirstIndex, bodyLastIndex, previousBreak);
// add label areas
if (labelFirstIndex <= labelLastIndex) {
KnuthPossPosIter labelIter = new KnuthPossPosIter(labelList,
labelFirstIndex, labelLastIndex + 1);
lc.setFlags(LayoutContext.FIRST_AREA, layoutContext.isFirstArea());
lc.setFlags(LayoutContext.LAST_AREA, layoutContext.isLastArea());
// set the space adjustment ratio
lc.setSpaceAdjust(layoutContext.getSpaceAdjust());
// TO DO: use the right stack limit for the label
lc.setStackLimitBP(layoutContext.getStackLimitBP());
label.addAreas(labelIter, lc);
}
// reset the area bpd after adding the label areas and before adding the body areas
int savedBPD = 0;
if (labelFirstIndex <= labelLastIndex
&& bodyFirstIndex <= bodyLastIndex) {
savedBPD = curBlockArea.getBPD();
curBlockArea.setBPD(0);
}
// add body areas
if (bodyFirstIndex <= bodyLastIndex) {
KnuthPossPosIter bodyIter = new KnuthPossPosIter(bodyList,
bodyFirstIndex, bodyLastIndex + 1);
lc.setFlags(LayoutContext.FIRST_AREA, layoutContext.isFirstArea());
lc.setFlags(LayoutContext.LAST_AREA, layoutContext.isLastArea());
// set the space adjustment ratio
lc.setSpaceAdjust(layoutContext.getSpaceAdjust());
// TO DO: use the right stack limit for the body
lc.setStackLimitBP(layoutContext.getStackLimitBP());
body.addAreas(bodyIter, lc);
}
// after adding body areas, set the maximum area bpd
if (curBlockArea.getBPD() < savedBPD) {