From ec425f78168667d7b4432735a552b50b67e710ef Mon Sep 17 00:00:00 2001 From: Simon Steiner Date: Wed, 2 Nov 2022 09:01:56 +0000 Subject: [PATCH] FOP-3105: Infinite loop when using page break with changing ipd git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1904996 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/layoutmgr/BlockLayoutManager.java | 4 +- .../org/apache/fop/layoutmgr/RestartAtLM.java | 6 +- .../layoutmgr/inline/LineLayoutManager.java | 11 +++- .../flow_changing-ipd_7.xml | 62 +++++++++++++++++++ 4 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 fop/test/layoutengine/standard-testcases/flow_changing-ipd_7.xml diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockLayoutManager.java index ac0da5f6a..92fac64c4 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -141,7 +141,9 @@ public class BlockLayoutManager extends SpacedBorderedPaddedBlockLayoutManager return childLM.getNextKnuthElements(childLC, alignment); } else { if (childLM instanceof LineLayoutManager) { - assert (restartPosition instanceof LeafPosition); + if (!(restartPosition instanceof LeafPosition)) { + restartPosition = null; + } return ((LineLayoutManager) childLM).getNextKnuthElements(childLC, alignment, (LeafPosition) restartPosition); } else { diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/RestartAtLM.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/RestartAtLM.java index 9c8aa8252..6dd80075d 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/RestartAtLM.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/RestartAtLM.java @@ -92,8 +92,10 @@ class RestartAtLM { position = position.getPosition(); } if (position.getPosition() == null) { - position.getLM().getFObj().setForceKeepTogether(true); - invalidPosition = true; + if (!position.getLM().getFObj().isForceKeepTogether()) { + position.getLM().getFObj().setForceKeepTogether(true); + invalidPosition = true; + } return null; } restartAtLM = position.getPosition().getLM(); diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index d19642ab5..60d05b581 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -651,8 +651,13 @@ public class LineLayoutManager extends InlineStackingLayoutManager */ public List getNextKnuthElements(LayoutContext context, int alignment, LeafPosition restartPosition) { - log.trace("Restarting line breaking from index " + restartPosition.getIndex()); - int parIndex = restartPosition.getLeafPos(); + int parIndex = 0; + int restartPositionIdx = 0; + if (restartPosition != null) { + log.trace("Restarting line breaking from index " + restartPosition.getIndex()); + parIndex = restartPosition.getLeafPos(); + restartPositionIdx = restartPosition.getIndex(); + } for (int i = 0; i < parIndex; i++) { knuthParagraphs.remove(0); @@ -664,7 +669,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager ((Paragraph) paragraph).ignoreAtStart = 0; isFirstInBlock = false; } - paragraph.subList(0, restartPosition.getIndex() + 1).clear(); + paragraph.subList(0, restartPositionIdx + 1).clear(); Iterator iter = paragraph.iterator(); while (iter.hasNext() && !iter.next().isBox()) { iter.remove(); diff --git a/fop/test/layoutengine/standard-testcases/flow_changing-ipd_7.xml b/fop/test/layoutengine/standard-testcases/flow_changing-ipd_7.xml new file mode 100644 index 000000000..9da3cd033 --- /dev/null +++ b/fop/test/layoutengine/standard-testcases/flow_changing-ipd_7.xml @@ -0,0 +1,62 @@ + + + + + +

+ This test checks that a list can be relaid out when a change in ipd happens across pages. +

+
+ + + + + + + + + + + + + + + + + + + + + + + + Call if you need us + + + + + + + + + + + + + +
-- 2.39.5