Commit 92922018 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Handle undo correctly when an attempt to paste fails.

2000-05-28  Jody Goldberg <jgoldberg@home.com>

	* src/commands.c (cmd_paste_copy_undo) : handle paste errors.
	(cmd_paste_copy_destroy) : do not release unless we are permitted to.

	* src/clipboard.c (clipboard_paste_region) : Return a boolean
	  indicating success or failure.

2000-05-27  Jody Goldberg <jgoldberg@home.com>

	* src/clipboard.c (clipboard_paste_region) : Off by one error.
parent 760f6863
2000-05-28 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_paste_copy_undo) : handle paste errors.
(cmd_paste_copy_destroy) : do not release unless we are permitted to.
* src/clipboard.c (clipboard_paste_region) : Return a boolean
indicating success or failure.
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_paste_region) : Off by one error.
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_update) : When recalulating all spans, we may
......
2000-05-28 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_paste_copy_undo) : handle paste errors.
(cmd_paste_copy_destroy) : do not release unless we are permitted to.
* src/clipboard.c (clipboard_paste_region) : Return a boolean
indicating success or failure.
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_paste_region) : Off by one error.
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_update) : When recalulating all spans, we may
......
2000-05-28 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_paste_copy_undo) : handle paste errors.
(cmd_paste_copy_destroy) : do not release unless we are permitted to.
* src/clipboard.c (clipboard_paste_region) : Return a boolean
indicating success or failure.
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_paste_region) : Off by one error.
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_update) : When recalulating all spans, we may
......
2000-05-28 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_paste_copy_undo) : handle paste errors.
(cmd_paste_copy_destroy) : do not release unless we are permitted to.
* src/clipboard.c (clipboard_paste_region) : Return a boolean
indicating success or failure.
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_paste_region) : Off by one error.
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_update) : When recalulating all spans, we may
......
2000-05-28 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_paste_copy_undo) : handle paste errors.
(cmd_paste_copy_destroy) : do not release unless we are permitted to.
* src/clipboard.c (clipboard_paste_region) : Return a boolean
indicating success or failure.
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_paste_region) : Off by one error.
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_update) : When recalulating all spans, we may
......
2000-05-28 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_paste_copy_undo) : handle paste errors.
(cmd_paste_copy_destroy) : do not release unless we are permitted to.
* src/clipboard.c (clipboard_paste_region) : Return a boolean
indicating success or failure.
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_paste_region) : Off by one error.
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_update) : When recalulating all spans, we may
......
2000-05-28 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_paste_copy_undo) : handle paste errors.
(cmd_paste_copy_destroy) : do not release unless we are permitted to.
* src/clipboard.c (clipboard_paste_region) : Return a boolean
indicating success or failure.
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/clipboard.c (clipboard_paste_region) : Off by one error.
2000-05-27 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_update) : When recalulating all spans, we may
......
......@@ -87,7 +87,7 @@ paste_cell_flags (Sheet *dest_sheet, int target_col, int target_row,
}
/**
* clipboard_paste_region: Main entry point for the paste code.
* clipboard_paste_region:
* @context : The context for error handling.
* @pt : Where to paste the values.
* @content : The CellRegion to paste.
......@@ -96,8 +96,10 @@ paste_cell_flags (Sheet *dest_sheet, int target_col, int target_row,
* PasteTarget (@pt). This operation is not undoable. It does not auto grow
* the destination if the target is a singleton. This is a simple interface to
* paste a region.
*
* returns : TRUE if there was a problem.
*/
void
gboolean
clipboard_paste_region (CommandContext *context,
PasteTarget const *pt,
CellRegion *content)
......@@ -124,7 +126,7 @@ clipboard_paste_region (CommandContext *context,
dst_cols, src_cols);
gnumeric_error_invalid (context, _("Unable to paste"), msg);
g_free (msg);
return;
return TRUE;
}
repeat_vertical = dst_rows/src_rows;
......@@ -135,14 +137,14 @@ clipboard_paste_region (CommandContext *context,
dst_rows, src_rows);
gnumeric_error_invalid (context, _("Unable to paste"), msg);
g_free (msg);
return;
return TRUE;
}
if ((pt->range.start.col + dst_cols) >= SHEET_MAX_COLS ||
(pt->range.start.row + dst_rows) >= SHEET_MAX_ROWS) {
if ((pt->range.start.col + dst_cols) > SHEET_MAX_COLS ||
(pt->range.start.row + dst_rows) > SHEET_MAX_ROWS) {
gnumeric_error_invalid (context, _("Unable to paste"),
_("result passes the sheet boundary"));
return;
return TRUE;
}
tmp = 0;
......@@ -210,6 +212,8 @@ clipboard_paste_region (CommandContext *context,
sheet_range_calc_spans (pt->sheet, pt->range, SPANCALC_RENDER);
sheet_flag_status_update_range (pt->sheet, &pt->range);
}
return FALSE;
}
typedef struct {
......
......@@ -52,7 +52,7 @@ struct _PasteTarget {
CellRegion *clipboard_copy_range (Sheet *sheet, Range const *r);
void clipboard_release (CellRegion *region);
void clipboard_paste_region (CommandContext *context,
gboolean clipboard_paste_region (CommandContext *context,
PasteTarget const *pt,
CellRegion *content);
void clipboard_paste (CommandContext *context,
......
......@@ -1832,7 +1832,11 @@ cmd_paste_copy_undo (GnumericCommand *cmd, CommandContext *context)
g_return_val_if_fail (me->content != NULL, TRUE);
content = clipboard_copy_range (me->dst.sheet, &me->dst.range);
clipboard_paste_region (context, &me->dst, me->content);
if (clipboard_paste_region (context, &me->dst, me->content)) {
/* There was a problem, avoid leaking */
clipboard_release (content);
return TRUE;
}
if (me->release_content)
clipboard_release (me->content);
......@@ -1864,7 +1868,8 @@ cmd_paste_copy_destroy (GtkObject *cmd)
CmdPasteCopy *me = CMD_PASTE_COPY(cmd);
if (me->content) {
clipboard_release (me->content);
if (me->release_content)
clipboard_release (me->content);
me->content = NULL;
}
gnumeric_command_destroy (cmd);
......
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