mirror of https://github.com/apache/poi.git
bug 58339: patch from Patrick Zimmermann to allow OFFSET() to accept missing optional width or height parameters
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1730606 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e7729d8b1b
commit
b6a21ab3aa
|
@ -20,6 +20,7 @@ package org.apache.poi.ss.formula.functions;
|
||||||
import org.apache.poi.ss.formula.eval.AreaEval;
|
import org.apache.poi.ss.formula.eval.AreaEval;
|
||||||
import org.apache.poi.ss.formula.eval.ErrorEval;
|
import org.apache.poi.ss.formula.eval.ErrorEval;
|
||||||
import org.apache.poi.ss.formula.eval.EvaluationException;
|
import org.apache.poi.ss.formula.eval.EvaluationException;
|
||||||
|
import org.apache.poi.ss.formula.eval.MissingArgEval;
|
||||||
import org.apache.poi.ss.formula.eval.OperandResolver;
|
import org.apache.poi.ss.formula.eval.OperandResolver;
|
||||||
import org.apache.poi.ss.formula.eval.RefEval;
|
import org.apache.poi.ss.formula.eval.RefEval;
|
||||||
import org.apache.poi.ss.formula.eval.ValueEval;
|
import org.apache.poi.ss.formula.eval.ValueEval;
|
||||||
|
@ -171,12 +172,18 @@ public final class Offset implements Function {
|
||||||
int columnOffset = evaluateIntArg(args[2], srcCellRow, srcCellCol);
|
int columnOffset = evaluateIntArg(args[2], srcCellRow, srcCellCol);
|
||||||
int height = baseRef.getHeight();
|
int height = baseRef.getHeight();
|
||||||
int width = baseRef.getWidth();
|
int width = baseRef.getWidth();
|
||||||
|
// optional arguments
|
||||||
|
// If height or width is omitted, it is assumed to be the same height or width as reference.
|
||||||
switch(args.length) {
|
switch(args.length) {
|
||||||
case 5:
|
case 5:
|
||||||
|
if(!(args[4] instanceof MissingArgEval)) {
|
||||||
width = evaluateIntArg(args[4], srcCellRow, srcCellCol);
|
width = evaluateIntArg(args[4], srcCellRow, srcCellCol);
|
||||||
|
}
|
||||||
case 4:
|
case 4:
|
||||||
|
if(!(args[3] instanceof MissingArgEval)) {
|
||||||
height = evaluateIntArg(args[3], srcCellRow, srcCellCol);
|
height = evaluateIntArg(args[3], srcCellRow, srcCellCol);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Zero height or width raises #REF! error
|
// Zero height or width raises #REF! error
|
||||||
if(height == 0 || width == 0) {
|
if(height == 0 || width == 0) {
|
||||||
return ErrorEval.REF_INVALID;
|
return ErrorEval.REF_INVALID;
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue