[gnumeric] Provide undo for cut between 2 gnumeric processes. [#640922]



commit f1039649b8d270699529d0fca6674bcced101d87
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue Jul 12 12:53:56 2011 -0600

    Provide undo for cut between 2 gnumeric processes. [#640922]
    
    2011-07-12  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/gui-clipboard.c (x_clipboard_get_cb): provide undo of cut.

 ChangeLog           |    4 ++++
 NEWS                |    3 ++-
 src/gui-clipboard.c |   26 ++++++++++++++++++--------
 3 files changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 62b1404..49c2496 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2011-07-09  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* src/gui-clipboard.c (x_clipboard_get_cb): provide undo of cut.
+
+2011-07-09  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* src/style-conditions.c (gnm_style_conditions_eval): != IS_LESS is
 	not the same as == IS_EQUAL || == IS_GREATER
 
diff --git a/NEWS b/NEWS
index 9f73a74..99f9194 100644
--- a/NEWS
+++ b/NEWS
@@ -8,7 +8,8 @@ Andreas:
 	* Fix keyword handling in properties dialog. [#653378]
 	* Allow document properties to be edited and added.
 	* Add an interface for conditional styles.
-	* Fix ODF import of styles with inherited conditional styles. [#654214]  
+	* Fix ODF import of styles with inherited conditional styles. [#654214] 
+	* Provide undo for cut between 2 gnumeric processes. [#640922] 
 
 Morten:
 	* Fix --with-gnome compilation:  [#652802]
diff --git a/src/gui-clipboard.c b/src/gui-clipboard.c
index 8ad866d..1704307 100644
--- a/src/gui-clipboard.c
+++ b/src/gui-clipboard.c
@@ -25,6 +25,7 @@
 #include "sheet-style.h"
 #include "sheet-object.h"
 #include "sheet-control-gui.h"
+#include "sheet-view.h"
 #include "commands.h"
 #include "value.h"
 #include "number-match.h"
@@ -949,14 +950,23 @@ x_clipboard_get_cb (GtkClipboard *gclipboard, GtkSelectionData *selection_data,
 
 		/* If the other app was a gnumeric, emulate a cut */
 		if (to_gnumeric) {
-			/* FIXME: This needs undo.
-			 * Use a variant of cmd_selection_clear that would use
-			 * the src range rather than the current selection */
-			sheet_clear_region (sheet,
-				a->start.col, a->start.row,
-				a->end.col,   a->end.row,
-				CLEAR_VALUES|CLEAR_COMMENTS|CLEAR_RECALC_DEPS,
-				ctx);
+			GOUndo *redo, *undo;
+			GnmSheetRange *sr    = gnm_sheet_range_new (sheet, a);
+			SheetView const *sv  = gnm_app_clipboard_sheet_view_get ();
+			SheetControl *sc     = g_ptr_array_index (sv->controls, 0);
+			WorkbookControl *wbc = sc_wbc (sc);
+			char *name;
+			char *text;
+
+			redo = sheet_clear_region_undo 
+				(sr, 
+				 CLEAR_VALUES|CLEAR_COMMENTS|CLEAR_RECALC_DEPS);
+			undo = clipboard_copy_range_undo (sheet, a);
+			name = undo_range_name (sheet, a);
+			text = g_strdup_printf (_("Cut of %s"), name);
+			g_free (name);
+			cmd_generic (wbc, text, undo, redo);
+			g_free (text);
 			gnm_app_clipboard_clear (TRUE);
 		}
 



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