context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, false);
// add an infinite penalty to forbid a break between
// blocks
contentList.add(new BreakElement(
new Position(this), KnuthElement.INFINITE, context));
//contentList.add(new KnuthPenalty(0,
// KnuthElement.INFINITE, false,
// new Position(this), false));
} else if (!(((ListElement) contentList.getLast()).isGlue()
|| (((ListElement)contentList.getLast()).isPenalty()
&& ((KnuthPenalty)contentList.getLast()).getP() < KnuthElement.INFINITE)
|| (contentList.getLast() instanceof BreakElement
&& ((BreakElement)contentList.getLast()).getPenaltyValue() < KnuthElement.INFINITE))) {
// TODO vh: this is hacky
// The getNextKnuthElements method of TableCellLM must not be called
// twice, otherwise some settings like indents or borders will be
// counted several times and lead to a wrong output. Anyway the
// getNextKnuthElements methods should be called only once eventually
// (i.e., when multi-threading the code), even when there are forced
// breaks.
// If we add a break possibility after a forced break the
// AreaAdditionUtil.addAreas method will act on a sequence starting
// with a SpaceResolver.SpaceHandlingBreakPosition element, having no
// LM associated to it. Thus it will stop early instead of adding
// areas for following Positions. The above test aims at preventing
// such a situation from occuring. add a null penalty to allow a break
// between blocks
contentList.add(new BreakElement(
new Position(this), 0, context));
//contentList.add(new KnuthPenalty(0, 0, false,
// new Position(this), false));
} else {
// the last element in contentList is a feasible breakpoint, there is
// no need to add a penalty