From 22b5573fe407e09746a701b52bcd0ffe274d8dbd Mon Sep 17 00:00:00 2001 From: Simon Steiner Date: Tue, 5 May 2020 08:12:02 +0000 Subject: [PATCH] FOP-2934: Absolute element should not be removed git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1877372 13f79535-47bb-0310-9956-ffa450edef68 --- .../BlockContainerLayoutManager.java | 2 +- .../fop/layoutmgr/ElementListUtils.java | 16 ++++- ...ontainer_absolute-position_break-after.xml | 67 +++++++++++++++++++ 3 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 fop/test/layoutengine/standard-testcases/block-container_absolute-position_break-after.xml diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java index f0fc77577..dced73317 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java @@ -161,7 +161,7 @@ public class BlockContainerLayoutManager extends SpacedBorderedPaddedBlockLayout return indents; } - private boolean isAbsoluteOrFixed() { + protected boolean isAbsoluteOrFixed() { return (abProps.absolutePosition == EN_ABSOLUTE || abProps.absolutePosition == EN_FIXED); } diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListUtils.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListUtils.java index e0f2daea0..9b964843e 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListUtils.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListUtils.java @@ -229,10 +229,20 @@ public final class ElementListUtils { public static boolean isEmptyBox(List elements) { if (elements.size() == 1 && elements.get(0) instanceof KnuthBox) { KnuthBox kb = (KnuthBox) elements.get(0); - if (kb.getWidth() == 0) { - return true; - } + return kb.getWidth() == 0 && !isAbsoluteOrFixed(kb.getPosition()); } return false; } + + private static boolean isAbsoluteOrFixed(Position pos) { + if (pos == null || pos == pos.getPosition()) { + return false; + } + LayoutManager lm = pos.getLM(); + if (lm instanceof BlockContainerLayoutManager && ((BlockContainerLayoutManager)lm).isAbsoluteOrFixed()) { + return true; + } + return isAbsoluteOrFixed(pos.getPosition()); + } + } diff --git a/fop/test/layoutengine/standard-testcases/block-container_absolute-position_break-after.xml b/fop/test/layoutengine/standard-testcases/block-container_absolute-position_break-after.xml new file mode 100644 index 000000000..e12626d76 --- /dev/null +++ b/fop/test/layoutengine/standard-testcases/block-container_absolute-position_break-after.xml @@ -0,0 +1,67 @@ + + + + + +

+ This test checks absolutely positioned block-containers. +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + 2 + + + + 3 + + + + + + + + +
-- 2.39.5