[gnumeric] Add ODF compatibility function ISFORMULA.



commit 869f56c2fe143e02eb9625959ae630e90f58e7d8
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Fri Oct 23 23:48:35 2009 -0600

    Add ODF compatibility function ISFORMULA.
    
    2009-10-24  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (oo_func_map_in): we now have ISFORMULA
    	* openoffice-write.c (odf_expr_func_handler): ditto
    
    2009-10-24  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* functions.c: add new ISFORMULA function.

 NEWS                                  |    2 +-
 plugins/fn-info/ChangeLog             |    4 +++
 plugins/fn-info/functions.c           |   37 ++++++++++++++++++++++++++++++--
 plugins/fn-info/plugin.xml.in         |    1 +
 plugins/openoffice/ChangeLog          |    5 ++++
 plugins/openoffice/openoffice-read.c  |    1 -
 plugins/openoffice/openoffice-write.c |    2 +-
 7 files changed, 46 insertions(+), 6 deletions(-)
---
diff --git a/NEWS b/NEWS
index e8c348b..dd6d2cc 100644
--- a/NEWS
+++ b/NEWS
@@ -5,7 +5,7 @@ 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 function DAYS.
+	* Add ODF compatibility functions DAYS and ISFORMULA.
 	* Work around OpenOffice.org saving function names in lowercase.
 
 Jody:
diff --git a/plugins/fn-info/ChangeLog b/plugins/fn-info/ChangeLog
index 4fe5608..cd870e2 100644
--- a/plugins/fn-info/ChangeLog
+++ b/plugins/fn-info/ChangeLog
@@ -1,3 +1,7 @@
+2009-10-24  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* functions.c: add new ISFORMULA function.
+
 2009-10-11  Morten Welinder <terra gnome org>
 
 	* Release 1.9.14
diff --git a/plugins/fn-info/functions.c b/plugins/fn-info/functions.c
index c05bec8..099d985 100644
--- a/plugins/fn-info/functions.c
+++ b/plugins/fn-info/functions.c
@@ -1212,7 +1212,7 @@ static GnmFuncHelp const help_get_formula[] = {
 	{ GNM_FUNC_HELP_EXAMPLES, F_("If A1 is empty and A2 contains =B1+B2, then\n"
 				     "GET.FORMULA(A2) yields '=B1+B2' and\n"
 				     "GET.FORMULA(A1) yields ''.") },
-	{ GNM_FUNC_HELP_SEEALSO, "EXPRESSION"},
+	{ GNM_FUNC_HELP_SEEALSO, "EXPRESSION,ISFORMULA"},
 	{ GNM_FUNC_HELP_END }
 };
 
@@ -1245,6 +1245,36 @@ gnumeric_get_formula (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
 	return value_new_empty ();
 }
 
+/***************************************************************************/
+
+static GnmFuncHelp const help_isformula[] = {
+	{ GNM_FUNC_HELP_NAME, F_("ISFORMULA:TRUE if @{cell} contains a formula.")},
+	{ GNM_FUNC_HELP_ARG, F_("cell:the referenced cell")},
+	{ GNM_FUNC_HELP_ODF, F_("ISFORMULA is OpenFormula compatible.") },
+	{ GNM_FUNC_HELP_SEEALSO, "GET_FORMULA"},
+	{ GNM_FUNC_HELP_END }
+};
+
+static GnmValue *
+gnumeric_isformula (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
+{
+	GnmValue const * const v = argv[0];
+	if (v->type == VALUE_CELLRANGE) {
+		GnmCell *cell;
+		GnmCellRef const * a = &v->v_range.cell.a;
+		GnmCellRef const * b = &v->v_range.cell.b;
+
+		if (a->col != b->col || a->row != b->row || a->sheet !=b->sheet)
+			return value_new_error_REF (ei->pos);
+
+		cell = sheet_cell_get (eval_sheet (a->sheet, ei->pos->sheet),
+				       a->col, a->row);
+		return value_new_bool (cell && gnm_cell_has_expr (cell));
+	}
+
+	return value_new_error_REF (ei->pos);
+}
+
 
 /***************************************************************************/
 
@@ -1849,11 +1879,12 @@ GnmFuncDescriptor const info_functions[] = {
 	{ "get.formula", "r",    help_get_formula,
 	  gnumeric_get_formula, NULL, NULL, NULL, NULL,
 	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
-
+	{ "isformula", "r",    help_isformula,
+	  gnumeric_isformula, NULL, NULL, NULL, NULL,
+	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_UNIQUE_TO_GNUMERIC, GNM_FUNC_TEST_STATUS_NO_TESTSUITE},
 	{ "getenv",	"s",  help_getenv,
 	  gnumeric_getenv, NULL, NULL, NULL, NULL,
 	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_UNIQUE_TO_GNUMERIC, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
 
-
         {NULL}
 };
diff --git a/plugins/fn-info/plugin.xml.in b/plugins/fn-info/plugin.xml.in
index fed1922..923da51 100644
--- a/plugins/fn-info/plugin.xml.in
+++ b/plugins/fn-info/plugin.xml.in
@@ -22,6 +22,7 @@
 				<function name="iserr"/>
 				<function name="iserror"/>
 				<function name="iseven"/>
+				<function name="isformula"/>
 				<function name="islogical"/>
 				<function name="isna"/>
 				<function name="isnontext"/>
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 8ab4729..0dcadde 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,8 @@
+2009-10-24  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-read.c (oo_func_map_in): we now have ISFORMULA
+	* openoffice-write.c (odf_expr_func_handler): ditto
+	
 2009-10-23  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* openoffice-read.c (oo_func_map_in): add EASTERSUNDAY
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 65a14d1..0e3f489 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4662,7 +4662,6 @@ oo_func_map_in (GnmConventions const *convs, Workbook *scope,
 		{ "COUNTIFS","ODF.COUNTIFS" },
 		{ "DDE","ODF.DDE" },
 		{ "IFNA","ODF.IFNA" },
-		{ "ISFORMULA","ODF.ISFORMULA" },
 		{ "MULTIPLE.OPERATIONS","ODF.MULTIPLE.OPERATIONS" },
 		{ "NUMBERVALUE","ODF.NUMBERVALUE" },
 		{ "SHEET","ODF.SHEET" },
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index fbe3f2f..a8f2271 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -1773,7 +1773,7 @@ odf_expr_func_handler (GnmConventionsOut *out, GnmExprFunction const *func)
 		{ "ISERR","ISERR" },
 		{ "ISERROR","ISERROR" },
 		{ "ISEVEN","ISEVEN" },
-		/* { "ISFORMULA","ISFORMULA" },  not implemented */
+		{ "ISFORMULA","ISFORMULA" },
 		{ "ISLOGICAL","ISLOGICAL" },
 		{ "ISNA","ISNA" },
 		{ "ISNONTEXT","ISNONTEXT" },



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