Commit 232b5ec2 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

undo support for shift range.

The first half of the solution to the paste_cut problems.

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

	* src/commands.c (cmd_ins_del_row_col_destroy) : Fix leak.
	(cmd_paste_cut_*) : We do need to worry about invalidations.  Any
	  references to the portions of the destination region that do not
	  overlap the src region get invalidated.

	* src/ranges.c (range_translate) : Adjust the semantics so that the
	  result warns of a range that was translated completly out of bounds.

	* src/sheet.c (sheet_move_range) : Invalidate the references to the
	  portions of the destination range that do NOT overlap with the src.
	(sheet_shift_{cols,rows}) : Rename and move to..
	* src/cmd-edit.c (cmd_shift_{cols,rows}) : here.  Use cmd_paste_cut
	  instead of sheet_move_range directly.

	* src/dialogs/dialog-{insert,delete}.c : Switch to cmd_shift_{cols,rows}.

	* src/history.c (history_menu_insert_separator) : Add a more detailed
	  explaination when the history lookup fails.
parent eb9a207a
2000-05-31 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_ins_del_row_col_destroy) : Fix leak.
(cmd_paste_cut_*) : We do need to worry about invalidations. Any
references to the portions of the destination region that do not
overlap the src region get invalidated.
* src/ranges.c (range_translate) : Adjust the semantics so that the
result warns of a range that was translated completly out of bounds.
* src/sheet.c (sheet_move_range) : Invalidate the references to the
portions of the destination range that do NOT overlap with the src.
(sheet_shift_{cols,rows}) : Rename and move to..
* src/cmd-edit.c (cmd_shift_{cols,rows}) : here. Use cmd_paste_cut
instead of sheet_move_range directly.
* src/dialogs/dialog-{insert,delete}.c : Switch to cmd_shift_{cols,rows}.
* src/history.c (history_menu_insert_separator) : Add a more detailed
explaination when the history lookup fails.
2000-05-30 Morten Welinder <terra@diku.dk>
* src/format.c (find_decimal_char): Remove over-constification.
......
2000-05-31 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_ins_del_row_col_destroy) : Fix leak.
(cmd_paste_cut_*) : We do need to worry about invalidations. Any
references to the portions of the destination region that do not
overlap the src region get invalidated.
* src/ranges.c (range_translate) : Adjust the semantics so that the
result warns of a range that was translated completly out of bounds.
* src/sheet.c (sheet_move_range) : Invalidate the references to the
portions of the destination range that do NOT overlap with the src.
(sheet_shift_{cols,rows}) : Rename and move to..
* src/cmd-edit.c (cmd_shift_{cols,rows}) : here. Use cmd_paste_cut
instead of sheet_move_range directly.
* src/dialogs/dialog-{insert,delete}.c : Switch to cmd_shift_{cols,rows}.
* src/history.c (history_menu_insert_separator) : Add a more detailed
explaination when the history lookup fails.
2000-05-30 Morten Welinder <terra@diku.dk>
* src/format.c (find_decimal_char): Remove over-constification.
......
2000-05-31 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_ins_del_row_col_destroy) : Fix leak.
(cmd_paste_cut_*) : We do need to worry about invalidations. Any
references to the portions of the destination region that do not
overlap the src region get invalidated.
* src/ranges.c (range_translate) : Adjust the semantics so that the
result warns of a range that was translated completly out of bounds.
* src/sheet.c (sheet_move_range) : Invalidate the references to the
portions of the destination range that do NOT overlap with the src.
(sheet_shift_{cols,rows}) : Rename and move to..
* src/cmd-edit.c (cmd_shift_{cols,rows}) : here. Use cmd_paste_cut
instead of sheet_move_range directly.
* src/dialogs/dialog-{insert,delete}.c : Switch to cmd_shift_{cols,rows}.
* src/history.c (history_menu_insert_separator) : Add a more detailed
explaination when the history lookup fails.
2000-05-30 Morten Welinder <terra@diku.dk>
* src/format.c (find_decimal_char): Remove over-constification.
......
2000-05-31 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_ins_del_row_col_destroy) : Fix leak.
(cmd_paste_cut_*) : We do need to worry about invalidations. Any
references to the portions of the destination region that do not
overlap the src region get invalidated.
* src/ranges.c (range_translate) : Adjust the semantics so that the
result warns of a range that was translated completly out of bounds.
* src/sheet.c (sheet_move_range) : Invalidate the references to the
portions of the destination range that do NOT overlap with the src.
(sheet_shift_{cols,rows}) : Rename and move to..
* src/cmd-edit.c (cmd_shift_{cols,rows}) : here. Use cmd_paste_cut
instead of sheet_move_range directly.
* src/dialogs/dialog-{insert,delete}.c : Switch to cmd_shift_{cols,rows}.
* src/history.c (history_menu_insert_separator) : Add a more detailed
explaination when the history lookup fails.
2000-05-30 Morten Welinder <terra@diku.dk>
* src/format.c (find_decimal_char): Remove over-constification.
......
2000-05-31 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_ins_del_row_col_destroy) : Fix leak.
(cmd_paste_cut_*) : We do need to worry about invalidations. Any
references to the portions of the destination region that do not
overlap the src region get invalidated.
* src/ranges.c (range_translate) : Adjust the semantics so that the
result warns of a range that was translated completly out of bounds.
* src/sheet.c (sheet_move_range) : Invalidate the references to the
portions of the destination range that do NOT overlap with the src.
(sheet_shift_{cols,rows}) : Rename and move to..
* src/cmd-edit.c (cmd_shift_{cols,rows}) : here. Use cmd_paste_cut
instead of sheet_move_range directly.
* src/dialogs/dialog-{insert,delete}.c : Switch to cmd_shift_{cols,rows}.
* src/history.c (history_menu_insert_separator) : Add a more detailed
explaination when the history lookup fails.
2000-05-30 Morten Welinder <terra@diku.dk>
* src/format.c (find_decimal_char): Remove over-constification.
......
2000-05-31 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_ins_del_row_col_destroy) : Fix leak.
(cmd_paste_cut_*) : We do need to worry about invalidations. Any
references to the portions of the destination region that do not
overlap the src region get invalidated.
* src/ranges.c (range_translate) : Adjust the semantics so that the
result warns of a range that was translated completly out of bounds.
* src/sheet.c (sheet_move_range) : Invalidate the references to the
portions of the destination range that do NOT overlap with the src.
(sheet_shift_{cols,rows}) : Rename and move to..
* src/cmd-edit.c (cmd_shift_{cols,rows}) : here. Use cmd_paste_cut
instead of sheet_move_range directly.
* src/dialogs/dialog-{insert,delete}.c : Switch to cmd_shift_{cols,rows}.
* src/history.c (history_menu_insert_separator) : Add a more detailed
explaination when the history lookup fails.
2000-05-30 Morten Welinder <terra@diku.dk>
* src/format.c (find_decimal_char): Remove over-constification.
......
2000-05-31 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_ins_del_row_col_destroy) : Fix leak.
(cmd_paste_cut_*) : We do need to worry about invalidations. Any
references to the portions of the destination region that do not
overlap the src region get invalidated.
* src/ranges.c (range_translate) : Adjust the semantics so that the
result warns of a range that was translated completly out of bounds.
* src/sheet.c (sheet_move_range) : Invalidate the references to the
portions of the destination range that do NOT overlap with the src.
(sheet_shift_{cols,rows}) : Rename and move to..
* src/cmd-edit.c (cmd_shift_{cols,rows}) : here. Use cmd_paste_cut
instead of sheet_move_range directly.
* src/dialogs/dialog-{insert,delete}.c : Switch to cmd_shift_{cols,rows}.
* src/history.c (history_menu_insert_separator) : Add a more detailed
explaination when the history lookup fails.
2000-05-30 Morten Welinder <terra@diku.dk>
* src/format.c (find_decimal_char): Remove over-constification.
......
......@@ -363,3 +363,67 @@ cmd_paste_to_selection (CommandContext *context, Sheet *dest_sheet, int paste_fl
pt.paste_flags = paste_flags;
cmd_paste (context, &pt, GDK_CURRENT_TIME);
}
/**
* cmd_shift_rows:
* @context The error context.
* @sheet the sheet
* @col column marking the start of the shift
* @start_row first row
* @end_row end row
* @count numbers of columns to shift. negative numbers will
* delete count columns, positive number will insert
* count columns.
*
* Takes the cells in the region (col,start_row):(MAX_COL,end_row)
* and copies them @count units (possibly negative) to the right.
*/
void
cmd_shift_rows (CommandContext *context, Sheet *sheet,
int col, int start_row, int end_row, int count)
{
ExprRelocateInfo rinfo;
rinfo.col_offset = count;
rinfo.row_offset = 0;
rinfo.origin_sheet = rinfo.target_sheet = sheet;
rinfo.origin.start.row = start_row;
rinfo.origin.start.col = col;
rinfo.origin.end.row = end_row;
rinfo.origin.end.col = SHEET_MAX_COLS-1;
cmd_paste_cut (context, &rinfo);
}
/**
* cmd_shift_cols:
* @context The error context.
* @sheet the sheet
* @start_col first column
* @end_col end column
* @row row marking the start of the shift
* @count numbers of rows to shift. a negative numbers will
* delete count rows, positive number will insert
* count rows.
*
* Takes the cells in the region (start_col,row):(end_col,MAX_ROW)
* and copies them @count units (possibly negative) downwards.
*/
void
cmd_shift_cols (CommandContext *context, Sheet *sheet,
int start_col, int end_col, int row, int count)
{
ExprRelocateInfo rinfo;
rinfo.col_offset = 0;
rinfo.row_offset = count;
rinfo.origin_sheet = rinfo.target_sheet = sheet;
rinfo.origin.start.col = start_col;
rinfo.origin.start.row = row;
rinfo.origin.end.col = end_col;
rinfo.origin.end.row = SHEET_MAX_ROWS-1;
cmd_paste_cut (context, &rinfo);
}
......@@ -14,4 +14,11 @@ void cmd_paste_to_selection (CommandContext *context, Sheet *sheet, int flags);
void cmd_paste (CommandContext *context, PasteTarget const *pt,
guint32 time);
void cmd_shift_cols (CommandContext *context, Sheet *sheet,
int start_col, int end_col,
int row, int count);
void cmd_shift_rows (CommandContext *context, Sheet *sheet,
int col,
int start_row, int end_row, int count);
#endif /* GNUMERIC_CMD_EDIT_H */
......@@ -768,6 +768,10 @@ cmd_ins_del_row_col_destroy (GtkObject *cmd)
clipboard_release (me->contents);
me->contents = NULL;
}
if (me->reloc_storage) {
workbook_expr_unrelocate_free (me->reloc_storage);
me->reloc_storage = NULL;
}
gnumeric_command_destroy (cmd);
}
......@@ -1698,6 +1702,7 @@ typedef struct
ExprRelocateInfo info;
CellRegion *contents;
GSList *reloc_storage;
} CmdPasteCut;
GNUMERIC_MAKE_COMMAND (CmdPasteCut, cmd_paste_cut);
......@@ -1708,6 +1713,7 @@ cmd_paste_cut_undo (GnumericCommand *cmd, CommandContext *context)
CmdPasteCut *me = CMD_PASTE_CUT(cmd);
ExprRelocateInfo reverse;
PasteTarget pt;
GSList *tmp = NULL;
g_return_val_if_fail (me != NULL, TRUE);
g_return_val_if_fail (me->contents != NULL, TRUE);
......@@ -1721,7 +1727,11 @@ cmd_paste_cut_undo (GnumericCommand *cmd, CommandContext *context)
reverse.col_offset = -me->info.col_offset;
reverse.row_offset = -me->info.row_offset;
sheet_move_range (context, &reverse);
sheet_move_range (context, &reverse, &tmp);
/* Throw away the undo info, we do not care */
workbook_expr_unrelocate_free (tmp);
clipboard_paste_region (context,
paste_target_init (&pt, me->info.target_sheet,
&reverse.origin, PASTE_ALL_TYPES),
......@@ -1729,6 +1739,11 @@ cmd_paste_cut_undo (GnumericCommand *cmd, CommandContext *context)
clipboard_release (me->contents);
me->contents = NULL;
/* Restore the changed expressions before the action */
workbook_expr_unrelocate (me->info.target_sheet->workbook,
me->reloc_storage);
me->reloc_storage = NULL;
/* Force update of the status area */
sheet_flag_status_update_range (me->info.target_sheet, NULL /* force update */);
......@@ -1747,10 +1762,18 @@ cmd_paste_cut_redo (GnumericCommand *cmd, CommandContext *context)
g_return_val_if_fail (me != NULL, TRUE);
g_return_val_if_fail (me->contents == NULL, TRUE);
g_return_val_if_fail (me->reloc_storage == NULL, TRUE);
tmp = me->info.origin;
range_translate (&tmp, me->info.col_offset, me->info.row_offset);
if (range_translate (&tmp, me->info.col_offset, me->info.row_offset)) {
g_warning ("Attempt to move range entirely off sheet ??");
return TRUE;
}
/* FIXME FIXME FIXME
* need to store any portions of src content that are moving off the
* sheet.
*/
/* Store the original contents */
me->contents = clipboard_copy_range (me->info.target_sheet, &tmp);
......@@ -1760,7 +1783,7 @@ cmd_paste_cut_redo (GnumericCommand *cmd, CommandContext *context)
tmp.start.col, tmp.start.row,
tmp.end.col, tmp.end.row);
sheet_move_range (context, &me->info);
sheet_move_range (context, &me->info, &me->reloc_storage);
sheet_set_dirty (me->info.target_sheet, TRUE);
workbook_recalc (me->info.target_sheet->workbook);
......@@ -1777,6 +1800,10 @@ cmd_paste_cut_destroy (GtkObject *cmd)
clipboard_release (me->contents);
me->contents = NULL;
}
if (me->reloc_storage) {
workbook_expr_unrelocate_free (me->reloc_storage);
me->reloc_storage = NULL;
}
gnumeric_command_destroy (cmd);
}
......@@ -1797,6 +1824,7 @@ cmd_paste_cut (CommandContext *context, ExprRelocateInfo const *info)
/* Store the specs for the object */
me->info = *info;
me->contents = NULL;
me->reloc_storage = NULL;
me->parent.cmd_descriptor = descriptor;
......@@ -1932,123 +1960,6 @@ cmd_paste_copy (CommandContext *context,
/******************************************************************/
#define CMD_SHIFT_CELLS_TYPE (cmd_shift_cells_get_type ())
#define CMD_SHIFT_CELLS(o) (GTK_CHECK_CAST ((o), CMD_SHIFT_CELLS_TYPE, CmdShiftCells))
typedef struct
{
GnumericCommand parent;
ExprRelocateInfo info;
CellRegion *contents;
} CmdShiftCells;
GNUMERIC_MAKE_COMMAND (CmdShiftCells, cmd_shift_cells);
static gboolean
cmd_shift_cells_undo (GnumericCommand *cmd, CommandContext *context)
{
CmdShiftCells *me = CMD_SHIFT_CELLS(cmd);
ExprRelocateInfo reverse;
PasteTarget pt;
g_return_val_if_fail (me != NULL, TRUE);
g_return_val_if_fail (me->contents != NULL, TRUE);
reverse.target_sheet = me->info.origin_sheet;
reverse.origin_sheet = me->info.target_sheet;
reverse.origin = me->info.origin;
range_translate (&reverse.origin,
me->info.col_offset,
me->info.row_offset);
reverse.col_offset = -me->info.col_offset;
reverse.row_offset = -me->info.row_offset;
sheet_move_range (context, &reverse);
clipboard_paste_region (context,
paste_target_init (&pt, me->info.target_sheet,
&reverse.origin, PASTE_ALL_TYPES),
me->contents);
clipboard_release (me->contents);
me->contents = NULL;
/* Force update of the status area */
sheet_flag_status_update_range (me->info.target_sheet, NULL /* force update */);
sheet_set_dirty (me->info.target_sheet, TRUE);
workbook_recalc (me->info.target_sheet->workbook);
sheet_update (me->info.target_sheet);
return FALSE;
}
static gboolean
cmd_shift_cells_redo (GnumericCommand *cmd, CommandContext *context)
{
CmdShiftCells *me = CMD_SHIFT_CELLS(cmd);
Range tmp;
g_return_val_if_fail (me != NULL, TRUE);
g_return_val_if_fail (me->contents == NULL, TRUE);
tmp = me->info.origin;
range_translate (&tmp, me->info.col_offset, me->info.row_offset);
/* Store the original contents */
me->contents = clipboard_copy_range (me->info.target_sheet, &tmp);
/* Make sure the destination is selected */
sheet_selection_set (me->info.target_sheet,
tmp.start.col, tmp.start.row,
tmp.start.col, tmp.start.row,
tmp.end.col, tmp.end.row);
sheet_move_range (context, &me->info);
sheet_set_dirty (me->info.target_sheet, TRUE);
workbook_recalc (me->info.target_sheet->workbook);
sheet_update (me->info.target_sheet);
return FALSE;
}
static void
cmd_shift_cells_destroy (GtkObject *cmd)
{
CmdShiftCells *me = CMD_SHIFT_CELLS(cmd);
if (me->contents) {
clipboard_release (me->contents);
me->contents = NULL;
}
gnumeric_command_destroy (cmd);
}
gboolean
cmd_shift_cells (CommandContext *context, ExprRelocateInfo const *info)
{
GtkObject *obj;
CmdShiftCells *me;
/* FIXME : improve on this */
char *descriptor = g_strdup_printf (_("Shift cells") );
g_return_val_if_fail (info != NULL, TRUE);
obj = gtk_type_new (CMD_SHIFT_CELLS_TYPE);
me = CMD_SHIFT_CELLS (obj);
/* Store the specs for the object */
me->info = *info;
me->contents = NULL;
me->parent.cmd_descriptor = descriptor;
/* Register the command object */
return command_push_undo (context, info->target_sheet->workbook, obj);
}
/******************************************************************/
/*
* - Complete colrow resize
*
......
......@@ -871,7 +871,7 @@ Sheet_shift_rows (PortableServer_Servant servant,
verify_row (end_row);
verify_col (col);
sheet_shift_rows (
cmd_shift_rows (
command_context_corba (sheet->workbook), sheet,
col, start_row, end_row, count);
}
......@@ -888,7 +888,7 @@ Sheet_shift_cols (PortableServer_Servant servant,
verify_row (start_row);
verify_row (end_row);
sheet_shift_cols (
cmd_shift_cols (
command_context_corba (sheet->workbook), sheet,
col, start_row, end_row, count);
}
......
......@@ -15,6 +15,7 @@
#include "workbook-view.h"
#include "workbook.h"
#include "commands.h"
#include "cmd-edit.h"
#define GLADE_FILE "delete-cells.glade"
......@@ -46,15 +47,15 @@ dialog_delete_cells_impl (Workbook *wb, Sheet *sheet, GladeXML *gui)
rows = ss->user.end.row - ss->user.start.row + 1;
if (i == 0)
sheet_shift_rows (workbook_command_context_gui (wb), sheet,
ss->user.start.col + cols,
ss->user.start.row,
ss->user.end.row, -cols);
cmd_shift_rows (workbook_command_context_gui (wb), sheet,
ss->user.start.col + cols,
ss->user.start.row,
ss->user.end.row, -cols);
else if (i == 1)
sheet_shift_cols (workbook_command_context_gui (wb), sheet,
ss->user.start.col,
ss->user.end.col,
ss->user.start.row + rows, -rows);
cmd_shift_cols (workbook_command_context_gui (wb), sheet,
ss->user.start.col,
ss->user.end.col,
ss->user.start.row + rows, -rows);
else if (i == 2)
cmd_delete_rows (workbook_command_context_gui (wb), sheet,
ss->user.start.row, rows);
......
......@@ -15,6 +15,7 @@
#include "workbook-view.h"
#include "workbook.h"
#include "commands.h"
#include "cmd-edit.h"
#define GLADE_FILE "insert-cells.glade"
......@@ -46,15 +47,15 @@ dialog_insert_cells_impl (Workbook *wb, Sheet *sheet, GladeXML *gui)
rows = ss->user.end.row - ss->user.start.row + 1;
if (i == 0)
sheet_shift_rows (workbook_command_context_gui (wb), sheet,
ss->user.start.col,
ss->user.start.row,
ss->user.end.row, cols);
cmd_shift_rows (workbook_command_context_gui (wb), sheet,
ss->user.start.col,
ss->user.start.row,
ss->user.end.row, cols);
else if (i == 1)
sheet_shift_cols (workbook_command_context_gui (wb), sheet,
ss->user.start.col,
ss->user.end.col,
ss->user.start.row, rows);
cmd_shift_cols (workbook_command_context_gui (wb), sheet,
ss->user.start.col,
ss->user.end.col,
ss->user.start.row, rows);
else if (i == 2)
cmd_insert_rows (workbook_command_context_gui (wb), sheet,
ss->user.start.row, rows);
......
......@@ -132,8 +132,9 @@ history_menu_locate_separator (Workbook *wb)
MenuPos ret;
#ifndef ENABLE_BONOBO
char const * menu_name = _("File/Print preview");
ret.menu = gnome_app_find_menu_pos (GNOME_APP (wb->toplevel)->menubar,
_("File/Print preview"), &ret.pos);
menu_name, &ret.pos);
#else
ret.menu = NULL;
ret.pos = bonobo_ui_handler_menu_get_pos (wb->uih,
......@@ -153,12 +154,18 @@ history_menu_insert_separator (Workbook *wb)
#ifndef ENABLE_BONOBO
GtkWidget *item;
char const * menu_name = _("File/Print preview");
ret.menu = gnome_app_find_menu_pos (GNOME_APP (wb->toplevel)->menubar,
_("File/Print preview"), &ret.pos);
item = gtk_menu_item_new ();
gtk_widget_show (item);
gtk_menu_shell_insert (GTK_MENU_SHELL (ret.menu), item, ret.pos);
menu_name, &ret.pos);
if (ret.menu != NULL) {
item = gtk_menu_item_new ();
gtk_widget_show (item);
gtk_menu_shell_insert (GTK_MENU_SHELL (ret.menu), item, ret.pos);
} else
g_warning ("Probable mis-translation. '%s' : was not found. "
"Does this match the 'File/Print preview' menu exactly ?",
menu_name);
#else
ret = history_menu_locate_separator (wb);
bonobo_ui_handler_menu_new_separator (wb->uih, "/File/histsep",
......
......@@ -969,55 +969,45 @@ ranges_set_style (Sheet *sheet, GSList *ranges, MStyle *mstyle)
* @col_offset:
* @row_offset:
*
* Translate the range, returns TRUE if the range was clipped
* otherwise FALSE.
*
* Return value: range clipped.
* Translate the range clipping to the sheet bounds as needed.
*
* return TRUE if the range is no longer valid.
**/
gboolean
range_translate (Range *range, int col_offset,
int row_offset)
range_translate (Range *range, int col_offset, int row_offset)
{
gboolean clipped = FALSE;
if (range->end.col + col_offset < 0 ||
range->start.col + col_offset >= SHEET_MAX_COLS)
clipped = TRUE;
if (range->end.row + row_offset < 0 ||
range->start.row + row_offset >= SHEET_MAX_ROWS)
clipped = TRUE;
range->start.col = MIN (range->start.col + col_offset,
SHEET_MAX_COLS - 1);
range->end.col = MIN (range->end.col + col_offset,
SHEET_MAX_COLS - 1);
range->start.row = MIN (range->start.row + row_offset,
SHEET_MAX_ROWS - 1);
range->end.row = MIN (range->end.row + row_offset,
SHEET_MAX_ROWS - 1);
if (range->start.col < 0) {
range->start.col = 0;
clipped = TRUE;
range->start.col += col_offset;
range->end.col += col_offset;
range->start.row += row_offset;
range->end.row += row_offset;
/* check for inversion */
if (range->start.col > range->end.col) {
int tmp = range->start.col;
range->start.col = range->end.col;
range->end.col = tmp;
}
if (range->start.row < 0) {
range->start.row = 0;
clipped = TRUE;
if (range->start.row > range->end.row) {
int tmp = range->start.row;
range->start.row = range->end.row;
range->end.row = tmp;
}
if (range->end.col < 0) {
range->end.col = 0;
clipped = TRUE;
}
/* check for completely out of bounds */
if (range->start.col >= SHEET_MAX_COLS || range->end.col < 0 ||
range->start.row >= SHEET_MAX_ROWS || range->end.row < 0)
return TRUE;
if (range->end.row < 0) {
range->end.row = 0;
clipped = TRUE;
}
if (range->start.col < 0)
range->start.col = 0;
if (range->end.col >= SHEET_MAX_COLS)
range->end.col = SHEET_MAX_COLS-1;
if (range->start.row < 0)
range->start.row = 0;
if (range->end.row >= SHEET_MAX_ROWS)
range->end.row = SHEET_MAX_ROWS-1;
return clipped;
return FALSE;
}
/**
......
......@@ -656,7 +656,7 @@ sheet_selection_cut (CommandContext *context, Sheet *sheet)
* @allow_intersection : Divide the selection into nonoverlappign subranges.
*/
GSList *
selection_get_ranges (Sheet * sheet, gboolean const allow_intersection)
selection_get_ranges (Sheet *sheet, gboolean const allow_intersection)
{
GList *l;
GSList *proposed = NULL;
......@@ -696,7 +696,6 @@ selection_get_ranges (Sheet * sheet, gboolean const allow_intersection)
continue;
}
#ifdef DEBUG_SELECTION
fprintf (stderr, "a = ");
range_dump (a);
......
......@@ -3128,17 +3128,15 @@ sheet_delete_rows (CommandContext *context, Sheet *sheet,
return FALSE;
}
/*
* Excel does not support paste special from a 'cut' will we want to
* do that ?
*/
void
sheet_move_range (CommandContext *context,
ExprRelocateInfo const * rinfo)
ExprRelocateInfo const *rinfo,
GSList **reloc_storage)
{
GList *cells = NULL;
Cell *cell;
gboolean inter_sheet_formula;
Range dst;
gboolean inter_sheet_formula, out_of_range;
g_return_if_fail (rinfo != NULL);
g_return_if_fail (rinfo->origin_sheet != NULL);
......@@ -3146,17 +3144,14 @@ sheet_move_range (CommandContext *context,
g_return_if_fail (rinfo->target_sheet != NULL);
g_return_if_fail (IS_SHEET (rinfo->target_sheet));
dst = rinfo->origin;
out_of_range = range_translate (&dst,
rinfo->col_offset, rinfo->row_offset);
/* 0. Walk cells in the moving range and ensure arrays aren't divided. */
/* 1. Fix references to and from the cells which are moving */
/* All we really want is the workbook so either sheet will do */
/*
* move can never move something off the edge, so we do not need the
* list.
*/
workbook_expr_unrelocate_free (
workbook_expr_relocate (rinfo->origin_sheet->workbook, rinfo));