aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2008-05-18 16:25:00 +0000
committerNick Burch <nick@apache.org>2008-05-18 16:25:00 +0000
commitd0fec10d56efe5047151c7c6e7f795581abfde43 (patch)
tree94eeacb2fe9a2024862f63a5652b8d0e6fb7ccd4 /src/testcases/org/apache/poi
parent4a3f50df569cbc73fe2cdc821f99af646370667f (diff)
downloadpoi-d0fec10d56efe5047151c7c6e7f795581abfde43.tar.gz
poi-d0fec10d56efe5047151c7c6e7f795581abfde43.zip
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653814,653817-653830,653832-653891,653893-653944,653946-654055,654057-654355,654357-654365,654367-654648,654651-655215,655217-655277,655279-655281,655283-655911,655913-656212,656214,656216-656251,656253-656698,656700-656756,656758-656892,656894-657135,657137-657578 via svnmerge from
https://svn.apache.org:443/repos/asf/poi/trunk ........ r657166 | josh | 2008-05-16 19:46:04 +0100 (Fri, 16 May 2008) | 1 line Simplification of BiffViewer. Made easier to send results to file. ........ r657167 | josh | 2008-05-16 19:55:02 +0100 (Fri, 16 May 2008) | 1 line Fix for bug 40414 - update selected/active sheet after removing sheet from workbook ........ r657180 | josh | 2008-05-16 20:24:47 +0100 (Fri, 16 May 2008) | 1 line fixed bug number in junit msg - from r656893 bug 44523 ........ r657355 | yegor | 2008-05-17 15:00:30 +0100 (Sat, 17 May 2008) | 1 line added HSSFName.isDeleted() to check if the name points to cell that no longer exists ........ r657358 | yegor | 2008-05-17 15:03:27 +0100 (Sat, 17 May 2008) | 1 line misc bug fixes ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@657579 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi')
-rwxr-xr-xsrc/testcases/org/apache/poi/hssf/data/24207.xlsbin0 -> 13824 bytes
-rwxr-xr-xsrc/testcases/org/apache/poi/hssf/data/36947.xlsbin0 -> 142336 bytes
-rwxr-xr-xsrc/testcases/org/apache/poi/hssf/data/39634.xlsbin0 -> 68608 bytes
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java41
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java81
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestNamedRange.java24
6 files changed, 142 insertions, 4 deletions
diff --git a/src/testcases/org/apache/poi/hssf/data/24207.xls b/src/testcases/org/apache/poi/hssf/data/24207.xls
new file mode 100755
index 0000000000..eca56425ef
--- /dev/null
+++ b/src/testcases/org/apache/poi/hssf/data/24207.xls
Binary files differ
diff --git a/src/testcases/org/apache/poi/hssf/data/36947.xls b/src/testcases/org/apache/poi/hssf/data/36947.xls
new file mode 100755
index 0000000000..4c7bde6c2a
--- /dev/null
+++ b/src/testcases/org/apache/poi/hssf/data/36947.xls
Binary files differ
diff --git a/src/testcases/org/apache/poi/hssf/data/39634.xls b/src/testcases/org/apache/poi/hssf/data/39634.xls
new file mode 100755
index 0000000000..0f76bffe47
--- /dev/null
+++ b/src/testcases/org/apache/poi/hssf/data/39634.xls
Binary files differ
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
index 2985278c54..0a55d65087 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
@@ -911,4 +911,45 @@ public final class TestBugs extends TestCase {
writeOutAndReadBack(wb);
assertTrue("no errors writing sample xls", true);
}
+
+ /**
+ * Bug 21334: "File error: data may have been lost" with a file
+ * that contains macros and this formula:
+ * {=SUM(IF(FREQUENCY(IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),""),IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),""))>0,1))}
+ */
+ public void test21334() {
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFSheet sh = wb.createSheet();
+ HSSFCell cell = sh.createRow(0).createCell((short)0);
+ String formula = "SUM(IF(FREQUENCY(IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),\"\"),IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),\"\"))>0,1))";
+ cell.setCellFormula(formula);
+
+ HSSFWorkbook wb_sv = writeOutAndReadBack(wb);
+ HSSFCell cell_sv = wb_sv.getSheetAt(0).getRow(0).getCell((short)0);
+ assertEquals(formula, cell_sv.getCellFormula());
+ }
+
+ public void test36947() throws Exception {
+ HSSFWorkbook wb = openSample("36947.xls");
+ assertTrue("no errors reading sample xls", true);
+ writeOutAndReadBack(wb);
+ assertTrue("no errors writing sample xls", true);
+ }
+
+ /**
+ * Bug 42448: Can't parse SUMPRODUCT(A!C7:A!C67, B8:B68) / B69
+ */
+ public void test42448(){
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFCell cell = wb.createSheet().createRow(0).createCell((short)0);
+ cell.setCellFormula("SUMPRODUCT(A!C7:A!C67, B8:B68) / B69");
+ assertTrue("no errors parsing formula", true);
+ }
+
+ public void test39634() throws Exception {
+ HSSFWorkbook wb = openSample("39634.xls");
+ assertTrue("no errors reading sample xls", true);
+ writeOutAndReadBack(wb);
+ assertTrue("no errors writing sample xls", true);
+ }
}
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
index e1afb453bc..cb5b3d3554 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
@@ -232,11 +232,11 @@ public final class TestHSSFWorkbook extends TestCase {
// Demonstrate bug 44525:
// Well... not quite, since isActive + isSelected were also added in the same bug fix
if (sheet1.isSelected()) {
- throw new AssertionFailedError("Identified bug 44525 a");
+ throw new AssertionFailedError("Identified bug 44523 a");
}
wb.setActiveSheet(1);
if (sheet1.isActive()) {
- throw new AssertionFailedError("Identified bug 44525 b");
+ throw new AssertionFailedError("Identified bug 44523 b");
}
confirmActiveSelected(sheet1, false);
@@ -299,8 +299,81 @@ public final class TestHSSFWorkbook extends TestCase {
}
}
+
+ public void testActiveSheetAfterDelete_bug40414() {
+ HSSFWorkbook wb=new HSSFWorkbook();
+ HSSFSheet sheet0 = wb.createSheet("Sheet0");
+ HSSFSheet sheet1 = wb.createSheet("Sheet1");
+ HSSFSheet sheet2 = wb.createSheet("Sheet2");
+ HSSFSheet sheet3 = wb.createSheet("Sheet3");
+ HSSFSheet sheet4 = wb.createSheet("Sheet4");
+
+ // confirm default activation/selection
+ confirmActiveSelected(sheet0, true);
+ confirmActiveSelected(sheet1, false);
+ confirmActiveSelected(sheet2, false);
+ confirmActiveSelected(sheet3, false);
+ confirmActiveSelected(sheet4, false);
+
+ wb.setActiveSheet(3);
+ wb.setSelectedTab(3);
+
+ confirmActiveSelected(sheet0, false);
+ confirmActiveSelected(sheet1, false);
+ confirmActiveSelected(sheet2, false);
+ confirmActiveSelected(sheet3, true);
+ confirmActiveSelected(sheet4, false);
+
+ wb.removeSheetAt(3);
+ // after removing the only active/selected sheet, another should be active/selected in its place
+ if (!sheet4.isSelected()) {
+ throw new AssertionFailedError("identified bug 40414 a");
+ }
+ if (!sheet4.isActive()) {
+ throw new AssertionFailedError("identified bug 40414 b");
+ }
+
+ confirmActiveSelected(sheet0, false);
+ confirmActiveSelected(sheet1, false);
+ confirmActiveSelected(sheet2, false);
+ confirmActiveSelected(sheet4, true);
+
+ sheet3 = sheet4; // re-align local vars in this test case
+
+ // Some more cases of removing sheets
+
+ // Starting with a multiple selection, and different active sheet
+ wb.setSelectedTabs(new int[] { 1, 3, });
+ wb.setActiveSheet(2);
+ confirmActiveSelected(sheet0, false, false);
+ confirmActiveSelected(sheet1, false, true);
+ confirmActiveSelected(sheet2, true, false);
+ confirmActiveSelected(sheet3, false, true);
+
+ // removing a sheet that is not active, and not the only selected sheet
+ wb.removeSheetAt(3);
+ confirmActiveSelected(sheet0, false, false);
+ confirmActiveSelected(sheet1, false, true);
+ confirmActiveSelected(sheet2, true, false);
+
+ // removing the only selected sheet
+ wb.removeSheetAt(1);
+ confirmActiveSelected(sheet0, false, false);
+ confirmActiveSelected(sheet2, true, true);
+
+ // The last remaining sheet should always be active+selected
+ wb.removeSheetAt(1);
+ confirmActiveSelected(sheet0, true, true);
+ }
+
private static void confirmActiveSelected(HSSFSheet sheet, boolean expected) {
- assertEquals(expected, sheet.isActive());
- assertEquals(expected, sheet.isSelected());
+ confirmActiveSelected(sheet, expected, expected);
+ }
+
+
+ private static void confirmActiveSelected(HSSFSheet sheet,
+ boolean expectedActive, boolean expectedSelected) {
+ assertEquals("active", expectedActive, sheet.isActive());
+ assertEquals("selected", expectedSelected, sheet.isSelected());
}
}
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestNamedRange.java b/src/testcases/org/apache/poi/hssf/usermodel/TestNamedRange.java
index 98500960da..b3d08bf724 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestNamedRange.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestNamedRange.java
@@ -533,4 +533,28 @@ public final class TestNamedRange extends TestCase {
String contents = c.getStringCellValue();
assertEquals("Contents of cell retrieved by its named reference", contents, cvalue);
}
+
+ public void testDeletedReference() throws Exception {
+ HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("24207.xls");
+ assertEquals(2, wb.getNumberOfNames());
+
+ HSSFName name1 = wb.getNameAt(0);
+ assertEquals("a", name1.getNameName());
+ assertEquals("Sheet1!$A$1", name1.getReference());
+ AreaReference ref1 = new AreaReference(name1.getReference());
+ assertTrue("Successfully constructed first reference", true);
+
+ HSSFName name2 = wb.getNameAt(1);
+ assertEquals("b", name2.getNameName());
+ assertEquals("#REF!", name2.getReference());
+ assertTrue(name2.isDeleted());
+ try {
+ AreaReference ref2 = new AreaReference(name2.getReference());
+ fail("attempt to supply an invalid reference to AreaReference constructor results in exception");
+ } catch (Exception e){
+ ;
+ }
+
+ }
+
}