Make the test related to bug #30978, which shows that named ranges pointing to deleted sheets is ok, more complete
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@668155 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
acfbb1648c
commit
895d30e055
@ -276,8 +276,8 @@ public class Area3DPtg extends OperandPtg implements AreaI {
|
|||||||
} else {
|
} else {
|
||||||
// Normal
|
// Normal
|
||||||
SheetNameFormatter.appendFormat(retval, sheetName);
|
SheetNameFormatter.appendFormat(retval, sheetName);
|
||||||
retval.append( '!' );
|
|
||||||
}
|
}
|
||||||
|
retval.append( '!' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now the normal area bit
|
// Now the normal area bit
|
||||||
|
Binary file not shown.
@ -410,19 +410,26 @@ public final class TestHSSFWorkbook extends TestCase {
|
|||||||
*/
|
*/
|
||||||
public void testNamesToDeleteSheets() throws Exception {
|
public void testNamesToDeleteSheets() throws Exception {
|
||||||
HSSFWorkbook b = openSample("30978-deleted.xls");
|
HSSFWorkbook b = openSample("30978-deleted.xls");
|
||||||
assertEquals(1, b.getNumberOfNames());
|
assertEquals(3, b.getNumberOfNames());
|
||||||
|
|
||||||
// Sheet 2 deleted
|
// Sheet 2 is deleted
|
||||||
assertEquals("Sheet1", b.getSheetName(0));
|
assertEquals("Sheet1", b.getSheetName(0));
|
||||||
assertEquals("Sheet3", b.getSheetName(1));
|
assertEquals("Sheet3", b.getSheetName(1));
|
||||||
|
|
||||||
|
Area3DPtg ptg;
|
||||||
|
NameRecord nr;
|
||||||
|
HSSFName n;
|
||||||
|
|
||||||
|
/* ======= Name pointing to deleted sheet ====== */
|
||||||
|
|
||||||
// First at low level
|
// First at low level
|
||||||
NameRecord nr = b.getWorkbook().getNameRecord(0);
|
nr = b.getWorkbook().getNameRecord(0);
|
||||||
assertEquals("On2", nr.getNameText());
|
assertEquals("On2", nr.getNameText());
|
||||||
|
assertEquals(0, nr.getIndexToSheet());
|
||||||
assertEquals(1, nr.getExternSheetNumber());
|
assertEquals(1, nr.getExternSheetNumber());
|
||||||
assertEquals(1, nr.getNameDefinition().size());
|
assertEquals(1, nr.getNameDefinition().size());
|
||||||
|
|
||||||
Area3DPtg ptg = (Area3DPtg)nr.getNameDefinition().get(0);
|
ptg = (Area3DPtg)nr.getNameDefinition().get(0);
|
||||||
assertEquals(1, ptg.getExternSheetIndex());
|
assertEquals(1, ptg.getExternSheetIndex());
|
||||||
assertEquals(0, ptg.getFirstColumn());
|
assertEquals(0, ptg.getFirstColumn());
|
||||||
assertEquals(0, ptg.getFirstRow());
|
assertEquals(0, ptg.getFirstRow());
|
||||||
@ -430,10 +437,56 @@ public final class TestHSSFWorkbook extends TestCase {
|
|||||||
assertEquals(2, ptg.getLastRow());
|
assertEquals(2, ptg.getLastRow());
|
||||||
|
|
||||||
// Now at high level
|
// Now at high level
|
||||||
HSSFName n = b.getNameAt(0);
|
n = b.getNameAt(0);
|
||||||
assertEquals("On2", n.getNameName());
|
assertEquals("On2", n.getNameName());
|
||||||
assertEquals("", n.getSheetName());
|
assertEquals("", n.getSheetName());
|
||||||
assertEquals("#REF$A$1:$A$3", n.getReference());
|
assertEquals("#REF!$A$1:$A$3", n.getReference());
|
||||||
|
|
||||||
|
|
||||||
|
/* ======= Name pointing to 1st sheet ====== */
|
||||||
|
|
||||||
|
// First at low level
|
||||||
|
nr = b.getWorkbook().getNameRecord(1);
|
||||||
|
assertEquals("OnOne", nr.getNameText());
|
||||||
|
assertEquals(0, nr.getIndexToSheet());
|
||||||
|
assertEquals(0, nr.getExternSheetNumber());
|
||||||
|
assertEquals(1, nr.getNameDefinition().size());
|
||||||
|
|
||||||
|
ptg = (Area3DPtg)nr.getNameDefinition().get(0);
|
||||||
|
assertEquals(0, ptg.getExternSheetIndex());
|
||||||
|
assertEquals(0, ptg.getFirstColumn());
|
||||||
|
assertEquals(2, ptg.getFirstRow());
|
||||||
|
assertEquals(0, ptg.getLastColumn());
|
||||||
|
assertEquals(3, ptg.getLastRow());
|
||||||
|
|
||||||
|
// Now at high level
|
||||||
|
n = b.getNameAt(1);
|
||||||
|
assertEquals("OnOne", n.getNameName());
|
||||||
|
assertEquals("Sheet1", n.getSheetName());
|
||||||
|
assertEquals("Sheet1!$A$3:$A$4", n.getReference());
|
||||||
|
|
||||||
|
|
||||||
|
/* ======= Name pointing to 3rd sheet ====== */
|
||||||
|
|
||||||
|
// First at low level
|
||||||
|
nr = b.getWorkbook().getNameRecord(2);
|
||||||
|
assertEquals("OnSheet3", nr.getNameText());
|
||||||
|
assertEquals(0, nr.getIndexToSheet());
|
||||||
|
assertEquals(2, nr.getExternSheetNumber());
|
||||||
|
assertEquals(1, nr.getNameDefinition().size());
|
||||||
|
|
||||||
|
ptg = (Area3DPtg)nr.getNameDefinition().get(0);
|
||||||
|
assertEquals(2, ptg.getExternSheetIndex());
|
||||||
|
assertEquals(0, ptg.getFirstColumn());
|
||||||
|
assertEquals(0, ptg.getFirstRow());
|
||||||
|
assertEquals(0, ptg.getLastColumn());
|
||||||
|
assertEquals(1, ptg.getLastRow());
|
||||||
|
|
||||||
|
// Now at high level
|
||||||
|
n = b.getNameAt(2);
|
||||||
|
assertEquals("OnSheet3", n.getNameName());
|
||||||
|
assertEquals("Sheet3", n.getSheetName());
|
||||||
|
assertEquals("Sheet3!$A$1:$A$2", n.getReference());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user