[gnumeric] Change how we import GAUSS



commit 3b76825bba2d4c1ab32076c24f18a9266897cd92
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Mon Aug 24 09:14:42 2009 -0600

    Change how we import GAUSS
    
    2009-08-24  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (odf_func_gauss_handler): use ERF
    	(oo_func_map_in): map GAUSS to ODF.GAUSS if it has more than one
    	  argument

 plugins/openoffice/ChangeLog         |    6 ++++++
 plugins/openoffice/openoffice-read.c |   32 ++++++++++++++++++--------------
 2 files changed, 24 insertions(+), 14 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index a12e10a..cbb8c47 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,9 @@
+2009-08-24  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-read.c (odf_func_gauss_handler): use ERF
+	(oo_func_map_in): map GAUSS to ODF.GAUSS if it has more than one
+	  argument
+	
 2009-08-23  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* openoffice-read.c (odf_func_gauss_handler): new
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index d8ec23e..ac8f375 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4342,20 +4342,24 @@ odf_func_phi_handler (GnmConventions const *convs, Workbook *scope, GnmExprList
 static GnmExpr const *
 odf_func_gauss_handler (GnmConventions const *convs, Workbook *scope, GnmExprList *args)
 {
-	GnmFunc  *f = gnm_func_lookup_or_add_placeholder ("NORMDIST", scope, FALSE);
-	
-	args = g_slist_append (args,
-			       (gpointer) gnm_expr_new_constant (value_new_int (0)));
-	args = g_slist_append (args,
-			       (gpointer) gnm_expr_new_constant (value_new_int (1)));
+	guint argc = gnm_expr_list_length (args);
+	GnmFunc  *f = gnm_func_lookup_or_add_placeholder ("ERF", scope, FALSE);
+	GnmFunc  *fs = gnm_func_lookup_or_add_placeholder ("SQRT", scope, FALSE);
+	GnmExpr const * expr;
 
-	args = g_slist_append (args,
-			       (gpointer) gnm_expr_new_funcall 
-			       (gnm_func_lookup_or_add_placeholder ("FALSE", scope, TRUE), NULL));
-	
-	return gnm_expr_new_binary (gnm_expr_new_funcall (f, args),
-				    GNM_EXPR_OP_SUB,
-				    gnm_expr_new_constant (value_new_float (0.5)));
+	if (argc != 1)
+		return NULL;
+
+	expr = gnm_expr_new_binary (gnm_expr_new_funcall1 
+				    (f, gnm_expr_new_binary ((gnm_expr_copy ((GnmExpr const *)(args->data))),
+							     GNM_EXPR_OP_DIV,
+									     gnm_expr_new_funcall1 (fs,
+												    gnm_expr_new_constant 
+												    (value_new_int (2))))),
+				    GNM_EXPR_OP_DIV,
+				    gnm_expr_new_constant (value_new_int (2)));
+	gnm_expr_list_unref (args);
+	return expr;
 }
 
 static GnmExpr const *
@@ -4628,7 +4632,7 @@ oo_func_map_in (GnmConventions const *convs, Workbook *scope,
 		{ "CHISQDIST","ODF.CHISQDIST" },      /* see handler */
 		{ "FLOOR","ODF.FLOOR" },              /* see handler */
 		{ "FORMULA","GET.FORMULA" },
-		{ "GAUSS","NORMDIST" },              /* see handler */
+		{ "GAUSS","ODF.GAUSS" },              /* see handler */
 		{ "LEGACY.CHIDIST","CHIDIST" },
 		{ "LEGACY.CHIINV","CHIINV" },
 		{ "LEGACY.CHITEST","CHITEST" },



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]