package org.apache.poi.hssf.record.formula.functions;
+import org.apache.poi.hssf.record.formula.eval.AreaEval;
import org.apache.poi.hssf.record.formula.eval.BoolEval;
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
import org.apache.poi.hssf.record.formula.eval.Eval;
* Super class for all Evals for financial function evaluation.
*
*/
-public abstract class FinanceFunction extends NumericFunction {
+public abstract class FinanceFunction implements Function {
private static final ValueEvalToNumericXlator DEFAULT_NUM_XLATOR =
new ValueEvalToNumericXlator((short) (0
| ValueEvalToNumericXlator.BOOL_IS_PARSED
}
return retval;
}
+
+ protected final ValueEval singleOperandEvaluate(Eval eval, int srcRow, short srcCol) {
+
+ if (eval instanceof AreaEval) {
+ AreaEval ae = (AreaEval) eval;
+ if (ae.contains(srcRow, srcCol)) { // circular ref!
+ return ErrorEval.CIRCULAR_REF_ERROR;
+ }
+ if (ae.isRow()) {
+ if (ae.isColumn()) {
+ return ae.getRelativeValue(0, 0);
+ }
+ if (ae.containsColumn(srcCol)) {
+ ValueEval ve = ae.getValueAt(ae.getFirstRow(), srcCol);
+ ve = getXlator().attemptXlateToNumeric(ve);
+ return getXlator().attemptXlateToNumeric(ve);
+ }
+ return ErrorEval.VALUE_INVALID;
+ }
+ if (ae.isColumn()) {
+ if (ae.containsRow(srcRow)) {
+ ValueEval ve = ae.getValueAt(srcRow, ae.getFirstColumn());
+ return getXlator().attemptXlateToNumeric(ve);
+ }
+ return ErrorEval.VALUE_INVALID;
+ }
+ return ErrorEval.VALUE_INVALID;
+ }
+ return getXlator().attemptXlateToNumeric((ValueEval) eval);
+ }
+
}
import org.apache.poi.hssf.record.formula.eval.AreaEval;
import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
import org.apache.poi.hssf.record.formula.eval.Eval;
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
import org.apache.poi.hssf.record.formula.eval.Ref2DEval;
* classes that take variable number of operands, and
* where the order of operands does not matter
*/
-public abstract class MultiOperandNumericFunction extends NumericFunction {
+public abstract class MultiOperandNumericFunction implements Function {
static final double[] EMPTY_DOUBLE_ARRAY = { };
private static class DoubleList {
}
+ protected final ValueEval singleOperandEvaluate(Eval eval, int srcRow, short srcCol) {
+
+ if (eval instanceof AreaEval) {
+ AreaEval ae = (AreaEval) eval;
+ if (ae.contains(srcRow, srcCol)) { // circular ref!
+ return ErrorEval.CIRCULAR_REF_ERROR;
+ }
+ if (ae.isRow()) {
+ if (ae.isColumn()) {
+ return ae.getRelativeValue(0, 0);
+ }
+ if (ae.containsColumn(srcCol)) {
+ ValueEval ve = ae.getValueAt(ae.getFirstRow(), srcCol);
+ ve = getXlator().attemptXlateToNumeric(ve);
+ return getXlator().attemptXlateToNumeric(ve);
+ }
+ return ErrorEval.VALUE_INVALID;
+ }
+ if (ae.isColumn()) {
+ if (ae.containsRow(srcRow)) {
+ ValueEval ve = ae.getValueAt(srcRow, ae.getFirstColumn());
+ return getXlator().attemptXlateToNumeric(ve);
+ }
+ return ErrorEval.VALUE_INVALID;
+ }
+ return ErrorEval.VALUE_INVALID;
+ }
+ return getXlator().attemptXlateToNumeric((ValueEval) eval);
+ }
}