diff options
author | Nick Burch <nick@apache.org> | 2014-07-19 21:27:28 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2014-07-19 21:27:28 +0000 |
commit | d3104416320eb3f040d1969cc09b368c2b837c40 (patch) | |
tree | f469727d035047b69d61de4f0765deb460c23a83 /src/java/org/apache/poi | |
parent | 85936fcbdb31846a1cafb1e7803c301455b473fc (diff) | |
download | poi-d3104416320eb3f040d1969cc09b368c2b837c40.tar.gz poi-d3104416320eb3f040d1969cc09b368c2b837c40.zip |
Better reporting on why a test is failing, and partial NameXPxg eval
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1611969 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi')
-rw-r--r-- | src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java | 20 | ||||
-rw-r--r-- | src/java/org/apache/poi/ss/formula/eval/NameXEval.java | 3 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java b/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java index ec3f984315..6dd5dd2068 100644 --- a/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java +++ b/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java @@ -62,6 +62,7 @@ import org.apache.poi.ss.formula.ptg.MemFuncPtg; import org.apache.poi.ss.formula.ptg.MissingArgPtg; import org.apache.poi.ss.formula.ptg.NamePtg; import org.apache.poi.ss.formula.ptg.NameXPtg; +import org.apache.poi.ss.formula.ptg.NameXPxg; import org.apache.poi.ss.formula.ptg.NumberPtg; import org.apache.poi.ss.formula.ptg.OperationPtg; import org.apache.poi.ss.formula.ptg.Ptg; @@ -650,6 +651,25 @@ public final class WorkbookEvaluator { return eval; } } + if (ptg instanceof NameXPxg) { + // TODO This is a temporary hack.... + NameXPxg pxg = (NameXPxg)ptg; + int sIdx = -1; + if (pxg.getSheetName() != null) { + sIdx = _workbook.getSheetIndex(pxg.getSheetName()); + } + EvaluationName evalName = _workbook.getName(pxg.getNameName(), sIdx); + if (evalName == null) { + // We don't know about that name, sorry + // TODO What about UDFs? + logInfo("Unknown Name referenced: " + pxg.getNameName()); + return ErrorEval.NAME_INVALID; + } + + int nIdx = evalName.createPtg().getIndex(); + NameXPtg nptg = new NameXPtg(sIdx, nIdx); + return getEvalForPtg(nptg, ec); + } if (ptg instanceof IntPtg) { return new NumberEval(((IntPtg)ptg).getValue()); diff --git a/src/java/org/apache/poi/ss/formula/eval/NameXEval.java b/src/java/org/apache/poi/ss/formula/eval/NameXEval.java index 32831bc258..e7e9bf881a 100644 --- a/src/java/org/apache/poi/ss/formula/eval/NameXEval.java +++ b/src/java/org/apache/poi/ss/formula/eval/NameXEval.java @@ -20,10 +20,9 @@ package org.apache.poi.ss.formula.eval; import org.apache.poi.ss.formula.ptg.NameXPtg; /** - * @author Josh Micich + * Evaluation of a Name defined in a Sheet or Workbook scope */ public final class NameXEval implements ValueEval { - private final NameXPtg _ptg; public NameXEval(NameXPtg ptg) { |