]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-3177: Remove space generated by fo:wrapper
authorSimon Steiner <ssteiner@apache.org>
Mon, 15 Apr 2024 13:54:14 +0000 (14:54 +0100)
committerSimon Steiner <ssteiner@apache.org>
Mon, 15 Apr 2024 13:54:14 +0000 (14:54 +0100)
fop-core/src/main/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java
fop/test/layoutengine/standard-testcases/wrapper_space.xml [new file with mode: 0644]

index ff2c59f4a9bd59d32933f512d5078b1c1c73f94c..c6a2b05b2a0dd1814f2a0056cb4b393c2534e1f6 100644 (file)
@@ -19,6 +19,9 @@
 
 package org.apache.fop.layoutmgr.inline;
 
+import java.util.Collections;
+import java.util.List;
+
 import org.apache.fop.area.Block;
 import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.fo.flow.Wrapper;
@@ -87,4 +90,11 @@ public class WrapperLayoutManager extends LeafNodeLayoutManager {
         getPSLM().addIDToPage(fobj.getId());
     }
 
+    public List getNextKnuthElements(LayoutContext context, int alignment) {
+        List list = super.getNextKnuthElements(context, alignment);
+        if (parentLayoutManager instanceof LineLayoutManager && !fobj.hasId() && fobj.hasChildren()) {
+            return Collections.emptyList();
+        }
+        return list;
+    }
 }
diff --git a/fop/test/layoutengine/standard-testcases/wrapper_space.xml b/fop/test/layoutengine/standard-testcases/wrapper_space.xml
new file mode 100644 (file)
index 0000000..e90f3b1
--- /dev/null
@@ -0,0 +1,53 @@
+<?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 fo:wrapper surrounding block-level content.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+      <fo:layout-master-set>
+        <fo:simple-page-master margin-top="13mm" margin-bottom="5mm" margin-left="15mm" margin-right="16mm" page-width="210mm" page-height="297mm" master-name="First Page">
+          <fo:region-body margin-bottom="7mm" margin-left="0mm" margin-right="0mm" margin-top="67mm" region-name="Body"/>
+          <fo:region-before region-name="First Header" extent="65mm" background-color="yellow"/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence format="1" id="th_default_sequence1" master-reference="First Page">
+        <fo:static-content flow-name="First Header">
+          <fo:block>
+            <fo:wrapper role="artifact">
+              <fo:block>
+                <fo:external-graphic scaling="uniform" src="url(test.png)" width="5cm" content-width="5cm" height="1.6cm" content-height="1.6cm" />
+              </fo:block>
+            </fo:wrapper>
+          </fo:block>
+        </fo:static-content>
+        <fo:flow flow-name="Body">
+          <fo:block>a</fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="51138" xpath="//block/@bpd"/>
+    <eval expected="2" xpath="count(//lineArea)"/>
+  </checks>
+</testcase>