aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2006-05-18 15:54:17 +0000
committerJeremias Maerki <jeremias@apache.org>2006-05-18 15:54:17 +0000
commitf970e15d282ae09cd0a00f04745d237e3fa71ac4 (patch)
tree8f43df91ad4de8ddcceb3daafc0980df79955bd9 /src/java/org/apache/fop
parent09aeb982edfdeafc0148bf7abdf1db3d3cde7feb (diff)
downloadxmlgraphics-fop-f970e15d282ae09cd0a00f04745d237e3fa71ac4.tar.gz
xmlgraphics-fop-f970e15d282ae09cd0a00f04745d237e3fa71ac4.zip
Bugzilla #39533:
Bugfix: NullPointerException in RTF output when a table does not contain table-columns. The code now informs the user that he should explicitely define the table-columns. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@407576 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop')
-rw-r--r--src/java/org/apache/fop/render/rtf/RTFHandler.java10
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableColumnsInfo.java2
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java24
3 files changed, 23 insertions, 13 deletions
diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java
index ed33cf9df..d50cd7a61 100644
--- a/src/java/org/apache/fop/render/rtf/RTFHandler.java
+++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java
@@ -1585,8 +1585,14 @@ public class RTFHandler extends FOEventHandler {
Table table = (Table) foNode;
//recurse all table-columns
- for (Iterator it = table.getColumns().iterator(); it.hasNext();) {
- recurseFONode( (FONode) it.next() );
+ if (table.getColumns() != null) {
+ for (Iterator it = table.getColumns().iterator(); it.hasNext();) {
+ recurseFONode( (FONode) it.next() );
+ }
+ } else {
+ //TODO Implement implicit column setup handling!
+ log.warn("No table-columns found on table. RTF output requires that all"
+ + " table-columns for a table are defined. Output will be incorrect.");
}
//recurse table-header
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableColumnsInfo.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableColumnsInfo.java
index f744ec7ec..2f624fa7d 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableColumnsInfo.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableColumnsInfo.java
@@ -31,7 +31,7 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc;
public interface ITableColumnsInfo {
/** value for invalid column width */
- float INVALID_COLUM_WIDTH = 200f;
+ float INVALID_COLUMN_WIDTH = 200f;
/** reset the column iteration index, meant to be called when creating a new row */
void selectFirstColumn();
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java
index 0f5f67635..176e173de 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java
@@ -94,12 +94,10 @@ public class TableContext implements ITableColumnsInfo {
}
/**
- *
+ * Adds a column and sets its width.
* @param width Width of next column
- * @throws Exception
*/
- public void setNextColumnWidth(Float width)
- throws Exception {
+ public void setNextColumnWidth(Float width) {
colWidths.add(width);
}
@@ -165,6 +163,9 @@ public class TableContext implements ITableColumnsInfo {
boolean bFirstSpanningCol) {
if (colIndex < colRowSpanningNumber.size()) {
+ while (colIndex >= colFirstSpanningCol.size()) {
+ setNextFirstSpanningCol(false);
+ }
colFirstSpanningCol.set(colIndex, new Boolean(bFirstSpanningCol));
} else {
colFirstSpanningCol.add(new Boolean(bFirstSpanningCol));
@@ -229,13 +230,16 @@ public class TableContext implements ITableColumnsInfo {
* 'number-columns-spanned' processing
*/
public float getColumnWidth() {
- try {
- return ((Float)colWidths.get(colIndex)).floatValue();
- } catch (IndexOutOfBoundsException ex) {
- // this code contributed by Trembicki-Guy, Ed <GuyE@DNB.com>
- log.warn("fo:table-column width not defined, using " + INVALID_COLUM_WIDTH);
- return INVALID_COLUM_WIDTH;
+ if (colIndex < 0) {
+ throw new IllegalStateException("colIndex must not be negative!");
+ } else if (colIndex >= getNumberOfColumns()) {
+ log.warn("Column width for column " + (colIndex + 1) + " is not defined, using "
+ + INVALID_COLUMN_WIDTH);
+ while (colIndex >= getNumberOfColumns()) {
+ setNextColumnWidth(new Float(INVALID_COLUMN_WIDTH));
+ }
}
+ return ((Float)colWidths.get(colIndex)).floatValue();
}
/**