poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1675745 - in /poi/trunk/src/ooxml: java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
Date Fri, 24 Apr 2015 02:13:08 GMT
Author: nick
Date: Fri Apr 24 02:13:07 2015
New Revision: 1675745

URL: http://svn.apache.org/r1675745
Log:
#57642 Fix setSheetName with ISERROR on XSSF

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java?rev=1675745&r1=1675744&r2=1675745&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java Fri
Apr 24 02:13:07 2015
@@ -24,6 +24,7 @@ import org.apache.poi.ss.formula.Formula
 import org.apache.poi.ss.formula.FormulaType;
 import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.formula.ptg.Pxg;
+import org.apache.poi.ss.formula.ptg.Pxg3D;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -125,9 +126,17 @@ public final class XSSFFormulaUtils {
         if (ptg instanceof Pxg) {
             Pxg pxg = (Pxg)ptg;
             if (pxg.getExternalWorkbookNumber() < 1) {
-                if (pxg.getSheetName().equals(oldName)) {
+                if (pxg.getSheetName() != null &&
+                        pxg.getSheetName().equals(oldName)) {
                     pxg.setSheetName(newName);
                 }
+                if (pxg instanceof Pxg3D) {
+                    Pxg3D pxg3D = (Pxg3D)pxg;
+                    if (pxg3D.getLastSheetName() != null &&
+                            pxg3D.getLastSheetName().equals(oldName)) {
+                        pxg3D.setLastSheetName(newName);
+                    }
+                }
             }
         }
     }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1675745&r1=1675744&r2=1675745&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Fri Apr
24 02:13:07 2015
@@ -2367,4 +2367,20 @@ public final class TestXSSFBugs extends
 		assertNotNull(bgColor);
 		assertEquals("FF00FFFF", fgColor.getARGBHex());
 	}
+
+    @Test
+    public void bug57642() throws Exception {
+        XSSFWorkbook wb = new XSSFWorkbook();
+        XSSFSheet s = wb.createSheet("TestSheet");
+        XSSFCell c = s.createRow(0).createCell(0);
+        c.setCellFormula("ISERROR(TestSheet!A1)");
+        c = s.createRow(1).createCell(1);
+        c.setCellFormula("ISERROR(B2)");
+
+        wb.setSheetName(0, "CSN");
+        c = s.getRow(0).getCell(0);
+        assertEquals("ISERROR(CSN!A1)", c.getCellFormula());
+        c = s.getRow(1).getCell(1);
+        assertEquals("ISERROR(B2)", c.getCellFormula());
+    }
 }



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


Mime
View raw message