summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2019-12-12 09:42:19 +0000
committerSimon Steiner <ssteiner@apache.org>2019-12-12 09:42:19 +0000
commitc668267826963ff998b71ca6090b8b371081407a (patch)
treee3e09fd6eb08cf3f494bbdd81b269c3d8f32076c
parent5c35af7a0dc7e9d50b1b5c6994522b961563d8ce (diff)
downloadxmlgraphics-fop-c668267826963ff998b71ca6090b8b371081407a.tar.gz
xmlgraphics-fop-c668267826963ff998b71ca6090b8b371081407a.zip
FOP-2894: Fit table contents onto current page
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1871261 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableStepper.java16
-rwxr-xr-xfop/test/layoutengine/standard-testcases/table_border_padding_7.xml203
2 files changed, 212 insertions, 7 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableStepper.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableStepper.java
index 136f9c4e3..3bcec5e9a 100644
--- a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableStepper.java
+++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableStepper.java
@@ -274,17 +274,19 @@ public class TableStepper {
laststep = step;
step = getNextStep();
-
if (penaltyOrGlueLen < 0) {
+ int shrink = 0;
+ int stretch = 0;
+ int width = -penaltyOrGlueLen;
if (keep.getPenalty() == KnuthElement.INFINITE) {
- if (boxLen > -penaltyOrGlueLen && boxLen < maxRemainingHeight) {
- returnList.add(new KnuthGlue(boxLen, 0, 0, new Position(null), true));
- } else {
- returnList.add(new KnuthGlue(0, -penaltyOrGlueLen, 0, new Position(null), true));
+ width = (boxLen + -penaltyOrGlueLen) / 2;
+ if (-penaltyOrGlueLen > maxRemainingHeight) {
+ width = 0;
}
- } else {
- returnList.add(new KnuthGlue(-penaltyOrGlueLen, 0, 0, new Position(null), true));
+ stretch = Math.max(boxLen, -penaltyOrGlueLen);
+ shrink = Math.min(boxLen, -penaltyOrGlueLen);
}
+ returnList.add(new KnuthGlue(width, stretch, shrink, new Position(null), true));
}
} while (step >= 0);
assert !returnList.isEmpty();
diff --git a/fop/test/layoutengine/standard-testcases/table_border_padding_7.xml b/fop/test/layoutengine/standard-testcases/table_border_padding_7.xml
new file mode 100755
index 000000000..fdc70360c
--- /dev/null
+++ b/fop/test/layoutengine/standard-testcases/table_border_padding_7.xml
@@ -0,0 +1,203 @@
+<?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 border and padding conditionality on table.
+ </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 margin-top="10mm" master-name="FirstPage" page-width="210mm" page-height="297mm" margin-bottom="5mm" margin-right="5mm" margin-left="5mm">
+ <fo:region-body margin-bottom="25mm" margin-top="20mm" margin-right="7mm" margin-left="7mm" region-name="PageBody"/>
+
+ </fo:simple-page-master>
+ <fo:simple-page-master margin-top="10mm" margin-right="5mm" margin-left="5mm" margin-bottom="5mm" master-name="ReversePage" page-width="210mm" page-height="297mm">
+ <fo:region-body margin-bottom="30mm" margin-top="4mm" margin-right="7mm" margin-left="7mm" region-name="PageBody"/>
+
+ </fo:simple-page-master>
+ <fo:simple-page-master margin-top="10mm" margin-left="5mm" margin-right="5mm" master-name="ContinuationPage" page-width="210mm" page-height="297mm" margin-bottom="5mm">
+ <fo:region-body margin-top="20mm" margin-bottom="20mm" margin-right="7mm" margin-left="7mm" region-name="PageBody"/>
+
+ </fo:simple-page-master>
+ <fo:page-sequence-master master-name="PageSequence">
+ <fo:repeatable-page-master-alternatives>
+ <fo:conditional-page-master-reference odd-or-even="odd" page-position="first" master-reference="FirstPage"/>
+ <fo:conditional-page-master-reference odd-or-even="even" master-reference="ReversePage"/>
+ <fo:conditional-page-master-reference odd-or-even="odd" page-position="rest" master-reference="ContinuationPage"/>
+ </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="auto" initial-page-number="auto" master-reference="PageSequence">
+
+ <fo:flow flow-name="PageBody">
+
+ <fo:block-container>
+ <fo:block>
+ <fo:block font-size="18pt" keep-with-next.within-column="always" space-before="7pt" text-align="left">Your retirement options</fo:block>
+ <fo:table id="1" border-collapse="separate" border-style="solid" border-width="2pt" keep-together.within-page="always" padding="10pt" space-before="7pt" 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>
+ <fo:block>
+ <fo:block>
+ <fo:block font-size="12pt" keep-with-next.within-column="always" space-before="7pt" role="H2" id="N100CD">You’ll need to choose an option for your pension savings, such as:</fo:block>
+ <fo:list-block font-size="10pt" space-before="7pt" >
+ <fo:list-item space-before="6pt">
+ <fo:list-item-label end-indent="label-end()" font-size="9pt" >
+ <fo:block>
+ <fo:inline>●</fo:inline>
+ </fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>
+ <fo:inline >Buy</fo:inline>
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item space-before="6pt">
+ <fo:list-item-label end-indent="label-end()" font-size="9pt" >
+ <fo:block>
+ <fo:inline>●</fo:inline>
+ </fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>
+ <fo:inline >Re</fo:inline>
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item space-before="6pt">
+ <fo:list-item-label end-indent="label-end()" font-size="9pt" >
+ <fo:block>
+ <fo:inline>●</fo:inline>
+ </fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>
+ <fo:inline >Take</fo:inline>
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </fo:list-block>
+ <fo:list-block font-size="10pt" space-before="7pt" >
+ <fo:list-item space-before="6pt">
+ <fo:list-item-label end-indent="label-end()" font-size="9pt" >
+ <fo:block>
+ <fo:inline>●</fo:inline>
+ </fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>
+ <fo:inline >Mix</fo:inline>
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item space-before="6pt">
+ <fo:list-item-label end-indent="label-end()" font-size="9pt" >
+ <fo:block>
+ <fo:inline>●</fo:inline>
+ </fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>
+ <fo:inline >Leave</fo:inline>
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </fo:list-block>
+ </fo:block>
+ </fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-body>
+ </fo:table>
+ <fo:table id="2" border-collapse="separate" border-style="solid" keep-together.within-page="always" padding="10pt" space-before="7pt" 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>
+ <fo:block>
+ <fo:block font-size="12pt" keep-with-next.within-column="always" space-before="7pt" role="H2" id="N10114">test test test test test test test test </fo:block>
+ <fo:block font-size="10pt" >test test test test test test test test test test test test test test test </fo:block>
+ <fo:block font-size="10pt" space-before="7pt">
+ test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test </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>
+ <fo:block>
+ <fo:block font-size="10pt" space-before="7pt" text-align="center">
+ <fo:inline >test test test test test test test test test test test </fo:inline>
+ </fo:block>
+ </fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-body>
+ </fo:table>
+ <fo:block font-size="10pt" space-before="7pt">
+ test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test </fo:block>
+ <fo:block font-size="10pt" space-before="7pt">
+ test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test </fo:block>
+ <fo:block font-size="10pt" space-before="7pt">
+ test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test </fo:block>
+ <fo:block font-size="10pt" space-before="7pt">
+ test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
+ </fo:block>
+ <fo:block font-size="10pt" space-before="7pt">test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test </fo:block>
+
+ </fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-body>
+ </fo:table>
+ <fo:table id="3" border-collapse="separate" border-style="solid" keep-together.within-page="always" padding="10pt" space-before="7pt" 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>
+ <fo:block>
+ <fo:block font-size="10pt" >test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test </fo:block>
+ <fo:block font-size="10pt" space-before="7pt">test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test </fo:block>
+
+ </fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-body>
+ </fo:table>
+
+
+
+
+ </fo:block>
+ </fo:block-container>
+
+ </fo:flow>
+ </fo:page-sequence>
+</fo:root>
+
+ </fo>
+ <checks>
+ <eval expected="1" xpath="count(//pageViewport)"/>
+ <eval expected="587" xpath="count(//pageViewport[1]//word)"/>
+ </checks>
+</testcase>