[gnumeric] SheetSize: fix NULL error.



commit 4448796bbda4d71929579324a03eec00ebc5e0de
Author: Morten Welinder <terra gnome org>
Date:   Wed Jun 3 16:47:07 2009 -0400

    SheetSize: fix NULL error.
---
 ChangeLog   |    6 ++++++
 src/expr.c  |   38 +++++++++++++++++++++++---------------
 src/expr.h  |    4 +++-
 src/sheet.c |    1 +
 4 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4ea76a0..f4bba32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-06-03  Morten Welinder  <terra gnome org>
+
+	* src/expr.c (cellref_boundingbox, gnm_expr_get_boundingbox,
+	gnm_expr_top_get_boundingbox): Add sheet parameter for size.
+	All callers changed.
+
 2009-06-02  Morten Welinder  <terra gnome org>
 
 	* src/wbc-gtk-actions.c (cb_format_as_currency): Deal with goffice
diff --git a/src/expr.c b/src/expr.c
index 60fdccc..b11f91a 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -2256,11 +2256,17 @@ gnm_expr_first_funcall (GnmExpr const *expr)
 }
 
 static void
-cellref_boundingbox (GnmCellRef const *cr, GnmRange *bound)
+cellref_boundingbox (GnmCellRef const *cr, Sheet const *sheet, GnmRange *bound)
 {
+	GnmSheetSize const *ss;
+
+	if (cr->sheet)
+		sheet = cr->sheet;
+	ss = gnm_sheet_get_size (sheet);
+
 	if (cr->col_relative) {
 		if (cr->col >= 0) {
-			int const c = gnm_sheet_get_max_cols (cr->sheet) - cr->col - 1;
+			int const c = ss->max_cols - cr->col - 1;
 			if (bound->end.col > c)
 				bound->end.col = c;
 		} else {
@@ -2271,7 +2277,7 @@ cellref_boundingbox (GnmCellRef const *cr, GnmRange *bound)
 	}
 	if (cr->row_relative) {
 		if (cr->row >= 0) {
-			int const r = gnm_sheet_get_max_rows (cr->sheet) - cr->row - 1;
+			int const r = ss->max_rows - cr->row - 1;
 			if (bound->end.row > r)
 				bound->end.row = r;
 		} else {
@@ -2396,7 +2402,8 @@ gnm_expr_contains_subtotal (GnmExpr const *expr)
 }
 
 static void
-gnm_expr_get_boundingbox (GnmExpr const *expr, GnmRange *bound)
+gnm_expr_get_boundingbox (GnmExpr const *expr, Sheet const *sheet,
+			  GnmRange *bound)
 {
 	g_return_if_fail (expr != NULL);
 
@@ -2404,24 +2411,24 @@ gnm_expr_get_boundingbox (GnmExpr const *expr, GnmRange *bound)
 	case GNM_EXPR_OP_RANGE_CTOR:
 	case GNM_EXPR_OP_INTERSECT:
 	case GNM_EXPR_OP_ANY_BINARY:
-		gnm_expr_get_boundingbox (expr->binary.value_a, bound);
-		gnm_expr_get_boundingbox (expr->binary.value_b, bound);
+		gnm_expr_get_boundingbox (expr->binary.value_a, sheet, bound);
+		gnm_expr_get_boundingbox (expr->binary.value_b, sheet, bound);
 		break;
 
 	case GNM_EXPR_OP_ANY_UNARY:
-		gnm_expr_get_boundingbox (expr->unary.value, bound);
+		gnm_expr_get_boundingbox (expr->unary.value, sheet, bound);
 		break;
 
 	case GNM_EXPR_OP_FUNCALL: {
 		int i;
 		for (i = 0; i < expr->func.argc; i++)
-			gnm_expr_get_boundingbox (expr->func.argv[i], bound);
+			gnm_expr_get_boundingbox (expr->func.argv[i], sheet, bound);
 		break;
 	}
 	case GNM_EXPR_OP_SET: {
 		int i;
 		for (i = 0; i < expr->set.argc; i++)
-			gnm_expr_get_boundingbox (expr->set.argv[i], bound);
+			gnm_expr_get_boundingbox (expr->set.argv[i], sheet, bound);
 		break;
 	}
 
@@ -2431,21 +2438,21 @@ gnm_expr_get_boundingbox (GnmExpr const *expr, GnmRange *bound)
 		break;
 
 	case GNM_EXPR_OP_CELLREF:
-		cellref_boundingbox (&expr->cellref.ref, bound);
+		cellref_boundingbox (&expr->cellref.ref, sheet, bound);
 		break;
 
 	case GNM_EXPR_OP_CONSTANT: {
 		GnmValue const *v = expr->constant.value;
 
 		if (v->type == VALUE_CELLRANGE) {
-			cellref_boundingbox (&v->v_range.cell.a, bound);
-			cellref_boundingbox (&v->v_range.cell.b, bound);
+			cellref_boundingbox (&v->v_range.cell.a, sheet, bound);
+			cellref_boundingbox (&v->v_range.cell.b, sheet, bound);
 		}
 		break;
 	}
 
 	case GNM_EXPR_OP_ARRAY_CORNER:
-		gnm_expr_get_boundingbox (expr->array_corner.expr, bound);
+		gnm_expr_get_boundingbox (expr->array_corner.expr, sheet, bound);
 		break;
 
 	case GNM_EXPR_OP_ARRAY_ELEM:
@@ -3044,11 +3051,12 @@ gnm_expr_top_first_funcall (GnmExprTop const *texpr)
  * out of bounds.
  **/
 void
-gnm_expr_top_get_boundingbox (GnmExprTop const *texpr, GnmRange *bound)
+gnm_expr_top_get_boundingbox (GnmExprTop const *texpr, Sheet const *sheet,
+			      GnmRange *bound)
 {
 	g_return_if_fail (IS_GNM_EXPR_TOP (texpr));
 
-	gnm_expr_get_boundingbox (texpr->expr, bound);
+	gnm_expr_get_boundingbox (texpr->expr, sheet, bound);
 }
 
 gboolean
diff --git a/src/expr.h b/src/expr.h
index b33f946..6ee851f 100644
--- a/src/expr.h
+++ b/src/expr.h
@@ -131,7 +131,9 @@ gboolean	gnm_expr_top_is_array		(GnmExprTop const *texpr);
 GnmValue       *gnm_expr_top_get_range		(GnmExprTop const *texpr);
 GSList	       *gnm_expr_top_get_ranges		(GnmExprTop const *texpr);
 GnmValue const *gnm_expr_top_get_constant	(GnmExprTop const *texpr);
-void		gnm_expr_top_get_boundingbox	(GnmExprTop const *texpr, GnmRange *bound);
+void		gnm_expr_top_get_boundingbox	(GnmExprTop const *texpr,
+						 Sheet const *sheet,
+						 GnmRange *bound);
 gboolean	gnm_expr_top_contains_subtotal	(GnmExprTop const *texpr);
 GSList	       *gnm_expr_top_referenced_sheets	(GnmExprTop const *texpr);
 GnmExpr const  *gnm_expr_top_first_funcall	(GnmExprTop const *texpr);
diff --git a/src/sheet.c b/src/sheet.c
index aa8ea7d..3316994 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -2396,6 +2396,7 @@ sheet_range_set_text (GnmParsePos const *pos, GnmRange const *r, char const *str
 	if (closure.texpr) {
 		range_init_full_sheet (&closure.expr_bound, pos->sheet);
 		gnm_expr_top_get_boundingbox (closure.texpr,
+					      pos->sheet,
 					      &closure.expr_bound);
 	}
 



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