From fc34b198fd486c5db87e4982b118ba558dcbbedd Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Wed, 31 Oct 2007 15:06:35 +0000 Subject: - Enforced check for proper number of columns in a table. Now if a table has explicit table-columns, those fix the total number of columns and any row having more columns will lead to an error. - Set up a framework for unit-testing classes from the FO tree, and added some first testcases for the number of columns in tables. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@590705 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fo/flow/Table.java | 7 +++++++ src/java/org/apache/fop/fo/flow/TableCellContainer.java | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'src/java/org/apache/fop') diff --git a/src/java/org/apache/fop/fo/flow/Table.java b/src/java/org/apache/fop/fo/flow/Table.java index 7bc2d49ec..2dfc06fdf 100644 --- a/src/java/org/apache/fop/fo/flow/Table.java +++ b/src/java/org/apache/fop/fo/flow/Table.java @@ -83,6 +83,8 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder { private boolean tableFooterFound = false; private boolean tableBodyFound = false; + private boolean hasExplicitColumns = false; + /** * The table's property list. Used in case the table has * no explicit columns, as a parent property list to @@ -236,6 +238,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder { switch (childId) { case FO_TABLE_COLUMN: + hasExplicitColumns = true; if (!inMarker()) { addColumnNode((TableColumn) child); } else { @@ -313,6 +316,10 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder { columnNumberManager.signalUsedColumnNumbers(colNumber, colNumber + colRepeat - 1); } + boolean hasExplicitColumns() { + return hasExplicitColumns; + } + /** @return true of table-layout="auto" */ public boolean isAutoLayout() { return (tableLayout == EN_AUTO); diff --git a/src/java/org/apache/fop/fo/flow/TableCellContainer.java b/src/java/org/apache/fop/fo/flow/TableCellContainer.java index 228e3c80d..348ae93f2 100644 --- a/src/java/org/apache/fop/fo/flow/TableCellContainer.java +++ b/src/java/org/apache/fop/fo/flow/TableCellContainer.java @@ -24,6 +24,7 @@ import java.util.List; import org.apache.fop.apps.FOPException; import org.apache.fop.datatypes.Length; import org.apache.fop.fo.FONode; +import org.apache.fop.fo.ValidationException; /** * A common class for fo:table-body and fo:table-row which both can contain fo:table-cell. @@ -66,6 +67,12 @@ public abstract class TableCellContainer extends TableFObj implements ColumnNumb int colSpan = cell.getNumberColumnsSpanned(); 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 (firstRow) { handleCellWidth(cell, colNumber, colSpan); updatePendingSpansSize(cell, colNumber, colSpan); -- cgit v1.2.3