From: Simon Steiner Date: Wed, 4 Sep 2024 11:37:38 +0000 (+0100) Subject: FOP-3204: Missing content for last page with change ipd X-Git-Tag: 2_10~6 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6ef241f67c4bd27a698c56cdb8edbfade5d8aea4;p=xmlgraphics-fop.git FOP-3204: Missing content for last page with change ipd --- 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 08189cba9..80b1487a4 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 @@ -23,6 +23,7 @@ import java.util.Iterator; import java.util.LinkedList; import org.apache.fop.events.EventBroadcaster; +import org.apache.fop.layoutmgr.table.TableContentPosition; /** * Class to find the restart layoutmanager for changing IPD @@ -39,6 +40,9 @@ class RestartAtLM { optimalBreak = null; } int positionIndex = findPositionIndex(breaker, optimalBreak, alg, start); + if (breaker.positionAtBreak.getLM() instanceof BlockLayoutManager) { + positionIndex = findPositionIndex(breaker, optimalBreak, alg, 0); + } if (ipdChangesOnNextPage || (breaker.positionAtBreak != null && breaker.positionAtBreak.getIndex() > -1)) { breaker.firstElementsForRestart = Collections.EMPTY_LIST; if (ipdChangesOnNextPage) { @@ -112,9 +116,20 @@ class RestartAtLM { if (onLastPageAndIPDChanges && !visitedBefore && breaker.positionAtBreak.getPosition() != null) { restartAtLM = breaker.positionAtBreak.getPosition().getLM(); } + findLeafPosition(breaker); return restartAtLM; } + private void findLeafPosition(AbstractBreaker breaker) { + while (breaker.positionAtBreak instanceof NonLeafPosition) { + Position pos = breaker.positionAtBreak.getPosition(); + if (pos instanceof TableContentPosition) { + break; + } + breaker.positionAtBreak = pos; + } + } + private int findPositionIndex(AbstractBreaker breaker, BreakingAlgorithm.KnuthNode optimalBreak, PageBreakingAlgorithm alg, int start) { int positionIndex = (optimalBreak != null) ? optimalBreak.position : start; 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 ddffde3e1..2fff6c494 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 @@ -660,7 +660,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager } for (int i = 0; i < parIndex; i++) { - knuthParagraphs.remove(0); + if (knuthParagraphs.size() > 1) { + knuthParagraphs.remove(0); + } } parIndex = 0; diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableContentPosition.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableContentPosition.java index 98d474f8e..3f1236d4d 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableContentPosition.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableContentPosition.java @@ -30,7 +30,7 @@ import org.apache.fop.layoutmgr.Position; * This class represents a Position specific to TableContentLayoutManager. Used for normal * content cases. */ -class TableContentPosition extends Position { +public class TableContentPosition extends Position { /** The position is the first of the row group. */ public static final int FIRST_IN_ROWGROUP = 1; diff --git a/fop/test/layoutengine/standard-testcases/flow_changing-ipd_last-page_12.xml b/fop/test/layoutengine/standard-testcases/flow_changing-ipd_last-page_12.xml index 10fb45e5a..d3918fcaa 100644 --- a/fop/test/layoutengine/standard-testcases/flow_changing-ipd_last-page_12.xml +++ b/fop/test/layoutengine/standard-testcases/flow_changing-ipd_last-page_12.xml @@ -60,5 +60,6 @@ + diff --git a/fop/test/layoutengine/standard-testcases/flow_changing-ipd_last-page_19.xml b/fop/test/layoutengine/standard-testcases/flow_changing-ipd_last-page_19.xml new file mode 100755 index 000000000..a854fe8ab --- /dev/null +++ b/fop/test/layoutengine/standard-testcases/flow_changing-ipd_last-page_19.xml @@ -0,0 +1,60 @@ + + + + + +

+ This test checks that the definition of a special page-master for the last page with a + different width that the previous "rest" page causes FOP to redo the line breaking layout. +

+
+ + + + + + + + + + + + + + + + + + + + + test + test2 + test3 + + + + + + + + + + + +