return EMPTY_ARRAY;
}
final Section section = this.section;
this.section = null;
final SectionRenderBox sectionBox = section.getSectionBox();
sectionBox.close();
final int sectionType = section.getType();
switch (sectionType)
{
case Renderer.TYPE_NORMALFLOW:
{
final RenderNode firstChild = sectionBox.getFirstChild();
if (firstChild == null)
{
// the whole section is empty; therefore we can ignore it.
sectionBox.makeReusable();
sectionBoxes[sectionType] = sectionBox;
return normalFlowLayoutBuilder.endSection(getPageBox(), sectionBox);
}
final int type = firstChild.getNodeType();
if (sectionBox.getLastChild() == firstChild &&
type == LayoutNodeTypes.TYPE_BOX_INLINE_PROGRESS_MARKER ||
type == LayoutNodeTypes.TYPE_BOX_PROGRESS_MARKER)
{
if (mergeSection(sectionBox))
{
sectionBox.makeReusable();
sectionBoxes[sectionType] = sectionBox;
return normalFlowLayoutBuilder.endSection(getPageBox(), sectionBox);
}
}
addBox(sectionBox);
markDirty();
return normalFlowLayoutBuilder.endSection(getPageBox(), sectionBox);
}
case Renderer.TYPE_FOOTER:
{
final BlockRenderBox footerArea = pageBox.getFooterArea();
if (sectionBox.getFirstChild() == sectionBox.getLastChild() &&
isEmptyOrMarker(footerArea.getFirstChild()) &&
isEmptyOrMarker(sectionBox.getFirstChild()))
{
// both boxes are empty, so we can ignore it ...
return footerLayoutBuilder.endSection(footerArea, sectionBox);
}
markDirty();
return footerLayoutBuilder.endSection(footerArea, sectionBox);
}
case Renderer.TYPE_HEADER:
{
final BlockRenderBox headerArea = pageBox.getHeaderArea();
if (sectionBox.getFirstChild() == sectionBox.getLastChild() &&
isEmptyOrMarker(headerArea.getFirstChild()) &&
isEmptyOrMarker(sectionBox.getFirstChild()))
{
// both boxes are empty, so we can ignore it ...
return headerLayoutBuilder.endSection(headerArea, sectionBox);
}
markDirty();
return headerLayoutBuilder.endSection(headerArea, sectionBox);
}
case Renderer.TYPE_WATERMARK:
{
// ignore for now.
final WatermarkAreaBox watermarkArea = pageBox.getWatermarkArea();
if (sectionBox.getFirstChild() == sectionBox.getLastChild() &&
isEmptyOrMarker(watermarkArea.getFirstChild()) &&
isEmptyOrMarker(sectionBox.getFirstChild()))
{
// both boxes are empty, so we can ignore it ...
return watermarkLayoutBuilder.endSection(watermarkArea, sectionBox);
}
markDirty();