diff options
7 files changed, 347 insertions, 65 deletions
diff --git a/src/java/org/apache/fop/fo/flow/Table.java b/src/java/org/apache/fop/fo/flow/Table.java index 2dfc06fdf..87f224c65 100644 --- a/src/java/org/apache/fop/fo/flow/Table.java +++ b/src/java/org/apache/fop/fo/flow/Table.java @@ -35,6 +35,7 @@ import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.KeepProperty; import org.apache.fop.fo.properties.LengthPairProperty; import org.apache.fop.fo.properties.LengthRangeProperty; +import org.apache.fop.fo.properties.TableColLength; import org.xml.sax.Locator; /** @@ -84,6 +85,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder { private boolean tableBodyFound = false; private boolean hasExplicitColumns = false; + private boolean columnsFinalized = false; /** * The table's property list. Used in case the table has @@ -244,46 +246,68 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder { } else { columns.add((TableColumn) child); } - return; - case FO_TABLE_FOOTER: - tableFooter = (TableBody) child; break; case FO_TABLE_HEADER: - tableHeader = (TableBody) child; + case FO_TABLE_FOOTER: + case FO_TABLE_BODY: + if (hasExplicitColumns && !columnsFinalized) { + columnsFinalized = true; + finalizeColumns(); + } + switch (childId) { + case FO_TABLE_FOOTER: + tableFooter = (TableBody) child; + break; + case FO_TABLE_HEADER: + tableHeader = (TableBody) child; + break; + default: + super.addChildNode(child); + } break; default: super.addChildNode(child); } } + private void finalizeColumns() throws FOPException { + for (int i = 0; i < columns.size(); i++) { + if (columns.get(i) == null) { + columns.set(i, createImplicitColumn(i + 1)); + } + } + } + /** {@inheritDoc} */ public Table getTable() { return this; } /** - * Adds a default column to the columns list (called from - * TableBody.addChildNode() when the table has no explicit - * columns, and if processing the first row) + * Creates the appropriate number of additional implicit columns to match the given + * column number. Used when the table has no explicit column: the number of columns is + * then determined by the row that has the most columns. * - * @param colWidth the column's width (null if the default should be used) - * @param colNr the column-number from the cell - * @throws FOPException if there was an error creating the property list + * @param columnNumber the table must at least have this number of column + * @throws FOPException if there was an error creating the property list for implicit + * columns */ - void addDefaultColumn(Length colWidth, int colNr) + void ensureColumnNumber(int columnNumber) throws FOPException { + for (int i = columns.size() + 1; i <= columnNumber; i++) { + columns.add(createImplicitColumn(i)); + } + } + + private TableColumn createImplicitColumn(int colNumber) throws FOPException { - TableColumn defaultColumn = new TableColumn(this, true); + TableColumn implicitColumn = new TableColumn(this, true); PropertyList pList = new StaticPropertyList( - defaultColumn, this.propList); + implicitColumn, this.propList); pList.setWritingMode(); - defaultColumn.bind(pList); - if (colWidth != null) { - defaultColumn.setColumnWidth(colWidth); - } - if (colNr != 0) { - defaultColumn.setColumnNumber(colNr); - } - addColumnNode(defaultColumn); + implicitColumn.bind(pList); + implicitColumn.setColumnWidth(new TableColLength(1.0, implicitColumn)); + implicitColumn.setColumnNumber(colNumber); + return implicitColumn; } /** @@ -335,17 +359,13 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder { } /** - * Returns the column at the given index, if any. + * Returns the column at the given index. * * @param index index of the column to be retrieved, 0-based - * @return the corresponding column, or null if their is no column at the given index + * @return the corresponding column (may be an implicitly created column) */ TableColumn getColumn(int index) { - if (index >= columns.size()) { - return null; - } else { - return (TableColumn) columns.get(index); - } + return (TableColumn) columns.get(index); } /** diff --git a/src/java/org/apache/fop/fo/flow/TableBody.java b/src/java/org/apache/fop/fo/flow/TableBody.java index e18675aa0..72c0ff610 100644 --- a/src/java/org/apache/fop/fo/flow/TableBody.java +++ b/src/java/org/apache/fop/fo/flow/TableBody.java @@ -19,7 +19,8 @@ package org.apache.fop.fo.flow; -// Java +import java.util.ArrayList; + import org.apache.fop.apps.FOPException; import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; @@ -76,11 +77,16 @@ public class TableBody extends TableCellContainer { Attributes attlist, PropertyList pList) throws FOPException { if (!inMarker()) { - int cap = getTable().getNumberOfColumns(); - if (cap == 0) { - cap = 10; // Default value for ArrayList + Table t = getTable(); + if (t.hasExplicitColumns()) { + int size = t.getNumberOfColumns(); + pendingSpans = new ArrayList(size); + for (int i = 0; i < size; i++) { + pendingSpans.add(null); + } + } else { + pendingSpans = new ArrayList(); } - pendingSpans = new java.util.ArrayList(cap); columnNumberManager = new ColumnNumberManager(); } super.processNode(elementName, locator, attlist, pList); diff --git a/src/java/org/apache/fop/fo/flow/TableCellContainer.java b/src/java/org/apache/fop/fo/flow/TableCellContainer.java index 348ae93f2..9f9b72d75 100644 --- a/src/java/org/apache/fop/fo/flow/TableCellContainer.java +++ b/src/java/org/apache/fop/fo/flow/TableCellContainer.java @@ -68,14 +68,21 @@ public abstract class TableCellContainer extends TableFObj implements ColumnNumb int rowSpan = cell.getNumberRowsSpanned(); Table t = getTable(); - if (t.hasExplicitColumns() && colNumber + colSpan - 1 > t.getNumberOfColumns()) { - throw new ValidationException(FONode.errorText(locator) + "column-number or number " - + "of cells in the row overflows the number of fo:table-column specified " - + "for the table."); + if (t.hasExplicitColumns()) { + if (colNumber + colSpan - 1 > t.getNumberOfColumns()) { + throw new ValidationException(FONode.errorText(locator) + "column-number or " + + "number of cells in the row overflows the number of fo:table-column " + + "specified for the table."); + } + } else { + t.ensureColumnNumber(colNumber + colSpan - 1); + // re-cap the size of pendingSpans + while (pendingSpans.size() < colNumber + colSpan - 1) { + pendingSpans.add(null); + } } if (firstRow) { handleCellWidth(cell, colNumber, colSpan); - updatePendingSpansSize(cell, colNumber, colSpan); } /* if the current cell spans more than one row, @@ -101,26 +108,12 @@ public abstract class TableCellContainer extends TableFObj implements ColumnNumb for (int i = colNumber; i < colNumber + colSpan; ++i) { TableColumn col = t.getColumn(i - 1); - if (col == null) { - t.addDefaultColumn(colWidth, - i == colNumber - ? cell.getColumnNumber() - : 0); - } else { - if (!col.isDefaultColumn() - && colWidth != null) { - col.setColumnWidth(colWidth); - } + if (colWidth != null) { + col.setColumnWidth(colWidth); } } } - private void updatePendingSpansSize(TableCell cell, int colNumber, int colSpan) { - while (pendingSpans.size() < colNumber + colSpan - 1) { - pendingSpans.add(null); - } - } - /** {@inheritDoc} */ public ColumnNumberManager getColumnNumberManager() { return columnNumberManager; diff --git a/src/java/org/apache/fop/fo/flow/TableColumn.java b/src/java/org/apache/fop/fo/flow/TableColumn.java index 775b27ff3..89d967303 100644 --- a/src/java/org/apache/fop/fo/flow/TableColumn.java +++ b/src/java/org/apache/fop/fo/flow/TableColumn.java @@ -46,7 +46,7 @@ public class TableColumn extends TableFObj { // private int visibility; // End of property values - private boolean defaultColumn; + private boolean implicitColumn; private PropertyList pList = null; /** @@ -58,11 +58,12 @@ public class TableColumn extends TableFObj { /** * @param parent FONode that is the parent of this object - * @param defaultColumn true if this table-column has been manually created as a default column + * @param implicit true if this table-column has automatically been created (does not + * correspond to an explicit fo:table-column in the input document) */ - public TableColumn(FONode parent, boolean defaultColumn) { + public TableColumn(FONode parent, boolean implicit) { super(parent); - this.defaultColumn = defaultColumn; + this.implicitColumn = implicit; } @@ -93,7 +94,7 @@ public class TableColumn extends TableFObj { * warn only for explicit columns */ if (columnWidth.getEnum() == EN_AUTO) { - if (!this.defaultColumn && !getTable().isAutoLayout()) { + if (!this.implicitColumn && !getTable().isAutoLayout()) { log.warn("table-layout=\"fixed\" and column-width unspecified " + "=> falling back to proportional-column-width(1)"); } @@ -105,7 +106,7 @@ public class TableColumn extends TableFObj { * we need a reference to the column's property list * (cleared in Table.endOfNode()) */ - if (!this.defaultColumn) { + if (!this.implicitColumn) { this.pList = pList; } } @@ -199,8 +200,8 @@ public class TableColumn extends TableFObj { * user feedback (see ColumnSetup). * @return true if this table-column has been created as default column */ - public boolean isDefaultColumn() { - return defaultColumn; + public boolean isImplicitColumn() { + return implicitColumn; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java index bb33547e9..05f5ea4c9 100644 --- a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java +++ b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java @@ -100,7 +100,7 @@ public class ColumnSetup { if (index > size) { if (index > maxColIndexReferenced) { maxColIndexReferenced = index; - if (!(size == 1 && getColumn(1).isDefaultColumn())) { + if (!(size == 1 && getColumn(1).isImplicitColumn())) { log.warn(FONode.decorateWithContextInfo( "There are fewer table-columns than are needed. " + "Column " + index + " was accessed, but only " diff --git a/test/fotree/unittests/table/implicit_columns_column-number.fo b/test/fotree/unittests/table/implicit_columns_column-number.fo new file mode 100644 index 000000000..9a0699477 --- /dev/null +++ b/test/fotree/unittests/table/implicit_columns_column-number.fo @@ -0,0 +1,240 @@ +<?xml version="1.0" standalone="no"?> +<!-- + 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$ --> +<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> + <fo:layout-master-set> + <fo:simple-page-master master-name="page" page-height="29.7cm" page-width="21cm" margin="10pt"> + <fo:region-body/> + </fo:simple-page-master> + </fo:layout-master-set> + <fo:page-sequence master-reference="page"> + <fo:flow flow-name="xsl-region-body"> + <fo:block space-after="10pt">Checking that the number of columns is correctly computed + for tables without explicit fo:table-column.</fo:block> + + <fo:block space-before="10pt" space-after="2pt">Number of columns determined by the header’s + first row.</fo:block> + <fo:table table-layout="fixed" border-collapse="separate" width="200pt"> + <fo:table-header> + <fo:table-cell id="h1_1.1" border="1pt solid black"><fo:block>Header 1.1</fo:block></fo:table-cell> + <fo:table-cell id="h1_1.2" border="1pt solid black"><fo:block>Header 1.2</fo:block></fo:table-cell> + <fo:table-cell id="h1_2.1" starts-row="true" + border="1pt solid black"><fo:block>Header 2.1</fo:block></fo:table-cell> + </fo:table-header> + <fo:table-footer> + <fo:table-cell id="f1_1.1" border="1pt solid black"><fo:block>Footer 1.1</fo:block></fo:table-cell> + </fo:table-footer> + <fo:table-body> + <fo:table-cell id="b1_1.1" border="1pt solid black"><fo:block>Cell 1.1</fo:block></fo:table-cell> + <fo:table-cell id="b1_2.1" starts-row="true" + border="1pt solid black"><fo:block>Cell 2.1</fo:block></fo:table-cell> + </fo:table-body> + </fo:table> + + <fo:block space-before="10pt" space-after="2pt">Number of columns determined by the header’s + second row.</fo:block> + <fo:table table-layout="fixed" border-collapse="separate" width="200pt"> + <fo:table-header> + <fo:table-row> + <fo:table-cell id="h2_1.1" border="1pt solid black"><fo:block>Header 1.1</fo:block></fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell id="h2_2.1" border="1pt solid black"><fo:block>Header 2.1</fo:block></fo:table-cell> + <fo:table-cell id="h2_2.2" border="1pt solid black"><fo:block>Header 2.2</fo:block></fo:table-cell> + </fo:table-row> + </fo:table-header> + <fo:table-footer> + <fo:table-row> + <fo:table-cell id="f2_1.1" border="1pt solid black"><fo:block>Footer 1.1</fo:block></fo:table-cell> + </fo:table-row> + </fo:table-footer> + <fo:table-body> + <fo:table-row> + <fo:table-cell id="b2_1.1" border="1pt solid black"><fo:block>Cell 1.1</fo:block></fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell id="b2_2.1" border="1pt solid black"><fo:block>Cell 2.1</fo:block></fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + + <fo:block space-before="10pt" space-after="2pt">Number of columns determined by the footer’s + first row.</fo:block> + <fo:table table-layout="fixed" border-collapse="separate" width="200pt"> + <fo:table-header> + <fo:table-row> + <fo:table-cell id="h3_1.1" border="1pt solid black"><fo:block>Header 1.1</fo:block></fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell id="h3_2.1" border="1pt solid black"><fo:block>Header 2.1</fo:block></fo:table-cell> + </fo:table-row> + </fo:table-header> + <fo:table-footer> + <fo:table-row> + <fo:table-cell id="f3_1.1" border="1pt solid black"><fo:block>Footer 1.1</fo:block></fo:table-cell> + <fo:table-cell id="f3_1.2" border="1pt solid black"><fo:block>Footer 1.2</fo:block></fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell id="f3_2.1" border="1pt solid black"><fo:block>Footer 2.1</fo:block></fo:table-cell> + </fo:table-row> + </fo:table-footer> + <fo:table-body> + <fo:table-row> + <fo:table-cell id="b3_1.1" border="1pt solid black"><fo:block>Cell 1.1</fo:block></fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell id="b3_2.1" border="1pt solid black"><fo:block>Cell 2.1</fo:block></fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + + <fo:block space-before="10pt" space-after="2pt">Number of columns determined by the footer’s + second row.</fo:block> + <fo:table table-layout="fixed" border-collapse="separate" width="200pt"> + <fo:table-header> + <fo:table-cell id="h4_1.1" border="1pt solid black"><fo:block>Header 1.1</fo:block></fo:table-cell> + </fo:table-header> + <fo:table-footer> + <fo:table-cell id="f4_1.1" border="1pt solid black"><fo:block>Footer 1.1</fo:block></fo:table-cell> + <fo:table-cell id="f4_2.2" starts-row="true" column-number="2" + border="1pt solid black"><fo:block>Footer 2.2</fo:block></fo:table-cell> + </fo:table-footer> + <fo:table-body> + <fo:table-cell id="b4_1.1" border="1pt solid black"><fo:block>Cell 1.1</fo:block></fo:table-cell> + <fo:table-cell id="b4_2.1" starts-row="true" + border="1pt solid black"><fo:block>Cell 2.1</fo:block></fo:table-cell> + </fo:table-body> + </fo:table> + + <fo:block space-before="10pt" space-after="2pt">Number of columns determined by the body’s + first row.</fo:block> + <fo:table table-layout="fixed" border-collapse="separate" width="300pt"> + <fo:table-header> + <fo:table-row> + <fo:table-cell id="h5_1.1" border="1pt solid black"><fo:block>Header 1.1</fo:block></fo:table-cell> + <fo:table-cell id="h5_1.2" border="1pt solid black"><fo:block>Header 1.2</fo:block></fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell id="h5_2.1" border="1pt solid black"><fo:block>Header 2.1</fo:block></fo:table-cell> + <fo:table-cell id="h5_2.2" border="1pt solid black"><fo:block>Header 2.2</fo:block></fo:table-cell> + </fo:table-row> + </fo:table-header> + <fo:table-footer> + <fo:table-row> + <fo:table-cell id="f5_1.1" border="1pt solid black"><fo:block>Footer 1.1</fo:block></fo:table-cell> + <fo:table-cell id="f5_1.2" border="1pt solid black"><fo:block>Footer 1.2</fo:block></fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell id="f5_2.1" border="1pt solid black"><fo:block>Footer 2.1</fo:block></fo:table-cell> + </fo:table-row> + </fo:table-footer> + <fo:table-body> + <fo:table-row> + <fo:table-cell id="b5_1.1" border="1pt solid black"><fo:block>Cell 1.1</fo:block></fo:table-cell> + <fo:table-cell id="b5_1.2" border="1pt solid black"><fo:block>Cell 1.2</fo:block></fo:table-cell> + <fo:table-cell id="b5_1.3" border="1pt solid black"><fo:block>Cell 1.3</fo:block></fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell id="b5_2.1" border="1pt solid black"><fo:block>Cell 2.1</fo:block></fo:table-cell> + <fo:table-cell id="b5_2.2" border="1pt solid black"><fo:block>Cell 2.2</fo:block></fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + + <fo:block space-before="10pt" space-after="2pt">Number of columns determined by the body’s + not first row.</fo:block> + <fo:table table-layout="fixed" border-collapse="separate" width="300pt"> + <fo:table-header> + <fo:table-cell id="h6_1.1" border="1pt solid black"><fo:block>Header 1.1</fo:block></fo:table-cell> + <fo:table-cell id="h6_1.2" border="1pt solid black"><fo:block>Header 1.2</fo:block></fo:table-cell> + <fo:table-cell id="h6_2.1" starts-row="true" + border="1pt solid black"><fo:block>Header 2.1</fo:block></fo:table-cell> + <fo:table-cell id="h6_2.2" border="1pt solid black"><fo:block>Header 2.2</fo:block></fo:table-cell> + </fo:table-header> + <fo:table-footer> + <fo:table-cell id="f6_1.1" border="1pt solid black"><fo:block>Footer 1.1</fo:block></fo:table-cell> + <fo:table-cell id="f6_1.2" border="1pt solid black"><fo:block>Footer 1.2</fo:block></fo:table-cell> + <fo:table-cell id="f6_2.1" starts-row="true" + border="1pt solid black"><fo:block>Footer 2.1</fo:block></fo:table-cell> + </fo:table-footer> + <fo:table-body> + <fo:table-cell id="b6_1.1" border="1pt solid black"><fo:block>Cell 1.1</fo:block></fo:table-cell> + <fo:table-cell id="b6_1.2" border="1pt solid black"><fo:block>Cell 1.2</fo:block></fo:table-cell> + <fo:table-cell id="b6_2.1" starts-row="true" + border="1pt solid black"><fo:block>Cell 2.1</fo:block></fo:table-cell> + <fo:table-cell id="b6_2.2" border="1pt solid black"><fo:block>Cell 2.2</fo:block></fo:table-cell> + <fo:table-cell id="b6_3.1" starts-row="true" column-number="3" + border="1pt solid black"><fo:block>Cell 3.1</fo:block></fo:table-cell> + <fo:table-cell id="b6_3.2" border="1pt solid black"><fo:block>Cell 3.2</fo:block></fo:table-cell> + </fo:table-body> + </fo:table> + + <fo:block space-before="10pt" space-after="2pt">Number of columns determined by the second + body.</fo:block> + <fo:table table-layout="fixed" border-collapse="separate" width="300pt"> + <fo:table-header> + <fo:table-row> + <fo:table-cell id="h7_1.1" border="1pt solid black"><fo:block>Header 1.1</fo:block></fo:table-cell> + <fo:table-cell id="h7_1.2" border="1pt solid black"><fo:block>Header 1.2</fo:block></fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell id="h7_2.2" column-number="2" + border="1pt solid black"><fo:block>Header 2.2</fo:block></fo:table-cell> + </fo:table-row> + </fo:table-header> + <fo:table-footer> + <fo:table-row> + <fo:table-cell id="f7_1.1" border="1pt solid black"><fo:block>Footer 1.1</fo:block></fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell id="f7_2.1" border="1pt solid black"><fo:block>Footer 2.1</fo:block></fo:table-cell> + <fo:table-cell id="f7_2.2" border="1pt solid black"><fo:block>Footer 2.2</fo:block></fo:table-cell> + </fo:table-row> + </fo:table-footer> + <fo:table-body> + <fo:table-cell id="b71_1.1" border="1pt solid black"><fo:block>Cell 1.1</fo:block></fo:table-cell> + <fo:table-cell id="b71_1.2" border="1pt solid black"><fo:block>Cell 1.2</fo:block></fo:table-cell> + <fo:table-cell id="b71_2.1" starts-row="true" + border="1pt solid black"><fo:block>Cell 2.1</fo:block></fo:table-cell> + <fo:table-cell id="b71_2.2" border="1pt solid black"><fo:block>Cell 2.2</fo:block></fo:table-cell> + <fo:table-cell id="b71_3.1" starts-row="true" + border="1pt solid black"><fo:block>Cell 3.1</fo:block></fo:table-cell> + <fo:table-cell id="b71_3.2" border="1pt solid black"><fo:block>Cell 3.2</fo:block></fo:table-cell> + </fo:table-body> + <fo:table-body> + <fo:table-row> + <fo:table-cell id="b72_1.1" border="1pt solid blue"><fo:block>Cell 1.1</fo:block></fo:table-cell> + <fo:table-cell id="b72_1.2" border="1pt solid blue"><fo:block>Cell 1.2</fo:block></fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell id="b72_2.1" border="1pt solid blue"><fo:block>Cell 2.1</fo:block></fo:table-cell> + <fo:table-cell id="b72_2.2" border="1pt solid blue"><fo:block>Cell 2.2</fo:block></fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell id="b72_3.3" column-number="3" + border="1pt solid blue"><fo:block>Cell 3.3</fo:block></fo:table-cell> + <fo:table-cell id="b72_3.1" column-number="1" + border="1pt solid blue"><fo:block>Cell 3.1</fo:block></fo:table-cell> + <fo:table-cell id="b72_3.2" border="1pt solid blue"><fo:block>Cell 3.2</fo:block></fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + + </fo:flow> + </fo:page-sequence> +</fo:root> diff --git a/test/java/org/apache/fop/fo/flow/TableColumnColumnNumberTestCase.java b/test/java/org/apache/fop/fo/flow/TableColumnColumnNumberTestCase.java index 9ec83a26b..2af11c272 100644 --- a/test/java/org/apache/fop/fo/flow/TableColumnColumnNumberTestCase.java +++ b/test/java/org/apache/fop/fo/flow/TableColumnColumnNumberTestCase.java @@ -51,11 +51,11 @@ public class TableColumnColumnNumberTestCase extends AbstractTableTestCase { super(); } - private void checkColumn(Table t, int number, boolean isDefault, int spans, int repeated, int width) { + private void checkColumn(Table t, int number, boolean isImplicit, int spans, int repeated, int width) { TableColumn c = t.getColumn(number - 1); // TODO a repeated column has a correct number only for its first occurrence // assertEquals(number, c.getColumnNumber()); - assertEquals(isDefault, c.isDefaultColumn()); + assertEquals(isImplicit, c.isImplicitColumn()); assertEquals(spans, c.getNumberColumnsSpanned()); assertEquals(repeated, c.getNumberColumnsRepeated()); assertEquals(width, c.getColumnWidth().getValue(percentBaseContext)); @@ -88,4 +88,26 @@ public class TableColumnColumnNumberTestCase extends AbstractTableTestCase { checkColumn(t, 3, false, 1, 1, 150000); checkColumn(t, 4, false, 1, 1, 175000); } + + private void checkImplicitColumns(Iterator tableIter, int columnNumber) { + Table t = (Table) tableIter.next(); + assertEquals(columnNumber, t.getNumberOfColumns()); + for (int i = 1; i <= columnNumber; i++) { + checkColumn(t, i, true, 1, 1, 100000); + } + } + + public void testImplicitColumns() throws Exception { + setUp("table/implicit_columns_column-number.fo"); + percentBaseContext.setUnitaryWidth(100000); + Iterator tableIter = getTableHandler().getTables().iterator(); + + checkImplicitColumns(tableIter, 2); + checkImplicitColumns(tableIter, 2); + checkImplicitColumns(tableIter, 2); + checkImplicitColumns(tableIter, 2); + checkImplicitColumns(tableIter, 3); + checkImplicitColumns(tableIter, 4); + checkImplicitColumns(tableIter, 3); + } } |