Author: cedricwalter Date: Mon Oct 7 09:42:38 2013 New Revision: 1529809 URL: http://svn.apache.org/r1529809 Log: Bug 55037: patch for missing function DELTA Add missing TestDeltaFunctionsFromSpreadsheet and register Delta in AnalysisToolPak
Added: poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/TestDeltaFunctionsFromSpreadsheet.java poi/trunk/test-data/spreadsheet/DeltaFunctionTestCaseData.xls (with props) Modified: poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java poi/trunk/src/java/org/apache/poi/ss/formula/functions/Delta.java Modified: poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java?rev=1529809&r1=1529808&r2=1529809&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java (original) +++ poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java Mon Oct 7 09:42:38 2013 @@ -91,7 +91,7 @@ public final class AnalysisToolPak imple r(m, "DEC2BIN", null); r(m, "DEC2HEX", null); r(m, "DEC2OCT", null); - r(m, "DELTA", null); + r(m, "DELTA", Delta.instance); r(m, "DISC", null); r(m, "DOLLARDE", null); r(m, "DOLLARFR", null); Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/Delta.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/Delta.java?rev=1529809&r1=1529808&r2=1529809&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/ss/formula/functions/Delta.java (original) +++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/Delta.java Mon Oct 7 09:42:38 2013 @@ -17,6 +17,7 @@ package org.apache.poi.ss.formula.functions; +import org.apache.poi.ss.formula.OperationEvaluationContext; import org.apache.poi.ss.formula.eval.*; import java.math.BigDecimal; @@ -37,7 +38,9 @@ import java.math.BigDecimal; * * @author cedric dot walter @ gmail dot com */ -public final class Delta extends Fixed2ArgFunction { +public final class Delta extends Fixed2ArgFunction implements FreeRefFunction { + + public static final FreeRefFunction instance = new Delta(); private final static NumberEval ONE = new NumberEval(1); private final static NumberEval ZERO = new NumberEval(0); @@ -72,4 +75,11 @@ public final class Delta extends Fixed2A return result == 0 ? ONE : ZERO; } + public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) { + if (args.length == 2) { + return evaluate(ec.getRowIndex(), ec.getColumnIndex(), args[0], args[1]); + } + + return ErrorEval.VALUE_INVALID; + } } \ No newline at end of file Added: poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/TestDeltaFunctionsFromSpreadsheet.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/TestDeltaFunctionsFromSpreadsheet.java?rev=1529809&view=auto ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/TestDeltaFunctionsFromSpreadsheet.java (added) +++ poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/TestDeltaFunctionsFromSpreadsheet.java Mon Oct 7 09:42:38 2013 @@ -0,0 +1,13 @@ +package org.apache.poi.ss.formula.functions; + +/** +* Tests DELTA() as loaded from a test data spreadsheet.<p/> +* +* @author cedric dot walter @ gmail dot com +*/ +public class TestDeltaFunctionsFromSpreadsheet extends BaseTestFunctionsFromSpreadsheet { + + protected String getFilename() { + return "DeltaFunctionTestCaseData.xls"; + } +} Added: poi/trunk/test-data/spreadsheet/DeltaFunctionTestCaseData.xls URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/DeltaFunctionTestCaseData.xls?rev=1529809&view=auto ============================================================================== Binary file - no diff available. Propchange: poi/trunk/test-data/spreadsheet/DeltaFunctionTestCaseData.xls ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org For additional commands, e-mail: commits-h...@poi.apache.org