diff options
author | Simon Steiner <ssteiner@apache.org> | 2016-03-29 11:17:23 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2016-03-29 11:17:23 +0000 |
commit | 1f5a254a57c081e092d8ff009a28e5975be71618 (patch) | |
tree | e22d82358fefa1dea4978ad171f8fcf4074ad0da /fop-core | |
parent | 1e47ef470b00c1540d31de7ba35589724f77781f (diff) | |
download | xmlgraphics-fop-1f5a254a57c081e092d8ff009a28e5975be71618.tar.gz xmlgraphics-fop-1f5a254a57c081e092d8ff009a28e5975be71618.zip |
FOP-2596: NPE with changing ipd
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1736999 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core')
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/layoutmgr/AbstractBreaker.java | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/AbstractBreaker.java index d0594ce8a..cc598ff88 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/AbstractBreaker.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/AbstractBreaker.java @@ -464,15 +464,7 @@ public abstract class AbstractBreaker { if (onLastPageAndIPDChanges && visitedBefore && this.originalRestartAtLM == null) { optimalBreak = null; } - - int positionIndex = (optimalBreak != null) ? optimalBreak.position : start; - KnuthElement elementAtBreak = alg.getElement(positionIndex); - if (elementAtBreak.getPosition() == null) { - elementAtBreak = alg.getElement(0); - } - positionAtBreak = elementAtBreak.getPosition(); - /* Retrieve the original position wrapped into this space position */ - positionAtBreak = positionAtBreak.getPosition(); + int positionIndex = findPositionIndex(optimalBreak, alg, start); if (ipdChangesOnNextPage || (positionAtBreak != null && positionAtBreak.getIndex() > -1)) { firstElementsForRestart = Collections.EMPTY_LIST; if (ipdChangesOnNextPage) { @@ -542,6 +534,23 @@ public abstract class AbstractBreaker { return restartAtLM; } + private int findPositionIndex(KnuthNode optimalBreak, PageBreakingAlgorithm alg, int start) { + int positionIndex = (optimalBreak != null) ? optimalBreak.position : start; + for (int i = positionIndex; i < alg.par.size(); i++) { + KnuthElement elementAtBreak = alg.getElement(i); + if (elementAtBreak.getPosition() == null) { + elementAtBreak = alg.getElement(0); + } + positionAtBreak = elementAtBreak.getPosition(); + /* Retrieve the original position wrapped into this space position */ + positionAtBreak = positionAtBreak.getPosition(); + if (positionAtBreak != null) { + return i; + } + } + return positionIndex; + } + /** * Returns {@code true} if the given position or one of its descendants * corresponds to a non-restartable LM. |