[gnumeric] Add ODF compatibility function SHEETS
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] Add ODF compatibility function SHEETS
- Date: Sun, 25 Oct 2009 00:14:07 +0000 (UTC)
commit 64398e6cb275a34b693d59c55f4b34ca7321daa2
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Sat Oct 24 18:13:28 2009 -0600
Add ODF compatibility function SHEETS
2009-10-24 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (oo_func_map_in): we now have SHEETS
* openoffice-write.c (odf_expr_func_handler): ditto
2009-10-24 Andreas J. Guelzow <aguelzow pyrshep ca>
* functions.c (help_sheets): new
(gnumeric_sheets): new
(stat_functions): add SHEETS
* plugin.xml.in: add SHEETS
NEWS | 4 +-
plugins/fn-lookup/ChangeLog | 7 +++++
plugins/fn-lookup/functions.c | 45 +++++++++++++++++++++++++++++++++
plugins/fn-lookup/plugin.xml.in | 1 +
plugins/openoffice/ChangeLog | 5 +++
plugins/openoffice/openoffice-read.c | 1 -
plugins/openoffice/openoffice-write.c | 2 +-
7 files changed, 61 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index 789b25f..08e9aae 100644
--- a/NEWS
+++ b/NEWS
@@ -5,8 +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, IFNA and
- NUMBERVALUE.
+ * Add ODF compatibility functions DAYS, ISFORMULA, IFNA, SHEETS
+ 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-lookup/ChangeLog b/plugins/fn-lookup/ChangeLog
index d2f0413..4a90c30 100644
--- a/plugins/fn-lookup/ChangeLog
+++ b/plugins/fn-lookup/ChangeLog
@@ -1,3 +1,10 @@
+2009-10-24 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * functions.c (help_sheets): new
+ (gnumeric_sheets): new
+ (stat_functions): add SHEETS
+ * plugin.xml.in: add SHEETS
+
2009-10-11 Morten Welinder <terra gnome org>
* Release 1.9.14
diff --git a/plugins/fn-lookup/functions.c b/plugins/fn-lookup/functions.c
index b0d5ce5..e8ed35e 100644
--- a/plugins/fn-lookup/functions.c
+++ b/plugins/fn-lookup/functions.c
@@ -39,6 +39,8 @@
#include <expr-name.h>
#include <mathfunc.h>
#include <gutils.h>
+#include <workbook.h>
+#include <sheet.h>
#include <parse-util.h>
#include <gnm-i18n.h>
@@ -1533,6 +1535,46 @@ gnumeric_rows (GnmFuncEvalInfo *ei, GnmValue const * const *args)
/***************************************************************************/
+static GnmFuncHelp const help_sheets[] = {
+ { GNM_FUNC_HELP_NAME, F_("SHEETS:number of sheets in @{reference}")},
+ { GNM_FUNC_HELP_ARG, F_("reference:array, reference, or range, defaults to the maximum range")},
+ { GNM_FUNC_HELP_NOTE, F_("If @{reference} is neither an array nor a reference nor a range, "
+ "SHEETS returns #VALUE!")},
+ { GNM_FUNC_HELP_EXAMPLES, "=SHEETS(Sheet1!H7:Sheet2!I13)" },
+ { GNM_FUNC_HELP_EXAMPLES, "=SHEETS()" },
+ { GNM_FUNC_HELP_SEEALSO, "COLUMNS,ROWS"},
+ { GNM_FUNC_HELP_END}
+};
+
+static GnmValue *
+gnumeric_sheets (GnmFuncEvalInfo *ei, GnmValue const * const *args)
+{
+ Workbook const *wb = ei->pos->sheet->workbook;
+ GnmValue const *v = args[0];
+
+ if(v) {
+ if (v->type == VALUE_CELLRANGE) {
+ GnmRangeRef const *r = &v->v_range.cell;
+ int ans_min, ans_max, a, b;
+
+ a = g_slist_index (workbook_sheets (wb), r->a.sheet);
+ b = g_slist_index (workbook_sheets (wb), r->b.sheet);
+
+ ans_min = (a < b) ? a : b;
+ ans_max = (a < b) ? b : a;
+
+ if (ans_min == -1)
+ return value_new_int (1);
+
+ return value_new_int (ans_max - ans_min + 1);
+ } else
+ return value_new_int (1);
+ } else
+ return value_new_int (workbook_sheet_count (wb));
+}
+
+/***************************************************************************/
+
static GnmFuncHelp const help_hyperlink[] = {
{ GNM_FUNC_HELP_NAME, F_("HYPERLINK:second or first arguments")},
{ GNM_FUNC_HELP_ARG, F_("link_location:string")},
@@ -1639,6 +1681,9 @@ GnmFuncDescriptor const lookup_functions[] = {
{ "rows", "A",
help_rows, gnumeric_rows, NULL, NULL, NULL, NULL,
GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
+ { "sheets", "|A",
+ help_sheets, gnumeric_sheets, NULL, NULL, NULL, NULL,
+ GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_UNIQUE_TO_GNUMERIC, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
{ "transpose", "A",
help_transpose, gnumeric_transpose, NULL, NULL, NULL, NULL,
GNM_FUNC_RETURNS_NON_SCALAR, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
diff --git a/plugins/fn-lookup/plugin.xml.in b/plugins/fn-lookup/plugin.xml.in
index b963b87..d210cb7 100644
--- a/plugins/fn-lookup/plugin.xml.in
+++ b/plugins/fn-lookup/plugin.xml.in
@@ -26,6 +26,7 @@
<function name="offset"/>
<function name="row"/>
<function name="rows"/>
+ <function name="sheets"/>
<function name="transpose"/>
<function name="vlookup"/>
</functions>
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index f7e2029..29b57f5 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,10 @@
2009-10-24 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * openoffice-read.c (oo_func_map_in): we now have SHEETS
+ * 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 IFNA
(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 89bcd3e..34338f5 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4660,7 +4660,6 @@ oo_func_map_in (GnmConventions const *convs, Workbook *scope,
{ "DDE","ODF.DDE" },
{ "MULTIPLE.OPERATIONS","ODF.MULTIPLE.OPERATIONS" },
{ "SHEET","ODF.SHEET" },
- { "SHEETS","ODF.SHEETS" },
{ "SUMIFS","ODF.SUMIFS" },
/* The following is a complete list of the functions defined in ODF OpenFormula draft 20090508 */
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 48847f8..947d59e 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -1897,7 +1897,7 @@ odf_expr_func_handler (GnmConventionsOut *out, GnmExprFunction const *func)
{ "SECOND","SECOND" },
{ "SERIESSUM","SERIESSUM" },
/* { "SHEET","SHEET" }, not implemented */
- /* { "SHEETS","SHEETS" }, not implemented */
+ { "SHEETS","SHEETS" },
{ "SIGN","SIGN" },
{ "SIN","SIN" },
{ "SINH","SINH" },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]