diff options
author | Yegor Kozlov <yegor@apache.org> | 2013-06-02 23:25:07 +0000 |
---|---|---|
committer | Yegor Kozlov <yegor@apache.org> | 2013-06-02 23:25:07 +0000 |
commit | 782fd29471780a941ae63315cbe7373c352a2121 (patch) | |
tree | 18fc8bbbcb14383c7ca2396383a587ddd4296043 | |
parent | 24967623a9c23d1b3fb602fd7e4719ec908b72fc (diff) | |
download | poi-782fd29471780a941ae63315cbe7373c352a2121.tar.gz poi-782fd29471780a941ae63315cbe7373c352a2121.zip |
added missing tests for Bug 55042: patch for missing function COMPLEX
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1488808 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java | 6 | ||||
-rw-r--r-- | src/java/org/apache/poi/ss/formula/functions/Complex.java | 16 | ||||
-rw-r--r-- | test-data/spreadsheet/ComplexFunctionTestCaseData.xls | bin | 0 -> 28160 bytes |
3 files changed, 17 insertions, 5 deletions
diff --git a/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java b/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java index 28215641fd..373b653827 100644 --- a/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java +++ b/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java @@ -15,9 +15,7 @@ import org.apache.poi.ss.formula.eval.NotImplementedException; import org.apache.poi.ss.formula.eval.ValueEval; import org.apache.poi.ss.formula.function.FunctionMetadata; import org.apache.poi.ss.formula.function.FunctionMetadataRegistry; -import org.apache.poi.ss.formula.functions.EDate; -import org.apache.poi.ss.formula.functions.FreeRefFunction; -import org.apache.poi.ss.formula.functions.Sumifs; +import org.apache.poi.ss.formula.functions.*; import org.apache.poi.ss.formula.udf.UDFFinder; import java.util.*; @@ -74,7 +72,7 @@ public final class AnalysisToolPak implements UDFFinder { r(m, "BIN2DEC", null); r(m, "BIN2HEX", null); r(m, "BIN2OCT", null); - r(m, "COMPLEX", null); + r(m, "COMPLEX", Complex.instance); r(m, "CONVERT", null); r(m, "COUNTIFS", null); r(m, "COUPDAYBS", null); diff --git a/src/java/org/apache/poi/ss/formula/functions/Complex.java b/src/java/org/apache/poi/ss/formula/functions/Complex.java index d37ab70def..0c39811028 100644 --- a/src/java/org/apache/poi/ss/formula/functions/Complex.java +++ b/src/java/org/apache/poi/ss/formula/functions/Complex.java @@ -1,5 +1,6 @@ package org.apache.poi.ss.formula.functions;
+import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.*;
/**
@@ -30,7 +31,9 @@ import org.apache.poi.ss.formula.eval.*; *
* @author cedric dot walter @ gmail dot com
*/
-public class Complex extends Var2or3ArgFunction {
+public class Complex extends Var2or3ArgFunction implements FreeRefFunction {
+
+ public static final FreeRefFunction instance = new Complex();
public static final String DEFAULT_SUFFIX = "i";
public static final String SUPPORTED_SUFFIX = "j";
@@ -116,4 +119,15 @@ public class Complex extends Var2or3ArgFunction { return (number == Math.floor(number)) && !Double.isInfinite(number);
}
+ @Override
+ public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
+ if (args.length == 2) {
+ return evaluate(ec.getRowIndex(), ec.getColumnIndex(), args[0], args[1]);
+ }
+ if (args.length == 3) {
+ return evaluate(ec.getRowIndex(), ec.getColumnIndex(), args[0], args[1], args[2]);
+ }
+
+ return ErrorEval.VALUE_INVALID;
+ }
}
diff --git a/test-data/spreadsheet/ComplexFunctionTestCaseData.xls b/test-data/spreadsheet/ComplexFunctionTestCaseData.xls Binary files differnew file mode 100644 index 0000000000..0d72e7d14d --- /dev/null +++ b/test-data/spreadsheet/ComplexFunctionTestCaseData.xls |