private boolean handleAutomaticPagebreak(final RenderBox box,
final PaginationShiftState boxContext)
{
final long shift = boxContext.getShiftForNextChild();
final PageBreakPositions breakUtility = paginationTableState.getBreakPositions();
final long boxHeightAndWidowArea = Math.max
(box.getHeight(), PaginationStepLib.getWidowConstraint(box, boxContext, paginationTableState));
if (breakUtility.isCrossingPagebreak(box.getY(), boxHeightAndWidowArea, shift) == false)
{
// The whole box fits on the current page. No need to do anything fancy.
final RenderBox.BreakIndicator breakIndicator = box.getManualBreakIndicator();
if (breakIndicator == RenderBox.BreakIndicator.INDIRECT_MANUAL_BREAK ||
box.getRestrictFinishedClearOut() == RenderBox.RestrictFinishClearOut.RESTRICTED)
{
// One of the children of this box will cause a manual pagebreak. We have to dive deeper into this child.
// for now, we will only apply the ordinary shift.
final long boxY = box.getY();
box.setY(boxY + shift);
updateStateKey(box);
return true;
}
else // if (breakIndicator == RenderBox.BreakIndicator.NO_MANUAL_BREAK)
{
// As neither this box nor any of the children will cause a pagebreak, we can shift them and skip the processing
// from here.
BoxShifter.shiftBox(box, shift);
updateStateKeyDeep(box);
return false;
}
}
// At this point we know, that the box may cause some shifting. It crosses at least one minor or major pagebreak.
// Right now, we are just evaluating the next break. In a future version, we could search all possible break
// positions up to the next major break.
final long boxY = box.getY();
final long boxYShifted = boxY + shift;
final long nextMinorBreak = breakUtility.findNextBreakPosition(boxYShifted);
final long spaceAvailable = nextMinorBreak - boxYShifted;
// This box sits directly on a pagebreak. This means, the page is empty, and there is no need for additional
// shifting.
if (spaceAvailable == 0)