Fop
  1. Fop
  2. FOP-1188

[PATCH] NullPointerException in RtfTableRow : tableBorderAttributes

    Details

    • Type: Bug Bug
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: 0.92
    • Fix Version/s: None
    • Component/s: renderer/rtf
    • Labels:
    • Environment:
      Operating System: Windows XP
      Platform: PC
    • External issue ID:
      39607

      Description

      The changes in the class RtfTableRow between 0.91 and 0.92 now generate a
      NullPointerException,
      due to the variable tableBorderAttributes declared at line 189:
      RtfAttributes tableBorderAttributes = getTable().getBorderAttributes();
      being null when the code:
      tableBorderAttributes.getValue(....) (line 209)
      is called.

      Example of java code which worked under 0.91 and doesn't work anymore:

      // Start of class
      import java.io.File;
      import java.io.FileWriter;
      import java.io.IOException;

      import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
      import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFile;
      import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
      import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
      import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable;
      import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow;

      public class TestFop {

      public static void main(String[] args) {
      try

      { FileWriter writer = new FileWriter(new File("C:/test.doc")); RtfFile f = new RtfFile(writer); RtfDocumentArea doc = f.startDocumentArea(); RtfSection section = doc.newSection(); RtfParagraph paragraph = section.newParagraph(); paragraph.newText("Testing fop - rtf module - class RtfTableRow"); paragraph.close(); RtfTable table = section.newTable(null); RtfTableRow row = table.newTableRow(); row.newTableCell(2000).newParagraph().newText("blah"); row.newTableCell(5000).newParagraph().newText("doubleBlah"); row.close(); table.close(); section.close(); doc.close(); f.flush(); }

      catch (IOException ioe)

      { ioe.printStackTrace(); }

      }
      }
      //End of class

      Stacktrace when the code is executed:
      Exception in thread "main" java.lang.NullPointerException
      at
      org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow.writeRowAndCellsDefintions(RtfTableRow.java:209)
      at
      org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow.writeRtfContent(RtfTableRow.java:142)
      at org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement.writeRtf(RtfElement.java:85)
      at
      org.apache.fop.render.rtf.rtflib.rtfdoc.RtfContainer.writeRtfContent(RtfContainer.java:134)
      at org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement.writeRtf(RtfElement.java:85)
      at
      org.apache.fop.render.rtf.rtflib.rtfdoc.RtfContainer.writeRtfContent(RtfContainer.java:134)
      at org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement.writeRtf(RtfElement.java:85)
      at
      org.apache.fop.render.rtf.rtflib.rtfdoc.RtfContainer.writeRtfContent(RtfContainer.java:134)
      at org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement.writeRtf(RtfElement.java:85)
      at
      org.apache.fop.render.rtf.rtflib.rtfdoc.RtfContainer.writeRtfContent(RtfContainer.java:134)
      at org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement.writeRtf(RtfElement.java:85)
      at org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFile.flush(RtfFile.java:218)
      at test.TestFop.main(TestFop.java:37)

      Simple way to fix this:
      add a test to check wether tableBorderAttributes is null.
      (I will join the modified RtfTableRow.java later)

      1. RtfTableRow.java
        14 kB
        Julien Aymé
      2. TestFop.java
        1 kB
        Julien Aymé

        Activity

        Hide
        Glenn Adams added a comment -

        batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed

        Show
        Glenn Adams added a comment - batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed
        Hide
        Jeremias Maerki added a comment -

        Applied. Thanks, especially for the sample code to reproduce the problem!
        http://svn.apache.org/viewvc?rev=407553&view=rev

        Julien, please send proposed code changes as Subversion patches in the future.
        That makes it a lot easier for us. Thank you! See:
        http://xmlgraphics.apache.org/fop/dev/index.html#patches

        Show
        Jeremias Maerki added a comment - Applied. Thanks, especially for the sample code to reproduce the problem! http://svn.apache.org/viewvc?rev=407553&view=rev Julien, please send proposed code changes as Subversion patches in the future. That makes it a lot easier for us. Thank you! See: http://xmlgraphics.apache.org/fop/dev/index.html#patches
        Hide
        Julien Aymé added a comment -

        Attachment RtfTableRow.java has been added with description: modified RtfTableRow.java

        Show
        Julien Aymé added a comment - Attachment RtfTableRow.java has been added with description: modified RtfTableRow.java
        Hide
        Julien Aymé added a comment -

        I've added the following lines: 203,204,237

        Show
        Julien Aymé added a comment - I've added the following lines: 203,204,237
        Hide
        Julien Aymé added a comment -

        Attachment TestFop.java has been added with description: source of TestFop.java

        Show
        Julien Aymé added a comment - Attachment TestFop.java has been added with description: source of TestFop.java

          People

          • Assignee:
            fop-dev
            Reporter:
            Julien Aymé
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development