final long textIndent = paragraph.getTextIndent();
final long firstLineIndent = paragraph.getFirstLineIndent();
// This aligns all direct childs. Once that is finished, we have to
// check, whether possibly existing inner-paragraphs are still valid
// or whether moving them violated any of the inner-pagebreak constraints.
final TextAlignmentProcessor processor = create(textAlignment);
final SequenceList sequence = breakState.getSequence();
final long lineEnd;
final boolean overflowX = paragraph.getStaticBoxLayoutProperties().isOverflowX();
if (overflowX)
{
lineEnd = nodeContext.getX1() + AbstractMinorAxisLayoutStep.OVERFLOW_DUMMY_WIDTH;
}
else
{
lineEnd = nodeContext.getX2();
}
long lineStart = Math.min(lineEnd, nodeContext.getX1() + firstLineIndent);
if (lineEnd - lineStart <= 0)
{
final long minimumChunkWidth = paragraph.getPool().getMinimumChunkWidth();
processor.initialize(metaData, sequence, lineStart, lineStart + minimumChunkWidth, pageGrid, overflowX);
nodeContext.updateX2(lineStart + minimumChunkWidth);
logger.warn("Auto-Corrected zero-width first-line on paragraph - " + paragraph.getName());
}
else
{
processor.initialize(metaData, sequence, lineStart, lineEnd, pageGrid, overflowX);
if (overflowX == false)
{
nodeContext.updateX2(lineEnd);
}
}
while (processor.hasNext())
{
final RenderNode linebox = processor.next();
if (linebox.getLayoutNodeType() != LayoutNodeTypes.TYPE_BOX_LINEBOX)
{
throw new IllegalStateException("Line must not be null");
}
paragraph.addGeneratedChild(linebox);
if (processor.hasNext())
{
lineStart = Math.min(lineEnd, nodeContext.getX1() + textIndent);
if (lineEnd - lineStart <= 0)
{
final long minimumChunkWidth = paragraph.getPool().getMinimumChunkWidth();
processor.updateLineSize(lineStart, lineStart + minimumChunkWidth);
nodeContext.updateX2(lineStart + minimumChunkWidth);
logger.warn("Auto-Corrected zero-width text-line on paragraph continuation - " + paragraph.getName());
}
else
{
processor.updateLineSize(lineStart, lineEnd);
if (overflowX == false)
{
nodeContext.updateX2(lineEnd);
}
}
}
}
processor.deinitialize();
}