Commit d2e3ba6b authored by Andreas J. Guelzow 's avatar Andreas J. Guelzow

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
parent fac60238
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
......
......@@ -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]
......
......@@ -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")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment