[gnumeric] Avoid extra undo items when entering expressions.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Avoid extra undo items when entering expressions.
- Date: Fri, 13 Aug 2010 23:43:21 +0000 (UTC)
commit e14523caee9e690ce29a365d94904e3d6144eb44
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Fri Aug 13 17:42:47 2010 -0600
Avoid extra undo items when entering expressions.
2010-08-13 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/commands.c (cmd_set_text_full_check_texpr): new
(cmd_set_text_full): check whether we are entering the same expression
already in all cells.
ChangeLog | 6 ++++++
src/commands.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2c841a5..ac0f61f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2010-08-13 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * src/commands.c (cmd_set_text_full_check_texpr): new
+ (cmd_set_text_full): check whether we are entering the same expression
+ already in all cells.
+
+2010-08-13 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* src/commands.c (cmd_set_text_full): always autofit the rows and also
autofit the columns for non-strings.
diff --git a/src/commands.c b/src/commands.c
index 845b258..bd6e534 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -748,6 +748,14 @@ cmd_set_text_full_autofit_col (Sheet *sheet, GnmRange *r)
}
+static GnmValue *
+cmd_set_text_full_check_texpr (GnmCellIter const *iter, GnmExprTop const *texpr)
+{
+ if (iter->cell == NULL ||
+ !gnm_expr_top_equal (iter->cell->base.texpr, texpr))
+ return VALUE_TERMINATE;
+ return NULL;
+}
/******************************************************************/
@@ -817,6 +825,30 @@ cmd_set_text_full (WorkbookControl *wbc, GSList *selection, GnmEvalPos *ep,
if (texpr != NULL) {
GOFormat *sf;
GnmStyle *new_style = NULL;
+ gboolean same_texpr = TRUE;
+
+ /* We should check whether we are in fact changing anything: */
+ for (l = selection; l != NULL && same_texpr; l = l->next) {
+ GnmRange *r = l->data;
+ GnmValue *val =
+ sheet_foreach_cell_in_range
+ (sheet, CELL_ITER_ALL,
+ r->start.col, r->start.row,
+ r->end.col, r->end.row,
+ (CellIterFunc) cmd_set_text_full_check_texpr,
+ (gpointer) texpr);
+
+ same_texpr = (val != VALUE_TERMINATE);
+ if (val != NULL && same_texpr)
+ value_release (val);
+ }
+
+ if (same_texpr) {
+ gnm_expr_top_unref (texpr);
+ g_free (name);
+ range_fragment_free (selection);
+ return TRUE;
+ }
text = g_strdup_printf (_("Inserting expression in %s"), name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]