aboutsummaryrefslogtreecommitdiffstats
path: root/fop-core
diff options
context:
space:
mode:
authorChris Bowditch <cbowditch@apache.org>2023-03-02 15:27:00 +0000
committerChris Bowditch <cbowditch@apache.org>2023-03-02 15:27:00 +0000
commit03a69c051cbb867d3d037ed95c2344ab996b5dc4 (patch)
tree8ca703b501b044f3f9801357899388e8fcdac44a /fop-core
parentf4205e68b07a965481f326515ba33f08490ebc0a (diff)
downloadxmlgraphics-fop-03a69c051cbb867d3d037ed95c2344ab996b5dc4.tar.gz
xmlgraphics-fop-03a69c051cbb867d3d037ed95c2344ab996b5dc4.zip
Fix FOP-3098. Submitted by Dave Roxburgh
Diffstat (limited to 'fop-core')
-rw-r--r--fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java40
1 files changed, 40 insertions, 0 deletions
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<ListElement> 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) {