aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf/model
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2014-07-18 18:30:16 +0000
committerNick Burch <nick@apache.org>2014-07-18 18:30:16 +0000
commit9b36a0dd9ff5f934aae217179b78e5526ffaab0e (patch)
tree295614e627fe402161a42c14a1ad3205e3f5cc14 /src/testcases/org/apache/poi/hssf/model
parent6372368ef3a78b729ae14fcd3d9090c39e00785e (diff)
downloadpoi-9b36a0dd9ff5f934aae217179b78e5526ffaab0e.tar.gz
poi-9b36a0dd9ff5f934aae217179b78e5526ffaab0e.zip
Start to support formula parsing of sheet-specified named ranges, required for a full fix to bug #56737
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1611753 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/model')
-rw-r--r--src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java39
-rw-r--r--src/testcases/org/apache/poi/hssf/model/TestLinkTable.java14
2 files changed, 47 insertions, 6 deletions
diff --git a/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java b/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
index fa872e1e31..59faa04303 100644
--- a/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
+++ b/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
@@ -37,7 +37,40 @@ import org.apache.poi.ss.formula.FormulaParseException;
import org.apache.poi.ss.formula.FormulaParser;
import org.apache.poi.ss.formula.FormulaType;
import org.apache.poi.ss.formula.constant.ErrorConstant;
-import org.apache.poi.ss.formula.ptg.*;
+import org.apache.poi.ss.formula.ptg.AbstractFunctionPtg;
+import org.apache.poi.ss.formula.ptg.AddPtg;
+import org.apache.poi.ss.formula.ptg.Area3DPtg;
+import org.apache.poi.ss.formula.ptg.AreaI;
+import org.apache.poi.ss.formula.ptg.AreaPtg;
+import org.apache.poi.ss.formula.ptg.AreaPtgBase;
+import org.apache.poi.ss.formula.ptg.ArrayPtg;
+import org.apache.poi.ss.formula.ptg.AttrPtg;
+import org.apache.poi.ss.formula.ptg.BoolPtg;
+import org.apache.poi.ss.formula.ptg.ConcatPtg;
+import org.apache.poi.ss.formula.ptg.DividePtg;
+import org.apache.poi.ss.formula.ptg.EqualPtg;
+import org.apache.poi.ss.formula.ptg.ErrPtg;
+import org.apache.poi.ss.formula.ptg.FuncPtg;
+import org.apache.poi.ss.formula.ptg.FuncVarPtg;
+import org.apache.poi.ss.formula.ptg.IntPtg;
+import org.apache.poi.ss.formula.ptg.MemAreaPtg;
+import org.apache.poi.ss.formula.ptg.MemFuncPtg;
+import org.apache.poi.ss.formula.ptg.MissingArgPtg;
+import org.apache.poi.ss.formula.ptg.MultiplyPtg;
+import org.apache.poi.ss.formula.ptg.NamePtg;
+import org.apache.poi.ss.formula.ptg.NumberPtg;
+import org.apache.poi.ss.formula.ptg.ParenthesisPtg;
+import org.apache.poi.ss.formula.ptg.PercentPtg;
+import org.apache.poi.ss.formula.ptg.PowerPtg;
+import org.apache.poi.ss.formula.ptg.Ptg;
+import org.apache.poi.ss.formula.ptg.RangePtg;
+import org.apache.poi.ss.formula.ptg.Ref3DPtg;
+import org.apache.poi.ss.formula.ptg.RefPtg;
+import org.apache.poi.ss.formula.ptg.StringPtg;
+import org.apache.poi.ss.formula.ptg.SubtractPtg;
+import org.apache.poi.ss.formula.ptg.UnaryMinusPtg;
+import org.apache.poi.ss.formula.ptg.UnaryPlusPtg;
+import org.apache.poi.ss.formula.ptg.UnionPtg;
import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
import org.apache.poi.ss.usermodel.Name;
import org.apache.poi.util.HexRead;
@@ -1175,7 +1208,9 @@ public final class TestFormulaParser extends TestCase {
confirmParseError(wb, "A1:ROUND(B1,1)", "The RHS of the range operator ':' at position 3 is not a proper reference.");
- confirmParseError(wb, "Sheet1!Sheet1", "Cell reference expected after sheet name at index 8.");
+ confirmParseError(wb, "Sheet1!!!", "Parse error near char 7 '!' in specified formula 'Sheet1!!!'. Expected number, string, or defined name");
+ confirmParseError(wb, "Sheet1!.Name", "Parse error near char 7 '.' in specified formula 'Sheet1!.Name'. Expected number, string, or defined name");
+ confirmParseError(wb, "Sheet1!Sheet1", "Specified name 'Sheet1' for sheet Sheet1 not found");
confirmParseError(wb, "Sheet1!F:Sheet1!G", "'Sheet1!F' is not a proper reference.");
confirmParseError(wb, "Sheet1!F..foobar", "Complete area reference expected after sheet name at index 11.");
confirmParseError(wb, "Sheet1!A .. B", "Dotted range (full row or column) expression 'A .. B' must not contain whitespace.");
diff --git a/src/testcases/org/apache/poi/hssf/model/TestLinkTable.java b/src/testcases/org/apache/poi/hssf/model/TestLinkTable.java
index 48c81ea0bb..4f25a1d08c 100644
--- a/src/testcases/org/apache/poi/hssf/model/TestLinkTable.java
+++ b/src/testcases/org/apache/poi/hssf/model/TestLinkTable.java
@@ -211,13 +211,19 @@ public final class TestLinkTable extends TestCase {
ExternSheetRecord extSheet = (ExternSheetRecord)wrl.get(3);
assertEquals(0, extSheet.getNumOfRefs());
- assertNull(tbl.getNameXPtg("ISODD"));
+ assertNull(tbl.getNameXPtg("ISODD", -1));
assertEquals(5, wrl.getRecords().size()); //still have five records
NameXPtg namex1 = tbl.addNameXPtg("ISODD"); // adds two new rercords
assertEquals(0, namex1.getSheetRefIndex());
assertEquals(0, namex1.getNameIndex());
- assertEquals(namex1.toString(), tbl.getNameXPtg("ISODD").toString());
+ assertEquals(namex1.toString(), tbl.getNameXPtg("ISODD", -1).toString());
+
+ // Can only find on the right sheet ref, if restricting
+ assertEquals(namex1.toString(), tbl.getNameXPtg("ISODD", 0).toString());
+ assertNull(tbl.getNameXPtg("ISODD", 1));
+ assertNull(tbl.getNameXPtg("ISODD", 2));
+
// assure they are in place:
// [BOFRecord]
// [CountryRecord]
@@ -241,11 +247,11 @@ public final class TestLinkTable extends TestCase {
assertEquals(0, tbl.resolveNameXIx(namex1.getSheetRefIndex(), namex1.getNameIndex()));
assertEquals("ISODD", tbl.resolveNameXText(namex1.getSheetRefIndex(), namex1.getNameIndex(), null));
- assertNull(tbl.getNameXPtg("ISEVEN"));
+ assertNull(tbl.getNameXPtg("ISEVEN", -1));
NameXPtg namex2 = tbl.addNameXPtg("ISEVEN"); // adds two new rercords
assertEquals(0, namex2.getSheetRefIndex());
assertEquals(1, namex2.getNameIndex()); // name index increased by one
- assertEquals(namex2.toString(), tbl.getNameXPtg("ISEVEN").toString());
+ assertEquals(namex2.toString(), tbl.getNameXPtg("ISEVEN", -1).toString());
assertEquals(8, wrl.getRecords().size());
// assure they are in place:
// [BOFRecord]