[gnumeric] Protect against accidentally pushing data off the sheet. [#98562]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Protect against accidentally pushing data off the sheet. [#98562]
- Date: Fri, 30 Apr 2010 22:47:59 +0000 (UTC)
commit d2e3ba6baa7a79948b31d45136bc8599d30fb614
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Fri Apr 30 16:47:34 2010 -0600
Protect against accidentally pushing data off the sheet. [#98562]
2010-04-30 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/cmd-edit.c (cmd_shift_rows): protect against data loss
(cmd_shift_cols): ditto
ChangeLog | 5 +++++
NEWS | 3 +--
src/cmd-edit.c | 27 +++++++++++++++++++++++++--
3 files changed, 31 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9f2ea8c..47bd064 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2010-04-30 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * src/cmd-edit.c (cmd_shift_rows): protect against data loss
+ (cmd_shift_cols): ditto
+
+2010-04-30 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* src/commands.c (cmd_insert_cols): protect against data loss
(cmd_insert_rows): ditto
diff --git a/NEWS b/NEWS
index f3acd6d..e878db0 100644
--- a/NEWS
+++ b/NEWS
@@ -5,8 +5,7 @@ Andreas:
* Fix printing and preview of graph only sheets. [#616475]
* Make even active sheets invisible. [#616474]
* Improve date & time import from and export to ODF. [#617208]
- * Protect (partially) against accidentally pushing data
- off the sheet. [#98562]
+ * Protect against accidentally pushing data off the sheet. [#98562]
Jean:
* Implement graph only sheets. [#158170]
diff --git a/src/cmd-edit.c b/src/cmd-edit.c
index e9b12d5..cd7bb7d 100644
--- a/src/cmd-edit.c
+++ b/src/cmd-edit.c
@@ -40,6 +40,7 @@
#include "commands.h"
#include "clipboard.h"
#include "value.h"
+#include "wbc-gtk.h"
/**
* sv_select_cur_row:
@@ -400,8 +401,20 @@ cmd_shift_rows (WorkbookControl *wbc, Sheet *sheet,
rinfo.origin.start.col = col;
rinfo.origin.end.row = end_row;
rinfo.origin.end.col = gnm_sheet_get_last_col (sheet);
- if (count > 0)
+
+
+ if (count > 0) {
+ GnmRange r = rinfo.origin;
+ r.start.col = r.end.col - count + 1;
+
+ if (!sheet_is_region_empty (sheet, &r)) {
+ go_gtk_notice_dialog (wbcg_toplevel (WBC_GTK (wbc)), GTK_MESSAGE_ERROR,
+ _("Inserting these cells would push data off the sheet. "
+ "Please enlarge the sheet first."));
+ return;
+ }
rinfo.origin.end.col -= count;
+ }
desc = g_strdup_printf ((start_row != end_row)
? _("Shift rows %s")
@@ -439,8 +452,18 @@ cmd_shift_cols (WorkbookControl *wbc, Sheet *sheet,
rinfo.origin.start.row = row;
rinfo.origin.end.col = end_col;
rinfo.origin.end.row = gnm_sheet_get_last_row (sheet);
- if (count > 0)
+ if (count > 0) {
+ GnmRange r = rinfo.origin;
+ r.start.row = r.end.row - count + 1;
+
+ if (!sheet_is_region_empty (sheet, &r)) {
+ go_gtk_notice_dialog (wbcg_toplevel (WBC_GTK (wbc)), GTK_MESSAGE_ERROR,
+ _("Inserting these cells would push data off the sheet. "
+ "Please enlarge the sheet first."));
+ return;
+ }
rinfo.origin.end.row -= count;
+ }
desc = g_strdup_printf ((start_col != end_col)
? _("Shift columns %s")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]