diff options
author | Simon Steiner <ssteiner@apache.org> | 2020-05-05 08:12:02 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2020-05-05 08:12:02 +0000 |
commit | 22b5573fe407e09746a701b52bcd0ffe274d8dbd (patch) | |
tree | 8936e24e1a4cec28c5ae4fc48745bb0d271fed5d | |
parent | ccd1b149a719ce315ffe885fc153fce25d139fd5 (diff) | |
download | xmlgraphics-fop-22b5573fe407e09746a701b52bcd0ffe274d8dbd.tar.gz xmlgraphics-fop-22b5573fe407e09746a701b52bcd0ffe274d8dbd.zip |
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
3 files changed, 81 insertions, 4 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<!-- $Id$ --> +<testcase> + <info> + <p> + This test checks absolutely positioned block-containers. + </p> + </info> + <fo> +<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"> + <fo:layout-master-set> + <fo:simple-page-master master-name="Page_1" page-width="8.5in" page-height="11in"> + <fo:region-body region-name="Body"/> + </fo:simple-page-master> + <fo:simple-page-master master-name="Page_Odd_Even" page-width="8.5in" page-height="11in"> + <fo:region-body region-name="Body"/> + </fo:simple-page-master> + <fo:simple-page-master master-name="Page_last" page-width="8.5in" page-height="11in"> + <fo:region-body margin-bottom="16pt" region-name="Body"/> + </fo:simple-page-master> + <fo:page-sequence-master master-name="Page_Sequence"> + <fo:repeatable-page-master-alternatives maximum-repeats="5"> + <fo:conditional-page-master-reference blank-or-not-blank="any" page-position="last" master-reference="Page_last"/> + <fo:conditional-page-master-reference page-position="first" master-reference="Page_1"/> + <fo:conditional-page-master-reference page-position="rest" master-reference="Page_Odd_Even"/> + </fo:repeatable-page-master-alternatives> + </fo:page-sequence-master> + </fo:layout-master-set> + <fo:page-sequence format="1" id="th_default_sequence1" force-page-count="even" initial-page-number="1" master-reference="Page_Sequence"> + <fo:flow overflow="error-if-overflow" flow-name="Body"> + <fo:block-container page-break-after="always"> + <fo:block-container left="0.375in" top="0.375in" height="10.25in" width="7.75in" absolute-position="absolute"> + <fo:block>1</fo:block> + </fo:block-container> + </fo:block-container> + <fo:block-container page-break-after="always"> + <fo:block-container left="0.375in" height="10.25in" width="7.75in" top="0.375in" absolute-position="absolute"> + <fo:block>2</fo:block> + </fo:block-container> + </fo:block-container> + <fo:block-container page-break-after="always"> + <fo:block>3</fo:block> + </fo:block-container> + </fo:flow> + </fo:page-sequence> +</fo:root> + </fo> + <checks> + <eval expected="4" xpath="count(//pageViewport)"/> + </checks> +</testcase> |