aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJaven O'Neal <onealj@apache.org>2016-02-15 20:27:59 +0000
committerJaven O'Neal <onealj@apache.org>2016-02-15 20:27:59 +0000
commitb6a21ab3aa2e2b1ab04c3af4f9b0d0cbdc4fa710 (patch)
treeb431b1e1672c4b4a74e821d89fc5343007baa395 /src
parente7729d8b1b74aa06c146e899d4f40a4e910e8e5a (diff)
downloadpoi-b6a21ab3aa2e2b1ab04c3af4f9b0d0cbdc4fa710.tar.gz
poi-b6a21ab3aa2e2b1ab04c3af4f9b0d0cbdc4fa710.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/poi/ss/formula/functions/Offset.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/java/org/apache/poi/ss/formula/functions/Offset.java b/src/java/org/apache/poi/ss/formula/functions/Offset.java
index d9f240d67e..cffa26a4c4 100644
--- a/src/java/org/apache/poi/ss/formula/functions/Offset.java
+++ b/src/java/org/apache/poi/ss/formula/functions/Offset.java
@@ -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.ErrorEval;
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.RefEval;
import org.apache.poi.ss.formula.eval.ValueEval;
@@ -171,11 +172,17 @@ public final class Offset implements Function {
int columnOffset = evaluateIntArg(args[2], srcCellRow, srcCellCol);
int height = baseRef.getHeight();
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) {
case 5:
- width = evaluateIntArg(args[4], srcCellRow, srcCellCol);
+ if(!(args[4] instanceof MissingArgEval)) {
+ width = evaluateIntArg(args[4], srcCellRow, srcCellCol);
+ }
case 4:
- height = evaluateIntArg(args[3], srcCellRow, srcCellCol);
+ if(!(args[3] instanceof MissingArgEval)) {
+ height = evaluateIntArg(args[3], srcCellRow, srcCellCol);
+ }
}
// Zero height or width raises #REF! error
if(height == 0 || width == 0) {