improved shifting of sheet-level names, also fixed an incorrect Bugzilla number in status.xml

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@748064 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2009-02-26 09:10:35 +00:00
parent b93d8e4ff7
commit 1dfecf377c
5 changed files with 30 additions and 11 deletions

View 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">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="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="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">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="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> <action dev="POI-DEVELOPERS" type="add">46544 - command line interface for hssf ExcelExtractor</action>

View 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">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="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="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">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="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> <action dev="POI-DEVELOPERS" type="add">46544 - command line interface for hssf ExcelExtractor</action>

View File

@ -2320,7 +2320,7 @@ public final class Workbook implements Model {
for (int i = 0 ; i < getNumNames() ; ++i){ for (int i = 0 ; i < getNumNames() ; ++i){
NameRecord nr = getNameRecord(i); NameRecord nr = getNameRecord(i);
Ptg[] ptgs = nr.getNameDefinition(); Ptg[] ptgs = nr.getNameDefinition();
if (shifter.adjustFormula(ptgs, nr.getExternSheetNumber())) { if (shifter.adjustFormula(ptgs, nr.getSheetNumber())) {
nr.setNameDefinition(ptgs); nr.setNameDefinition(ptgs);
} }
} }

View File

@ -102,11 +102,11 @@ public class XSSFRowShifter {
*/ */
public void updateNamedRanges(FormulaShifter shifter) { public void updateNamedRanges(FormulaShifter shifter) {
XSSFWorkbook wb = sheet.getWorkbook(); XSSFWorkbook wb = sheet.getWorkbook();
int sheetIndex = wb.getSheetIndex(sheet);
XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb); XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb);
for (int i = 0; i < wb.getNumberOfNames(); i++) { for (int i = 0; i < wb.getNumberOfNames(); i++) {
XSSFName name = wb.getNameAt(i); XSSFName name = wb.getNameAt(i);
String formula = name.getRefersToFormula(); String formula = name.getRefersToFormula();
int sheetIndex = name.getSheetIndex();
Ptg[] ptgs = FormulaParser.parse(formula, fpb, FormulaType.NAMEDRANGE, sheetIndex); Ptg[] ptgs = FormulaParser.parse(formula, fpb, FormulaType.NAMEDRANGE, sheetIndex);
if (shifter.adjustFormula(ptgs, sheetIndex)) { if (shifter.adjustFormula(ptgs, sheetIndex)) {

View File

@ -194,25 +194,44 @@ public abstract class BaseTestSheetShiftRows extends TestCase {
public final void baseTestShiftWithNames() { public final void baseTestShiftWithNames() {
Workbook wb = getTestDataProvider().createWorkbook(); Workbook wb = getTestDataProvider().createWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet1 = wb.createSheet("Sheet1");
Row row = sheet.createRow(0); Sheet sheet2 = wb.createSheet("Sheet2");
Row row = sheet1.createRow(0);
row.createCell(0).setCellValue(1.1); row.createCell(0).setCellValue(1.1);
row.createCell(1).setCellValue(2.2); row.createCell(1).setCellValue(2.2);
Name name1 = wb.createName(); Name name1 = wb.createName();
name1.setNameName("name1"); name1.setNameName("name1");
name1.setRefersToFormula("A1+B1"); name1.setRefersToFormula("Sheet1!$A$1+Sheet1!$B$1");
Name name2 = wb.createName(); Name name2 = wb.createName();
name2.setNameName("name2"); 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); name1 = wb.getNameAt(0);
assertEquals("A3+B3", name1.getRefersToFormula()); assertEquals("Sheet1!$A$3+Sheet1!$B$3", name1.getRefersToFormula());
name2 = wb.getNameAt(1); 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() { public final void baseTestShiftWithMergedRegions() {