aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2007-11-06 11:53:38 +0000
committerVincent Hennebert <vhennebert@apache.org>2007-11-06 11:53:38 +0000
commit335f9a3502c0a8d39a95a599119e6053bc005d3d (patch)
treebdae1fd6adcf5894e212009d5a6ae63e88ec2982 /src
parentac5c95850272b55df51f9cb450f1bca44ca65702 (diff)
downloadxmlgraphics-fop-335f9a3502c0a8d39a95a599119e6053bc005d3d.tar.gz
xmlgraphics-fop-335f9a3502c0a8d39a95a599119e6053bc005d3d.zip
Added check for table-cells which span more rows than available in their parent element
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@592392 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java18
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableBody.java23
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableFooter.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableHeader.java2
4 files changed, 30 insertions, 15 deletions
diff --git a/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java b/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java
index e321547a8..2f9a009c2 100644
--- a/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java
+++ b/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java
@@ -22,6 +22,7 @@ package org.apache.fop.fo.flow.table;
import java.util.ArrayList;
import java.util.List;
+import org.apache.fop.fo.ValidationException;
import org.apache.fop.layoutmgr.table.GridUnit;
import org.apache.fop.layoutmgr.table.PrimaryGridUnit;
@@ -113,19 +114,18 @@ abstract class RowGroupBuilder {
}
/**
- * Finishes and records the last row-group of the given table-body, if any. If there
- * is no fo:table-row and the last cell of the table-body didn't have ends-row="true",
- * then the {@link signalNewRow} method has not been called and the last row group has
- * yet to be recorded.
+ * Signals that the end of a table-header/footer/body has been reached. The current
+ * row-group is checked for emptiness. This row group builder is reset for handling
+ * further possible table parts.
*
- * @param tableBody
+ * @param tableBody the table part being finished
+ * @throws ValidationException if a cell is spanning further than the given table part
*/
- void finishLastRowGroup(TableBody tableBody) {
+ void signalEndOfPart(TableBody tableBody) throws ValidationException {
if (rows.size() > 0) {
- tableBody.addRowGroup(rows);
+ throw new ValidationException(
+ "A table-cell is spanning more rows than available in its parent element.");
}
- // Reset, in case this rowGroupBuilder is re-used for other
- // table-header/footer/body
initialize();
}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableBody.java b/src/java/org/apache/fop/fo/flow/table/TableBody.java
index 7671a9c4f..7e4ee2fb0 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableBody.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableBody.java
@@ -57,6 +57,8 @@ public class TableBody extends TableCellContainer {
private boolean rowsStarted = false;
+ private boolean lastCellEndsRow = true;
+
private List rowGroups = new LinkedList();
/**
@@ -124,7 +126,20 @@ public class TableBody extends TableCellContainer {
getParent().removeChild(this);
}
} else {
- getTable().getRowGroupBuilder().finishLastRowGroup(this);
+ finishLastRowGroup();
+ }
+ }
+
+ protected void finishLastRowGroup() throws ValidationException {
+ RowGroupBuilder rowGroupBuilder = getTable().getRowGroupBuilder();
+ if (tableRowsFound || !lastCellEndsRow) {
+ rowGroupBuilder.signalRowEnd(this);
+ }
+ try {
+ rowGroupBuilder.signalEndOfPart(this);
+ } catch (ValidationException e) {
+ e.setLocator(locator);
+ throw e;
}
}
@@ -179,7 +194,8 @@ public class TableBody extends TableCellContainer {
rowsStarted = true;
TableCell cell = (TableCell) child;
addTableCellChild(cell, firstRow);
- if (cell.endsRow()) {
+ lastCellEndsRow = cell.endsRow();
+ if (lastCellEndsRow) {
firstRow = false;
columnNumberManager.prepareForNextRow(pendingSpans);
getTable().getRowGroupBuilder().signalRowEnd(this);
@@ -231,8 +247,7 @@ public class TableBody extends TableCellContainer {
void signalNewRow() {
if (rowsStarted) {
firstRow = false;
- TableCell previousCell = (TableCell) getChildNodes().lastNode();
- if (!previousCell.endsRow()) {
+ if (!lastCellEndsRow) {
columnNumberManager.prepareForNextRow(pendingSpans);
getTable().getRowGroupBuilder().signalRowEnd(this);
}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableFooter.java b/src/java/org/apache/fop/fo/flow/table/TableFooter.java
index fe3521318..a7ee21406 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableFooter.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableFooter.java
@@ -51,7 +51,7 @@ public class TableFooter extends TableBody {
if (!(tableRowsFound || tableCellsFound)) {
missingChildElementError("marker* (table-row+|table-cell+)");
} else {
- getTable().getRowGroupBuilder().finishLastRowGroup(this);
+ finishLastRowGroup();
}
// convertCellsToRows();
}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableHeader.java b/src/java/org/apache/fop/fo/flow/table/TableHeader.java
index 3cfb782c0..bc9d88952 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableHeader.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableHeader.java
@@ -51,7 +51,7 @@ public class TableHeader extends TableBody {
if (!(tableRowsFound || tableCellsFound)) {
missingChildElementError("marker* (table-row+|table-cell+)");
} else {
- getTable().getRowGroupBuilder().finishLastRowGroup(this);
+ finishLastRowGroup();
}
// convertCellsToRows();
}