You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/02/15 21:27:59 UTC

svn commit: r1730606 - in /poi/trunk: src/java/org/apache/poi/ss/formula/functions/Offset.java test-data/spreadsheet/FormulaEvalTestData.xls test-data/spreadsheet/FormulaEvalTestData_Copy.xlsx

Author: onealj
Date: Mon Feb 15 20:27:59 2016
New Revision: 1730606

URL: http://svn.apache.org/viewvc?rev=1730606&view=rev
Log:
bug 58339: patch from Patrick Zimmermann to allow OFFSET() to accept missing optional width or height parameters

Modified:
    poi/trunk/src/java/org/apache/poi/ss/formula/functions/Offset.java
    poi/trunk/test-data/spreadsheet/FormulaEvalTestData.xls
    poi/trunk/test-data/spreadsheet/FormulaEvalTestData_Copy.xlsx

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/Offset.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/Offset.java?rev=1730606&r1=1730605&r2=1730606&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/functions/Offset.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/Offset.java Mon Feb 15 20:27:59 2016
@@ -20,6 +20,7 @@ package org.apache.poi.ss.formula.functi
 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 Fun
 			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) {

Modified: poi/trunk/test-data/spreadsheet/FormulaEvalTestData.xls
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/FormulaEvalTestData.xls?rev=1730606&r1=1730605&r2=1730606&view=diff
==============================================================================
Binary files - no diff available.

Modified: poi/trunk/test-data/spreadsheet/FormulaEvalTestData_Copy.xlsx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/FormulaEvalTestData_Copy.xlsx?rev=1730606&r1=1730605&r2=1730606&view=diff
==============================================================================
Binary files - no diff available.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org