[gnumeric] xls: fix importing of non-Excel functions from LibreOffice's xls.



commit 1e3b922193b0f1b85c8644854fdbee73451473b1
Author: Morten Welinder <terra gnome org>
Date:   Wed Apr 10 09:40:56 2013 -0400

    xls: fix importing of non-Excel functions from LibreOffice's xls.

 NEWS                            |    1 +
 plugins/excel/ChangeLog         |    5 +++++
 plugins/excel/ms-formula-read.c |   14 +++++++++++---
 3 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index ed397d7..73e1724 100644
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,7 @@ Morten:
        * Add test sheet for complex number parsing.
        * Improve complex number parsing.
        * Fix error codes for complex number functions.
+       * Fix import of non-Excel functions from LO's xls files.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.1
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 4a512d7..bf912c4 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-10  Morten Welinder  <terra gnome org>
+
+       * ms-formula-read.c (make_function): Fix importing of GAMMA (and
+       others) from LibreOffice's xls files.
+
 2013-04-09  Morten Welinder  <terra gnome org>
 
        * ms-formula-read.c (make_function): Fix importing of IFERROR and
diff --git a/plugins/excel/ms-formula-read.c b/plugins/excel/ms-formula-read.c
index f668330..623a605 100644
--- a/plugins/excel/ms-formula-read.c
+++ b/plugins/excel/ms-formula-read.c
@@ -657,12 +657,20 @@ make_function (GnmExprList **stack, int fn_idx, int numargs, Workbook *wb)
                        return FALSE;
                }
 
-               /* This happens for IFERROR */
+               name = NULL;
+
                if (g_str_has_prefix (f_name, "_xlfn.") &&
-                   gnm_func_lookup (f_name + 6, wb))
+                   (name = gnm_func_lookup (f_name + 6, wb))) {
+                       /* This happens for IFERROR, for example. */
                        f_name += 6;
+               } else if (g_str_has_prefix (f_name, "_xlfnodf.") &&
+                          (name = gnm_func_lookup (f_name + 9, wb))) {
+                       /* This happens for GAMMA, for example. */
+                       f_name += 69;
+               }
 
-               name = gnm_func_lookup (f_name, wb);
+               if (!name)
+                       name = gnm_func_lookup (f_name, wb);
                d (2, g_printerr ("Function '%s' of %d args\n",
                               f_name, numargs););
 


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