poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1356102 - in /poi/trunk/src/ooxml: java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java
Date Mon, 02 Jul 2012 08:07:18 GMT
Author: yegor
Date: Mon Jul  2 08:07:16 2012
New Revision: 1356102

URL: http://svn.apache.org/viewvc?rev=1356102&view=rev
Log:
avoid NPE when setting line properties if linewidth is zero

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java?rev=1356102&r1=1356101&r2=1356102&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java Mon Jul  2
08:07:16 2012
@@ -299,7 +299,7 @@ public abstract class XSLFSimpleShape ex
     public void setLineWidth(double width) {
         CTShapeProperties spPr = getSpPr();
         if (width == 0.) {
-            if (spPr.isSetLn())
+            if (spPr.isSetLn() && spPr.getLn().isSetW())
                 spPr.getLn().unsetW();
         } else {
             CTLineProperties ln = spPr.isSetLn() ? spPr.getLn() : spPr
@@ -353,7 +353,7 @@ public abstract class XSLFSimpleShape ex
     public void setLineDash(LineDash dash) {
         CTShapeProperties spPr = getSpPr();
         if (dash == null) {
-            if (spPr.isSetLn())
+            if (spPr.isSetLn() &&  spPr.getLn().isSetPrstDash())
                 spPr.getLn().unsetPrstDash();
         } else {
             CTPresetLineDashProperties val = CTPresetLineDashProperties.Factory
@@ -406,7 +406,7 @@ public abstract class XSLFSimpleShape ex
     public void setLineCap(LineCap cap) {
         CTShapeProperties spPr = getSpPr();
         if (cap == null) {
-            if (spPr.isSetLn())
+            if (spPr.isSetLn() && spPr.getLn().isSetCap())
                 spPr.getLn().unsetCap();
         } else {
             CTLineProperties ln = spPr.isSetLn() ? spPr.getLn() : spPr

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java?rev=1356102&r1=1356101&r2=1356102&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java Mon
Jul  2 08:07:16 2012
@@ -100,6 +100,20 @@ public class TestXSLFSimpleShape extends
         assertEquals(null, shape.getLineColor());
         // setting dash width to null unsets the SolidFill element
         assertFalse(shape.getSpPr().getLn().isSetSolidFill());
+
+        XSLFSimpleShape ln2 = slide.createAutoShape();
+        ln2.setLineDash(LineDash.DOT);
+        assertEquals(LineDash.DOT, ln2.getLineDash());
+        ln2.setLineWidth(0.);
+        assertEquals(0., ln2.getLineWidth());
+
+        XSLFSimpleShape ln3 = slide.createAutoShape();
+        ln3.setLineWidth(1.);
+        assertEquals(1., ln3.getLineWidth());
+        ln3.setLineDash(null);
+        assertEquals(null, ln3.getLineDash());
+        ln3.setLineCap(null);
+        assertEquals(null, ln3.getLineDash());
     }
 
     public void testFill() {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message