poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r801339 - in /poi/trunk/src: documentation/content/xdocs/status.xml ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java
Date Wed, 05 Aug 2009 17:54:56 GMT
Author: yegor
Date: Wed Aug  5 17:54:56 2009
New Revision: 801339

URL: http://svn.apache.org/viewvc?rev=801339&view=rev
Log:
Avoid FormulaParseException in XSSFWorkbook.setRepeatingRowsAndColumns when removing repeated
rows and columns, see Bugzilla 47620

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=801339&r1=801338&r2=801339&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Wed Aug  5 17:54:56 2009
@@ -33,6 +33,7 @@
 
     <changes>
         <release version="3.5-beta7" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">47620 - Avoid FormulaParseException
in XSSFWorkbook.setRepeatingRowsAndColumns when removing repeated rows and columns</action>
            <action dev="POI-DEVELOPERS" type="fix">47606 - Fixed  XSSFCell to correctly
parse column indexes greater than 702 (ZZ)</action>
            <action dev="POI-DEVELOPERS" type="fix">47598 - Improved formula evaluator
number comparison</action>
            <action dev="POI-DEVELOPERS" type="fix">47571 - Fixed XWPFWordExtractor
to extract inserted/deleted text</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=801339&r1=801338&r2=801339&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Wed Aug  5 17:54:56
2009
@@ -937,17 +937,18 @@
         boolean removingRange = startColumn == -1 && endColumn == -1 && startRow
== -1 && endRow == -1;
 
         XSSFName name = getBuiltInName(XSSFName.BUILTIN_PRINT_TITLE, sheetIndex);
-        if (removingRange && name != null) {
-            namedRanges.remove(name);
+        if (removingRange) {
+            if(name != null)namedRanges.remove(name);
             return;
         }
         if (name == null) {
             name = createBuiltInName(XSSFName.BUILTIN_PRINT_TITLE, sheetIndex);
-            String reference = getReferenceBuiltInRecord(name.getSheetName(), startColumn,
endColumn, startRow, endRow);
-            name.setRefersToFormula(reference);
             namedRanges.add(name);
         }
 
+        String reference = getReferenceBuiltInRecord(name.getSheetName(), startColumn, endColumn,
startRow, endRow);
+        name.setRefersToFormula(reference);
+
         XSSFPrintSetup printSetup = sheet.getPrintSetup();
         printSetup.setValidSettings(false);
     }
@@ -959,17 +960,26 @@
 
         String escapedName = SheetNameFormatter.format(sheetName);
 
-        String c = escapedName + "!$" + colRef.getCellRefParts()[2] + ":$" + colRef2.getCellRefParts()[2];
+        String c;
+        if(startC == -1 && endC == -1) c= "";
+        else c = escapedName + "!$" + colRef.getCellRefParts()[2] + ":$" + colRef2.getCellRefParts()[2];
 
         CellReference rowRef = new CellReference(sheetName, startR, 0, true, true);
         CellReference rowRef2 = new CellReference(sheetName, endR, 0, true, true);
 
         String r = "";
-
-        if (!rowRef.getCellRefParts()[1].equals("0") && !rowRef2.getCellRefParts()[1].equals("0"))
{
-            r = "," + escapedName + "!$" + rowRef.getCellRefParts()[1] + ":$" + rowRef2.getCellRefParts()[1];
+        if(startR == -1 && endR == -1) r = "";
+        else {
+            if (!rowRef.getCellRefParts()[1].equals("0") && !rowRef2.getCellRefParts()[1].equals("0"))
{
+                r = escapedName + "!$" + rowRef.getCellRefParts()[1] + ":$" + rowRef2.getCellRefParts()[1];
+            }
         }
-        return c + r;
+        
+        StringBuffer rng = new StringBuffer();
+        rng.append(c);
+        if(rng.length() > 0 && r.length() > 0) rng.append(',');
+        rng.append(r);
+        return rng.toString();
     }
 
     private static String getReferencePrintArea(String sheetName, int startC, int endC, int
startR, int endR) {

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java?rev=801339&r1=801338&r2=801339&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java Wed Aug
 5 17:54:56 2009
@@ -39,6 +39,8 @@
         XSSFWorkbook wb = getTestDataProvider().createWorkbook();
         XSSFSheet sheet = wb.createSheet("First Sheet");
 
+        wb.setRepeatingRowsAndColumns(0, -1, -1, -1, -1);
+
         // set repeating rows and columns twice for the first sheet
         for (int i = 0; i < 2; i++) {
             wb.setRepeatingRowsAndColumns(0, 0, 0, 0, 3);
@@ -50,6 +52,20 @@
         assertEquals(XSSFName.BUILTIN_PRINT_TITLE, nr1.getNameName());
         assertEquals("'First Sheet'!$A:$A,'First Sheet'!$1:$4", nr1.getRefersToFormula());
 
+        //remove the columns part
+        wb.setRepeatingRowsAndColumns(0, -1, -1, 0, 3);
+        assertEquals("'First Sheet'!$1:$4", nr1.getRefersToFormula());
+
+        //revert
+        wb.setRepeatingRowsAndColumns(0, 0, 0, 0, 3);
+
+        //remove the rows part
+        wb.setRepeatingRowsAndColumns(0, 0, 0, -1, -1);
+        assertEquals("'First Sheet'!$A:$A", nr1.getRefersToFormula());
+
+        //revert
+        wb.setRepeatingRowsAndColumns(0, 0, 0, 0, 3);
+
         // Save and re-open
         XSSFWorkbook nwb = XSSFTestDataSamples.writeOutAndReadBack(wb);
 



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


Mime
View raw message