[gnumeric] Make sure gnm_cellpos_init_cellref gets a proper sheet.



commit d9883ea068ff984e4861ff471fc6a8ab2bd56ea0
Author: Morten Welinder <terra gnome org>
Date:   Fri Apr 17 09:24:31 2009 -0400

    Make sure gnm_cellpos_init_cellref gets a proper sheet.
---
 ChangeLog                         |    2 ++
 src/position.c                    |   13 ++++++++-----
 src/widgets/ChangeLog             |    5 +++++
 src/widgets/gnumeric-expr-entry.c |   18 +++++++++++-------
 4 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 326c088..b90eb9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,8 @@
 	* src/position.c (gnm_cellpos_hash, gnm_cellref_hash,
 	gnm_rangeref_hash): Improve these in light on variable-size
 	sheets.
+	(gnm_rangeref_normalize): : Evaluate sheets early so we can ship them
+	to gnm_cellpos_init_cellref.
 
 2009-04-16  Morten Welinder  <terra gnome org>
 
diff --git a/src/position.c b/src/position.c
index 657b5c1..bb2e454 100644
--- a/src/position.c
+++ b/src/position.c
@@ -393,15 +393,18 @@ void
 gnm_rangeref_normalize (GnmRangeRef const *ref, GnmEvalPos const *ep,
 			Sheet **start_sheet, Sheet **end_sheet, GnmRange *dest)
 {
+	GnmRangeRef r;
+
 	g_return_if_fail (ref != NULL);
 	g_return_if_fail (ep != NULL);
 
-	gnm_cellpos_init_cellref (&dest->start, &ref->a, &ep->eval);
-	gnm_cellpos_init_cellref (&dest->end, &ref->b, &ep->eval);
-	range_normalize (dest);
+	r = *ref;
+	r.a.sheet = *start_sheet = eval_sheet (r.a.sheet, ep->sheet);
+	r.b.sheet = *end_sheet   = eval_sheet (r.b.sheet, *start_sheet);
 
-	*start_sheet = eval_sheet (ref->a.sheet, ep->sheet);
-	*end_sheet   = eval_sheet (ref->b.sheet, *start_sheet);
+	gnm_cellpos_init_cellref (&dest->start, &r.a, &ep->eval);
+	gnm_cellpos_init_cellref (&dest->end, &r.b, &ep->eval);
+	range_normalize (dest);
 }
 
 guint
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index 1c536b5..37f2934 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,3 +1,8 @@
+2009-04-17  Morten Welinder  <terra gnome org>
+
+	* gnumeric-expr-entry.c (gnm_expr_entry_get_rangesel): Evaluate
+	sheet early so we can ship it to gnm_cellpos_init_cellref.
+
 2009-03-22  Morten Welinder <terra gnome org>
 
 	* Release 1.9.5
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index bdcdc14..afa777c 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -1361,18 +1361,22 @@ gnm_expr_entry_get_rangesel (GnmExprEntry const *gee,
 	g_return_val_if_fail (IS_GNM_EXPR_ENTRY (gee), FALSE);
 
 	gee_prepare_range (gee, &ref);
-	if (r != NULL) {
-		gnm_cellpos_init_cellref (&r->start, &ref.a, &gee->pp.eval);
-		gnm_cellpos_init_cellref (&r->end, &ref.b, &gee->pp.eval);
-		range_normalize (r);
-	}
+
+	ref.a.sheet = eval_sheet (rs->ref.a.sheet, gee->sheet);
+	ref.b.sheet = eval_sheet (rs->ref.b.sheet, ref.a.sheet);
 
 	/* TODO : does not handle 3d, neither does this interface
 	 * should probably scrap the interface in favour of returning a
 	 * rangeref.
 	 */
-	if (sheet != NULL)
-		*sheet = eval_sheet (rs->ref.a.sheet, gee->sheet);
+	if (sheet)
+		*sheet = ref.a.sheet;
+
+	if (r != NULL) {
+		gnm_cellpos_init_cellref (&r->start, &ref.a, &gee->pp.eval);
+		gnm_cellpos_init_cellref (&r->end, &ref.b, &gee->pp.eval);
+		range_normalize (r);
+	}
 
 	return rs->is_valid;
 }



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