[gnumeric] xls: fix autofilter save problem.



commit b8ff054f73015915cccb6cc3a81cb78170f44db1
Author: Morten Welinder <terra gnome org>
Date:   Thu Aug 15 21:48:28 2013 -0400

    xls: fix autofilter save problem.

 NEWS                           |    1 +
 plugins/excel/ChangeLog        |    6 ++++++
 plugins/excel/ms-excel-write.c |   17 ++++++++++++++---
 3 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index 955a748..b18f5c4 100644
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,7 @@ Morten:
        * Fix (?) Applix pattern importer.  [#705946]
        * Fix FMR.  [Part of #705913]
        * Fix sheet removal dep problem.  [#706095]
+       * Fix test failure.  [#705947]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.4
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index b0d3616..b3cb0a5 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,9 @@
+2013-08-15  Morten Welinder  <terra gnome org>
+
+       * ms-excel-write.c (excel_write_autofilter_names): Fix last fix.
+       Sometimes we already have _FilterDatabase as a name.  If so,
+       brutally use it.  Fixes #705947.
+
 2013-08-15  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * ms-chart.c (BC_R(shtprops)): check whether we have enough data
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index 851798a..4a737c6 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -3890,10 +3890,19 @@ excel_write_autofilter_names (ExcelWriteState *ewb)
                if (sheet->filters != NULL) {
                        GnmFilter const *filter = sheet->filters->data;
                        GnmParsePos pp;
-                       GnmNamedExpr *nexpr = expr_name_new ("_FilterDatabase");
+                       GnmNamedExpr *nexpr;
+                       const char *name = "_FilterDatabase";
+                       gboolean is_new;
+
+                       parse_pos_init_sheet (&pp, sheet);
+
+                       nexpr = expr_name_lookup (&pp, name);
+                       is_new = (nexpr == NULL);
+                       if (is_new)
+                               nexpr = expr_name_new (name);
+
                        nexpr->is_hidden = TRUE;
                        expr_name_set_is_placeholder (nexpr, FALSE);
-                       parse_pos_init_sheet (&pp, sheet);
                        expr_name_set_pos (nexpr, &pp);
                        expr_name_set_expr (nexpr,
                                            gnm_expr_top_new_constant
@@ -3903,7 +3912,9 @@ excel_write_autofilter_names (ExcelWriteState *ewb)
                        if (NULL != sheet->filters->next) {
                                /* TODO Warn of lost autofilters */
                        }
-                       expr_name_unref (nexpr);
+
+                       if (is_new)
+                               expr_name_remove (nexpr);
                }
        }
 }


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