diff options
4 files changed, 259 insertions, 1 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java b/fop-core/src/main/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java index aa7e27c5a..fd490dd21 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java +++ b/fop-core/src/main/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java @@ -113,6 +113,7 @@ public class PrimaryGridUnit extends GridUnit { */ public void setElements(List elements) { this.elements = elements; + contentLength = -1; } /** diff --git a/fop-core/src/test/java/org/apache/fop/fo/flow/table/PrimaryGridUnitTestCase.java b/fop-core/src/test/java/org/apache/fop/fo/flow/table/PrimaryGridUnitTestCase.java new file mode 100644 index 000000000..3633a8a4b --- /dev/null +++ b/fop-core/src/test/java/org/apache/fop/fo/flow/table/PrimaryGridUnitTestCase.java @@ -0,0 +1,81 @@ +/* + * 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$ */ + +package org.apache.fop.fo.flow.table; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.fop.datatypes.Length; +import org.apache.fop.fo.properties.LengthPairProperty; +import org.apache.fop.fo.properties.Property; +import org.apache.fop.layoutmgr.KnuthBox; +import org.apache.fop.layoutmgr.KnuthElement; + +/** + * Tests that the fox:header property is correctly parsed and set up at the FO tree level. + */ +public class PrimaryGridUnitTestCase { + + private static final int WIDTH = 10; + + @Test + public void testContentLength() { + TableCell tableCell = mock(TableCell.class); + Table table = mock(Table.class); + LengthPairProperty lengthPair = mock(LengthPairProperty.class); + Property property = mock(Property.class); + Length length = mock(Length.class); + + when(length.getValue()).thenReturn(1); + when(property.getLength()).thenReturn(length); + when(lengthPair.getBPD()).thenReturn(property); + when(table.getBorderSeparation()).thenReturn(lengthPair); + when(tableCell.getTable()).thenReturn(table); + when(table.isSeparateBorderModel()).thenReturn(true); + + int size = 3; + PrimaryGridUnit unit = new PrimaryGridUnit(tableCell, 0); + unit.setElements(createKnuthElementList(size)); + + assertEquals("Content length must be the sum of the widths", + WIDTH * size, unit.getContentLength()); + + size = 4; + unit.setElements(createKnuthElementList(size)); + + assertEquals("ContentLength must be updated after adding new elements", + WIDTH * size, unit.getContentLength()); + } + + private List<KnuthElement> createKnuthElementList(int size) { + List<KnuthElement> list = new ArrayList<>(); + for (int i = 0; i < size; i++) { + list.add(new KnuthBox(WIDTH, null, false)); + } + + return list; + } +} diff --git a/fop/test/layoutengine/standard-testcases/table_border_padding_3.xml b/fop/test/layoutengine/standard-testcases/table_border_padding_3.xml index 7fb15a244..38a744bb0 100644 --- a/fop/test/layoutengine/standard-testcases/table_border_padding_3.xml +++ b/fop/test/layoutengine/standard-testcases/table_border_padding_3.xml @@ -76,6 +76,6 @@ </fo:root> </fo> <checks> - <eval expected="test2" xpath="//pageViewport[3]//block/block[1]//word"/> + <eval expected="test2" xpath="//pageViewport[2]//block/block[3]//word"/> </checks> </testcase> diff --git a/fop/test/layoutengine/standard-testcases/table_layout_change_ipd.xml b/fop/test/layoutengine/standard-testcases/table_layout_change_ipd.xml new file mode 100644 index 000000000..fb05cdcce --- /dev/null +++ b/fop/test/layoutengine/standard-testcases/table_layout_change_ipd.xml @@ -0,0 +1,176 @@ +<?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 the positioning of footnotes when the body bpd changes + from page to page. + </p> + </info> + <fo> + <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> + <fo:layout-master-set> + <fo:simple-page-master margin-left="0.55in" master-name="PageEven"> + <fo:region-body margin-right="0.75in" region-name="Body"/> + </fo:simple-page-master> + <fo:simple-page-master margin-left="0.55in" master-name="PageOdd"> + <fo:region-body region-name="Body"/> + </fo:simple-page-master> + <fo:page-sequence-master master-name="PageOrder"> + <fo:repeatable-page-master-alternatives> + <fo:conditional-page-master-reference odd-or-even="even" master-reference="PageEven"/> + <fo:conditional-page-master-reference odd-or-even="odd" master-reference="PageOdd"/> + </fo:repeatable-page-master-alternatives> + </fo:page-sequence-master> + </fo:layout-master-set> + <fo:page-sequence format="1" id="th_default_sequence1" master-reference="PageOrder"> + <fo:flow flow-name="Body"> + <fo:block> + <fo:block>a</fo:block> + <fo:table font-family="Arial WGL" font-size="10pt" table-layout="fixed" width="100%" + page-break-before="always"> + <fo:table-header> + <fo:table-row keep-together.within-page="always" keep-with-next.within-page="always" + keep-with-next="always"> + <fo:table-cell border-right-style="solid" border-top-width="1pt" + border-left-style="solid" border-right-width="1pt" + border-left-color="black" border-top-color="black" + border-right-color="black" border-left-width="1pt" + border-top-style="solid"> + <fo:block> + <fo:table table-layout="fixed" width="100%"> + <fo:table-body> + <fo:table-row> + <fo:table-cell font-weight="normal" font-family="Arial WGL" + font-size="8pt" padding-top="1.5pt" + padding-bottom="0.5pt"> + <fo:block> + <fo:block font-family="Arial WGL" font-size="7pt"> + HASAAPPLICANTHASAAPPLICANTAHADAAAFORECLOSURE,AREPOSSESSION,AHASAAPPLICANTAHADAAAFORECLOSURE,AREPOSSESSION + TESTTESTTEST + </fo:block> + <fo:block font-family="Arial WGL" font-size="3pt"> + <fo:leader/> + </fo:block> + </fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + <fo:table table-layout="fixed" width="100%"> + <fo:table-body> + <fo:table-row> + <fo:table-cell font-weight="normal" font-family="Arial WGL" + font-size="8pt" padding-top="1.5pt" + padding-bottom="0.5pt" border-right-style="solid" + border-bottom-color="black" + border-top-width="1pt" border-right-width="1pt" + border-bottom-width="1pt" + border-top-color="black" + border-bottom-style="solid" + border-right-color="black" + border-top-style="solid"> + <fo:block> + <fo:block font-family="Arial WGL" font-size="7pt"> + <fo:inline font-weight="bold">OCCUR DATE</fo:inline> + </fo:block> + </fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + </fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-header> + <fo:table-body> + <fo:table-row keep-together.within-page="always" keep-with-next.within-page="always" + keep-with-next="always"> + <fo:table-cell border-right-style="solid" border-left-style="solid" + border-right-width="1pt" border-left-color="black" + border-right-color="black" border-left-width="1pt"> + <fo:block> + <fo:table table-layout="fixed" width="100%"> + <fo:table-column column-width="proportional-column-width(100)" + column-number="1"/> + <fo:table-body> + <fo:table-row> + <fo:table-cell font-weight="normal" font-family="Arial WGL" + font-size="8pt" padding-top="1.5pt" + padding-bottom="0.5pt" border-right-style="solid" + border-bottom-color="black" + border-top-width="1pt" border-right-width="1pt" + border-bottom-width="1pt" + border-top-color="black" + border-bottom-style="solid" + border-right-color="black" + border-top-style="solid"> + <fo:block> + <fo:block font-family="Arial WGL" font-size="7pt"> + 01/14/2022 + </fo:block> + </fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + </fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + </fo:block> + </fo:flow> + </fo:page-sequence> + </fo:root> + </fo> + <checks> + <eval expected="2" xpath="count(//pageViewport)"/> + <!-- body width for page 1 --> + <eval expected="555120" xpath="//pageViewport[1]/page/regionViewport/@ipd"/> + <!-- body width for page 2 --> + <eval expected="501120" xpath="//pageViewport[2]/page/regionViewport/@ipd"/> + <eval expected="HASAAPPLICANTHASAAPPLICANTAHADAAAFORECLOSURE,AREPOSSESSION,AHASAAPPLICANTAHADAAAFORECLOSURE,AREPOSSESSION" + xpath="//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block/block/block/block/block/block/block[1]/lineArea[1]"/> + <eval expected="500120" + xpath="//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block/block/block/block/block/block/block[1]/lineArea[1]/@ipd"/> + <eval expected="6300" + xpath="//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block/block/block/block/block/block/block[1]/lineArea[1]/@bpd"/> + <eval expected="TESTTESTTEST" + xpath="//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block/block/block/block/block/block/block[1]/lineArea[2]"/> + <eval expected="500120" + xpath="//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block/block/block/block/block/block/block[1]/lineArea[2]/@ipd"/> + <eval expected="6300" + xpath="//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block/block/block/block/block/block/block[1]/lineArea[2]/@bpd"/> + <eval expected="OCCUR DATE" + xpath="//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block/block/block/block[2]"/> + <eval expected="500120" + xpath="//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block/block/block/block[2]/@ipd"/> + <eval expected="11400" + xpath="//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block/block/block/block[2]/@bpd"/> + <eval expected="01/14/2022" + xpath="//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block/block[2]"/> + <eval expected="500120" + xpath="//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block/block[2]/@ipd"/> + <eval expected="11400" + xpath="//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block/block[2]/@bpd"/> + <eval expected="45700" + xpath="//pageViewport[2]/page/regionViewport/regionBody/mainReference/span/flow/block/block/@bpd"/> + </checks> +</testcase> |