From 77d320fbcda503079eab89eaa12bedf6a1122769 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Tue, 20 Oct 2009 12:19:54 +0000 Subject: Bugfix: crash occurring when no restartable element could be found after a changing IPD break git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@827047 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/layoutmgr/AbstractBreaker.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/java') diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java index 825840351..2ee4a8a3a 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java @@ -400,9 +400,11 @@ public abstract class AbstractBreaker { if (position instanceof SpaceResolver.SpaceHandlingBreakPosition) { /* Retrieve the original position wrapped into this space position */ positionAtBreak = position.getPosition(); + } else { + positionAtBreak = null; } } - if (positionAtBreak.getIndex() == -1) { + if (positionAtBreak != null && positionAtBreak.getIndex() == -1) { /* * This is an indication that we are between two blocks * (possibly surrounded by another block), not inside a @@ -678,8 +680,23 @@ public abstract class AbstractBreaker { BlockSequence blockList; List returnedList; - if (positionAtIPDChange == null) { + if (firstElements == null) { returnedList = getNextKnuthElements(childLC, alignment); + } else if (positionAtIPDChange == null) { + /* + * No restartable element found after changing IPD break. Simply add the + * non-restartable elements found after the break. + */ + returnedList = firstElements; + /* + * Remove the last 3 penalty-filler-forced break elements that were added by + * the Knuth algorithm. They will be re-added later on. + */ + ListIterator iter = returnedList.listIterator(returnedList.size()); + for (int i = 0; i < 3; i++) { + iter.previous(); + iter.remove(); + } } else { returnedList = getNextKnuthElements(childLC, alignment, positionAtIPDChange, restartAtLM); -- cgit v1.2.3