[gnumeric] Improve import of CONCATENATE from ODF.



commit 90c17d1b2e32a5527f513c58de92cc37ecdcee3e
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Sun Oct 15 18:37:16 2017 -0600

     Improve import of CONCATENATE from ODF.
    
    2017-10-15  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (oo_func_map_in): import some instances of CONCATENATE as
        concatenate instead of ODF.CONCATENATE

 plugins/openoffice/ChangeLog         |    7 ++++++-
 plugins/openoffice/openoffice-read.c |   27 +++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 9e2d9cc..8f225b2 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,8 +1,13 @@
+2017-10-15  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * openoffice-read.c (oo_func_map_in): import some instances of CONCATENATE as
+       concatenate instead of ODF.CONCATENATE
+
 2017-10-14  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * openoffice-write.c (odf_expr_func_handler): write CONCATENATE
        as COM.MICROSOFT.CONCAT
-       * openoffice-read.c (oo_func_map_in): import CONCATENATE as 
+       * openoffice-read.c (oo_func_map_in): import CONCATENATE as
        ODF.CONCATENATE
 
 2017-10-12  Andreas J. Guelzow <aguelzow pyrshep ca>
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index d97eaec..732ec69 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -12948,6 +12948,32 @@ odf_func_norm_s_dist_handler (G_GNUC_UNUSED GnmConventions const *convs, G_GNUC_
        return NULL;
 }
 
+static void
+odf_func_concatenate_handler_cb (gpointer data, gpointer user_data)
+{
+       GnmExpr const *expr = data;
+       gboolean *check =  (gboolean *)(user_data);
+
+       if (gnm_expr_is_rangeref (expr))
+               (*check) = (*check) || (GNM_EXPR_GET_OPER (expr) != GNM_EXPR_OP_CELLREF);
+}
+
+static GnmExpr const *
+odf_func_concatenate_handler (G_GNUC_UNUSED GnmConventions const *convs, G_GNUC_UNUSED Workbook *scope, 
GnmExprList *args)
+{
+       gboolean has_range = FALSE;
+       GnmFunc  *fd;
+
+       g_slist_foreach ((GSList *) args, odf_func_concatenate_handler_cb, (gpointer) &has_range);
+
+       if (has_range)
+               return NULL;
+       
+       fd = gnm_func_lookup_or_add_placeholder ("CONCATENATE");
+       
+       return gnm_expr_new_funcall (fd, args);
+}
+
 static GnmExpr const *
 odf_func_t_dist_tail_handler (GnmExprList *args, int tails)
 {
@@ -13034,6 +13060,7 @@ oo_func_map_in (GnmConventions const *convs, Workbook *scope,
                {"GAUSS", odf_func_gauss_handler},
                {"TRUE", odf_func_true_handler},
                {"FALSE", odf_func_false_handler},
+               {"CONCATENATE", odf_func_concatenate_handler},
                {"COM.MICROSOFT.F.DIST", odf_func_f_dist_handler},
                {"COM.MICROSOFT.LOGNORM.DIST", odf_func_lognorm_dist_handler},
                {"COM.MICROSOFT.NEGBINOM.DIST", odf_func_negbinom_dist_handler},


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