[gnumeric] Add ODF compatibility function IFNA



commit 20ab36202848915652924ea1ea3ebb1d7ca2fa9a
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Sat Oct 24 15:07:59 2009 -0600

    Add ODF compatibility function IFNA
    
    2009-10-24  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* functions.c (help_ifna): new
    	(gnumeric_ifna): new
    	(stat_functions): add IFNA
    	* plugin.xml.in: add IFNA
    
    2009-10-24  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (oo_func_map_in): we now have IFNA
    	  (equivalent to the ODF function B)
    	* openoffice-write.c (odf_expr_func_handler): ditto

 NEWS                                  |    3 ++-
 plugins/fn-logical/ChangeLog          |    7 +++++++
 plugins/fn-logical/functions.c        |   23 +++++++++++++++++++++++
 plugins/fn-logical/plugin.xml.in      |    1 +
 plugins/openoffice/ChangeLog          |    6 ++++++
 plugins/openoffice/openoffice-read.c  |    1 -
 plugins/openoffice/openoffice-write.c |    2 +-
 7 files changed, 40 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index 4abca42..789b25f 100644
--- a/NEWS
+++ b/NEWS
@@ -5,7 +5,8 @@ Andreas:
 	* Add R.PSNORM, R.DSNORM and R.DST.
 	* Fix small sort dialog problem. [#599091]
 	* A few functions from the christian liturgical calendar.
-	* Add ODF compatibility functions DAYS, ISFORMULA and NUMBERVALUE.
+	* Add ODF compatibility functions DAYS, ISFORMULA, IFNA and 
+	  NUMBERVALUE.
 	* Work around OpenOffice.org saving function names in lowercase.
 	* Add BINOM.DIST.RANGE (equivalent to the ODF function B).
 
diff --git a/plugins/fn-logical/ChangeLog b/plugins/fn-logical/ChangeLog
index 91a5f65..b1e582c 100644
--- a/plugins/fn-logical/ChangeLog
+++ b/plugins/fn-logical/ChangeLog
@@ -1,3 +1,10 @@
+2009-10-24  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* functions.c (help_ifna): new
+	(gnumeric_ifna): new
+	(stat_functions): add IFNA
+	* plugin.xml.in: add IFNA
+
 2009-10-11  Morten Welinder <terra gnome org>
 
 	* Release 1.9.14
diff --git a/plugins/fn-logical/functions.c b/plugins/fn-logical/functions.c
index 046a79b..30884d5 100644
--- a/plugins/fn-logical/functions.c
+++ b/plugins/fn-logical/functions.c
@@ -244,6 +244,25 @@ gnumeric_iferror (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
 
 /***************************************************************************/
 
+static GnmFuncHelp const help_ifna[] = {
+	{ GNM_FUNC_HELP_NAME, F_("IFNA:Test for #NA! error.") },
+	{ GNM_FUNC_HELP_ARG, F_("x:value to test for #NA! error.") },
+	{ GNM_FUNC_HELP_ARG, F_("y:alternate value.") },
+	{ GNM_FUNC_HELP_DESCRIPTION, F_("This function returns the first value, unless that is #NA!, in which case it returns the second.") },
+        { GNM_FUNC_HELP_EXAMPLES, "=IFNA(12,14)" },
+        { GNM_FUNC_HELP_EXAMPLES, "=IFNA(1/0,14)" },
+        { GNM_FUNC_HELP_EXAMPLES, "=IFNA(NA(),14)" },
+	{ GNM_FUNC_HELP_SEEALSO, "IF,ISERROR" },
+	{ GNM_FUNC_HELP_END }
+};
+
+static GnmValue *
+gnumeric_ifna (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
+{
+	return value_dup ((value_error_classify (argv[0]) == GNM_ERROR_NA) ? argv[1] : argv[0]);
+}
+
+/***************************************************************************/
 static GnmFuncHelp const help_true[] = {
 	{ GNM_FUNC_HELP_NAME, F_("TRUE:the value TRUE.") },
 	{ GNM_FUNC_HELP_DESCRIPTION, F_("TRUE returns the value TRUE.") },
@@ -296,6 +315,10 @@ GnmFuncDescriptor const logical_functions[] = {
 	{ "iferror", "EE",  help_iferror,
 	  gnumeric_iferror, NULL, NULL, NULL, NULL,
 	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
+	{ "ifna", "EE",  help_ifna,
+	  gnumeric_ifna, NULL, NULL, NULL, NULL,
+	  GNM_FUNC_SIMPLE,  GNM_FUNC_IMPL_STATUS_UNIQUE_TO_GNUMERIC, 
+	  GNM_FUNC_TEST_STATUS_NO_TESTSUITE},
 	{ "true", "", help_true, gnumeric_true,
 	  NULL, NULL, NULL, NULL,
 	  GNM_FUNC_SIMPLE + GNM_FUNC_AUTO_UNITLESS,
diff --git a/plugins/fn-logical/plugin.xml.in b/plugins/fn-logical/plugin.xml.in
index d1cf5d8..5f8c878 100644
--- a/plugins/fn-logical/plugin.xml.in
+++ b/plugins/fn-logical/plugin.xml.in
@@ -16,6 +16,7 @@
 				<function name="xor"/>
 				<function name="not"/>
 				<function name="iferror"/>
+				<function name="ifna"/>
 				<function name="true"/>
 				<function name="false"/>
 			</functions>
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 71fb9a8..f7e2029 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,11 @@
 2009-10-24  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-read.c (oo_func_map_in): we now have IFNA
+	  (equivalent to the ODF function B)
+	* openoffice-write.c (odf_expr_func_handler): ditto
+
+2009-10-24  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-read.c (oo_func_map_in): we now have BINOM.DIST.RANGE
 	  (equivalent to the ODF function B)
 	* openoffice-write.c (odf_expr_func_handler): ditto
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index fbcca24..89bcd3e 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4658,7 +4658,6 @@ oo_func_map_in (GnmConventions const *convs, Workbook *scope,
 		{ "AVERAGEIFS","ODF.AVERAGEIFS" },
 		{ "COUNTIFS","ODF.COUNTIFS" },
 		{ "DDE","ODF.DDE" },
-		{ "IFNA","ODF.IFNA" },
 		{ "MULTIPLE.OPERATIONS","ODF.MULTIPLE.OPERATIONS" },
 		{ "SHEET","ODF.SHEET" },
 		{ "SHEETS","ODF.SHEETS" },
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index ce26edc..48847f8 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -1737,7 +1737,7 @@ odf_expr_func_handler (GnmConventionsOut *out, GnmExprFunction const *func)
 		{ "HYPGEOMDIST","HYPGEOMDIST" },
 		{ "IF","IF" },
 		{ "IFERROR","IFERROR" },
-		/* { "IFNA","IFNA" },  not implemented */
+		{ "IFNA","IFNA" },
 		{ "IMABS","IMABS" },
 		{ "IMAGINARY","IMAGINARY" },
 		{ "IMARGUMENT","IMARGUMENT" },



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