[gnumeric] Check with user before pasting too many copies. [#530956]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Check with user before pasting too many copies. [#530956]
- Date: Wed, 16 Jun 2010 18:56:52 +0000 (UTC)
commit fee47e31dbf596cf3140e5c7f7815f7061e2e142
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Wed Jun 16 12:56:26 2010 -0600
Check with user before pasting too many copies. [#530956]
2010-06-16 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/commands.c (cmd_paste_copy): check with user if more than
10000 copies are to be pasted.
ChangeLog | 5 +++++
NEWS | 1 +
src/commands.c | 47 ++++++++++++++++++++++++++++++-----------------
3 files changed, 36 insertions(+), 17 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 90484ad..24afd98 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-16 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/commands.c (cmd_paste_copy): check with user if more than
+ 10000 copies are to be pasted.
+
2010-06-16 Morten Welinder <terra gnome org>
* src/gui-util.c (gnumeric_create_tooltip): Set type hint and
diff --git a/NEWS b/NEWS
index 57cf4e6..8cbe4b5 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ Andreas:
* Provide a tool tip showing function syntax. [#56172]
* Provide more navigation options. [#15010]
* Check with user before hiding all rows or columns. [#316976]
+ * Check with user before pasting too many copies. [#530956]
Jean:
* Do not ungrab a not grabbed item. [#620369]
diff --git a/src/commands.c b/src/commands.c
index 81e6c07..d3701b3 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -2944,7 +2944,7 @@ cmd_paste_copy (WorkbookControl *wbc,
GnmPasteTarget const *pt, GnmCellRegion *cr)
{
CmdPasteCopy *me;
- int n;
+ int n_r = 1, n_c = 1;
char *range_name;
g_return_val_if_fail (pt != NULL, TRUE);
@@ -2974,34 +2974,34 @@ cmd_paste_copy (WorkbookControl *wbc,
/* see if we need to do any tiling */
GnmRange *r = &me->dst.range;
if (pt->paste_flags & PASTE_TRANSPOSE) {
- n = range_width (r) / cr->rows;
- if (n < 1) n = 1;
- r->end.col = r->start.col + n * cr->rows - 1;
+ n_c = range_width (r) / cr->rows;
+ if (n_c < 1) n_c = 1;
+ r->end.col = r->start.col + n_c * cr->rows - 1;
- n = range_height (r) / cr->cols;
- if (n < 1) n = 1;
- r->end.row = r->start.row + n * cr->cols - 1;
+ n_r = range_height (r) / cr->cols;
+ if (n_r < 1) n_r = 1;
+ r->end.row = r->start.row + n_r * cr->cols - 1;
} else {
/* Before looking for tiling if we are not transposing,
* allow pasting a full col or row from a single cell */
- n = range_width (r);
- if (n == 1 && cr->cols == gnm_sheet_get_max_cols (me->cmd.sheet)) {
+ n_c = range_width (r);
+ if (n_c == 1 && cr->cols == gnm_sheet_get_max_cols (me->cmd.sheet)) {
r->start.col = 0;
r->end.col = gnm_sheet_get_last_col (me->cmd.sheet);
} else {
- n /= cr->cols;
- if (n < 1) n = 1;
- r->end.col = r->start.col + n * cr->cols - 1;
+ n_c /= cr->cols;
+ if (n_c < 1) n_c = 1;
+ r->end.col = r->start.col + n_c * cr->cols - 1;
}
- n = range_height (r);
- if (n == 1 && cr->rows == gnm_sheet_get_max_rows (me->cmd.sheet)) {
+ n_r = range_height (r);
+ if (n_r == 1 && cr->rows == gnm_sheet_get_max_rows (me->cmd.sheet)) {
r->start.row = 0;
r->end.row = gnm_sheet_get_last_row (me->cmd.sheet);
} else {
- n /= cr->rows;
- if (n < 1) n = 1;
- r->end.row = r->start.row + n * cr->rows - 1;
+ n_r /= cr->rows;
+ if (n_r < 1) n_r = 1;
+ r->end.row = r->start.row + n_r * cr->rows - 1;
}
}
@@ -3027,6 +3027,19 @@ cmd_paste_copy (WorkbookControl *wbc,
}
}
+ if (n_c * (gnm_float)n_r > 10000.) {
+ char *number = g_strdup_printf ("%0.0" GNM_FORMAT_f,
+ (gnm_float)n_c * (gnm_float)n_r);
+ gboolean result = go_gtk_query_yes_no (wbcg_toplevel (WBC_GTK (wbc)), FALSE,
+ _("Do you really want to paste "
+ "%s copies?"), number);
+ g_free (number);
+ if (!result) {
+ g_object_unref (me);
+ return TRUE;
+ }
+ }
+
/* Use translate to do a quiet sanity check */
if (range_translate (&me->dst.range, pt->sheet, 0, 0)) {
go_cmd_context_error_invalid (GO_CMD_CONTEXT (wbc),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]