public org.apache.poi.hssf.record.formula.eval.Eval | evaluate(org.apache.poi.hssf.record.formula.eval.Eval[] operands, int srcRow, short srcCol)
ValueEval retval = null;
boolean b = true;
ValueEval tempVe = null;
switch (operands.length) {
default:
retval = ErrorEval.VALUE_INVALID;
break;
case 1:
if (operands[0] instanceof AreaEval) {
AreaEval ae = (AreaEval) operands[0];
if (ae.isRow() && ae.containsColumn(srcCol)) {
ValueEval ve = ae.getValueAt(ae.getFirstRow(), srcCol);
tempVe = singleOperandEvaluate(ve);
} else if (ae.isColumn() && ae.containsRow(srcRow)) {
ValueEval ve = ae.getValueAt(srcRow, ae.getFirstColumn());
tempVe = singleOperandEvaluate(ve);
} else {
retval = ErrorEval.VALUE_INVALID;
}
}
else {
tempVe = singleOperandEvaluate(operands[0]);
if (tempVe instanceof StringEval) {
retval = ErrorEval.VALUE_INVALID;
}
else if (tempVe instanceof ErrorEval) {
retval = tempVe;
}
}
}
if (retval == null) { // if no error
if (tempVe instanceof BoolEval) {
b = b && ((BoolEval) tempVe).getBooleanValue();
}
else if (tempVe instanceof StringEval) {
retval = ErrorEval.VALUE_INVALID;
}
else if (tempVe instanceof ErrorEval) {
retval = tempVe;
}
retval = b ? BoolEval.FALSE : BoolEval.TRUE;
}
return retval;
|