Commit 8769a02b authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Undo ins/del row/col mostly works.

A few rough edges but mostly functional.

2000-01-07  Jody Goldberg <jgoldberg@home.com>

	* src/commands.c (cmd_ins_del_row_col_*) : Implement.

	* src/cell.c (cell_set_formula_tree_simple) : Correct the docs.

	* src/sheet.c (sheet_insert_cols, sheet_insert_rows,
	  sheet_delete_cols, sheet_delete_rows) : Return flags to
	  indicate failure.  return list of expressions and locations that
	  were modified as a result of the change.

	* src/workbook.c (workbook_expr_relocate) : Correct documentation.
	(sheet_suspend_auto_expr, sheet_resume_auto_expr) : Delete unused functions.
	(workbook_expr_unrelocate, workbook_expr_unrelocate_free) : New functions.

	* src/eval.c (sheet_get_intersheet_deps) : No need for sheet member.
	(sheet_region_get_deps) : No need to init sheet.  Use g_list_concat.
	(sheet_recalc_dependencies) : All regions & cells in the sheet
	  contribute.
	(cb_cell_get_all_depends) : New function.
	(cb_sheet_get_all_depends) : New function.
parent 224121de
2000-01-07 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_ins_del_row_col_*) : Implement.
* src/cell.c (cell_set_formula_tree_simple) : Correct the docs.
* src/sheet.c (sheet_insert_cols, sheet_insert_rows,
sheet_delete_cols, sheet_delete_rows) : Return flags to
indicate failure. return list of expressions and locations that
were modified as a result of the change.
* src/workbook.c (workbook_expr_relocate) : Correct documentation.
(sheet_suspend_auto_expr, sheet_resume_auto_expr) : Delete unused functions.
(workbook_expr_unrelocate, workbook_expr_unrelocate_free) : New functions.
* src/eval.c (sheet_get_intersheet_deps) : No need for sheet member.
(sheet_region_get_deps) : No need to init sheet. Use g_list_concat.
(sheet_recalc_dependencies) : All regions & cells in the sheet
contribute.
(cb_cell_get_all_depends) : New function.
(cb_sheet_get_all_depends) : New function.
2000-01-06 Jody Goldberg <jgoldberg@home.com>
* configure.in : correct typo as per bug 4936.
......
2000-01-07 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_ins_del_row_col_*) : Implement.
* src/cell.c (cell_set_formula_tree_simple) : Correct the docs.
* src/sheet.c (sheet_insert_cols, sheet_insert_rows,
sheet_delete_cols, sheet_delete_rows) : Return flags to
indicate failure. return list of expressions and locations that
were modified as a result of the change.
* src/workbook.c (workbook_expr_relocate) : Correct documentation.
(sheet_suspend_auto_expr, sheet_resume_auto_expr) : Delete unused functions.
(workbook_expr_unrelocate, workbook_expr_unrelocate_free) : New functions.
* src/eval.c (sheet_get_intersheet_deps) : No need for sheet member.
(sheet_region_get_deps) : No need to init sheet. Use g_list_concat.
(sheet_recalc_dependencies) : All regions & cells in the sheet
contribute.
(cb_cell_get_all_depends) : New function.
(cb_sheet_get_all_depends) : New function.
2000-01-06 Jody Goldberg <jgoldberg@home.com>
* configure.in : correct typo as per bug 4936.
......
......@@ -585,9 +585,6 @@ cell_set_text (Cell *cell, const char *text)
*
* - It does not queue redraws (so you have to queue the redraw yourself
* or queue a full redraw).
*
* - It does not queue any recomputations. You have to queue the
* recompute yourself.
*/
void
cell_set_formula_tree_simple (Cell *cell, ExprTree *formula)
......
......@@ -12,11 +12,11 @@
#include "sheet.h"
#include "workbook-view.h"
#include "utils.h"
#include "clipboard.h"
/*
* NOTE : This is a work in progress
* Only the SetText command is complete and working
* insert/delete row/col is connected but not implemented.
* Only the SetText and insert/delete row/col commands are complete and working
* the rest need to be filled in.
*
* Feel free to lend a hand. There are several distinct stages to
......@@ -409,6 +409,8 @@ typedef struct
int count;
double *sizes;
CellRegion *contents;
GSList *reloc_storage;
} CmdInsDelRowCol;
GNUMERIC_MAKE_COMMAND (CmdInsDelRowCol, cmd_ins_del_row_col);
......@@ -418,68 +420,111 @@ cmd_ins_del_row_col_undo (GnumericCommand *cmd, CommandContext *context)
{
CmdInsDelRowCol *me = CMD_INS_DEL_ROW_COL(cmd);
int index;
GSList *tmp = NULL;
gboolean trouble;
g_return_val_if_fail (me != NULL, TRUE);
g_return_val_if_fail (me->sizes != NULL, TRUE);
g_return_val_if_fail (me->contents != NULL, TRUE);
/* TODO : 1) Restore the values of the deleted cells */
/* TODO : 2) Restore the styles in the cleared range */
if (!me->is_insert) {
index = me->index;
if (me->is_cols)
sheet_insert_cols (context, me->sheet, me->index, me->count);
trouble = sheet_insert_cols (context, me->sheet, me->index, me->count, &tmp);
else
sheet_insert_rows (context, me->sheet, me->index, me->count);
trouble = sheet_insert_rows (context, me->sheet, me->index, me->count, &tmp);
} else {
index = ((me->is_cols) ? SHEET_MAX_COLS : SHEET_MAX_ROWS) - me->count;
if (me->is_cols)
sheet_delete_cols (context, me->sheet, me->index, me->count);
trouble = sheet_delete_cols (context, me->sheet, me->index, me->count, &tmp);
else
sheet_delete_rows (context, me->sheet, me->index, me->count);
trouble = sheet_delete_rows (context, me->sheet, me->index, me->count, &tmp);
}
/* restore row/col sizes */
sheet_restore_row_col_sizes (me->sheet, me->is_cols, index, me->count,
me->sizes);
me->sizes = NULL;
return FALSE;
/* restore row/col contents */
if (me->is_cols)
clipboard_paste_region (context, me->contents, me->sheet,
index, 0, PASTE_ALL_TYPES,
GDK_CURRENT_TIME);
else
clipboard_paste_region (context, me->contents, me->sheet,
0, index, PASTE_ALL_TYPES,
GDK_CURRENT_TIME);
clipboard_release (me->contents);
me->contents = NULL;
/* Throw away the undo info for the expressions after the action*/
workbook_expr_unrelocate_free (tmp);
/* Restore the changed expressions before the action */
workbook_expr_unrelocate (me->sheet->workbook, me->reloc_storage);
me->reloc_storage = NULL;
return trouble;
}
static gboolean
cmd_ins_del_row_col_redo (GnumericCommand *cmd, CommandContext *context)
{
CmdInsDelRowCol *me = CMD_INS_DEL_ROW_COL(cmd);
gboolean trouble;
int index;
g_return_val_if_fail (me != NULL, TRUE);
g_return_val_if_fail (me->sizes == NULL, TRUE);
g_return_val_if_fail (me->contents == NULL, TRUE);
index = (me->is_insert)
? (((me->is_cols) ? SHEET_MAX_COLS : SHEET_MAX_ROWS) - me->count)
: me->index;
me->sizes = sheet_save_row_col_sizes (me->sheet, me->is_cols,
index, me->count);
me->contents = (me->is_cols)
? clipboard_copy_cell_range (me->sheet,
index, 0,
index + me->count - 1, SHEET_MAX_ROWS-1)
: clipboard_copy_cell_range (me->sheet,
0, index,
SHEET_MAX_COLS-1, index + me->count - 1);
/* TODO : 1) Save the values of the deleted cells */
/* TODO : 2) Save the styles in the cleared range */
if (me->is_insert) {
int const index = ((me->is_cols) ? SHEET_MAX_COLS : SHEET_MAX_ROWS) -
me->count;
me->sizes = sheet_save_row_col_sizes (me->sheet, me->is_cols,
index, me->count);
if (me->is_cols)
sheet_insert_cols (context, me->sheet, me->index, me->count);
trouble = sheet_insert_cols (context, me->sheet, me->index,
me->count, &me->reloc_storage);
else
sheet_insert_rows (context, me->sheet, me->index, me->count);
trouble = sheet_insert_rows (context, me->sheet, me->index,
me->count, &me->reloc_storage);
} else {
me->sizes = sheet_save_row_col_sizes (me->sheet, me->is_cols,
me->index, me->count);
if (me->is_cols)
sheet_delete_cols (context, me->sheet, me->index, me->count);
trouble = sheet_delete_cols (context, me->sheet, me->index,
me->count, &me->reloc_storage);
else
sheet_delete_rows (context, me->sheet, me->index, me->count);
trouble =sheet_delete_rows (context, me->sheet, me->index,
me->count, &me->reloc_storage);
}
return FALSE;
return trouble;
}
static void
cmd_ins_del_row_col_destroy (GtkObject *cmd)
{
CmdInsDelRowCol *me = CMD_INS_DEL_ROW_COL(cmd);
if (me->sizes)
if (me->sizes) {
g_free (me->sizes);
me->sizes = NULL;
}
if (me->contents) {
clipboard_release (me->contents);
me->contents = NULL;
}
gnumeric_command_destroy (cmd);
}
......@@ -505,6 +550,7 @@ cmd_ins_del_row_col (CommandContext *context,
me->index = index;
me->count = count;
me->sizes = NULL;
me->contents = NULL;
me->parent.cmd_descriptor = descriptor;
......
......@@ -943,7 +943,6 @@ sheet_get_intersheet_deps (Sheet *sheet)
typedef struct {
Range r;
Sheet *sheet;
GList *list;
} get_range_dep_closure_t;
......@@ -955,11 +954,10 @@ search_range_deps (gpointer key, gpointer value, gpointer closure)
get_range_dep_closure_t *c = closure;
GList *l;
/* No intersection is the common case */
if (!range_overlap (range, &c->r))
return;
/* verbose list concat */
/* concat a copy of depend list */
for (l = deprange->cell_list; l; l = l->next)
c->list = g_list_prepend (c->list, l->data);
}
......@@ -977,33 +975,71 @@ sheet_region_get_deps (Sheet *sheet, int start_col, int start_row,
closure.r.start.row = start_row;
closure.r.end.col = end_col;
closure.r.end.row = end_row;
closure.sheet = sheet;
closure.list = NULL;
g_hash_table_foreach (sheet->deps->range_hash,
&search_range_deps, &closure);
/*
* FIXME : Only an existing cell can depend on things.
* we should clip this.
*/
for (ix = start_col; ix <= end_col; ix++) {
for (iy = start_row; iy <= end_row; iy++) {
GList *l = get_single_dependencies (sheet, ix, iy);
closure.list = g_list_append (closure.list, l);
closure.list = g_list_concat (closure.list, l);
}
}
return closure.list;
}
static void
cb_sheet_get_all_depends (gpointer key, gpointer value, gpointer closure)
{
DependencyRange *deprange = key;
GList *l, *res = *((GList **)closure);
/* concat a copy of depend list */
for (l = deprange->cell_list; l; l = l->next)
res = g_list_prepend (res, l->data);
*((GList **)closure) = res;
}
static void
cb_cell_get_all_depends (gpointer key, gpointer value, gpointer closure)
{
Cell *cell = (Cell *) value;
GList *l = get_single_dependencies (cell->sheet,
cell->col->pos,
cell->row->pos);
*((GList **)closure) = g_list_concat (l, *((GList **)closure));
}
/**
* sheet_recalc_dependencies :
* Force a recalc of anything that depends on the cells in this sheet.
*
* @sheet : The sheet.
*
* This seems like over kill we could probably use a finer grained test.
*/
void
sheet_recalc_dependencies (Sheet *sheet)
{
GList *deps;
GList *deps = NULL;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
deps = sheet_region_get_deps (sheet, 0, 0, SHEET_MAX_COLS - 1,
SHEET_MAX_ROWS - 1);
/* Find anything that depends on something in this sheet */
g_hash_table_foreach (sheet->deps->range_hash,
&cb_sheet_get_all_depends, &deps);
/* Find anything that depends on existing cells. */
g_hash_table_foreach (sheet->cell_hash,
&cb_cell_get_all_depends, &deps);
if (deps) {
cell_queue_recalc_list (deps, TRUE);
......
......@@ -943,7 +943,6 @@ sheet_get_intersheet_deps (Sheet *sheet)
typedef struct {
Range r;
Sheet *sheet;
GList *list;
} get_range_dep_closure_t;
......@@ -955,11 +954,10 @@ search_range_deps (gpointer key, gpointer value, gpointer closure)
get_range_dep_closure_t *c = closure;
GList *l;
/* No intersection is the common case */
if (!range_overlap (range, &c->r))
return;
/* verbose list concat */
/* concat a copy of depend list */
for (l = deprange->cell_list; l; l = l->next)
c->list = g_list_prepend (c->list, l->data);
}
......@@ -977,33 +975,71 @@ sheet_region_get_deps (Sheet *sheet, int start_col, int start_row,
closure.r.start.row = start_row;
closure.r.end.col = end_col;
closure.r.end.row = end_row;
closure.sheet = sheet;
closure.list = NULL;
g_hash_table_foreach (sheet->deps->range_hash,
&search_range_deps, &closure);
/*
* FIXME : Only an existing cell can depend on things.
* we should clip this.
*/
for (ix = start_col; ix <= end_col; ix++) {
for (iy = start_row; iy <= end_row; iy++) {
GList *l = get_single_dependencies (sheet, ix, iy);
closure.list = g_list_append (closure.list, l);
closure.list = g_list_concat (closure.list, l);
}
}
return closure.list;
}
static void
cb_sheet_get_all_depends (gpointer key, gpointer value, gpointer closure)
{
DependencyRange *deprange = key;
GList *l, *res = *((GList **)closure);
/* concat a copy of depend list */
for (l = deprange->cell_list; l; l = l->next)
res = g_list_prepend (res, l->data);
*((GList **)closure) = res;
}
static void
cb_cell_get_all_depends (gpointer key, gpointer value, gpointer closure)
{
Cell *cell = (Cell *) value;
GList *l = get_single_dependencies (cell->sheet,
cell->col->pos,
cell->row->pos);
*((GList **)closure) = g_list_concat (l, *((GList **)closure));
}
/**
* sheet_recalc_dependencies :
* Force a recalc of anything that depends on the cells in this sheet.
*
* @sheet : The sheet.
*
* This seems like over kill we could probably use a finer grained test.
*/
void
sheet_recalc_dependencies (Sheet *sheet)
{
GList *deps;
GList *deps = NULL;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
deps = sheet_region_get_deps (sheet, 0, 0, SHEET_MAX_COLS - 1,
SHEET_MAX_ROWS - 1);
/* Find anything that depends on something in this sheet */
g_hash_table_foreach (sheet->deps->range_hash,
&cb_sheet_get_all_depends, &deps);
/* Find anything that depends on existing cells. */
g_hash_table_foreach (sheet->cell_hash,
&cb_cell_get_all_depends, &deps);
if (deps) {
cell_queue_recalc_list (deps, TRUE);
......
......@@ -3314,20 +3314,24 @@ colrow_move (Sheet *sheet,
* @col At which position we want to insert
* @count The number of columns to be inserted
*/
void
gboolean
sheet_insert_cols (CommandContext *context, Sheet *sheet,
int col, int count)
int col, int count, GSList **reloc_storage)
{
ExprRelocateInfo reloc_info;
int i;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (count != 0);
g_return_val_if_fail (reloc_storage != NULL, TRUE);
*reloc_storage = NULL;
g_return_val_if_fail (sheet != NULL, TRUE);
g_return_val_if_fail (IS_SHEET (sheet), TRUE);
g_return_val_if_fail (count != 0, TRUE);
/* Is there any work to do? */
if (sheet->cols.max_used < 0)
return;
return FALSE;
/* 0. Walk cells in displaced col and ensure arrays aren't divided. */
if (col > 0) /* No need to test leftmost column */
......@@ -3336,12 +3340,17 @@ sheet_insert_cols (CommandContext *context, Sheet *sheet,
&avoid_dividing_array_horizontal,
NULL) != NULL){
gnumeric_error_splits_array (context);
return;
return TRUE;
}
/* TODO TODO : Walk the right edge to make sure nothing is split
* due to over run.
*/
/* Walk the right edge to make sure nothing is split due to over run. */
if (sheet_cell_foreach_range (sheet, TRUE, SHEET_MAX_COLS-count, 0,
SHEET_MAX_COLS-1, SHEET_MAX_ROWS-1,
&avoid_dividing_array_horizontal,
NULL) != NULL){
gnumeric_error_splits_array (context);
return TRUE;
}
/* 1. Delete all columns (and their cells) that will fall off the end */
for (i = sheet->cols.max_used; i >= SHEET_MAX_COLS - count ; --i)
......@@ -3355,7 +3364,7 @@ sheet_insert_cols (CommandContext *context, Sheet *sheet,
reloc_info.origin_sheet = reloc_info.target_sheet = sheet;
reloc_info.col_offset = count;
reloc_info.row_offset = 0;
workbook_expr_relocate (sheet->workbook, &reloc_info);
*reloc_storage = workbook_expr_relocate (sheet->workbook, &reloc_info);
/* 3. Move the columns to their new location (From right to left) */
for (i = sheet->cols.max_used; i >= col ; --i)
......@@ -3370,6 +3379,8 @@ sheet_insert_cols (CommandContext *context, Sheet *sheet,
/* 6. Redraw */
sheet_redraw_all (sheet);
return FALSE;
}
/*
......@@ -3378,27 +3389,31 @@ sheet_insert_cols (CommandContext *context, Sheet *sheet,
* @col At which position we want to start deleting columns
* @count The number of columns to be deleted
*/
void
gboolean
sheet_delete_cols (CommandContext *context, Sheet *sheet,
int col, int count)
int col, int count, GSList **reloc_storage)
{
ExprRelocateInfo reloc_info;
int i;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (count != 0);
g_return_val_if_fail (reloc_storage != NULL, TRUE);
*reloc_storage = NULL;
g_return_val_if_fail (sheet != NULL, TRUE);
g_return_val_if_fail (IS_SHEET (sheet), TRUE);
g_return_val_if_fail (count != 0, TRUE);
/* Is there any work to do? */
if (sheet->cols.max_used < 0)
return;
return FALSE;
/* 0. Walk cells in deleted cols and ensure arrays aren't divided. */
if (!sheet_check_for_partial_array (sheet, 0, col,
SHEET_MAX_ROWS-1, col+count-1))
{
gnumeric_error_splits_array (context);
return;
return TRUE;
}
/* 1. Delete all columns (and their cells) that will fall off the end */
......@@ -3413,14 +3428,16 @@ sheet_delete_cols (CommandContext *context, Sheet *sheet,
reloc_info.origin_sheet = reloc_info.target_sheet = sheet;
reloc_info.col_offset = SHEET_MAX_COLS; /* send them to infinity */
reloc_info.row_offset = SHEET_MAX_ROWS; /* to force invalidation */
workbook_expr_relocate (sheet->workbook, &reloc_info);
*reloc_storage = workbook_expr_relocate (sheet->workbook, &reloc_info);
/* 3. Fix references to and from the cells which are moving */
reloc_info.origin.start.col = col+count;
reloc_info.origin.end.col = SHEET_MAX_COLS-1;
reloc_info.col_offset = -count;
reloc_info.row_offset = 0;
workbook_expr_relocate (sheet->workbook, &reloc_info);
*reloc_storage = g_slist_concat (*reloc_storage,
workbook_expr_relocate (sheet->workbook,
&reloc_info));
/* 4. Move the columns to their new location (from left to right) */
for (i = col + count ; i <= sheet->cols.max_used; ++i)
......@@ -3435,6 +3452,8 @@ sheet_delete_cols (CommandContext *context, Sheet *sheet,
/* 7. Redraw */
sheet_redraw_all (sheet);
return FALSE;
}
/**
......@@ -3443,20 +3462,24 @@ sheet_delete_cols (CommandContext *context, Sheet *sheet,
* @row At which position we want to insert
* @count The number of rows to be inserted
*/
void
gboolean
sheet_insert_rows (CommandContext *context, Sheet *sheet,
int row, int count)
int row, int count, GSList **reloc_storage)
{
ExprRelocateInfo reloc_info;
int i;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (count != 0);
g_return_val_if_fail (reloc_storage != NULL, TRUE);
*reloc_storage = NULL;
g_return_val_if_fail (sheet != NULL, TRUE);
g_return_val_if_fail (IS_SHEET (sheet), TRUE);
g_return_val_if_fail (count != 0, TRUE);
/* Is there any work to do? */
if (sheet->rows.max_used < 0)
return;
return FALSE;
/* 0. Walk cells in displaced row and ensure arrays aren't divided. */
if (row > 0) /* No need to test leftmost column */
......@@ -3466,12 +3489,17 @@ sheet_insert_rows (CommandContext *context, Sheet *sheet,
&avoid_dividing_array_vertical,
NULL) != NULL) {
gnumeric_error_splits_array (context);
return;
return TRUE;
}
/* TODO TODO : Walk the right edge to make sure nothing is split
* due to over run.
*/
/* Walk the lower edge to make sure nothing is split due to over run. */
if (sheet_cell_foreach_range (sheet, TRUE, 0, SHEET_MAX_ROWS-count,
SHEET_MAX_COLS-1, SHEET_MAX_ROWS-1,
&avoid_dividing_array_vertical,
NULL) != NULL){
gnumeric_error_splits_array (context);
return TRUE;
}
/* 1. Delete all rows (and their cells) that will fall off the end */
for (i = sheet->rows.max_used; i >= SHEET_MAX_ROWS - count ; --i)
......@@ -3485,7 +3513,7 @@ sheet_insert_rows (CommandContext *context, Sheet *sheet,
reloc_info.origin_sheet = reloc_info.target_sheet = sheet;
reloc_info.col_offset = 0;
reloc_info.row_offset = count;
workbook_expr_relocate (sheet->workbook, &reloc_info);
*reloc_storage = workbook_expr_relocate (sheet->workbook, &reloc_info);
/* 3. Move the rows to their new location (from bottom to top) */
for (i = sheet->rows.max_used; i >= row ; --i)
......@@ -3500,6 +3528,8 @@ sheet_insert_rows (CommandContext *context, Sheet *sheet,
/* 6. Redraw */
sheet_redraw_all (sheet);
return FALSE;
}
/*
......@@ -3508,27 +3538,31 @@ sheet_insert_rows (CommandContext *context, Sheet *sheet,
* @row At which position we want to start deleting rows
* @count The number of rows to be deleted
*/
void
gboolean
sheet_delete_rows (CommandContext *context, Sheet *sheet,
int row, int count)
int row, int count, GSList **reloc_storage)
{
ExprRelocateInfo reloc_info;
int i;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (count != 0);
g_return_val_if_fail (reloc_storage != NULL, TRUE);
*reloc_storage = NULL;
g_return_val_if_fail (sheet != NULL, TRUE);
g_return_val_if_fail (IS_SHEET (sheet), TRUE);
g_return_val_if_fail (count != 0, TRUE);
/* Is there any work to do? */
if (sheet->rows.max_used < 0)
return;
return FALSE;
/* 0. Walk cells in deleted rows and ensure arrays aren't divided. */
if (!sheet_check_for_partial_array (sheet, row, 0,
row+count-1, SHEET_MAX_COLS-1))
{
gnumeric_error_splits_array (context);
return;
return TRUE;
}
/* 1. Delete all cols (and their cells) that will fall off the end */
......@@ -3543,14 +3577,16 @@ sheet_delete_rows (CommandContext *context, Sheet *sheet,
reloc_info.origin_sheet = reloc_info.target_sheet = sheet;
reloc_info.col_offset = SHEET_MAX_COLS; /* send them to infinity */
reloc_info.row_offset = SHEET_MAX_ROWS; /* to force invalidation */
workbook_expr_relocate (sheet->workbook, &reloc_info);
*reloc_storage = workbook_expr_relocate (sheet->workbook, &reloc_info);
/* 3. Fix references to and from the cells which are moving */
reloc_info.origin.start.row = row + count;
reloc_info.origin.end.row = SHEET_MAX_ROWS-1;
reloc_info.col_offset = 0;
reloc_info.row_offset = -count;
workbook_expr_relocate (sheet->workbook, &reloc_info);
*reloc_storage = g_slist_concat (*reloc_storage,
workbook_expr_relocate (sheet->workbook,
&reloc_info));
/* 4. Move the rows to their new location (from top to bottom) */
for (i = row + count ; i <= sheet->rows.max_used; ++i)
......@@ -3565,6 +3601,8 @@ sheet_delete_rows (CommandContext *context, Sheet *sheet,
/* 7. Redraw */
sheet_redraw_all (sheet);
return FALSE;
}
/*
......
......@@ -317,15 +317,6 @@ void sheet_redraw_all (Sheet const *sheet);
void sheet_update_auto_expr (Sheet *sheet);
/*
* A Pair of utilities to temporarily suspend auto_expr's while reading
* worksheets.
*/
void sheet_suspend_auto_expr (Workbook *wb,
ExprTree **expr, String **desc);
void sheet_resume_auto_expr (Workbook *wb,
ExprTree *expr, String *desc);
void sheet_mark_clean (Sheet *sheet);
void sheet_set_dirty (Sheet *sheet, gboolean is_dirty);
gboolean sheet_is_pristine (Sheet *sheet);
......@@ -392,17 +383,17 @@ void sheet_corba_shutdown (Sheet *);
* These have undo/redo capabilities
* and will route error messages to the caller appropriately.
*/
void sheet_insert_cols (CommandContext *context, Sheet *sheet,
int col, int count);
void sheet_delete_cols (CommandContext *context, Sheet *sheet,
int col, int count);
gboolean sheet_insert_cols (CommandContext *context, Sheet *sheet,
int col, int count, GSList **reloc_storage);
gboolean sheet_delete_cols (CommandContext *context, Sheet *sheet,
int col, int count, GSList **reloc_storage);
void sheet_shift_cols (CommandContext *context, Sheet *sheet,
int start_col, int end_col,
int row, int count);
void sheet_insert_rows (CommandContext *context, Sheet *sheet,
int row, int count);
void sheet_delete_rows (CommandContext *context, Sheet *sheet,
int row, int count);
gboolean sheet_insert_rows (CommandContext *context, Sheet *sheet,
int row, int count, GSList **reloc_storage);
gboolean sheet_delete_rows (CommandContext *context, Sheet *sheet,
int row, int count, GSList **reloc_storage);
void sheet_shift_rows (CommandContext *context, Sheet *sheet,
int col,
int start_row, int end_row, int count);
......
......@@ -162,8 +162,11 @@ gboolean workbook_can_detach_sheet (Workbook *wb, Sheet *sheet);
GList *workbook_sheets (Workbook *wb);
char *workbook_selection_to_string (Workbook *wb, Sheet *base_sheet);
void workbook_expr_relocate (Workbook *wb,
GSList *workbook_expr_relocate (Workbook