You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/10/07 13:28:45 UTC
svn commit: r1893988 -
/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XDGFCell.java
Author: fanningpj
Date: Thu Oct 7 13:28:45 2021
New Revision: 1893988
URL: http://svn.apache.org/viewvc?rev=1893988&view=rev
Log:
[github-260] Check XDGFCell value for null to avoid NullPointerException. Thanks to Dmitry Komarov.
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XDGFCell.java
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XDGFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XDGFCell.java?rev=1893988&r1=1893987&r2=1893988&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XDGFCell.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XDGFCell.java Thu Oct 7 13:28:45 2021
@@ -31,7 +31,7 @@ import com.microsoft.schemas.office.visi
*
* The various attributes of a Cell are constrained, and are better defined in
* the XSD 1.1 visio schema
- *
+ *
* Values of a cell are often the result of a formula computation. Luckily for
* you, Visio seems to always write the result to the document file, so unless
* the values change we don't need to recompute the values.
@@ -39,9 +39,9 @@ import com.microsoft.schemas.office.visi
public class XDGFCell {
public static Boolean maybeGetBoolean(Map<String, XDGFCell> cells,
- String name) {
+ String name) {
XDGFCell cell = cells.get(name);
- if (cell == null)
+ if (cell == null || cell.getValue() == null)
return null;
if (cell.getValue().equals("0"))
@@ -61,7 +61,7 @@ public class XDGFCell {
}
public static Integer maybeGetInteger(Map<String, XDGFCell> cells,
- String name) {
+ String name) {
XDGFCell cell = cells.get(name);
if (cell != null)
return parseIntegerValue(cell._cell);
@@ -72,7 +72,7 @@ public class XDGFCell {
XDGFCell cell = cells.get(name);
if (cell != null) {
String v = cell._cell.getV();
- if (v.equals("Themed"))
+ if (v == null || v.equals("Themed"))
return null;
return v;
}
@@ -80,6 +80,9 @@ public class XDGFCell {
}
public static Double parseDoubleValue(CellType cell) {
+ if (cell.getV() == null) {
+ return null;
+ }
try {
return Double.parseDouble(cell.getV());
} catch (NumberFormatException e) {
@@ -91,6 +94,9 @@ public class XDGFCell {
}
public static Integer parseIntegerValue(CellType cell) {
+ if (cell.getV() == null) {
+ return null;
+ }
try {
return Integer.parseInt(cell.getV());
} catch (NumberFormatException e) {
@@ -106,6 +112,9 @@ public class XDGFCell {
* @return A value converted to inches
*/
public static Double parseVLength(CellType cell) {
+ if (cell.getV() == null) {
+ return null;
+ }
try {
return Double.parseDouble(cell.getV());
} catch (NumberFormatException e) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org