]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2934: Absolute element should not be removed
authorSimon Steiner <ssteiner@apache.org>
Tue, 5 May 2020 08:12:02 +0000 (08:12 +0000)
committerSimon Steiner <ssteiner@apache.org>
Tue, 5 May 2020 08:12:02 +0000 (08:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1877372 13f79535-47bb-0310-9956-ffa450edef68

fop-core/src/main/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListUtils.java
fop/test/layoutengine/standard-testcases/block-container_absolute-position_break-after.xml [new file with mode: 0644]

index f0fc77577084689f9d98d8481e7fef3d6f2fb370..dced733176948ff9b343319ff1f522cc373db48d 100644 (file)
@@ -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);
     }
index e0f2daea09503daf6d25782349d1ebf3453a290b..9b964843e7ae9635f50037230e1c1b65186a3d0c 100644 (file)
@@ -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 (file)
index 0000000..e12626d
--- /dev/null
@@ -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>