You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2006/05/18 17:54:17 UTC

svn commit: r407576 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/render/rtf/ src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ src/java/org/apache/fop/render/rtf/rtflib/tools/ test/java/org/apache/fop/render/rtf/rtflib/testdocs/

Author: jeremias
Date: Thu May 18 08:54:17 2006
New Revision: 407576

URL: http://svn.apache.org/viewvc?rev=407576&view=rev
Log:
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.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableColumnsInfo.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/render/rtf/rtflib/testdocs/DummyTableColumnsInfo.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java?rev=407576&r1=407575&r2=407576&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java Thu May 18 08:54:17 2006
@@ -1585,8 +1585,14 @@
             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

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableColumnsInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableColumnsInfo.java?rev=407576&r1=407575&r2=407576&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableColumnsInfo.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ITableColumnsInfo.java Thu May 18 08:54:17 2006
@@ -31,7 +31,7 @@
 
 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();

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java?rev=407576&r1=407575&r2=407576&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/tools/TableContext.java Thu May 18 08:54:17 2006
@@ -94,12 +94,10 @@
     }
 
     /**
-     * 
+     * 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 @@
             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 @@
      * 'number-columns-spanned' processing
      */
     public float getColumnWidth() {
-        try {
-            return ((Float)colWidths.get(colIndex)).floatValue();
-        } catch (IndexOutOfBoundsException ex) {
-            // this code contributed by Trembicki-Guy, Ed <Gu...@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();
     }
 
     /**

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/rtf/rtflib/testdocs/DummyTableColumnsInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/rtf/rtflib/testdocs/DummyTableColumnsInfo.java?rev=407576&r1=407575&r2=407576&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/render/rtf/rtflib/testdocs/DummyTableColumnsInfo.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/render/rtf/rtflib/testdocs/DummyTableColumnsInfo.java Thu May 18 08:54:17 2006
@@ -39,7 +39,7 @@
 class DummyTableColumnsInfo implements ITableColumnsInfo {
 
     public float getColumnWidth() {
-        return INVALID_COLUM_WIDTH;
+        return INVALID_COLUMN_WIDTH;
     }
 
     public void selectFirstColumn() {



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org