[gnumeric] Names: handle global names shadowed by sheet names.



commit caa2e07b8b7c8f2eb727ebf05f36d3341af8c81a
Author: Morten Welinder <terra gnome org>
Date:   Tue Apr 28 17:06:47 2009 -0400

    Names: handle global names shadowed by sheet names.
---
 ChangeLog        |    6 ++++++
 NEWS             |    1 +
 src/parse-util.c |    5 +++++
 src/parser.y     |   17 +++++++++++++++++
 4 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index edd1e19..a882ad0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-04-28  Morten Welinder  <terra gnome org>
+
+	* src/parse-util.c (std_expr_name_handler): Handle shadowed global
+	names.
+	* src/parser.y (workbookref): Ditto.  Fixes #306686.
+
 2009-04-27  Morten Welinder  <terra gnome org>
 
 	* src/position.c (gnm_rangeref_normalize_pp): New function
diff --git a/NEWS b/NEWS
index 5e21668..d0a9e15 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ Morten:
 	* Fix tooltip positioning.  [#580358]
 	* Fix xlst export problem.  [#580360]
 	* Fix size of sheets loaded from Applix files.
+	* Fix problem with global names shadowed by sheet names.  [#306686]
 
 --------------------------------------------------------------------------
 Gnumeric 1.9.6
diff --git a/src/parse-util.c b/src/parse-util.c
index 15370e5..867e6b4 100644
--- a/src/parse-util.c
+++ b/src/parse-util.c
@@ -1163,6 +1163,11 @@ std_expr_name_handler (GnmConventionsOut *out, GnmExprName const *name)
 		   thename->pos.sheet != out->pp->sheet) {
 		g_string_append (target, thename->pos.sheet->name_quoted);
 		g_string_append_unichar (target, out->convs->sheet_name_sep);
+	} else if (out->pp->sheet &&
+		   thename->pos.sheet == NULL &&
+		   expr_name_lookup (out->pp, expr_name_name (thename)) != thename) {
+		/* Special syntax for global names shadowed by sheet names.  */
+		g_string_append (target, "[]");
 	}
 
 	g_string_append (target, expr_name_name (thename));
diff --git a/src/parser.y b/src/parser.y
index 4d9c596..518790b 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -753,6 +753,23 @@ workbookref : '[' string_opt_quote ']'  {
 			YYERROR;
 		}
 	}
+	| '[' ']' {
+		/* Special syntax for global names shadowed by sheet names.  */
+		Workbook *wb = state->pos
+			? (state->pos->wb
+			   ? state->pos->wb
+			   : (state->pos->sheet
+			      ? state->pos->sheet->workbook
+			      : NULL))
+			: NULL;
+		$$ = wb;
+		if (wb == NULL) {
+			report_err (state, g_error_new (1, PERR_UNKNOWN_WORKBOOK,
+				_("Unknown workbook")),
+				state->ptr - 1, 1);
+			YYERROR;
+		}
+	}
 	;
 
 /* does not need to handle 3d case.  this is only used for names.



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