https://bz.apache.org/bugzilla/show_bug.cgi?id=65366

            Bug ID: 65366
           Summary: NullPointerException in XDDFDataSourcesFactory
           Product: POI
           Version: 5.0.0-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XDDF
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 37894
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=37894&action=edit
File containing the model chart

categoryDS.getNumRef() and valuesDS.getNumRef() are null in the case of an
existing .xlsx file containing a copied chart for which the links were removed
by the user.
Result: when reading this file, copying the model chart in order to use it in
another file, we have a NullPointerException in XDDFDataSourcesFactory when
calling xssfChart.getChartSeries()

            CTChartSpace chartSpace =
ChartSpaceDocument.Factory.parse(modelChart.getPackagePart().getInputStream(),
POIXMLTypeLoader.DEFAULT_XML_OPTIONS).getChartSpace(); 
            CTChart ctc = chartSpace.getChart();
            final CreationHelper helper = wb.getCreationHelper();
            final XSSFClientAnchor anchor = (XSSFClientAnchor)
helper.createClientAnchor();
            anchor.setAnchorType(AnchorType.MOVE_AND_RESIZE);
            anchor.setCol1(x);
            anchor.setCol2(x + w - 1);
            anchor.setRow1(y);
            anchor.setRow2(y + h - 1);
            xssfChart = drawing.createChart(anchor);
            xssfChart.getCTChart().set(ctc);
              existingSeries = xssfChart.getChartSeries();

java.lang.NullPointerException
        at
org.apache.poi.xddf.usermodel.chart.XDDFDataSourcesFactory$1.<init>(XDDFDataSourcesFactory.java:28)
        at
org.apache.poi.xddf.usermodel.chart.XDDFDataSourcesFactory.fromDataSource(XDDFDataSourcesFactory.java:27)
        at
org.apache.poi.xddf.usermodel.chart.XDDFScatterChartData$Series.<init>(XDDFScatterChartData.java:125)
        at
org.apache.poi.xddf.usermodel.chart.XDDFScatterChartData.<init>(XDDFScatterChartData.java:46)
        at
org.apache.poi.xddf.usermodel.chart.XDDFChart.getChartSeries(XDDFChart.java:488)

The solution was easy on my part: I copied XDDFDataSourcesFactory.java and
modified it, checking if getNumRef() returns null everywhere and handling the
resulting null category and values CTNumData

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to