Commit 946d8354 authored by Jody Goldberg's avatar Jody Goldberg

Support insert row/col in the presence of arrays.

parent f91b06f6
No preview for this file type
No preview for this file type
......@@ -271,13 +271,12 @@ add_tree_deps (Cell *cell, ExprTree *tree)
if (tree->u.array.x != 0 || tree->u.array.y != 0){
/* Non-corner cells depend on the corner */
DependencyRange range;
Cell * corner = tree->u.array.corner.cell;
range.ref_count = 0;
range.sheet = cell->sheet;
range.range.start.col = range.range.end.col =
corner->col->pos;
cell->col->pos - tree->u.array.x;
range.range.start.row = range.range.end.row =
corner->row->pos;
cell->row->pos - tree->u.array.y;
add_cell_range_dep (cell, &range);
} else
/* Corner cell depends on the contents of the expr */
......
......@@ -271,13 +271,12 @@ add_tree_deps (Cell *cell, ExprTree *tree)
if (tree->u.array.x != 0 || tree->u.array.y != 0){
/* Non-corner cells depend on the corner */
DependencyRange range;
Cell * corner = tree->u.array.corner.cell;
range.ref_count = 0;
range.sheet = cell->sheet;
range.range.start.col = range.range.end.col =
corner->col->pos;
cell->col->pos - tree->u.array.x;
range.range.start.row = range.range.end.row =
corner->row->pos;
cell->row->pos - tree->u.array.y;
add_cell_range_dep (cell, &range);
} else
/* Corner cell depends on the contents of the expr */
......
......@@ -318,16 +318,29 @@ expr_tree_array_formula (int const x, int const y, int const rows, int const col
static ExprTree *
expr_tree_array_formula_corner (ExprTree const *expr)
expr_tree_array_formula_corner (ExprTree const *expr, EvalPosition const *pos)
{
Cell * const corner = expr->u.array.corner.cell;
Cell * corner = expr->u.array.corner.cell;
g_return_val_if_fail (corner, NULL);
/* Attempt to set the corner if it is not already set */
if (corner == NULL) {
g_return_val_if_fail (pos != NULL, NULL);
g_return_val_if_fail (pos->sheet != NULL, NULL);
corner = sheet_cell_get (pos->sheet,
pos->eval_col - expr->u.array.x,
pos->eval_row - expr->u.array.y);
((ExprTree *)expr)->u.array.corner.cell = corner;
}
g_return_val_if_fail (corner != NULL, NULL);
g_return_val_if_fail (corner->parsed_node != NULL, NULL);
/* Sanity check incase the corner gets removed for some reason */
g_return_val_if_fail (corner->parsed_node != (void *)0xdeadbeef, NULL);
g_return_val_if_fail (corner->parsed_node->oper == OPER_ARRAY, NULL);
g_return_val_if_fail (corner->parsed_node->u.array.x == 0, NULL);
g_return_val_if_fail (corner->parsed_node->u.array.y == 0, NULL);
return corner->parsed_node;
}
......@@ -1083,7 +1096,7 @@ eval_expr_real (FunctionEvalInfo *s, ExprTree const *tree)
*((Value **)&(tree->u.array.corner.func.value)) = a;
} else {
ExprTree const * const array =
expr_tree_array_formula_corner (tree);
expr_tree_array_formula_corner (tree, &s->pos);
if (array)
a = array->u.array.corner.func.value;
else
......@@ -1372,7 +1385,8 @@ do_expr_decode_tree (ExprTree *tree, ParsePosition const *pp,
int const y = tree->u.array.y;
char *res;
if (x != 0 || y != 0) {
ExprTree *array = expr_tree_array_formula_corner (tree);
ExprTree *array =
expr_tree_array_formula_corner (tree, NULL);
if (array) {
ParsePosition tmp_pos;
tmp_pos.wb = pp->wb;
......
......@@ -2312,8 +2312,8 @@ sheet_destroy (Sheet *sheet)
struct sheet_clear_region_callback_data
{
int start_col, start_row, end_col, end_row;
GList *l;
Range r;
GList *l;
};
/*
......@@ -2337,13 +2337,13 @@ assemble_clear_cell_list (Sheet *sheet, int col, int row, Cell *cell,
/* Flag an attempt to delete a subset of an array */
if (cell->parsed_node && cell->parsed_node->oper == OPER_ARRAY){
ArrayRef * ref = &cell->parsed_node->u.array;
if ((col - ref->x) < cb->start_col)
if ((col - ref->x) < cb->r.start.col)
return value_terminate();
if ((row - ref->y) < cb->start_row)
if ((row - ref->y) < cb->r.start.row)
return value_terminate();
if ((col - ref->x + ref->cols -1) > cb->end_col)
if ((col - ref->x + ref->cols -1) > cb->r.end.col)
return value_terminate();
if ((row - ref->y + ref->rows -1) > cb->end_row)
if ((row - ref->y + ref->rows -1) > cb->r.end.row)
return value_terminate();
}
......@@ -2374,11 +2374,12 @@ sheet_clear_region (Sheet *sheet, int start_col, int start_row, int end_col, int
/* Queue a redraw for the cells being removed */
sheet_redraw_cell_region (sheet, start_col, start_row, end_col, end_row);
cb.start_col = start_col;
cb.start_row = start_row;
cb.end_col = end_col;
cb.end_row = end_row;
cb.r.start.col = start_col;
cb.r.start.row = start_row;
cb.r.end.col = end_col;
cb.r.end.row = end_row;
cb.l = NULL;
if (sheet_cell_foreach_range (sheet, TRUE,
start_col, start_row, end_col, end_row,
assemble_clear_cell_list, &cb) == NULL) {
......
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