poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1612150 - in /poi/trunk/src: java/org/apache/poi/ss/formula/ptg/ ooxml/testcases/org/apache/poi/xssf/usermodel/
Date Sun, 20 Jul 2014 18:53:28 GMT
Author: nick
Date: Sun Jul 20 18:53:27 2014
New Revision: 1612150

URL: http://svn.apache.org/r1612150
Log:
XSSF Pxgs must escape sheet names where required when generating the formula string

Modified:
    poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Area3DPxg.java
    poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Deleted3DPxg.java
    poi/trunk/src/java/org/apache/poi/ss/formula/ptg/NameXPxg.java
    poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Ref3DPxg.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Area3DPxg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Area3DPxg.java?rev=1612150&r1=1612149&r2=1612150&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Area3DPxg.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Area3DPxg.java Sun Jul 20 18:53:27 2014
@@ -17,6 +17,7 @@
 
 package org.apache.poi.ss.formula.ptg;
 
+import org.apache.poi.ss.formula.SheetNameFormatter;
 import org.apache.poi.ss.util.AreaReference;
 import org.apache.poi.util.LittleEndianOutput;
 
@@ -87,7 +88,7 @@ public final class Area3DPxg extends Are
             sb.append(externalWorkbookNumber);
             sb.append(']');
         }
-        sb.append(sheetName);
+        SheetNameFormatter.appendFormat(sb, sheetName);
         sb.append('!');
         sb.append(formatReferenceAsString());
         return sb.toString();

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Deleted3DPxg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Deleted3DPxg.java?rev=1612150&r1=1612149&r2=1612150&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Deleted3DPxg.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Deleted3DPxg.java Sun Jul 20 18:53:27
2014
@@ -17,6 +17,7 @@
 
 package org.apache.poi.ss.formula.ptg;
 
+import org.apache.poi.ss.formula.SheetNameFormatter;
 import org.apache.poi.ss.usermodel.ErrorConstants;
 import org.apache.poi.util.LittleEndianOutput;
 
@@ -71,7 +72,7 @@ public final class Deleted3DPxg extends 
             sb.append(']');
         }
         if (sheetName != null) {
-            sb.append(sheetName);
+            SheetNameFormatter.appendFormat(sb, sheetName);
         }
         sb.append('!');
         sb.append(ErrorConstants.getText(ErrorConstants.ERROR_REF));

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/ptg/NameXPxg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/ptg/NameXPxg.java?rev=1612150&r1=1612149&r2=1612150&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/ptg/NameXPxg.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/ptg/NameXPxg.java Sun Jul 20 18:53:27 2014
@@ -17,6 +17,7 @@
 
 package org.apache.poi.ss.formula.ptg;
 
+import org.apache.poi.ss.formula.SheetNameFormatter;
 import org.apache.poi.util.LittleEndianOutput;
 
 /**
@@ -79,7 +80,7 @@ public final class NameXPxg extends Oper
             sb.append(']');
         }
         if (sheetName != null) {
-            sb.append(sheetName);
+            SheetNameFormatter.appendFormat(sb, sheetName);
         }
         sb.append('!');
         sb.append(nameName);

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Ref3DPxg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Ref3DPxg.java?rev=1612150&r1=1612149&r2=1612150&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Ref3DPxg.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/ptg/Ref3DPxg.java Sun Jul 20 18:53:27 2014
@@ -17,6 +17,7 @@
 
 package org.apache.poi.ss.formula.ptg;
 
+import org.apache.poi.ss.formula.SheetNameFormatter;
 import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.util.LittleEndianOutput;
 
@@ -86,7 +87,9 @@ public final class Ref3DPxg extends RefP
             sb.append(externalWorkbookNumber);
             sb.append(']');
         }
-        sb.append(sheetName);
+        if (sheetName != null) {
+            SheetNameFormatter.appendFormat(sb, sheetName);
+        }
         sb.append('!');
         sb.append(formatReferenceAsString());
         return sb.toString();

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java?rev=1612150&r1=1612149&r2=1612150&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java
Sun Jul 20 18:53:27 2014
@@ -130,6 +130,15 @@ public final class TestXSSFFormulaParser
         assertEquals("A1", ((Ref3DPxg)ptgs[0]).format2DRefAsString());
         assertEquals("Uses!A1", ((Ref3DPxg)ptgs[0]).toFormulaString());
         
+        // Reference to a single cell in a different sheet, which needs quoting
+        ptgs = parse(fpb, "'Testing 47100'!A1");
+        assertEquals(1, ptgs.length);
+        assertEquals(Ref3DPxg.class, ptgs[0].getClass());
+        assertEquals(-1,   ((Ref3DPxg)ptgs[0]).getExternalWorkbookNumber());
+        assertEquals("Testing 47100", ((Ref3DPxg)ptgs[0]).getSheetName());
+        assertEquals("A1", ((Ref3DPxg)ptgs[0]).format2DRefAsString());
+        assertEquals("'Testing 47100'!A1", ((Ref3DPxg)ptgs[0]).toFormulaString());
+        
         // Reference to a sheet scoped named range from another sheet
         ptgs = parse(fpb, "Defines!NR_To_A1");
         assertEquals(1, ptgs.length);



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


Mime
View raw message