[gnumeric] xlsx: fix problem that cleared cells referencing other workbooks.



commit bd6dae23f91299da51d3d82c66eb1e4e9c164f7e
Author: Morten Welinder <terra gnome org>
Date:   Sun Mar 16 15:17:00 2014 -0400

    xlsx: fix problem that cleared cells referencing other workbooks.
    
    We end up destroying fake workbooks created for external references.
    That rewrites all dependencies which, in turn, cleared the values.

 ChangeLog                  |    5 +++++
 NEWS                       |    3 ++-
 plugins/excel/xlsx-utils.c |   12 ++++++++----
 src/cell.c                 |   13 ++++++-------
 src/rendered-value.c       |    4 +++-
 5 files changed, 24 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e397208..66e93e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-16  Morten Welinder  <terra gnome org>
+
+       * src/cell.c (cell_set_expr_internal): Don't change an existing
+       value.
+
 2014-03-15  Morten Welinder  <terra gnome org>
 
        * src/style-border.c (gnm_border_shutdown): New function to help
diff --git a/NEWS b/NEWS
index 20c5c75..77316d6 100644
--- a/NEWS
+++ b/NEWS
@@ -26,7 +26,8 @@ Morten:
        * Fix minor conditional format GUI issues.
        * Plug leak.
        * Fix font dialog problem with underline.
-       * Fix crash reading strane xls file.  [Redhat #1076912]
+       * Fix crash reading strange xls file.  [Redhat #1076912]
+       * Fix problem clearing existing values in some xlsx cells.  [#726297]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.12
diff --git a/plugins/excel/xlsx-utils.c b/plugins/excel/xlsx-utils.c
index 3810432..bfd6b9b 100644
--- a/plugins/excel/xlsx-utils.c
+++ b/plugins/excel/xlsx-utils.c
@@ -118,11 +118,15 @@ xlsx_conventions_add_extern_ref (GnmConventions *convs, char const *path)
 {
        XLSXExprConventions *xconv = (XLSXExprConventions *)convs;
        Workbook *res = g_object_new (WORKBOOK_TYPE, NULL);
+       char *id;
+
        (void) go_doc_set_uri (GO_DOC (res), path);
-       g_hash_table_insert (xconv->extern_wb_by_id,
-               g_strdup_printf ("%d", g_hash_table_size (xconv->extern_wb_by_id) + 1),
-               res);
-       if (0) g_printerr ("add %d = '%s'\n", g_hash_table_size (xconv->extern_wb_by_id), path);
+
+       id = g_strdup_printf ("%d", g_hash_table_size (xconv->extern_wb_by_id) + 1);
+       if (0) g_printerr ("add %s = '%s'\n", id, path);
+
+       g_hash_table_insert (xconv->extern_wb_by_id, id, res);
+
        return res;
 }
 
diff --git a/src/cell.c b/src/cell.c
index 9f9a386..35dcf58 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -209,19 +209,18 @@ gnm_cell_set_expr_and_value (GnmCell *cell, GnmExprTop const *texpr, GnmValue *v
 static void
 cell_set_expr_internal (GnmCell *cell, GnmExprTop const *texpr)
 {
+       GnmValue *save_value;
+
        gnm_expr_top_ref (texpr);
 
+       /* Don't touch the value.  */
+       save_value = cell->value ? cell->value : value_new_empty ();
+       cell->value = NULL;
        gnm_cell_cleanout (cell);
 
        cell->base.flags |= GNM_CELL_HAS_NEW_EXPR;
        cell->base.texpr = texpr;
-
-       /* Until the value is recomputed, we put in this value.
-        *
-        * We should consider using 0 instead and take out the
-        * gnm_cell_needs_recalc call in sheet_foreach_cell_in_range.
-        */
-       cell->value = value_new_empty ();
+       cell->value = save_value;
 }
 
 /*
diff --git a/src/rendered-value.c b/src/rendered-value.c
index 0b1cbe3..c33822a 100644
--- a/src/rendered-value.c
+++ b/src/rendered-value.c
@@ -238,7 +238,9 @@ gnm_rendered_value_new (GnmCell const *cell,
        sheet = cell->base.sheet;
 
        if (debug)
-               g_printerr ("Rendering %s\n", cell_name (cell));
+               g_printerr ("Rendering %s value [%s]\n",
+                           cell_name (cell),
+                           value_peek_string (cell->value));
 
        displayed_formula =
                gnm_cell_has_expr (cell) && sheet->display_formulas;


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