Commit 873e0386 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Match Xl behaviour for out of bounds array access.

Disable cutting a subset of an array.

TODO : Handle copying a subset of an array.

1999-12-18  Jody Goldberg <jgoldberg@home.com>

	* src/sheet.c (sheet_check_for_partial_array) : Rename from
	  range_check_for_partial_array and make public.

	* src/selection.c (sheet_selection_cut) : Disable cutting part of an
	  array.

	* src/expr.c (eval_expr_real) : Wrap out of bound aarray lookups when
	  the src is 1 element wide or tall.
parent b151ddfb
1999-12-18 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_check_for_partial_array) : Rename from
range_check_for_partial_array and make public.
* src/selection.c (sheet_selection_cut) : Disable cutting part of an
array.
* src/expr.c (eval_expr_real) : Wrap out of bound aarray lookups when
the src is 1 element wide or tall.
1999-12-17 Jody Goldberg <jgoldberg@home.com>
* src/cell.c (cell_cleanout) : Publicize.
......
1999-12-18 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_check_for_partial_array) : Rename from
range_check_for_partial_array and make public.
* src/selection.c (sheet_selection_cut) : Disable cutting part of an
array.
* src/expr.c (eval_expr_real) : Wrap out of bound aarray lookups when
the src is 1 element wide or tall.
1999-12-17 Jody Goldberg <jgoldberg@home.com>
* src/cell.c (cell_cleanout) : Publicize.
......
......@@ -924,8 +924,8 @@ eval_expr_real (FunctionEvalInfo *s, ExprTree const *tree)
case OPER_ARRAY:
{
/* The upper left corner manages the recalc of the expr */
int const x = tree->u.array.x;
int const y = tree->u.array.y;
int x = tree->u.array.x;
int y = tree->u.array.y;
if (x == 0 && y == 0){
/* Release old value if necessary */
a = tree->u.array.corner.func.value;
......@@ -949,17 +949,21 @@ eval_expr_real (FunctionEvalInfo *s, ExprTree const *tree)
int const num_x = value_area_get_width (&s->pos, a);
int const num_y = value_area_get_height (&s->pos, a);
if (x < num_x && y < num_y){
/* Evaluate relative to the upper left corner */
EvalPosition tmp_ep = s->pos;
tmp_ep.eval_col -= x;
tmp_ep.eval_row -= y;
a = (Value *)value_area_get_x_y (
&tmp_ep, a, x, y);
} else
/* Evaluate relative to the upper left corner */
EvalPosition tmp_ep = s->pos;
tmp_ep.eval_col -= x;
tmp_ep.eval_row -= y;
/* If the src array is 1 element wide or tall we wrap */
if (x >= 1 && num_x == 1)
x = 0;
if (y >= 1 && num_y == 1)
y = 0;
if (x >= num_x || y >= num_y)
return value_new_error (&s->pos, gnumeric_err_NA);
} else if (x >= 1 || y >= 1)
return value_new_error (&s->pos, gnumeric_err_NA);
a = (Value *)value_area_get_x_y (&tmp_ep, a, x, y);
}
if (a == NULL)
return NULL;
......
......@@ -656,7 +656,7 @@ item_cursor_do_action (ItemCursor *item_cursor, ActionType action, guint32 time)
case ACTION_SHIFT_RIGHT_AND_COPY:
case ACTION_SHIFT_DOWN_AND_MOVE:
case ACTION_SHIFT_RIGHT_AND_MOVE:
g_warning ("Operation not yet implemeneted\n");
g_warning ("Operation not yet implemented\n");
}
}
......
......@@ -614,7 +614,6 @@ sheet_selection_cut (CmdContext *context, Sheet *sheet)
{
SheetSelection *ss;
/* FIXME FIXME : disable cuting part of an array */
/*
* 'cut' is a poor description of what we're
* doing here. 'move' would be a better
......@@ -635,6 +634,12 @@ sheet_selection_cut (CmdContext *context, Sheet *sheet)
return FALSE;
ss = sheet->selections->data;
if (!sheet_check_for_partial_array (sheet,
ss->user.start.row,ss->user.start.col,
ss->user.end.row, ss->user.end.col)) {
gnumeric_no_modify_array_notice (sheet->workbook);
return;
}
application_clipboard_cut (sheet, &ss->user);
......
......@@ -1655,8 +1655,8 @@ sheet_is_cell_array (Sheet *sheet, int const col, int const row)
*
* returns FALSE is an array would be divided.
*/
static gboolean
range_check_for_partial_array (Sheet *sheet,
gboolean
sheet_check_for_partial_array (Sheet *sheet,
int const start_row, int const start_col,
int end_row, int end_col)
{
......@@ -2698,7 +2698,7 @@ sheet_fill_selection_with (Sheet *sheet, const char *str,
for (l = sheet->selections; l; l = l->next)
{
SheetSelection *ss = l->data;
if (!range_check_for_partial_array (sheet,
if (!sheet_check_for_partial_array (sheet,
ss->user.start.row,ss->user.start.col,
ss->user.end.row, ss->user.end.col)) {
gnumeric_no_modify_array_notice (sheet->workbook);
......@@ -3300,7 +3300,7 @@ sheet_delete_cols (CmdContext *context, Sheet *sheet,
return;
/* 0. Walk cells in deleted cols and ensure arrays aren't divided. */
if (!range_check_for_partial_array (sheet, 0, col,
if (!sheet_check_for_partial_array (sheet, 0, col,
SHEET_MAX_ROWS-1, col+count-1))
{
gnumeric_no_modify_array_notice (sheet->workbook);
......@@ -3440,7 +3440,7 @@ sheet_delete_rows (CmdContext *context, Sheet *sheet,
return;
/* 0. Walk cells in deleted rows and ensure arrays aren't divided. */
if (!range_check_for_partial_array (sheet, row, 0,
if (!sheet_check_for_partial_array (sheet, row, 0,
row+count-1, SHEET_MAX_COLS-1))
{
gnumeric_no_modify_array_notice (sheet->workbook);
......
......@@ -289,6 +289,10 @@ void sheet_cells_update (Sheet *sheet, Range r,
Range sheet_get_full_range (void);
Range sheet_get_extent (Sheet const *sheet);
gboolean sheet_check_for_partial_array (Sheet *sheet,
int const start_row, int const start_col,
int end_row, int end_col);
/* Redraw */
void sheet_compute_visible_ranges (Sheet const *sheet);
void sheet_redraw_cell_region (Sheet const *sheet,
......
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