You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2009/02/26 10:10:36 UTC

svn commit: r748064 - in /poi/trunk/src: documentation/content/xdocs/ java/org/apache/poi/hssf/model/ ooxml/java/org/apache/poi/xssf/usermodel/helpers/ testcases/org/apache/poi/ss/usermodel/

Author: yegor
Date: Thu Feb 26 09:10:35 2009
New Revision: 748064

URL: http://svn.apache.org/viewvc?rev=748064&view=rev
Log:
improved shifting of sheet-level names, also fixed an incorrect Bugzilla number in status.xml

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/model/Workbook.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=748064&r1=748063&r2=748064&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Thu Feb 26 09:10:35 2009
@@ -55,7 +55,7 @@
            <action dev="POI-DEVELOPERS" type="fix">46643 - Fixed formula parser to encode range operator with tMemFunc</action>
            <action dev="POI-DEVELOPERS" type="fix">46647 - Fixed COUNTIF NE operator and other special cases involving type conversion</action>
            <action dev="POI-DEVELOPERS" type="add">46635 - Added a method to remove slides</action>
-           <action dev="POI-DEVELOPERS" type="fix">46520 - Fixed HSSFFont.applyFont() to properly apply font to overlapping regions</action>
+           <action dev="POI-DEVELOPERS" type="fix">40520 - Fixed HSSFFont.applyFont() to properly apply font to overlapping regions</action>
            <action dev="POI-DEVELOPERS" type="fix">46545 - Fixed ObjRecord to ignore excessive padding written by previous POI versions</action>
            <action dev="POI-DEVELOPERS" type="fix">46613 - Fixed evaluator to perform case insensitive string comparisons</action>
            <action dev="POI-DEVELOPERS" type="add">46544 - command line interface for hssf ExcelExtractor</action>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=748064&r1=748063&r2=748064&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Thu Feb 26 09:10:35 2009
@@ -52,7 +52,7 @@
            <action dev="POI-DEVELOPERS" type="fix">46643 - Fixed formula parser to encode range operator with tMemFunc</action>
            <action dev="POI-DEVELOPERS" type="fix">46647 - Fixed COUNTIF NE operator and other special cases involving type conversion</action>
            <action dev="POI-DEVELOPERS" type="add">46635 - Added a method to remove slides</action>
-           <action dev="POI-DEVELOPERS" type="fix">46520 - Fixed HSSFFont.applyFont() to properly apply font to overlapping regions</action>
+           <action dev="POI-DEVELOPERS" type="fix">40520 - Fixed HSSFFont.applyFont() to properly apply font to overlapping regions</action>
            <action dev="POI-DEVELOPERS" type="fix">46545 - Fixed ObjRecord to ignore excessive padding written by previous POI versions</action>
            <action dev="POI-DEVELOPERS" type="fix">46613 - Fixed evaluator to perform case insensitive string comparisons</action>
            <action dev="POI-DEVELOPERS" type="add">46544 - command line interface for hssf ExcelExtractor</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/model/Workbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/model/Workbook.java?rev=748064&r1=748063&r2=748064&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/model/Workbook.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/model/Workbook.java Thu Feb 26 09:10:35 2009
@@ -2320,7 +2320,7 @@
         for (int i = 0 ; i < getNumNames() ; ++i){
             NameRecord nr = getNameRecord(i);
             Ptg[] ptgs = nr.getNameDefinition();
-            if (shifter.adjustFormula(ptgs, nr.getExternSheetNumber())) {
+            if (shifter.adjustFormula(ptgs, nr.getSheetNumber())) {
                 nr.setNameDefinition(ptgs);
             }
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java?rev=748064&r1=748063&r2=748064&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java Thu Feb 26 09:10:35 2009
@@ -102,11 +102,11 @@
      */
     public void updateNamedRanges(FormulaShifter shifter) {
         XSSFWorkbook wb = sheet.getWorkbook();
-        int sheetIndex = wb.getSheetIndex(sheet);
         XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb);
         for (int i = 0; i < wb.getNumberOfNames(); i++) {
             XSSFName name = wb.getNameAt(i);
             String formula = name.getRefersToFormula();
+            int sheetIndex = name.getSheetIndex();
 
             Ptg[] ptgs = FormulaParser.parse(formula, fpb, FormulaType.NAMEDRANGE, sheetIndex);
             if (shifter.adjustFormula(ptgs, sheetIndex)) {

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java?rev=748064&r1=748063&r2=748064&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java Thu Feb 26 09:10:35 2009
@@ -194,25 +194,44 @@
 
     public final void baseTestShiftWithNames() {
         Workbook wb = getTestDataProvider().createWorkbook();
-        Sheet sheet	= wb.createSheet();
-        Row row = sheet.createRow(0);
+        Sheet sheet1	= wb.createSheet("Sheet1");
+        Sheet sheet2	= wb.createSheet("Sheet2");
+        Row row = sheet1.createRow(0);
         row.createCell(0).setCellValue(1.1);
         row.createCell(1).setCellValue(2.2);
 
         Name name1 = wb.createName();
         name1.setNameName("name1");
-        name1.setRefersToFormula("A1+B1");
+        name1.setRefersToFormula("Sheet1!$A$1+Sheet1!$B$1");
 
         Name name2 = wb.createName();
         name2.setNameName("name2");
-        name2.setRefersToFormula("A1");
+        name2.setRefersToFormula("Sheet1!$A$1");
 
-        sheet.shiftRows(0, 1, 2);
+        //refers to A1 but on Sheet2. Should stay unaffected.
+        Name name3 = wb.createName();
+        name3.setNameName("name3");
+        name3.setRefersToFormula("Sheet2!$A$1");
+
+        //The scope of this one is Sheet2. Should stay unaffected.
+        Name name4 = wb.createName();
+        name4.setNameName("name4");
+        name4.setRefersToFormula("A1");
+        name4.setSheetIndex(1);
+
+        sheet1.shiftRows(0, 1, 2);  //shift down the top row on Sheet1.
         name1 = wb.getNameAt(0);
-        assertEquals("A3+B3", name1.getRefersToFormula());
+        assertEquals("Sheet1!$A$3+Sheet1!$B$3", name1.getRefersToFormula());
 
         name2 = wb.getNameAt(1);
-        assertEquals("A3", name2.getRefersToFormula());    
+        assertEquals("Sheet1!$A$3", name2.getRefersToFormula());    
+
+        //name3 and name4 refer to Sheet2 and should not be affected
+        name3 = wb.getNameAt(2);
+        assertEquals("Sheet2!$A$1", name3.getRefersToFormula());
+
+        name4 = wb.getNameAt(3);
+        assertEquals("A1", name4.getRefersToFormula());
     }
 
     public final void baseTestShiftWithMergedRegions() {



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