瀏覽代碼

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
tags/fop-2_5
Simon Steiner 4 年之前
父節點
當前提交
22b5573fe4

+ 1
- 1
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);
}

+ 13
- 3
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());
}

}

+ 67
- 0
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>

Loading…
取消
儲存