[gnumeric] Fix ODF import of charts with series consisting of multiple ranges. [#704742]



commit fa3e600feff49457822a975f0002b21c6d20f089
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue Jul 23 13:22:35 2013 -0600

    Fix ODF import of charts with series consisting of multiple ranges. [#704742]
    
    2013-07-23  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (oo_plot_assign_dim): accept a range list rather
        than just a single range

 NEWS                                 |    1 +
 plugins/openoffice/ChangeLog         |    5 ++++
 plugins/openoffice/openoffice-read.c |   37 ++++++++++++++++++++++++---------
 3 files changed, 33 insertions(+), 10 deletions(-)
---
diff --git a/NEWS b/NEWS
index dc1c4f7..80ccc74 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ Andreas:
        * Speed up loading of some ODF files. [#704422]
        * Fix ODF style import. [#704563]
        * Fix crash on corrupted files. [#704636]
+       * Fix ODF import of charts with series consisting of multiple ranges. [#704742]
 
 Jean:
        * Fix text wrap inside sheet objects. [#704417]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 8f8b03d..20446d8 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,8 @@
+2013-07-23  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * openoffice-read.c (oo_plot_assign_dim): accept a range list rather
+       than just a single range
+
 2013-07-20  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * openoffice-read.c (oo_table_start): don't store the extent any more
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index e77f5e9..e9bb8b9 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -8049,7 +8049,6 @@ oo_plot_assign_dim (GsfXMLIn *xin, xmlChar const *range, int dim_type, char cons
 
        /* force relative to A1, not the containing cell */
        GnmExprTop const *texpr;
-       GnmParsePos pp;
        GnmValue *v;
        int dim;
        gboolean set_default_labels = FALSE;
@@ -8067,14 +8066,32 @@ oo_plot_assign_dim (GsfXMLIn *xin, xmlChar const *range, int dim_type, char cons
                return;
 
        if (NULL != range) {
-               GnmRangeRef ref;
-               char const *ptr = oo_rangeref_parse
-                       (&ref, CXML2C (range),
-                        parse_pos_init_sheet (&pp, state->pos.sheet),
-                        NULL);
-               if (ptr == CXML2C (range) || ref.a.sheet == invalid_sheet)
-                       return;
-               v = value_new_cellrange (&ref.a, &ref.b, 0, 0);
+               char const *range_list = CXML2C (range);
+               GnmParsePos pp;
+               GnmExprList *args = NULL;
+               GnmExpr const *expr;
+
+               parse_pos_init_sheet (&pp, state->pos.sheet);
+               while (*range_list != 0) {
+                       GnmRangeRef ref;
+                       char const *ptr = oo_rangeref_parse
+                               (&ref, range_list, &pp, NULL);
+                       if (ptr == range_list || ref.a.sheet == invalid_sheet) {
+                               return;
+                       }
+                       v = value_new_cellrange (&ref.a, &ref.b, 0, 0);
+                       expr = gnm_expr_new_constant (v);
+                       while (*range_list == ' ')
+                               range_list++;
+                       args = gnm_expr_list_append (args, expr);
+                       range_list = ptr;
+               }
+               if (1 == gnm_expr_list_length (args)) {
+                       expr = args->data;
+                       gnm_expr_list_free (args);
+               } else
+                       expr = gnm_expr_new_set (args);
+               texpr = gnm_expr_top_new (expr);
                if (state->debug)
                        g_print ("%d = rangeref (%s)\n", dim, range);
        } else if (NULL != gog_dataset_get_dim (GOG_DATASET (state->chart.series), dim))
@@ -8100,9 +8117,9 @@ oo_plot_assign_dim (GsfXMLIn *xin, xmlChar const *range, int dim_type, char cons
 
                set_default_labels = state->chart.src_abscissa_set;
                set_default_series_name = state->chart.src_label_set;
+               texpr = gnm_expr_top_new_constant (v);
        }
 
-       texpr = gnm_expr_top_new_constant (v);
        if (NULL != texpr)
                gog_series_set_dim (state->chart.series, dim,
                        (dim_type != GOG_MS_DIM_LABELS)


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