Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-1188

[PATCH] NullPointerException in RtfTableRow : tableBorderAttributes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Resolution: Fixed
    • 0.92
    • None
    • renderer/rtf
    • Operating System: Windows XP
      Platform: PC
    • 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)

      Attachments

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

        Activity

          People

            fop-dev@xmlgraphics.apache.org fop-dev
            julien.ayme@gmail.com Julien Aymé
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: