Commit 17579c92 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

support merged cells. (sheet_find_boundary_vertical) : ditto.


2000-12-17  Jody Goldberg <jgoldberg@home.com>

	* src/sheet.c (sheet_find_boundary_horizontal) : support merged cells.
	(sheet_find_boundary_vertical) : ditto.
	(sheet_set_edit_pos) : Add edit_pos vs edit_pos_real to improve merged
	  cell support.
	(sheet_region_get_merged_cell) : new function.

	* src/gnumeric-sheet.c (move_cursor_horizontal) : Use edit_pos_real to
	  improve handling for merged cells.
	(move_cursor_vertical) : Ditto.
	(start_cell_selection) : Ditto.

2000-12-16  Jody Goldberg <jgoldberg@home.com>

	s/Sheet::cursor::edit_pos/Sheet::edit_pos/

	* src/gnumeric-sheet.c (gnumeric_sheet_new) : No need to pass in the
	  col/row items.  They are available from the sheet control.

	* src/sheet-control-gui.c (sheet_view_construct) : signature change to
	  gnumeric_sheet_new.
parent 5c96585d
2000-12-17 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_find_boundary_horizontal) : support merged cells.
(sheet_find_boundary_vertical) : ditto.
(sheet_set_edit_pos) : Add edit_pos vs edit_pos_real to improve merged
cell support.
(sheet_region_get_merged_cell) : new function.
* src/gnumeric-sheet.c (move_cursor_horizontal) : Use edit_pos_real to
improve handling for merged cells.
(move_cursor_vertical) : Ditto.
(start_cell_selection) : Ditto.
2000-12-16 Jody Goldberg <jgoldberg@home.com>
s/Sheet::cursor::edit_pos/Sheet::edit_pos/
* src/gnumeric-sheet.c (gnumeric_sheet_new) : No need to pass in the
col/row items. They are available from the sheet control.
......
2000-12-17 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_find_boundary_horizontal) : support merged cells.
(sheet_find_boundary_vertical) : ditto.
(sheet_set_edit_pos) : Add edit_pos vs edit_pos_real to improve merged
cell support.
(sheet_region_get_merged_cell) : new function.
* src/gnumeric-sheet.c (move_cursor_horizontal) : Use edit_pos_real to
improve handling for merged cells.
(move_cursor_vertical) : Ditto.
(start_cell_selection) : Ditto.
2000-12-16 Jody Goldberg <jgoldberg@home.com>
s/Sheet::cursor::edit_pos/Sheet::edit_pos/
* src/gnumeric-sheet.c (gnumeric_sheet_new) : No need to pass in the
col/row items. They are available from the sheet control.
......
2000-12-17 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_find_boundary_horizontal) : support merged cells.
(sheet_find_boundary_vertical) : ditto.
(sheet_set_edit_pos) : Add edit_pos vs edit_pos_real to improve merged
cell support.
(sheet_region_get_merged_cell) : new function.
* src/gnumeric-sheet.c (move_cursor_horizontal) : Use edit_pos_real to
improve handling for merged cells.
(move_cursor_vertical) : Ditto.
(start_cell_selection) : Ditto.
2000-12-16 Jody Goldberg <jgoldberg@home.com>
s/Sheet::cursor::edit_pos/Sheet::edit_pos/
* src/gnumeric-sheet.c (gnumeric_sheet_new) : No need to pass in the
col/row items. They are available from the sheet control.
......
2000-12-17 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_find_boundary_horizontal) : support merged cells.
(sheet_find_boundary_vertical) : ditto.
(sheet_set_edit_pos) : Add edit_pos vs edit_pos_real to improve merged
cell support.
(sheet_region_get_merged_cell) : new function.
* src/gnumeric-sheet.c (move_cursor_horizontal) : Use edit_pos_real to
improve handling for merged cells.
(move_cursor_vertical) : Ditto.
(start_cell_selection) : Ditto.
2000-12-16 Jody Goldberg <jgoldberg@home.com>
s/Sheet::cursor::edit_pos/Sheet::edit_pos/
* src/gnumeric-sheet.c (gnumeric_sheet_new) : No need to pass in the
col/row items. They are available from the sheet control.
......
2000-12-17 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_find_boundary_horizontal) : support merged cells.
(sheet_find_boundary_vertical) : ditto.
(sheet_set_edit_pos) : Add edit_pos vs edit_pos_real to improve merged
cell support.
(sheet_region_get_merged_cell) : new function.
* src/gnumeric-sheet.c (move_cursor_horizontal) : Use edit_pos_real to
improve handling for merged cells.
(move_cursor_vertical) : Ditto.
(start_cell_selection) : Ditto.
2000-12-16 Jody Goldberg <jgoldberg@home.com>
s/Sheet::cursor::edit_pos/Sheet::edit_pos/
* src/gnumeric-sheet.c (gnumeric_sheet_new) : No need to pass in the
col/row items. They are available from the sheet control.
......
......@@ -56,7 +56,7 @@ excel_gb_worksheet_activecell (GBRunEvalContext *ec,
sheet = EXCEL_GB_WORKSHEET (object)->sheet;
tmp.start = sheet->cursor.edit_pos;
tmp.start = sheet->edit_pos;
tmp.end = tmp.start;
range = excel_gb_range_new (ec, sheet, tmp);
......
......@@ -71,9 +71,9 @@ cmd_select_cur_row (Sheet *sheet)
sheet_selection_reset_only (sheet);
sheet_selection_add_range (sheet,
sheet->cursor.edit_pos.col, sheet->cursor.edit_pos.row,
0, sheet->cursor.edit_pos.row,
SHEET_MAX_COLS-1, sheet->cursor.edit_pos.row);
sheet->edit_pos.col, sheet->edit_pos.row,
0, sheet->edit_pos.row,
SHEET_MAX_COLS-1, sheet->edit_pos.row);
sheet_update (sheet);
}
......@@ -91,9 +91,9 @@ cmd_select_cur_col (Sheet *sheet)
sheet_selection_reset_only (sheet);
sheet_selection_add_range (sheet,
sheet->cursor.edit_pos.col, sheet->cursor.edit_pos.row,
sheet->cursor.edit_pos.col, 0,
sheet->cursor.edit_pos.col, SHEET_MAX_ROWS-1);
sheet->edit_pos.col, sheet->edit_pos.row,
sheet->edit_pos.col, 0,
sheet->edit_pos.col, SHEET_MAX_ROWS-1);
sheet_update (sheet);
}
......@@ -113,8 +113,8 @@ cmd_select_cur_array (Sheet *sheet)
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
col = sheet->cursor.edit_pos.col;
row = sheet->cursor.edit_pos.row;
col = sheet->edit_pos.col;
row = sheet->edit_pos.row;
array = cell_is_array (sheet_cell_get (sheet, col, row));
if (array == NULL)
......@@ -162,8 +162,8 @@ cmd_select_cur_depends (Sheet *sheet)
g_return_if_fail (IS_SHEET (sheet));
cur_cell = sheet_cell_get (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row);
sheet->edit_pos.col,
sheet->edit_pos.row);
if (cur_cell == NULL)
return;
......@@ -255,8 +255,8 @@ cmd_select_cur_inputs (Sheet *sheet)
g_return_if_fail (IS_SHEET (sheet));
cell = sheet_cell_get (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row);
sheet->edit_pos.col,
sheet->edit_pos.row);
if (cell == NULL || !cell_has_expr (cell))
return;
......
......@@ -2266,8 +2266,8 @@ dialog_cell_format (WorkbookControlGUI *wbcg, Sheet *sheet, FormatDialogPosition
return;
edit_cell = sheet_cell_get (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row);
sheet->edit_pos.col,
sheet->edit_pos.row);
sample_val = (edit_cell) ? edit_cell->value : NULL;
mstyle = sheet_selection_get_unique_style (sheet, borders);
......
......@@ -448,8 +448,8 @@ cb_name_guru_add (NameGuruState *state)
return TRUE;
pp = parse_pos_init (&pos, state->wb, state->sheet,
state->sheet->cursor.edit_pos.col,
state->sheet->cursor.edit_pos.row);
state->sheet->edit_pos.col,
state->sheet->edit_pos.row);
expr_name = expr_name_lookup (pp, name);
......
......@@ -666,8 +666,8 @@ dialog_formula_guru (WorkbookControlGUI *wbcg)
sheet = wb_control_cur_sheet (WORKBOOK_CONTROL (wbcg));
cell = sheet_cell_get (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row);
sheet->edit_pos.col,
sheet->edit_pos.row);
if (cell != NULL && cell_has_expr (cell))
expr = expr_tree_first_func (cell->base.expression);
......
......@@ -666,8 +666,8 @@ dialog_formula_guru (WorkbookControlGUI *wbcg)
sheet = wb_control_cur_sheet (WORKBOOK_CONTROL (wbcg));
cell = sheet_cell_get (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row);
sheet->edit_pos.col,
sheet->edit_pos.row);
if (cell != NULL && cell_has_expr (cell))
expr = expr_tree_first_func (cell->base.expression);
......
......@@ -271,7 +271,7 @@ dialog_goal_seek (WorkbookControlGUI *wbcg, Sheet *sheet)
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
set_entry_str = cell_pos_name (&sheet->cursor.edit_pos);
set_entry_str = cell_pos_name (&sheet->edit_pos);
if (!dialog) {
GtkWidget *set_label, *target_label, *change_label;
......
......@@ -730,7 +730,7 @@ dialog_solver (WorkbookControlGUI *wbcg, Sheet *sheet)
if (param->target_cell == NULL)
target_entry_str =
g_strdup (cell_pos_name (&sheet->cursor.edit_pos));
g_strdup (cell_pos_name (&sheet->edit_pos));
else
target_entry_str =
g_strdup (cell_name (param->target_cell));
......
......@@ -113,12 +113,11 @@ move_cursor_horizontal (GnumericSheet *gsheet, int count,
gboolean jump_to_boundaries)
{
Sheet *sheet = gsheet->scg->sheet;
int const new_col =
sheet_find_boundary_horizontal (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row,
count, jump_to_boundaries);
move_cursor (gsheet, new_col, sheet->cursor.edit_pos.row, TRUE);
int const new_col = sheet_find_boundary_horizontal (sheet,
sheet->edit_pos_real.col,
sheet->edit_pos_real.row,
count, jump_to_boundaries);
move_cursor (gsheet, new_col, sheet->edit_pos_real.row, TRUE);
}
static void
......@@ -144,12 +143,11 @@ move_cursor_vertical (GnumericSheet *gsheet, int count,
gboolean jump_to_boundaries)
{
Sheet *sheet = gsheet->scg->sheet;
int const new_row =
sheet_find_boundary_vertical (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row,
count, jump_to_boundaries);
move_cursor (gsheet, sheet->cursor.edit_pos.col, new_row, TRUE);
int const new_row = sheet_find_boundary_vertical (sheet,
sheet->edit_pos_real.col,
sheet->edit_pos_real.row,
count, jump_to_boundaries);
move_cursor (gsheet, sheet->edit_pos_real.col, new_row, TRUE);
}
static void
......@@ -293,8 +291,8 @@ start_cell_selection (GnumericSheet *gsheet)
{
Sheet *sheet = gsheet->scg->sheet;
start_cell_selection_at (gsheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row);
sheet->edit_pos_real.col,
sheet->edit_pos_real.row);
}
void
......@@ -671,7 +669,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
if ((event->state & GDK_CONTROL_MASK) != 0)
move_cursor (gsheet, 0, 0, TRUE);
else
(*movefn_horizontal)(gsheet, -sheet->cursor.edit_pos.col, FALSE);
(*movefn_horizontal)(gsheet, -sheet->edit_pos.col, FALSE);
break;
case GDK_KP_Delete:
......
......@@ -113,12 +113,11 @@ move_cursor_horizontal (GnumericSheet *gsheet, int count,
gboolean jump_to_boundaries)
{
Sheet *sheet = gsheet->scg->sheet;
int const new_col =
sheet_find_boundary_horizontal (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row,
count, jump_to_boundaries);
move_cursor (gsheet, new_col, sheet->cursor.edit_pos.row, TRUE);
int const new_col = sheet_find_boundary_horizontal (sheet,
sheet->edit_pos_real.col,
sheet->edit_pos_real.row,
count, jump_to_boundaries);
move_cursor (gsheet, new_col, sheet->edit_pos_real.row, TRUE);
}
static void
......@@ -144,12 +143,11 @@ move_cursor_vertical (GnumericSheet *gsheet, int count,
gboolean jump_to_boundaries)
{
Sheet *sheet = gsheet->scg->sheet;
int const new_row =
sheet_find_boundary_vertical (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row,
count, jump_to_boundaries);
move_cursor (gsheet, sheet->cursor.edit_pos.col, new_row, TRUE);
int const new_row = sheet_find_boundary_vertical (sheet,
sheet->edit_pos_real.col,
sheet->edit_pos_real.row,
count, jump_to_boundaries);
move_cursor (gsheet, sheet->edit_pos_real.col, new_row, TRUE);
}
static void
......@@ -293,8 +291,8 @@ start_cell_selection (GnumericSheet *gsheet)
{
Sheet *sheet = gsheet->scg->sheet;
start_cell_selection_at (gsheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row);
sheet->edit_pos_real.col,
sheet->edit_pos_real.row);
}
void
......@@ -671,7 +669,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
if ((event->state & GDK_CONTROL_MASK) != 0)
move_cursor (gsheet, 0, 0, TRUE);
else
(*movefn_horizontal)(gsheet, -sheet->cursor.edit_pos.col, FALSE);
(*movefn_horizontal)(gsheet, -sheet->edit_pos.col, FALSE);
break;
case GDK_KP_Delete:
......
......@@ -495,8 +495,8 @@ item_edit_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
item_edit->scg = item_edit->item_grid->scg;
sheet = item_edit->scg->sheet;
item_edit->entry = GTK_ENTRY (workbook_get_entry (item_edit->scg->wbcg));
item_edit->col = sheet->cursor.edit_pos.col;
item_edit->row = sheet->cursor.edit_pos.row;
item_edit->col = sheet->edit_pos.col;
item_edit->row = sheet->edit_pos.row;
entry = item_edit->entry;
item_edit->signal_changed = gtk_signal_connect (
......
......@@ -210,8 +210,8 @@ item_grid_draw_merged_range (GdkDrawable *drawable, ItemGrid *grid,
GdkGC * const gc = grid->empty_gc;
Cell const *cell = sheet_cell_get (sheet, range->start.col, range->start.row);
MStyle *mstyle = sheet_style_compute (sheet, range->start.col, range->start.row);
gboolean const is_selected = (sheet->cursor.edit_pos.col != range->start.col ||
sheet->cursor.edit_pos.row != range->start.row) &&
gboolean const is_selected = (sheet->edit_pos.col != range->start.col ||
sheet->edit_pos.row != range->start.row) &&
sheet_is_full_range_selected (sheet, range);
gboolean const no_background = !gnumeric_background_set_gc (mstyle, gc,
grid->canvas_item.canvas, is_selected);
......@@ -300,7 +300,7 @@ item_grid_draw_background (GdkDrawable *drawable, ItemGrid *item_grid,
gboolean const is_selected =
scg->current_object == NULL && scg->new_object == NULL &&
!(sheet->cursor.edit_pos.col == col && sheet->cursor.edit_pos.row == row) &&
!(sheet->edit_pos.col == col && sheet->edit_pos.row == row) &&
sheet_is_cell_selected (sheet, col, row);
if (gnumeric_background_set_gc (mstyle, gc, item_grid->canvas_item.canvas, is_selected))
......@@ -895,8 +895,8 @@ item_grid_event (GnomeCanvasItem *item, GdkEvent *event)
if (item_grid->selecting == ITEM_GRID_SELECTING_FORMULA_RANGE)
sheet_make_cell_visible (scg->sheet,
scg->sheet->cursor.edit_pos.col,
scg->sheet->cursor.edit_pos.row);
scg->sheet->edit_pos.col,
scg->sheet->edit_pos.row);
wb_view_selection_desc (wb_control_view (
WORKBOOK_CONTROL (scg->wbcg)), TRUE, NULL);
......
......@@ -114,8 +114,8 @@ sheet_selection_extend_to (Sheet *sheet, int col, int row)
return;
sheet_selection_set (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row,
sheet->edit_pos.col,
sheet->edit_pos.row,
sheet->cursor.base_corner.col,
sheet->cursor.base_corner.row,
col, row);
......@@ -1178,7 +1178,7 @@ sheet_selection_walk_step (Sheet *sheet,
g_return_if_fail (sheet != NULL);
g_return_if_fail (sheet->selections != NULL);
current = sheet->cursor.edit_pos;
current = sheet->edit_pos;
if (horizontal)
inc_x = diff;
......
......@@ -247,8 +247,8 @@ sheet_view_set_zoom_factor (SheetControlGUI *scg, double factor)
/* Ensure that the current cell remains visible when we zoom */
gnumeric_sheet_make_cell_visible
(gsheet,
scg->sheet->cursor.edit_pos.col,
scg->sheet->cursor.edit_pos.row,
scg->sheet->edit_pos.col,
scg->sheet->edit_pos.row,
TRUE);
sheet_view_update_cursor_pos (scg);
......@@ -334,8 +334,8 @@ sheet_view_make_edit_pos_visible (SheetControlGUI const *scg)
gnumeric_sheet_make_cell_visible
(gsheet,
scg->sheet->cursor.edit_pos.col,
scg->sheet->cursor.edit_pos.row,
scg->sheet->edit_pos.col,
scg->sheet->edit_pos.row,
TRUE);
}
......
......@@ -38,7 +38,7 @@
#include "sheet-object-impl.h"
#include "sheet-object-cell-comment.h"
#define GNUMERIC_SHEET_CONTROL_GUI(p) GNUMERIC_SHEET (SHEET_CONTROL_GUI(p)->canvas)
#define GNUMERIC_SHEET_CONTROL_GUI(p) GNUMERIC_SHEET (SHEET_CONTROL_GUI (p)->canvas)
static void sheet_redraw_partial_row (Sheet const *sheet, int const row,
int const start_col, int const end_col);
......@@ -415,7 +415,7 @@ sheet_update_zoom_controls (Sheet *sheet)
WORKBOOK_FOREACH_VIEW (sheet->workbook, view,
{
if (wb_view_cur_sheet (view) == sheet) {
WORKBOOK_VIEW_FOREACH_CONTROL(view, control,
WORKBOOK_VIEW_FOREACH_CONTROL (view, control,
wb_control_zoom_feedback (control););
}
});
......@@ -516,7 +516,7 @@ sheet_col_add (Sheet *sheet, ColRowInfo *cp)
if (*segment == NULL)
*segment = g_new0 (ColRowSegment, 1);
(*segment)->info[COLROW_SUB_INDEX(col)] = cp;
(*segment)->info[COLROW_SUB_INDEX (col)] = cp;
if (col > sheet->cols.max_used){
sheet->cols.max_used = col;
......@@ -535,7 +535,7 @@ sheet_row_add (Sheet *sheet, ColRowInfo *rp)
if (*segment == NULL)
*segment = g_new0 (ColRowSegment, 1);
(*segment)->info[COLROW_SUB_INDEX(row)] = rp;
(*segment)->info[COLROW_SUB_INDEX (row)] = rp;
if (rp->pos > sheet->rows.max_used){
sheet->rows.max_used = row;
......@@ -554,7 +554,7 @@ sheet_col_get_info (Sheet const *sheet, int const col)
segment = COLROW_GET_SEGMENT (&(sheet->cols), col);
if (segment != NULL) {
ci = segment->info[COLROW_SUB_INDEX(col)];
ci = segment->info[COLROW_SUB_INDEX (col)];
if (ci != NULL)
return ci;
}
......@@ -571,9 +571,9 @@ sheet_row_get_info (Sheet const *sheet, int const row)
g_return_val_if_fail (row >= 0, NULL);
g_return_val_if_fail (row < SHEET_MAX_ROWS, NULL);
segment = COLROW_GET_SEGMENT(&(sheet->rows), row);
segment = COLROW_GET_SEGMENT (&(sheet->rows), row);
if (segment != NULL) {
ri = segment->info[COLROW_SUB_INDEX(row)];
ri = segment->info[COLROW_SUB_INDEX (row)];
if (ri != NULL)
return ri;
}
......@@ -618,8 +618,8 @@ sheet_flag_status_update_cell (Cell const *cell)
/* If the edit cell changes value update the edit area
* and the format toolbar
*/
if (pos->col == sheet->cursor.edit_pos.col &&
pos->row == sheet->cursor.edit_pos.row) {
if (pos->col == sheet->edit_pos.col &&
pos->row == sheet->edit_pos.row) {
sheet->priv->edit_pos.content_changed =
sheet->priv->edit_pos.format_changed = TRUE;
}
......@@ -658,7 +658,7 @@ sheet_flag_status_update_range (Sheet const *sheet, Range const *range)
/* If the edit cell changes value update the edit area
* and the format toolbar
*/
if (range_contains(range, sheet->cursor.edit_pos.col, sheet->cursor.edit_pos.row)) {
if (range_contains (range, sheet->edit_pos.col, sheet->edit_pos.row)) {
sheet->priv->edit_pos.content_changed =
sheet->priv->edit_pos.format_changed = TRUE;
}
......@@ -674,7 +674,7 @@ sheet_flag_status_update_range (Sheet const *sheet, Range const *range)
void
sheet_flag_format_update_range (Sheet const *sheet, Range const *range)
{
if (range_contains(range, sheet->cursor.edit_pos.col, sheet->cursor.edit_pos.row))
if (range_contains (range, sheet->edit_pos.col, sheet->edit_pos.row))
sheet->priv->edit_pos.format_changed = TRUE;
}
......@@ -789,13 +789,13 @@ sheet_update (Sheet const *sheet)
/* FIXME : decide whether to do this here or in workbook view */
if (p->edit_pos.location_changed) {
char const *new_pos = cell_pos_name (&sheet->cursor.edit_pos);
char const *new_pos = cell_pos_name (&sheet->edit_pos);
p->edit_pos.location_changed = FALSE;
WORKBOOK_FOREACH_VIEW (sheet->workbook, view,
{
if (wb_view_cur_sheet (view) == sheet) {
WORKBOOK_VIEW_FOREACH_CONTROL(view, control,
WORKBOOK_VIEW_FOREACH_CONTROL (view, control,
wb_control_selection_descr_set (control, new_pos););
}
});
......@@ -928,7 +928,7 @@ sheet_get_extent (Sheet const *sheet)
g_return_val_if_fail (IS_SHEET (sheet), r);
g_hash_table_foreach(sheet->cell_hash, &sheet_get_extent_cb, &r);
g_hash_table_foreach (sheet->cell_hash, &sheet_get_extent_cb, &r);
if (r.start.col >= SHEET_MAX_COLS - 2)
r.start.col = 0;
......@@ -1310,7 +1310,7 @@ sheet_redraw_cell_region (Sheet const *sheet,
/* skip segments with no cells */
} else if (row == COLROW_SEGMENT_START (row)) {
ColRowSegment const * const segment =
COLROW_GET_SEGMENT(&(sheet->rows), row);
COLROW_GET_SEGMENT (&(sheet->rows), row);
if (segment == NULL)
row = COLROW_SEGMENT_END (row);
}
......@@ -1424,13 +1424,23 @@ sheet_find_boundary_horizontal (Sheet *sheet, int start_col, int row,
int count, gboolean jump_to_boundaries)
{
gboolean find_nonblank = sheet_is_cell_empty (sheet, start_col, row);
int new_col = start_col, prev_col = start_col;
gboolean keep_looking = FALSE;
int new_col, prev_col;
int iterations = 0;
CellPos pos;
Range const *merged;
g_return_val_if_fail (sheet != NULL, start_col);
/* Jumping to bounds requires steping cell by cell */
g_return_val_if_fail (count == 1 || count == -1 || !jump_to_boundaries, start_col);
g_return_val_if_fail (IS_SHEET (sheet), start_col);
pos.col = start_col;
pos.row = row;
merged = sheet_region_get_merged_cell (sheet, &pos);
if (merged != NULL)
start_col = (count > 0) ? merged->end.col : merged->start.col;
new_col = prev_col = start_col;
do {
new_col += count;
......@@ -1463,6 +1473,7 @@ sheet_find_boundary_horizontal (Sheet *sheet, int start_col, int row,
}
} while (keep_looking || sheet_col_is_hidden (sheet, new_col));
return new_col;
}
......@@ -1491,12 +1502,23 @@ sheet_find_boundary_vertical (Sheet *sheet, int col, int start_row,
int count, gboolean jump_to_boundaries)
{
gboolean find_nonblank = sheet_is_cell_empty (sheet, col, start_row);
int new_row = start_row, prev_row = start_row;
gboolean keep_looking = FALSE;
int new_row, prev_row;
int iterations = 0;
CellPos pos;
Range const *merged;
/* Jumping to bounds requires steping cell by cell */
g_return_val_if_fail (count == 1 || count == -1 || !jump_to_boundaries, start_row);
g_return_val_if_fail (IS_SHEET (sheet), start_row);
pos.col = col;
pos.row = start_row;
merged = sheet_region_get_merged_cell (sheet, &pos);
if (merged != NULL)
start_row = (count > 0) ? merged->end.row : merged->start.row;
new_row = prev_row = start_row;
do {
new_row += count;
......@@ -1656,7 +1678,7 @@ sheet_col_get (Sheet const *sheet, int const pos)
segment = COLROW_GET_SEGMENT (&(sheet->cols), pos);
if (segment != NULL)
return segment->info [COLROW_SUB_INDEX(pos)];
return segment->info [COLROW_SUB_INDEX (pos)];
return NULL;
}
/**
......@@ -1692,7 +1714,7 @@ sheet_row_get (Sheet const *sheet, int const pos)
segment = COLROW_GET_SEGMENT (&(sheet->rows), pos);
if (segment != NULL)
return segment->info [COLROW_SUB_INDEX(pos)];
return segment->info [COLROW_SUB_INDEX (pos)];
return NULL;
}
......@@ -1723,7 +1745,7 @@ sheet_row_fetch (Sheet *sheet, int pos)
* callbacks are only invoked for existing cells.
*
* Return value:
* non-NULL on error, or value_terminate() if some invoked routine requested
* non-NULL on error, or value_terminate () if some invoked routine requested
* to stop (by returning non-NULL).
*
* NOTE: between 0.56 and 0.57, the traversal order changed. The order is now
......@@ -1770,13 +1792,13 @@ sheet_cell_foreach_range (Sheet *sheet, gboolean only_existing,
/* skip segments with no cells */
if (i == COLROW_SEGMENT_START (i)) {
ColRowSegment const *segment =
COLROW_GET_SEGMENT(&(sheet->rows), i);
COLROW_GET_SEGMENT (&(sheet->rows), i);
if (segment == NULL)
i = COLROW_SEGMENT_END(i);
i = COLROW_SEGMENT_END (i);
}
} else {
for (j = start_col; j <= end_col; ++j) {
cont = (*callback)(sheet, j, i, NULL, closure);
cont = (*callback) (sheet, j, i, NULL, closure);
if (cont != NULL)
return cont;
}
......@@ -1796,14 +1818,14 @@ sheet_cell_foreach_range (Sheet *sheet, gboolean only_existing,
/* skip segments with no cells */
if (j == COLROW_SEGMENT_START (j)) {
ColRowSegment const *segment =
COLROW_GET_SEGMENT(&(sheet->cols), j);
COLROW_GET_SEGMENT (&(sheet->cols), j);
if (segment == NULL)
j = COLROW_SEGMENT_END(j);
j = COLROW_SEGMENT_END (j);
}
continue;
}
cont = (*callback)(sheet, j, i, cell, closure);
cont = (*callback) (sheet, j, i, cell, closure);
if (cont != NULL)
return cont;
}
......@@ -2011,7 +2033,7 @@ cb_free_cell (Sheet *sheet, int col, int row, Cell *cell, void *user_data)
static void
sheet_col_destroy (Sheet *sheet, int const col, gboolean free_cells)
{
ColRowSegment **segment = (ColRowSegment **)&COLROW_GET_SEGMENT(&(sheet->cols), col);
ColRowSegment **segment = (ColRowSegment **)&COLROW_GET_SEGMENT (&(sheet->cols), col);
int const sub = COLROW_SUB_INDEX (col);
ColRowInfo *ci = NULL;
......@@ -2045,8 +2067,8 @@ sheet_col_destroy (Sheet *sheet, int const col, gboolean free_cells)
static void
sheet_row_destroy (Sheet *sheet, int const row, gboolean free_cells)
{
ColRowSegment **segment = (ColRowSegment **)&COLROW_GET_SEGMENT(&(sheet->rows), row);
int const sub = COLROW_SUB_INDEX(row);
ColRowSegment **segment = (ColRowSegment **)&COLROW_GET_SEGMENT (&(sheet->rows), row);
int const sub = COLROW_SUB_INDEX (row);
ColRowInfo *ri = NULL;
if (*segment == NULL)
return;
......@@ -2283,9 +2305,9 @@ sheet_regen_adjacent_spans (Sheet *sheet,
/* skip segments with no cells */
if (row == COLROW_SEGMENT_START (row)) {
ColRowSegment const *segment =
COLROW_GET_SEGMENT(&(sheet->rows), row);
COLROW_GET_SEGMENT (&(sheet->rows), row);
if (segment == NULL)
row = COLROW_SEGMENT_END(row);
row = COLROW_SEGMENT_END (row);
}
continue;
}
......@@ -2391,7 +2413,7 @@ sheet_clear_region (WorkbookControl *wbc, Sheet *sheet,
sheet_cell_foreach_range (sheet, TRUE,
start_col, start_row, end_col, end_row,
&cb_empty_cell,
GINT_TO_POINTER(!(clear_flags & CLEAR_COMMENTS)));
GINT_TO_POINTER (!(clear_flags & CLEAR_COMMENTS)));
sheet_regen_adjacent_spans (sheet,
start_col, start_row,
......@@ -2427,11 +2449,12 @@ void
sheet_set_edit_pos (Sheet *sheet, int col, int row)
{
int old_col, old_row;
Range const *merged;
g_return_if_fail (IS_SHEET (sheet));
old_col = sheet->cursor.edit_pos.col;
old_row = sheet->cursor.edit_pos.row;
old_col = sheet->edit_pos.col;
old_row = sheet->edit_pos.row;
if (old_col != col || old_row != row) {
sheet->priv->edit_pos.location_changed =
......@@ -2441,11 +2464,20 @@ sheet_set_edit_pos (Sheet *sheet, int col, int row)
/* Redraw before change */
sheet_redraw_cell_region (sheet,
old_col, old_row, old_col, old_row);
sheet->cursor.edit_pos.col = col;
sheet->cursor.edit_pos.row = row;
sheet->edit_pos_real.col = col;
sheet->edit_pos_real.row = row;