Author: centic
Date: Sun Jun 2 09:39:57 2024
New Revision: 1918117
URL: http://svn.apache.org/viewvc?rev=1918117&view=rev
Log:
Avoid NPE and improve error message when saving a package-part fails
Added:
poi/trunk/test-data/spreadsheet/123233_charts.xlsx
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/marshallers/PackagePropertiesMarshaller.java
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/marshallers/PackagePropertiesMarshaller.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/marshallers/PackagePropertiesMarshaller.java?rev=1918117&r1=1918116&r2=1918117&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/marshallers/PackagePropertiesMarshaller.java
(original)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/marshallers/PackagePropertiesMarshaller.java
Sun Jun 2 09:39:57 2024
@@ -89,7 +89,8 @@ public class PackagePropertiesMarshaller
throws OpenXML4JException {
if (!(part instanceof PackagePropertiesPart))
throw new IllegalArgumentException(
- "'part' must be a PackagePropertiesPart instance.");
+ "'part' must be a PackagePropertiesPart instance, but had:
" + part.getClass() +
+ ", check logs while reading.");
propsPart = (PackagePropertiesPart) part;
// Configure the document
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java?rev=1918117&r1=1918116&r2=1918117&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java
(original)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java
Sun Jun 2 09:39:57 2024
@@ -63,13 +63,15 @@ public final class XSSFGraphicFrame exte
for (int i = 0; i < nodes.getLength(); i++) {
final Node node = nodes.item(i);
// if the frame references a chart, associate the chart with
this instance
- Node namedItem = node.getAttributes().getNamedItem("r:id");
- if (node.getNodeName().equals("c:chart") && namedItem != null)
{
- // this better succeed or the document is invalid
- POIXMLDocumentPart relation =
drawing.getRelationById(namedItem.getNodeValue());
- // Do XWPF charts need similar treatment?
- if (relation instanceof XSSFChart) {
- ((XSSFChart) relation).setGraphicFrame(this);
+ if (node.getAttributes() != null) {
+ Node namedItem = node.getAttributes().getNamedItem("r:id");
+ if (node.getNodeName().equals("c:chart") && namedItem !=
null) {
+ // this better succeed or the document is invalid
+ POIXMLDocumentPart relation =
drawing.getRelationById(namedItem.getNodeValue());
+ // Do XWPF charts need similar treatment?
+ if (relation instanceof XSSFChart) {
+ ((XSSFChart) relation).setGraphicFrame(this);
+ }
}
}
}
Added: poi/trunk/test-data/spreadsheet/123233_charts.xlsx
URL:
http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/123233_charts.xlsx?rev=1918117&view=auto
==============================================================================
Binary files poi/trunk/test-data/spreadsheet/123233_charts.xlsx (added) and
poi/trunk/test-data/spreadsheet/123233_charts.xlsx Sun Jun 2 09:39:57 2024
differ
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]