You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2021/06/08 08:32:13 UTC

[Bug 65366] New: NullPointerException in XDDFDataSourcesFactory

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: dev@poi.apache.org
          Reporter: monnomiznogoud@gmail.com
  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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 65366] NullPointerException in XDDFDataSourcesFactory

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65366

PJ Fanning <fa...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from PJ Fanning <fa...@yahoo.com> ---
I suspect this is also fixed - see
https://github.com/apache/poi/blob/trunk/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSourcesFactory.java#L48

The next release should happen in the next month or 2.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 65366] NullPointerException in XDDFDataSourcesFactory

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65366

--- Comment #2 from monnomiznogoud@gmail.com ---
It seems to be the case. Thanks.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 65366] NullPointerException in XDDFDataSourcesFactory

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65366

PJ Fanning <fa...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INFORMATIONPROVIDED
             Status|NEW                         |RESOLVED

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org