rowIx = pRowIx == -1 ? 0 : pRowIx;
columnIx = pColumnIx;
}
}
if (rowIx < -1 || columnIx < -1) {
throw new EvaluationException(ErrorEval.VALUE_INVALID);
}
} else if (ae.isColumn()) {
if (nArgs == 2) {
rowIx = pRowIx;
columnIx = 0;
} else {
rowIx = pRowIx;
columnIx = pColumnIx == -1 ? 0 : pColumnIx;
}
if (rowIx < -1 || columnIx < -1) {
throw new EvaluationException(ErrorEval.VALUE_INVALID);
}
} else {
if (nArgs == 2) {
// always an error with 2-D area refs
if (pRowIx < -1) {
throw new EvaluationException(ErrorEval.VALUE_INVALID);
}
throw new EvaluationException(ErrorEval.REF_INVALID);
}
// Normal case - area ref is 2-D, and both index args were provided
rowIx = pRowIx;
columnIx = pColumnIx;
}
int width = ae.getWidth();
int height = ae.getHeight();
// Slightly irregular logic for bounds checking errors
if (rowIx >= height || columnIx >= width) {
throw new EvaluationException(ErrorEval.REF_INVALID);
}
if (rowIx < 0 || columnIx < 0) {
throw new EvaluationException(ErrorEval.VALUE_INVALID);
}
return ae.getRelativeValue(rowIx, columnIx);
}