[gnumeric] Names: avoid direct access to nexpr->name



commit 9b55b5c3776c0cb0a707d81fed84155ffbc2d620
Author: Morten Welinder <terra gnome org>
Date:   Sun May 22 12:27:51 2011 -0400

    Names: avoid direct access to nexpr->name

 plugins/excel/ChangeLog        |    5 +++++
 plugins/excel/ms-excel-read.c  |    4 ++--
 plugins/excel/ms-excel-write.c |   22 ++++++++++++----------
 src/expr-name.c                |    2 +-
 src/expr-name.h                |    2 +-
 src/xml-sax-write.c            |    2 +-
 6 files changed, 22 insertions(+), 15 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 7cca730..21beded 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-22  Morten Welinder  <terra gnome org>
+
+	* ms-excel-write.c (excel_write_autofilter_names): Use proper
+	ctor/dtor methods for GnmNamedExpr.
+
 2011-05-21  Morten Welinder <terra gnome org>
 
 	* Release 1.10.15
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index 9684430..d4c5b6f 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -3728,13 +3728,13 @@ excel_read_NAME (BiffQuery *q, GnmXLImporter *importer, ExcelReadSheet *esheet)
 
 			/* Undocumented magic.
 			 * XL stores a hidden name with the details of an autofilter */
-			if (nexpr->is_hidden && !strcmp (nexpr->name->str, "_FilterDatabase"))
+			if (nexpr->is_hidden && !strcmp (expr_name_name (nexpr), "_FilterDatabase"))
 				excel_prepare_autofilter (importer, nexpr);
 			/* g_warning ("flags = %hx, state = %s\n", flags, global ? "global" : "sheet"); */
 
 			else if ((flags & 0xE) == 0xE) /* Function & VB-Proc & Proc */
 				gnm_func_add_placeholder (importer->wb,
-					nexpr->name->str, "VBA", TRUE);
+							  expr_name_name (nexpr), "VBA", TRUE);
 		}
 	}
 
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index bea48f9..2d2a607 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -3861,29 +3861,31 @@ static void
 excel_write_autofilter_names (ExcelWriteState *ewb)
 {
 	unsigned i;
-	GnmNamedExpr nexpr;
+	GnmNamedExpr *nexpr;
 
-	nexpr.name = go_string_new ("_FilterDatabase");
-	nexpr.is_hidden = TRUE;
-	nexpr.is_placeholder = FALSE;
+	nexpr = expr_name_new ("_FilterDatabase");
+	nexpr->is_hidden = TRUE;
+	nexpr->is_placeholder = FALSE;
 	for (i = 0; i < ewb->esheets->len; i++) {
 		ExcelWriteSheet const *esheet =
 			g_ptr_array_index (ewb->esheets, i);
 		Sheet *sheet = esheet->gnum_sheet;
 		if (sheet->filters != NULL) {
 			GnmFilter const *filter = sheet->filters->data;
-			parse_pos_init_sheet (&nexpr.pos, sheet);
-			nexpr.texpr = gnm_expr_top_new_constant
-				(value_new_cellrange_r (sheet, &filter->r));
-			excel_write_NAME (NULL, &nexpr, ewb);
-			gnm_expr_top_unref (nexpr.texpr);
+			GnmParsePos pp;
+			parse_pos_init_sheet (&pp, sheet);
+			expr_name_set_pos (nexpr, &pp);
+			expr_name_set_expr (nexpr,
+					    gnm_expr_top_new_constant
+					    (value_new_cellrange_r (sheet, &filter->r)));
+			excel_write_NAME (NULL, nexpr, ewb);
 
 			if (NULL != sheet->filters->next) {
 				/* TODO Warn of lost autofilters */
 			}
 		}
 	}
-	go_string_unref (nexpr.name);
+	expr_name_unref (nexpr);
 }
 
 static void
diff --git a/src/expr-name.c b/src/expr-name.c
index 47ee101..e956855 100644
--- a/src/expr-name.c
+++ b/src/expr-name.c
@@ -730,7 +730,7 @@ expr_name_set_name (GnmNamedExpr *nexpr,
 	if (go_str_compare (new_name, old_name) == 0)
 		return FALSE;
 
-#if 1
+#if 0
 	g_printerr ("Renaming %s to %s\n", old_name, new_name);
 #endif
 	h = nexpr->scope
diff --git a/src/expr-name.h b/src/expr-name.h
index 9789034..af43263 100644
--- a/src/expr-name.h
+++ b/src/expr-name.h
@@ -58,7 +58,6 @@ gboolean expr_name_in_use     (GnmNamedExpr *nexpr);
 int      expr_name_cmp_by_name    (GnmNamedExpr const *a, GnmNamedExpr const *b);
 gboolean expr_name_check_for_loop (char const *name, GnmExprTop const *texpr);
 
-GSList  *gnm_named_expr_collection_list (GnmNamedExprCollection const *scope);
 GList	   *sheet_names_get_available (Sheet const *sheet);
 char const *sheet_names_check	      (Sheet const *sheet, GnmRange const *r);
 
@@ -81,6 +80,7 @@ void gnm_named_expr_collection_relink (GnmNamedExprCollection *names);
 void gnm_named_expr_collection_foreach (GnmNamedExprCollection *names,
 					GHFunc func,
 					gpointer data);
+GSList  *gnm_named_expr_collection_list (GnmNamedExprCollection const *scope);
 
 GnmNamedExpr *gnm_named_expr_collection_lookup (GnmNamedExprCollection const *scope,
 						char const *name);
diff --git a/src/xml-sax-write.c b/src/xml-sax-write.c
index 9e6dce1..7a336a5 100644
--- a/src/xml-sax-write.c
+++ b/src/xml-sax-write.c
@@ -203,7 +203,7 @@ xml_write_name (GnmOutputXML *state, GnmNamedExpr *nexpr)
 
 	gsf_xml_out_start_element (state->output, GNM "Name");
 	gsf_xml_out_simple_element (state->output, GNM "name",
-		nexpr->name->str);
+				    expr_name_name (nexpr));
 	expr_str = expr_name_as_string (nexpr, NULL, state->convs);
 	gsf_xml_out_simple_element (state->output, GNM "value", expr_str);
 	g_free (expr_str);



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