Przeglądaj źródła

Bugfix: Fixed bug when the sum of column widths of a table is larger than the specified widths. The table width was not adjusted.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@471725 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-0_93
Jeremias Maerki 17 lat temu
rodzic
commit
9013b27ff9

+ 19
- 0
src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java Wyświetl plik

return xoffset; return xoffset;
} }


/**
* Calculates the sum of all column widths.
* @param context the context for percentage based calculations
* @return the requested sum in millipoints
*/
public int getSumOfColumnWidths(PercentBaseContext context) {
int sum = 0;
for (int i = 1, c = getColumnCount(); i <= c; i++) {
int effIndex = i;
if (i >= colWidths.size()) {
effIndex = colWidths.size() - 1;
}
if (colWidths.get(effIndex) != null) {
sum += ((Length) colWidths.get(effIndex)).getValue(context);
}
}
return sum;
}
} }

+ 8
- 4
src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java Wyświetl plik



import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.flow.Table; import org.apache.fop.fo.flow.Table;
import org.apache.fop.fo.flow.TableFObj;
import org.apache.fop.fo.flow.TableColumn; import org.apache.fop.fo.flow.TableColumn;
import org.apache.fop.fo.properties.TableColLength;
import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager; import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.ConditionalElementListener; import org.apache.fop.layoutmgr.ConditionalElementListener;
import org.apache.fop.layoutmgr.KnuthElement; import org.apache.fop.layoutmgr.KnuthElement;
updateContentAreaIPDwithOverconstrainedAdjust(); updateContentAreaIPDwithOverconstrainedAdjust();
} }


int sumOfColumns = columns.getSumOfColumnWidths(this);
if (!autoLayout && sumOfColumns > getContentAreaIPD()) {
log.debug(FONode.decorateWithContextInfo(
"The sum of all column widths is larger than the specified table width.",
getTable()));
updateContentAreaIPDwithOverconstrainedAdjust(sumOfColumns);
}

int availableIPD = referenceIPD - getIPIndents(); int availableIPD = referenceIPD - getIPIndents();
if (getContentAreaIPD() > availableIPD) { if (getContentAreaIPD() > availableIPD) {
log.warn(FONode.decorateWithContextInfo( log.warn(FONode.decorateWithContextInfo(

+ 4
- 0
status.xml Wyświetl plik



<changes> <changes>
<release version="FOP Trunk"> <release version="FOP Trunk">
<action context="Code" dev="JM" type="fix">
Bugfix: Fixed bug when the sum of column widths of a table is larger than the
specified widths. The table width was not adjusted.
</action>
<action context="Code" dev="JM" type="fix"> <action context="Code" dev="JM" type="fix">
Bugfix: Nested tables with headers and footers were not handled correctly and could Bugfix: Nested tables with headers and footers were not handled correctly and could
overlap with the region-after. overlap with the region-after.

+ 88
- 0
test/layoutengine/standard-testcases/table_table-layout_fixed_3.xml Wyświetl plik

<?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 tables with table-layout="fixed" and when width is set but is less
than the sum of all column widths.
</p>
</info>
<fo>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="normal" page-width="5in" page-height="5in" margin="20pt">
<fo:region-body margin="0pt" background-color="lightgray"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="normal" white-space-collapse="true">
<fo:flow flow-name="xsl-region-body">
<fo:table table-layout="fixed" width="100%" border-collapse="separate"
border="solid 5pt red" border-separation.inline-progression-direction="10pt">
<fo:table-column column-width="90pt"/>
<fo:table-column column-width="90pt"/>
<fo:table-column column-width="90pt"/>
<fo:table-column column-width="60pt"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell border="solid 2.5pt">
<fo:block>cell1</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 2.5pt" background-color="yellow">
<fo:block>cell2</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 2.5pt">
<fo:block>cell3</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 2.5pt" background-color="yellow">
<fo:block>cell4</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell background-color="orange">
<fo:block>cell5</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>cell6</fo:block>
</fo:table-cell>
<fo:table-cell background-color="orange">
<fo:block>cell7</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>cell8</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:flow>
</fo:page-sequence>
</fo:root>
</fo>
<checks>
<eval expected="340000" xpath="//flow/block[1]/@ipda"/>
<eval expected="330000" xpath="//flow/block[1]/@ipd"/>
<eval expected="80000" xpath="//flow/block[1]/block[1]/@ipda"/>
<eval expected="7500" xpath="//flow/block[1]/block[1]/@left-offset"/>
<eval expected="80000" xpath="//flow/block[1]/block[2]/@ipda"/>
<eval expected="97500" xpath="//flow/block[1]/block[2]/@left-offset"/>
<eval expected="80000" xpath="//flow/block[1]/block[3]/@ipda"/>
<eval expected="187500" xpath="//flow/block[1]/block[3]/@left-offset"/>
<eval expected="50000" xpath="//flow/block[1]/block[4]/@ipda"/>
<eval expected="277500" xpath="//flow/block[1]/block[4]/@left-offset"/>
</checks>
</testcase>

Ładowanie…
Anuluj
Zapisz