From: Chris Bowditch Date: Thu, 2 Mar 2023 15:27:00 +0000 (+0000) Subject: Fix FOP-3098. Submitted by Dave Roxburgh X-Git-Tag: 2_9~31 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=03a69c051cbb867d3d037ed95c2344ab996b5dc4;p=xmlgraphics-fop.git Fix FOP-3098. Submitted by Dave Roxburgh --- diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index ffc4e7c88..a15e58ad4 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -436,6 +436,15 @@ public class ListItemLayoutManager extends SpacedBorderedPaddedBlockLayoutManage addedBoxHeight += boxHeight; ListItemPosition stepPosition = new ListItemPosition(this, start[0], end[0], start[1], end[1]); stepPosition.setOriginalLabelPosition(originalLabelPosition); + if (originalBodyPosition != null && originalBodyPosition.getLM() instanceof ListItemContentLayoutManager) { + // Happens when ListItem has multiple blocks and a block (that's not the last block) ends at the same + // page height as a IPD change (e.g. FOP-3098). originalBodyPosition (reset) position needs to be a + // Block so that BlockStackingLayoutManager can stack it. Lookahead to find next Block. + Position block = extractBlock(elementLists[1], end[1] + 1); + if (block != null) { + originalBodyPosition = block; + } + } stepPosition.setOriginalBodyPosition(originalBodyPosition); if (floats.isEmpty()) { @@ -467,6 +476,37 @@ public class ListItemLayoutManager extends SpacedBorderedPaddedBlockLayoutManage return returnList; } + /** + * Extracts a block Position from a ListElement at a given index in a list of ListItem body elements. + * @param bodyElements The ListItem body elements. + * @param index The index of the ListElement containing the block. + * @return The required block Position as a LeafPosition or null on failure. + */ + private Position extractBlock(List bodyElements, int index) { + ListElement listElement; + Position position = null; + Position retval = null; + do { + if (bodyElements == null || index >= bodyElements.size()) { + break; + } + listElement = bodyElements.get(index); + if (listElement != null + && listElement.getLayoutManager() instanceof ListItemContentLayoutManager) { + position = listElement.getPosition(); + if (position != null + && position.getLM() instanceof ListItemContentLayoutManager) { + position = position.getPosition(); + if (position != null + && position.getLM() instanceof BlockLayoutManager) { + retval = new LeafPosition(position.getPosition().getLM(), 0); + } + } + } + } while (false); + return retval; + } + private boolean shouldWeAvoidBreak(List returnList, LayoutManager lm) { if (isChangingIPD(lm)) { if (lm instanceof BlockLayoutManager) { diff --git a/fop/test/layoutengine/standard-testcases/float_9.xml b/fop/test/layoutengine/standard-testcases/float_9.xml new file mode 100644 index 000000000..17bf5463e --- /dev/null +++ b/fop/test/layoutengine/standard-testcases/float_9.xml @@ -0,0 +1,88 @@ + + + +

+ This test checks floats. +

+
+ + + + + + + + + + + + + + + + Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam + + + + + + + Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy + eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et + accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem + ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing e + + + + + + + + + Yes, I would like to use all the options listed below in the sections + Individual Consent, XXXXXXXX-XXXX Ecosystem Consent and Further Individualization and give the + corresponding consent to the use of my dataX Plus another line of text Plus another line of text Plus + another line of + + 123456789 + + + + + + + + + + + + + + + + + + + + + +
+