[gnumeric] sheet duplicate: queue the new sheet for recalc.



commit fc54e569146aed46fd130f8ae7f41a10ad083ac4
Author: Morten Welinder <terra gnome org>
Date:   Mon May 3 11:34:21 2010 -0400

    sheet duplicate: queue the new sheet for recalc.

 ChangeLog   |    5 +++++
 src/sheet.c |   29 ++++++++---------------------
 2 files changed, 13 insertions(+), 21 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 77f5398..63f74a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-05-03  Morten Welinder  <terra gnome org>
+
+	* src/sheet.c (sheet_dup_cells): Queue recalc of the new sheet.
+	(cb_sheet_cell_copy): Don't copy computed values.
+
 2010-05-03 Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* src/mathfunc.c (gnm_matrix_eigen_max_index): stay in the matrix
diff --git a/src/sheet.c b/src/sheet.c
index 8ca6786..4a503cf 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -5395,47 +5395,33 @@ cb_sheet_cell_copy (gpointer unused, gpointer key, gpointer new_sheet_param)
 	Sheet *dst = new_sheet_param;
 	Sheet *src;
 	GnmExprArrayCorner const *array;
+	GnmExprTop const *texpr;
 
 	g_return_if_fail (dst != NULL);
 	g_return_if_fail (cell != NULL);
 
 	src = cell->base.sheet;
+	texpr = cell->base.texpr;
 	array = gnm_cell_is_array_corner (cell);
 
 	if (array) {
-		unsigned int i, j;
-		GnmExprTop const *texpr =
-			gnm_expr_top_relocate_sheet (cell->base.texpr, src, dst);
+		texpr = gnm_expr_top_relocate_sheet (texpr, src, dst);
 
 		gnm_cell_set_array_formula (dst,
 			cell->pos.col, cell->pos.row,
 			cell->pos.col + array->cols-1,
 			cell->pos.row + array->rows-1,
 			texpr);
-
-		for (i = 0; i < array->cols ; i++)
-			for (j = 0; j < array->rows ; j++)
-				if (i != 0 || j != 0) {
-					GnmCell const *in = sheet_cell_fetch (src,
-						cell->pos.col + i,
-						cell->pos.row + j);
-					GnmCell *out = sheet_cell_fetch (dst,
-						cell->pos.col + i,
-						cell->pos.row + j);
-					gnm_cell_assign_value (out, value_dup (in->value));
-				}
-	} else if (cell->base.texpr && gnm_expr_top_is_array_elem (cell->base.texpr, NULL, NULL)) {
+	} else if (texpr && gnm_expr_top_is_array_elem (texpr, NULL, NULL)) {
 		/* Not a corner -- ignore.  */
 	} else {
 		GnmCell *new_cell = sheet_cell_create (dst, cell->pos.col, cell->pos.row);
-		GnmValue *value = value_dup (cell->value);
 		if (gnm_cell_has_expr (cell)) {
-			GnmExprTop const *texpr =
-				gnm_expr_top_relocate_sheet (cell->base.texpr, src, dst);
-			gnm_cell_set_expr_and_value (new_cell, texpr, value, TRUE);
+			texpr = gnm_expr_top_relocate_sheet (texpr, src, dst);
+			gnm_cell_set_expr_and_value (new_cell, texpr, value_new_empty (), TRUE);
 			gnm_expr_top_unref (texpr);
 		} else
-			gnm_cell_set_value (new_cell, value);
+			gnm_cell_set_value (new_cell, value_dup (cell->value));
 	}
 }
 
@@ -5443,6 +5429,7 @@ static void
 sheet_dup_cells (Sheet const *src, Sheet *dst)
 {
 	sheet_cell_foreach (src, &cb_sheet_cell_copy, dst);
+	sheet_region_queue_recalc (dst, NULL);
 }
 
 static void



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