poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1488808 - in /poi/trunk: src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java src/java/org/apache/poi/ss/formula/functions/Complex.java test-data/spreadsheet/ComplexFunctionTestCaseData.xls
Date Sun, 02 Jun 2013 23:25:08 GMT
Author: yegor
Date: Sun Jun  2 23:25:07 2013
New Revision: 1488808

URL: http://svn.apache.org/r1488808
Log:
added missing tests for Bug 55042: patch for missing function COMPLEX

Added:
    poi/trunk/test-data/spreadsheet/ComplexFunctionTestCaseData.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/Complex.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=1488808&r1=1488807&r2=1488808&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 Sun Jun  2 23:25:07
2013
@@ -15,9 +15,7 @@ import org.apache.poi.ss.formula.eval.No
 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 imple
         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);

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/Complex.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/Complex.java?rev=1488808&r1=1488807&r2=1488808&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/functions/Complex.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/Complex.java Sun Jun  2 23:25:07
2013
@@ -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 Var2or3ArgF
         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;
+    }
 }

Added: poi/trunk/test-data/spreadsheet/ComplexFunctionTestCaseData.xls
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/ComplexFunctionTestCaseData.xls?rev=1488808&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/ComplexFunctionTestCaseData.xls
------------------------------------------------------------------------------
    svn:mime-type = application/vnd.ms-excel



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


Mime
View raw message