Commit 3b845536 authored by Morten Welinder's avatar Morten Welinder

Relocation and fixup patch.

parent 2a9a3045
1999-05-07 Heath Martin <martinh@pegasus.cc.ucf.edu>
* src/expr.c (expr_tree_invalidate_references): Add extra argument
for the sheet we are changing. All callers changed.
(expr_tree_fixup_references): Ditto.
1999-05-06 Morten Welinder <terra@diku.dk>
* src/eval.c (cell_queue_recalc): Don't re-queue cell.
......
1999-05-07 Heath Martin <martinh@pegasus.cc.ucf.edu>
* src/expr.c (expr_tree_invalidate_references): Add extra argument
for the sheet we are changing. All callers changed.
(expr_tree_fixup_references): Ditto.
1999-05-06 Morten Welinder <terra@diku.dk>
* src/eval.c (cell_queue_recalc): Don't re-queue cell.
......
1999-05-07 Heath Martin <martinh@pegasus.cc.ucf.edu>
* src/expr.c (expr_tree_invalidate_references): Add extra argument
for the sheet we are changing. All callers changed.
(expr_tree_fixup_references): Ditto.
1999-05-06 Morten Welinder <terra@diku.dk>
* src/eval.c (cell_queue_recalc): Don't re-queue cell.
......
1999-05-07 Heath Martin <martinh@pegasus.cc.ucf.edu>
* src/expr.c (expr_tree_invalidate_references): Add extra argument
for the sheet we are changing. All callers changed.
(expr_tree_fixup_references): Ditto.
1999-05-06 Morten Welinder <terra@diku.dk>
* src/eval.c (cell_queue_recalc): Don't re-queue cell.
......
......@@ -1467,7 +1467,7 @@ build_error_string (const char *txt)
struct expr_tree_frob_references {
Sheet *sheet;
Sheet *src_sheet;
int src_col, src_row;
gboolean invalidating_columns;
......@@ -1481,6 +1481,9 @@ struct expr_tree_frob_references {
/* Relative move (fixup only). */
int coldelta, rowdelta;
/* In this sheet */
Sheet *sheet;
/* Are we deleting? (fixup only). */
gboolean deleting;
};
......@@ -1630,8 +1633,9 @@ do_expr_tree_invalidate_references (ExprTree *src, const struct expr_tree_frob_r
* this is not intended for use when just the cell contents is delete.
*/
ExprTree *
expr_tree_invalidate_references (ExprTree *src, Sheet *sheet,
expr_tree_invalidate_references (ExprTree *src, Sheet *src_sheet,
int src_col, int src_row,
Sheet *sheet,
int col, int row,
int colcount, int rowcount)
{
......@@ -1639,13 +1643,16 @@ expr_tree_invalidate_references (ExprTree *src, Sheet *sheet,
ExprTree *dst;
g_return_val_if_fail (src != NULL, NULL);
g_return_val_if_fail (src_sheet != NULL, NULL);
g_return_val_if_fail (IS_SHEET (src_sheet), NULL);
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (IS_SHEET (sheet), NULL);
info.sheet = sheet;
info.src_sheet = src_sheet;
info.src_col = src_col;
info.src_row = src_row;
info.invalidating_columns = (colcount > 0);
info.sheet = sheet;
info.col = col;
info.colcount = colcount;
info.row = row;
......@@ -1653,7 +1660,7 @@ expr_tree_invalidate_references (ExprTree *src, Sheet *sheet,
{
char *str;
str = expr_decode_tree (src, sheet, src_col, src_row);
str = expr_decode_tree (src, src_sheet, src_col, src_row);
printf ("Invalidate: %s: [%s]\n", cell_name (src_col, src_row), str);
g_free (str);
}
......@@ -1662,7 +1669,7 @@ expr_tree_invalidate_references (ExprTree *src, Sheet *sheet,
{
char *str;
str = dst ? expr_decode_tree (dst, sheet, src_col, src_row) : g_strdup ("*");
str = dst ? expr_decode_tree (dst, src_sheet, src_col, src_row) : g_strdup ("*");
printf ("Invalidate: %s: [%s]\n\n", cell_name (src_col, src_row), str);
g_free (str);
}
......@@ -1750,7 +1757,7 @@ do_expr_tree_fixup_references (ExprTree *src, const struct expr_tree_frob_refere
case OPER_VAR: {
CellRef cr = src->u.ref; /* Copy a structure, not a pointer. */
/* If the sheet is wrong, do nothing. */
/* If the sheet is wrong, do nothing. */
if (cr.sheet != info->sheet)
return NULL;
......@@ -1859,20 +1866,23 @@ do_expr_tree_fixup_references (ExprTree *src, const struct expr_tree_frob_refere
ExprTree *
expr_tree_fixup_references (ExprTree *src, Sheet *sheet,
int src_col, int src_row, int col, int row,
expr_tree_fixup_references (ExprTree *src, Sheet *src_sheet,
int src_col, int src_row, Sheet *sheet, int col, int row,
int coldelta, int rowdelta)
{
struct expr_tree_frob_references info;
ExprTree *dst;
g_return_val_if_fail (src != NULL, NULL);
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (IS_SHEET (sheet), NULL);
info.sheet = sheet;
g_return_val_if_fail (src_sheet != NULL, NULL);
g_return_val_if_fail (IS_SHEET (src_sheet), NULL);
g_return_val_if_fail(sheet != NULL, NULL);
g_return_val_if_fail(IS_SHEET(sheet), NULL);
info.src_sheet = src_sheet;
info.src_col = src_col;
info.src_row = src_row;
info.sheet = sheet;
info.col = col;
info.row = row;
info.coldelta = coldelta;
......@@ -1883,7 +1893,7 @@ expr_tree_fixup_references (ExprTree *src, Sheet *sheet,
{
char *str;
str = expr_decode_tree (src, sheet, src_col, src_row);
str = expr_decode_tree (src, src_sheet, src_col, src_row);
printf ("Fixup: %s: [%s]\n", cell_name (src_col, src_row), str);
g_free (str);
}
......@@ -1892,7 +1902,7 @@ expr_tree_fixup_references (ExprTree *src, Sheet *sheet,
{
char *str;
str = dst ? expr_decode_tree (dst, sheet, src_col, src_row) : g_strdup ("*");
str = dst ? expr_decode_tree (dst, src_sheet, src_col, src_row) : g_strdup ("*");
printf ("Fixup: %s: [%s]\n\n", cell_name (src_col, src_row), str);
g_free (str);
}
......
......@@ -167,12 +167,12 @@ ExprTree *expr_tree_new (void);
void expr_tree_ref (ExprTree *tree);
void expr_tree_unref (ExprTree *tree);
ExprTree *expr_tree_invalidate_references (ExprTree *src, Sheet *sheet,
int src_col, int src_row, int col, int row,
ExprTree *expr_tree_invalidate_references (ExprTree *src, Sheet *src_sheet,
int src_col, int src_row, Sheet *sheet, int col, int row,
int colcount, int rowcount);
ExprTree *expr_tree_fixup_references (ExprTree *src, Sheet *sheet,
int src_col, int src_row, int col, int row,
ExprTree *expr_tree_fixup_references (ExprTree *src, Sheet *src_sheet,
int src_col, int src_row, Sheet *sheet, int col, int row,
int coldelta, int rowdelta);
Value *eval_expr (Sheet *sheet, ExprTree *tree,
......
......@@ -2671,7 +2671,7 @@ sheet_insert_col (Sheet *sheet, int col, int count)
cur_col = cur_col->prev;
} while (cur_col);
workbook_fixup_references (sheet->workbook, col, 0, count, 0);
workbook_fixup_references (sheet->workbook, sheet, col, 0, count, 0);
/* 2. Recompute dependencies */
deps = region_get_dependencies (sheet, col, 0, SHEET_MAX_COLS-1, SHEET_MAX_ROWS-1);
......@@ -2703,7 +2703,7 @@ sheet_delete_col (Sheet *sheet, int col, int count)
return;
/* Invalidate all references to cells being deleted. */
workbook_invalidate_references (sheet->workbook, col, 0, count, 0);
workbook_invalidate_references (sheet->workbook, sheet, col, 0, count, 0);
/* Assemble the list of columns to destroy */
destroy_list = NULL;
......@@ -2736,7 +2736,7 @@ sheet_delete_col (Sheet *sheet, int col, int count)
sheet_move_column (sheet, ci, ci->pos-count);
}
workbook_fixup_references (sheet->workbook, col, 0, -count, 0);
workbook_fixup_references (sheet->workbook, sheet, col, 0, -count, 0);
/* Recompute dependencies */
deps = region_get_dependencies (sheet, col, 0, SHEET_MAX_COLS-1, SHEET_MAX_ROWS-1);
......@@ -2961,7 +2961,7 @@ sheet_insert_row (Sheet *sheet, int row, int count)
g_list_free (cell_store);
workbook_fixup_references (sheet->workbook, 0, row, 0, count);
workbook_fixup_references (sheet->workbook, sheet, 0, row, 0, count);
/* 4. Recompute any changes required */
deps = region_get_dependencies (sheet, 0, row, SHEET_MAX_COLS-1, SHEET_MAX_ROWS-1);
......@@ -2988,7 +2988,7 @@ sheet_delete_row (Sheet *sheet, int row, int count)
g_return_if_fail (count != 0);
/* Invalidate all references to cells being deleted. */
workbook_invalidate_references (sheet->workbook, 0, row, 0, count);
workbook_invalidate_references (sheet->workbook, sheet, 0, row, 0, count);
/* 1. Remove cells from hash tables and grab all dangling rows */
cell_store = NULL;
......@@ -3058,7 +3058,7 @@ sheet_delete_row (Sheet *sheet, int row, int count)
}
g_list_free (cell_store);
workbook_fixup_references (sheet->workbook, 0, row, 0, -count);
workbook_fixup_references (sheet->workbook, sheet, 0, row, 0, -count);
/* 4. Recompute dependencies */
deps = region_get_dependencies (sheet, 0, row, SHEET_MAX_COLS-1, SHEET_MAX_ROWS-1);
......
......@@ -443,10 +443,10 @@ void workbook_foreach (WorkbookCallback cback,
void workbook_fixup_references (Workbook *wb, int col, int row,
void workbook_fixup_references (Workbook *wb, Sheet *sheet, int col, int row,
int coldelta, int rowdelta);
void workbook_invalidate_references (Workbook *wb, int col, int row,
void workbook_invalidate_references (Workbook *wb, Sheet *sheet, int col, int row,
int colcount, int rowcount);
/*
......
......@@ -2086,6 +2086,7 @@ workbook_foreach (WorkbookCallback cback, gpointer data)
/**
* workbook_fixup_references:
* @wb: the workbook to modify
* @sheet: the sheet containing the column/row that was moved
* @col: starting column that was moved.
* @row: starting row that was moved.
* @coldelta: signed column distance that cells were moved.
......@@ -2095,7 +2096,7 @@ workbook_foreach (WorkbookCallback cback, gpointer data)
*/
void
workbook_fixup_references (Workbook *wb, int col, int row,
workbook_fixup_references (Workbook *wb, Sheet *sheet, int col, int row,
int coldelta, int rowdelta)
{
GList *cells, *l;
......@@ -2116,7 +2117,7 @@ workbook_fixup_references (Workbook *wb, int col, int row,
thisrow = cell->row->pos;
newtree = expr_tree_fixup_references (cell->parsed_node, cell->sheet,
thiscol, thisrow,
thiscol, thisrow, sheet,
col, row, coldelta, rowdelta);
if (newtree) {
char *exprtxt, *eqexprtxt;
......@@ -2137,6 +2138,7 @@ workbook_fixup_references (Workbook *wb, int col, int row,
/**
* workbook_invalidate_references:
* @wb: the workbook to modify
* @sheet: the sheet containing column and row to be invalidated
* @col: starting column to be invalidated.
* @row: starting row to be invalidated.
* @colcount: number of columns to be invalidated.
......@@ -2146,7 +2148,7 @@ workbook_fixup_references (Workbook *wb, int col, int row,
*/
void
workbook_invalidate_references (Workbook *wb, int col, int row,
workbook_invalidate_references (Workbook *wb, Sheet *sheet, int col, int row,
int colcount, int rowcount)
{
GList *cells, *l;
......@@ -2169,7 +2171,7 @@ workbook_invalidate_references (Workbook *wb, int col, int row,
thisrow = cell->row->pos;
newtree = expr_tree_invalidate_references (cell->parsed_node, cell->sheet,
thiscol, thisrow,
thiscol, thisrow, sheet,
col, row, colcount, rowcount);
if (newtree) {
char *exprtxt, *eqexprtxt;
......
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