]> source.dussan.org Git - poi.git/commitdiff
improved shifting of sheet-level names, also fixed an incorrect Bugzilla number in...
authorYegor Kozlov <yegor@apache.org>
Thu, 26 Feb 2009 09:10:35 +0000 (09:10 +0000)
committerYegor Kozlov <yegor@apache.org>
Thu, 26 Feb 2009 09:10:35 +0000 (09:10 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@748064 13f79535-47bb-0310-9956-ffa450edef68

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

index 7e6538a4351103ef9eec66210bf6d784f00f3fdb..ac90a3b4369a6452f4b78af4f607427d489a8e26 100644 (file)
@@ -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>
index f47785ddfd3f9e2c4fe725dee56ee617f91703f3..4a5dd692493680e1f3f7b9d84ea602979c4c597e 100644 (file)
@@ -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>
index 5feaa76893bbd41a549de4db1d20d9c6cf67892d..60e33c2f8e5c1ba3f4ee8825f78cd1eef25636be 100644 (file)
@@ -2320,7 +2320,7 @@ public final class Workbook implements Model {
         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);
             }
         }
index 95ef50777a09e1e767dac58769408e77462887cf..26fdad839cce5297d556f5c71c79a6b5f4384e63 100755 (executable)
@@ -102,11 +102,11 @@ public class XSSFRowShifter {
      */\r
     public void updateNamedRanges(FormulaShifter shifter) {\r
         XSSFWorkbook wb = sheet.getWorkbook();\r
-        int sheetIndex = wb.getSheetIndex(sheet);\r
         XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb);\r
         for (int i = 0; i < wb.getNumberOfNames(); i++) {\r
             XSSFName name = wb.getNameAt(i);\r
             String formula = name.getRefersToFormula();\r
+            int sheetIndex = name.getSheetIndex();\r
 \r
             Ptg[] ptgs = FormulaParser.parse(formula, fpb, FormulaType.NAMEDRANGE, sheetIndex);\r
             if (shifter.adjustFormula(ptgs, sheetIndex)) {\r
index 083779c0b580eb59d6152a7914290c422734e9eb..f43568771d30aaad6aa0ab552092fbc650e5e629 100755 (executable)
@@ -194,25 +194,44 @@ public abstract class BaseTestSheetShiftRows  extends TestCase {
 \r
     public final void baseTestShiftWithNames() {\r
         Workbook wb = getTestDataProvider().createWorkbook();\r
-        Sheet sheet    = wb.createSheet();\r
-        Row row = sheet.createRow(0);\r
+        Sheet sheet1   = wb.createSheet("Sheet1");\r
+        Sheet sheet2   = wb.createSheet("Sheet2");\r
+        Row row = sheet1.createRow(0);\r
         row.createCell(0).setCellValue(1.1);\r
         row.createCell(1).setCellValue(2.2);\r
 \r
         Name name1 = wb.createName();\r
         name1.setNameName("name1");\r
-        name1.setRefersToFormula("A1+B1");\r
+        name1.setRefersToFormula("Sheet1!$A$1+Sheet1!$B$1");\r
 \r
         Name name2 = wb.createName();\r
         name2.setNameName("name2");\r
-        name2.setRefersToFormula("A1");\r
+        name2.setRefersToFormula("Sheet1!$A$1");\r
 \r
-        sheet.shiftRows(0, 1, 2);\r
+        //refers to A1 but on Sheet2. Should stay unaffected.\r
+        Name name3 = wb.createName();\r
+        name3.setNameName("name3");\r
+        name3.setRefersToFormula("Sheet2!$A$1");\r
+\r
+        //The scope of this one is Sheet2. Should stay unaffected.\r
+        Name name4 = wb.createName();\r
+        name4.setNameName("name4");\r
+        name4.setRefersToFormula("A1");\r
+        name4.setSheetIndex(1);\r
+\r
+        sheet1.shiftRows(0, 1, 2);  //shift down the top row on Sheet1.\r
         name1 = wb.getNameAt(0);\r
-        assertEquals("A3+B3", name1.getRefersToFormula());\r
+        assertEquals("Sheet1!$A$3+Sheet1!$B$3", name1.getRefersToFormula());\r
 \r
         name2 = wb.getNameAt(1);\r
-        assertEquals("A3", name2.getRefersToFormula());    \r
+        assertEquals("Sheet1!$A$3", name2.getRefersToFormula());    \r
+\r
+        //name3 and name4 refer to Sheet2 and should not be affected\r
+        name3 = wb.getNameAt(2);\r
+        assertEquals("Sheet2!$A$1", name3.getRefersToFormula());\r
+\r
+        name4 = wb.getNameAt(3);\r
+        assertEquals("A1", name4.getRefersToFormula());\r
     }\r
 \r
     public final void baseTestShiftWithMergedRegions() {\r