From 11d47a815eb1b9f4415a608657e00b88a0068be9 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Thu, 26 Jan 2006 11:05:43 +0000 Subject: [PATCH] Bugzilla #38397: Bugfix: Spanned cells could lead to an false error message about overlapping cells and ultimately a NullPointerException. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@372504 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/layoutmgr/table/TableRowIterator.java | 29 ++++-- status.xml | 4 + ...able-cell_number-rows-spanned_bug38397.xml | 97 +++++++++++++++++++ 3 files changed, 124 insertions(+), 6 deletions(-) create mode 100644 test/layoutengine/standard-testcases/table-cell_number-rows-spanned_bug38397.xml diff --git a/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java b/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java index 0781d4ee6..72c285700 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java @@ -355,6 +355,9 @@ public class TableRowIterator { colnum++; } } + if (pendingRowSpans < 0) { + throw new IllegalStateException("pendingRowSpans must not become negative!"); + } //Transfer available cells to their slots colnum = 1; @@ -368,9 +371,15 @@ public class TableRowIterator { //shouldn't happen here, since //overlapping cells already caught in //fo.flow.TableCell.bind()... - if (safelyGetListItem(gridUnits, colnum - 1) != null) { - log.error("Overlapping cell at position " + colnum); - //TODO throw layout exception + GridUnit other = (GridUnit)safelyGetListItem(gridUnits, colnum - 1); + if (other != null) { + String err = "A table-cell (" + + cell.getContextInfo() + + ") is overlapping with another (" + + other.getCell().getContextInfo() + + ") in column " + colnum; + throw new IllegalStateException(err + + " (this should have been catched by FO tree validation)"); } TableColumn col = columns.getColumn(colnum); @@ -390,12 +399,20 @@ public class TableRowIterator { for (int j = 1; j < cell.getNumberColumnsSpanned(); j++) { colnum++; GridUnit guSpan = new GridUnit(gu, columns.getColumn(colnum), colnum - 1, j); - if (safelyGetListItem(gridUnits, colnum - 1) != null) { - log.error("Overlapping cell at position " + colnum); - //TODO throw layout exception + //TODO: remove the check below??? + other = (GridUnit)safelyGetListItem(gridUnits, colnum - 1); + if (other != null) { + String err = "A table-cell (" + + cell.getContextInfo() + + ") is overlapping with another (" + + other.getCell().getContextInfo() + + ") in column " + colnum; + throw new IllegalStateException(err + + " (this should have been catched by FO tree validation)"); } safelySetListItem(gridUnits, colnum - 1, guSpan); if (hasRowSpanningLeft) { + pendingRowSpans++; safelySetListItem(lastRowsSpanningCells, colnum - 1, gu); } horzSpan[j] = guSpan; diff --git a/status.xml b/status.xml index f8f2acdb7..cd4b76c6c 100644 --- a/status.xml +++ b/status.xml @@ -27,6 +27,10 @@ + + Bugfix: Spanned cells could lead to an false error message about overlapping + cells and ultimately a NullPointerException. + Bugfix: Regions with non-standard names got ignored in RTF output leading to missing headers and footers. diff --git a/test/layoutengine/standard-testcases/table-cell_number-rows-spanned_bug38397.xml b/test/layoutengine/standard-testcases/table-cell_number-rows-spanned_bug38397.xml new file mode 100644 index 000000000..a6bbb5c99 --- /dev/null +++ b/test/layoutengine/standard-testcases/table-cell_number-rows-spanned_bug38397.xml @@ -0,0 +1,97 @@ + + + + + +

+ This test checks a bug with column number assignement in concert with row spanning. With the bug present, + the code produces an NPE in PrimaryGridUnit.getStartEndBorderWidths() as a follow-up problem. +

+
+ + + + + + + + + + + + + + + + + + cell1 + + + cell2 + + + cell3 + + + + + cell4 + + + + + cell5 + + + cell6 + + + + + cell7 + + + cell8 + + + cell9 + + + + + cell10 + + + cell11 + + + + + cell12 + + + + + + + + + + + +
-- 2.39.5