From: Simon Steiner Date: Tue, 23 Apr 2024 09:12:25 +0000 (+0100) Subject: FOP-3178: Reset content length for table changing ipd X-Git-Tag: 2_10~30 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c7660fe84c7eabdb41c3aa88970f45401df72991;p=xmlgraphics-fop.git FOP-3178: Reset content length for table changing ipd --- 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 createKnuthElementList(int size) { + List 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 @@ - + 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 @@ + + + + + +

+ This test checks the positioning of footnotes when the body bpd changes + from page to page. +

+
+ + + + + + + + + + + + + + + + + + + + a + + + + + + + + + + + + HASAAPPLICANTHASAAPPLICANTAHADAAAFORECLOSURE,AREPOSSESSION,AHASAAPPLICANTAHADAAAFORECLOSURE,AREPOSSESSION + TESTTESTTEST + + + + + + + + + + + + + + + + OCCUR DATE + + + + + + + + + + + + + + + + + + + + + + 01/14/2022 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +