Commit abb3aeca authored by Morten Welinder's avatar Morten Welinder

Cleanup: use gnm_sheet_get_last_(col|row) where appropriate.

parent f2e7d4d1
2009-04-18 Morten Welinder <terra@gnome.org>
* */*.c: Use gnm_sheet_get_last_(col|row) where appropriate.
2009-04-17 Morten Welinder <terra@gnome.org>
* src/ssconvert.c (setup_range): Parse in the context of the first
......
......@@ -1018,9 +1018,9 @@ gnumeric_lookup (GnmFuncEvalInfo *ei, GnmValue const * const *args)
range_init_value (&r, lookup, &ei->pos->eval);
range_normalize (&r);
if (vertical_lookup)
r.end.row = gnm_sheet_get_max_rows (ei->pos->sheet) - 1;
r.end.row = gnm_sheet_get_last_row (ei->pos->sheet);
else
r.end.col = gnm_sheet_get_max_cols (ei->pos->sheet) - 1;
r.end.col = gnm_sheet_get_last_col (ei->pos->sheet);
lookup = xlookup = value_new_cellrange_r (ei->pos->sheet, &r);
}
......
......@@ -1171,7 +1171,7 @@ lotus_rldb_walk_3d (LotusRLDB *rldb3,
rldb1 = g_ptr_array_index (rldb2->lower, ci);
ci++;
r.range.end.col =
MIN (gnm_sheet_get_max_cols (r.sheet) - 1,
MIN (gnm_sheet_get_last_col (r.sheet),
r.range.start.col + (rldb1->rll - 1));
ri = 0;
......@@ -1183,7 +1183,7 @@ lotus_rldb_walk_3d (LotusRLDB *rldb3,
rldb0 = g_ptr_array_index (rldb1->lower, ri);
ri++;
r.range.end.row =
MIN (gnm_sheet_get_max_rows (r.sheet) - 1,
MIN (gnm_sheet_get_last_row (r.sheet),
r.range.start.row + (rldb0->rll - 1));
data = rldb0->datanode;
......@@ -1212,7 +1212,7 @@ lotus_rldb_walk_2d (LotusRLDB *rldb2,
LotusRLDB *rldb1, *rldb0;
const GString *data;
Sheet *ref_sheet = workbook_sheet_by_index (state->wb, 0);
int max = iscol ? gnm_sheet_get_max_cols (ref_sheet) : gnm_sheet_get_max_rows (ref_sheet);
int max = colrow_max (iscol, ref_sheet);
int start, end;
Sheet *sheet;
......
......@@ -497,7 +497,7 @@ mps_create_sheet (MpsInputContext *ctxt, WorkbookView *wbv)
/* Autofit column A */
i = sheet_col_size_fit_pixels (sh, 0, 0, gnm_sheet_get_max_rows (ctxt->sheet) - 1, FALSE);
i = sheet_col_size_fit_pixels (sh, 0, 0, gnm_sheet_get_last_row (ctxt->sheet), FALSE);
if (i == 0)
return;
sheet_col_set_size_pixels (sh, 0, i, TRUE);
......
......@@ -56,7 +56,7 @@ sv_select_cur_row (SheetView *sv)
sv_selection_reset (sv);
sv_selection_add_full (sv,
sv->edit_pos.col, sv->edit_pos.row,
0, r.start.row, gnm_sheet_get_max_cols (sv->sheet)-1, r.end.row);
0, r.start.row, gnm_sheet_get_last_col (sv->sheet), r.end.row);
sheet_update (sv->sheet);
}
}
......@@ -76,7 +76,7 @@ sv_select_cur_col (SheetView *sv)
sv_selection_reset (sv);
sv_selection_add_full (sv,
sv->edit_pos.col, sv->edit_pos.row,
r.start.col, 0, r.end.col, gnm_sheet_get_max_rows (sv->sheet)-1);
r.start.col, 0, r.end.col, gnm_sheet_get_last_row (sv->sheet));
sheet_update (sv->sheet);
}
}
......@@ -399,7 +399,7 @@ cmd_shift_rows (WorkbookControl *wbc, Sheet *sheet,
rinfo.origin.start.row = start_row;
rinfo.origin.start.col = col;
rinfo.origin.end.row = end_row;
rinfo.origin.end.col = gnm_sheet_get_max_cols (sheet)-1;
rinfo.origin.end.col = gnm_sheet_get_last_col (sheet);
if (count > 0)
rinfo.origin.end.col -= count;
......@@ -438,7 +438,7 @@ cmd_shift_cols (WorkbookControl *wbc, Sheet *sheet,
rinfo.origin.start.col = start_col;
rinfo.origin.start.row = row;
rinfo.origin.end.col = end_col;
rinfo.origin.end.row = gnm_sheet_get_max_rows (sheet)-1;
rinfo.origin.end.row = gnm_sheet_get_last_row (sheet);
if (count > 0)
rinfo.origin.end.row -= count;
......
......@@ -433,19 +433,19 @@ colrow_set_sizes (Sheet *sheet, gboolean is_cols,
if (is_cols) {
rles->state.size_pts = sheet_col_get_default_size_pts (sheet);
sheet_col_set_default_size_pixels (sheet, new_size);
colrow_foreach (&sheet->cols, 0, gnm_sheet_get_max_cols (sheet)-1,
colrow_foreach (&sheet->cols, 0, gnm_sheet_get_last_col (sheet),
&cb_set_colrow_size, &closure);
} else {
rles->state.size_pts = sheet_row_get_default_size_pts (sheet);
sheet_row_set_default_size_pixels (sheet, new_size);
colrow_foreach (&sheet->rows, 0, gnm_sheet_get_max_rows (sheet)-1,
colrow_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet),
&cb_set_colrow_size, &closure);
}
/* force a re-render of cells with expanding formats */
if (is_cols)
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK,
0, 0, gnm_sheet_get_max_cols (sheet)-1, gnm_sheet_get_max_rows (sheet)-1,
0, 0, gnm_sheet_get_last_col (sheet), gnm_sheet_get_last_row (sheet),
(CellIterFunc) &cb_clear_variable_width_content, NULL);
/* Result is a magic 'default' record + >= 1 normal */
......@@ -455,7 +455,7 @@ colrow_set_sizes (Sheet *sheet, gboolean is_cols,
if (is_cols) {
/* force a re-render of cells with expanding formats */
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK,
index->first, 0, index->last, gnm_sheet_get_max_rows (sheet)-1,
index->first, 0, index->last, gnm_sheet_get_last_row (sheet),
(CellIterFunc) &cb_clear_variable_width_content, NULL);
/* In order to properly reposition cell comments in
......@@ -470,8 +470,8 @@ colrow_set_sizes (Sheet *sheet, gboolean is_cols,
if (tmp < 0)
/* Fall back to assigning the defaul if it is empty */
tmp = (is_cols)
? sheet_col_size_fit_pixels (sheet, i, 0, gnm_sheet_get_max_rows (sheet) - 1, FALSE)
: sheet_row_size_fit_pixels (sheet, i, 0, gnm_sheet_get_max_cols (sheet) - 1, FALSE);
? sheet_col_size_fit_pixels (sheet, i, 0, gnm_sheet_get_last_row (sheet), FALSE)
: sheet_row_size_fit_pixels (sheet, i, 0, gnm_sheet_get_last_col (sheet), FALSE);
if (tmp > 0) {
if (is_cols)
......@@ -597,7 +597,7 @@ colrow_restore_state_group (Sheet *sheet, gboolean is_cols,
/* force a re-render of cells with expanding formats */
if (is_cols)
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK,
index->first, 0, index->last, gnm_sheet_get_max_rows (sheet)-1,
index->first, 0, index->last, gnm_sheet_get_last_row (sheet),
(CellIterFunc) &cb_clear_variable_width_content, NULL);
colrow_state_list_destroy (ptr->data);
selection = selection->prev;
......@@ -897,7 +897,7 @@ colrow_set_visibility_list (Sheet *sheet, gboolean is_cols,
}
if (is_cols)
sheet_queue_respan (sheet, 0, gnm_sheet_get_max_rows (sheet)-1);
sheet_queue_respan (sheet, 0, gnm_sheet_get_last_row (sheet));
if (list != NULL)
sheet_redraw_all (sheet, TRUE);
}
......
......@@ -1890,8 +1890,8 @@ cmd_selection_format (WorkbookControl *wbc,
if (borders != NULL) {
if (range.start.col > 0) range.start.col--;
if (range.start.row > 0) range.start.row--;
if (range.end.col < gnm_sheet_get_max_cols (me->cmd.sheet)-1) range.end.col++;
if (range.end.row < gnm_sheet_get_max_rows (me->cmd.sheet)-1) range.end.row++;
if (range.end.col < gnm_sheet_get_last_col (me->cmd.sheet)) range.end.col++;
if (range.end.row < gnm_sheet_get_last_row (me->cmd.sheet)) range.end.row++;
}
os = g_new (CmdFormatOldStyle, 1);
......@@ -2200,10 +2200,10 @@ cmd_colrow_hide_correct_selection (CmdColRowHide *me, WorkbookControl *wbc)
sv_selection_reset (sv);
if (me->is_cols)
sv_selection_add_full (sv, y, x, y, 0,
y, gnm_sheet_get_max_rows (sheet) - 1);
y, gnm_sheet_get_last_row (sheet));
else
sv_selection_add_full (sv, y, x, 0, x,
gnm_sheet_get_max_cols (sheet) - 1, x);
gnm_sheet_get_last_col (sheet), x);
}
#endif
}
......@@ -3015,7 +3015,7 @@ cmd_paste_copy (WorkbookControl *wbc,
n = range_width (r);
if (n == 1 && cr->cols == gnm_sheet_get_max_cols (me->cmd.sheet)) {
r->start.col = 0;
r->end.col = gnm_sheet_get_max_cols (me->cmd.sheet)-1;
r->end.col = gnm_sheet_get_last_col (me->cmd.sheet);
} else {
n /= cr->cols;
if (n < 1) n = 1;
......@@ -3025,7 +3025,7 @@ cmd_paste_copy (WorkbookControl *wbc,
n = range_height (r);
if (n == 1 && cr->rows == gnm_sheet_get_max_rows (me->cmd.sheet)) {
r->start.row = 0;
r->end.row = gnm_sheet_get_max_rows (me->cmd.sheet)-1;
r->end.row = gnm_sheet_get_last_row (me->cmd.sheet);
} else {
n /= cr->rows;
if (n < 1) n = 1;
......@@ -3567,8 +3567,8 @@ cmd_selection_autoformat (WorkbookControl *wbc, GnmFormatTemplate *ft)
/* Store the containing range to handle borders */
if (range.start.col > 0) range.start.col--;
if (range.start.row > 0) range.start.row--;
if (range.end.col < gnm_sheet_get_max_cols (sv->sheet)-1) range.end.col++;
if (range.end.row < gnm_sheet_get_max_rows (sv->sheet)-1) range.end.row++;
if (range.end.col < gnm_sheet_get_last_col (sv->sheet)) range.end.col++;
if (range.end.row < gnm_sheet_get_last_row (sv->sheet)) range.end.row++;
os = g_new (CmdFormatOldStyle, 1);
......
......@@ -90,7 +90,7 @@ static GOMemChunk *cset_pool;
#define BUCKET_SIZE 128
#define BUCKET_OF_ROW(row) ((row) / BUCKET_SIZE)
#define BUCKET_LAST (BUCKET_OF_ROW (gnm_sheet_get_max_rows (sheet) - 1))
#define BUCKET_LAST (BUCKET_OF_ROW (gnm_sheet_get_last_row (sheet)))
#define BUCKET_START_ROW(b) ((b) * BUCKET_SIZE)
#define BUCKET_END_ROW(b) ((b) * BUCKET_SIZE + (BUCKET_SIZE - 1))
......
......@@ -522,11 +522,11 @@ gnm_pane_colrow_key_press (SheetControlGUI *scg, GdkEventKey *event,
range_init_full_sheet (&target, sv->sheet);
else { /* full row */
target.start.col = 0;
target.end.col = gnm_sheet_get_max_cols (sv->sheet) - 1;
target.end.col = gnm_sheet_get_last_col (sv->sheet);
}
} else if (event->state & GDK_CONTROL_MASK) { /* full col */
target.start.row = 0;
target.end.row = gnm_sheet_get_max_rows (sv->sheet) - 1;
target.end.row = gnm_sheet_get_last_row (sv->sheet);
} else
return FALSE;
......@@ -1242,11 +1242,11 @@ gnm_pane_find_col (GnmPane const *pane, int x, int *col_origin)
}
pixel += tmp;
}
} while (++col < gnm_sheet_get_max_cols (sheet) - 1);
} while (++col < gnm_sheet_get_last_col (sheet));
if (col_origin)
*col_origin = gnm_pane_x_w2c (pane, pixel);
return gnm_sheet_get_max_cols (sheet) - 1;
return gnm_sheet_get_last_col (sheet);
}
/**
......@@ -1292,10 +1292,10 @@ gnm_pane_find_row (GnmPane const *pane, int y, int *row_origin)
}
pixel += tmp;
}
} while (++row < gnm_sheet_get_max_rows (sheet)-1);
} while (++row < gnm_sheet_get_last_row (sheet));
if (row_origin)
*row_origin = pixel;
return gnm_sheet_get_max_rows (sheet)-1;
return gnm_sheet_get_last_row (sheet);
}
/*
......@@ -1369,8 +1369,8 @@ gnm_pane_compute_visible_region (GnmPane *pane,
} while (pixels < width && col < gnm_sheet_get_max_cols (sheet));
if (col >= gnm_sheet_get_max_cols (sheet)) {
pane->last_visible.col = gnm_sheet_get_max_cols (sheet)-1;
pane->last_full.col = gnm_sheet_get_max_cols (sheet)-1;
pane->last_visible.col = gnm_sheet_get_last_col (sheet);
pane->last_full.col = gnm_sheet_get_last_col (sheet);
}
/* Find out the last visible row and the last fully visible row */
......@@ -1401,8 +1401,8 @@ gnm_pane_compute_visible_region (GnmPane *pane,
} while (pixels < height && row < gnm_sheet_get_max_rows (sheet));
if (row >= gnm_sheet_get_max_rows (sheet)) {
pane->last_visible.row = gnm_sheet_get_max_rows (sheet)-1;
pane->last_full.row = gnm_sheet_get_max_rows (sheet)-1;
pane->last_visible.row = gnm_sheet_get_last_row (sheet);
pane->last_full.row = gnm_sheet_get_last_row (sheet);
}
/* Update the scrollbar sizes for the primary pane */
......@@ -1445,11 +1445,11 @@ gnm_pane_redraw_range (GnmPane *pane, GnmRange const *r)
pane->first_offset.col;
y1 = scg_colrow_distance_get (scg, FALSE, pane->first.row, tmp.start.row) +
pane->first_offset.row;
x2 = (tmp.end.col < (gnm_sheet_get_max_cols (sheet)-1))
x2 = (tmp.end.col < gnm_sheet_get_last_col (sheet))
? 4 + 1 + x1 + scg_colrow_distance_get (scg, TRUE,
tmp.start.col, tmp.end.col+1)
: INT_MAX;
y2 = (tmp.end.row < (gnm_sheet_get_max_rows (sheet)-1))
y2 = (tmp.end.row < gnm_sheet_get_last_row (sheet))
? 4 + 1 + y1 + scg_colrow_distance_get (scg, FALSE,
tmp.start.row, tmp.end.row+1)
: INT_MAX;
......@@ -1546,8 +1546,8 @@ cb_pane_sliding (GnmPane *pane)
if (slide_x) {
col = target_pane->last_full.col +
col_scroll_step (pane->sliding_dx, sheet);
if (col >= gnm_sheet_get_max_cols (sheet)-1) {
col = gnm_sheet_get_max_cols (sheet)-1;
if (col >= gnm_sheet_get_last_col (sheet)) {
col = gnm_sheet_get_last_col (sheet);
slide_x = FALSE;
}
}
......@@ -1601,8 +1601,8 @@ cb_pane_sliding (GnmPane *pane)
if (slide_y) {
row = target_pane->last_full.row +
row_scroll_step (pane->sliding_dy, sheet);
if (row >= gnm_sheet_get_max_rows (sheet)-1) {
row = gnm_sheet_get_max_rows (sheet)-1;
if (row >= gnm_sheet_get_last_row (sheet)) {
row = gnm_sheet_get_last_row (sheet);
slide_y = FALSE;
}
}
......
......@@ -147,9 +147,9 @@ item_bar_calc_size (ItemBar *ib)
/* 5 pixels left and right plus the width of the widest string I can think of */
if (char_label)
pango_layout_set_text (layout, "WWWWWWWWWW", strlen (col_name (gnm_sheet_get_max_cols (sheet) - 1)));
pango_layout_set_text (layout, "WWWWWWWWWW", strlen (col_name (gnm_sheet_get_last_col (sheet))));
else
pango_layout_set_text (layout, "8888888888", strlen (row_name (gnm_sheet_get_max_rows (sheet) - 1)));
pango_layout_set_text (layout, "8888888888", strlen (row_name (gnm_sheet_get_last_row (sheet))));
pango_layout_get_extents (layout, NULL, &logical_rect);
ib->cell_width = 5 + 5 + PANGO_PIXELS (logical_rect.width);
......
......@@ -283,7 +283,7 @@ ie_layout (FooCanvasItem *item)
while (col_size < width &&
col <= pane->last_full.col &&
col < gnm_sheet_get_max_cols (sheet)-1) {
col < gnm_sheet_get_last_col (sheet)) {
ci = sheet_col_get_info (sheet, ++col);
g_return_if_fail (ci != NULL);
......
......@@ -127,7 +127,7 @@ pg_get_row_offset (PreviewGrid *pg, int const y, int *row_origin)
if (row_origin)
*row_origin = pixel;
return gnm_sheet_get_max_rows (pg->sheet) - 1;
return gnm_sheet_get_last_row (pg->sheet);
}
/**
......@@ -159,7 +159,7 @@ pg_get_col_offset (PreviewGrid *pg, int const x, int *col_origin)
if (col_origin)
*col_origin = pixel;
return gnm_sheet_get_max_cols (pg->sheet) - 1;
return gnm_sheet_get_last_col (pg->sheet);
}
static void
......
......@@ -781,8 +781,8 @@ compute_scale_fit_to (Sheet const *sheet,
return min_p;
}
#define COL_FIT(col) (col >= gnm_sheet_get_max_cols (sheet) ? (gnm_sheet_get_max_cols (sheet)-1) : col)
#define ROW_FIT(row) (row >= gnm_sheet_get_max_rows (sheet) ? (gnm_sheet_get_max_rows (sheet)-1) : row)
#define COL_FIT(col) (MIN (col, gnm_sheet_get_last_col (sheet)))
#define ROW_FIT(row) (MIN (row, gnm_sheet_get_last_row (sheet)))
static void
compute_sheet_pages_add_sheet (PrintingInstance * pi, Sheet const *sheet, gboolean selection,
......
......@@ -136,12 +136,12 @@ sv_is_colrow_selected (SheetView const *sv, int colrow, gboolean is_col)
if (is_col) {
if (ss->start.row == 0 &&
ss->end.row >= gnm_sheet_get_max_rows (sv->sheet)-1 &&
ss->end.row >= gnm_sheet_get_last_row (sv->sheet) &&
ss->start.col <= colrow && colrow <= ss->end.col)
return TRUE;
} else {
if (ss->start.col == 0 &&
ss->end.col >= gnm_sheet_get_max_cols (sv->sheet)-1 &&
ss->end.col >= gnm_sheet_get_last_col (sv->sheet) &&
ss->start.row <= colrow && colrow <= ss->end.row)
return TRUE;
}
......@@ -169,12 +169,12 @@ sv_is_full_colrow_selected (SheetView const *sv, gboolean is_cols, int index)
for (l = sv->selections; l != NULL; l = l->next){
GnmRange const *r = l->data;
if (is_cols) {
if (r->start.row > 0 || r->end.row < gnm_sheet_get_max_rows (sv->sheet) - 1)
if (r->start.row > 0 || r->end.row < gnm_sheet_get_last_row (sv->sheet))
return FALSE;
if (r->start.col <= index && index <= r->end.col)
found = TRUE;
} else {
if (r->start.col > 0 || r->end.col < gnm_sheet_get_max_cols (sv->sheet) - 1)
if (r->start.col > 0 || r->end.col < gnm_sheet_get_last_col (sv->sheet))
return FALSE;
if (r->start.row <= index && index <= r->end.row)
found = TRUE;
......@@ -210,7 +210,7 @@ sv_selection_col_type (SheetView const *sv, int col)
continue;
if (sr->start.row == 0 &&
sr->end.row == gnm_sheet_get_max_rows (sv->sheet)-1)
sr->end.row == gnm_sheet_get_last_row (sv->sheet))
return COL_ROW_FULL_SELECTION;
ret = COL_ROW_PARTIAL_SELECTION;
......@@ -245,7 +245,7 @@ sv_selection_row_type (SheetView const *sv, int row)
continue;
if (sr->start.col == 0 &&
sr->end.col == gnm_sheet_get_max_cols (sv->sheet)-1)
sr->end.col == gnm_sheet_get_last_col (sv->sheet))
return COL_ROW_FULL_SELECTION;
ret = COL_ROW_PARTIAL_SELECTION;
......@@ -371,12 +371,12 @@ sv_selection_extend_to (SheetView *sv, int col, int row)
if (col < 0) {
base_col = 0;
col = gnm_sheet_get_max_cols (sv->sheet) - 1;
col = gnm_sheet_get_last_col (sv->sheet);
} else
base_col = sv->cursor.base_corner.col;
if (row < 0) {
base_row = 0;
row = gnm_sheet_get_max_rows (sv->sheet) - 1;
row = gnm_sheet_get_last_row (sv->sheet);
} else
base_row = sv->cursor.base_corner.row;
......@@ -460,8 +460,8 @@ sheet_selection_set_internal (SheetView *sv,
}
/* Has the entire row been selected/unselected */
if ((new_sel.start.row == 0 && new_sel.end.row == gnm_sheet_get_max_rows (sv->sheet)-1) ^
(old_sel.start.row == 0 && old_sel.end.row == gnm_sheet_get_max_rows (sv->sheet)-1)) {
if ((new_sel.start.row == 0 && new_sel.end.row == gnm_sheet_get_last_row (sv->sheet)) ^
(old_sel.start.row == 0 && old_sel.end.row == gnm_sheet_get_last_row (sv->sheet))) {
GnmRange tmp = range_union (&new_sel, &old_sel);
sv_redraw_headers (sv, TRUE, FALSE, &tmp);
} else {
......@@ -493,8 +493,8 @@ sheet_selection_set_internal (SheetView *sv,
}
/* Has the entire col been selected/unselected */
if ((new_sel.start.col == 0 && new_sel.end.col == gnm_sheet_get_max_cols (sv->sheet)-1) ^
(old_sel.start.col == 0 && old_sel.end.col == gnm_sheet_get_max_cols (sv->sheet)-1)) {
if ((new_sel.start.col == 0 && new_sel.end.col == gnm_sheet_get_last_col (sv->sheet)) ^
(old_sel.start.col == 0 && old_sel.end.col == gnm_sheet_get_last_col (sv->sheet))) {
GnmRange tmp = range_union (&new_sel, &old_sel);
sv_redraw_headers (sv, FALSE, TRUE, &tmp);
} else {
......@@ -853,7 +853,7 @@ selection_get_ranges (SheetView const *sv, gboolean allow_intersection)
case 1 : /* overlap bottom */
/* Split region */
if (b->end.row < (gnm_sheet_get_max_rows (sv->sheet)-1)) {
if (b->end.row < gnm_sheet_get_last_row (sv->sheet)) {
tmp = range_dup (a);
tmp->start.col = b->start.col;
tmp->start.row = b->end.row + 1;
......@@ -1340,12 +1340,12 @@ characterize_vec (Sheet *sheet, GnmRange *vector,
if (!expand_text)
return TRUE;
if (as_cols) {
if (vector->end.col >= gnm_sheet_get_max_cols (sheet)-1)
if (vector->end.col >= gnm_sheet_get_last_col (sheet))
return TRUE;
vector->end.col += dx;
dx = 1;
} else {
if (vector->end.row >= gnm_sheet_get_max_rows (sheet)-1)
if (vector->end.row >= gnm_sheet_get_last_row (sheet))
return TRUE;
vector->end.row += dy;
dy = 1;
......
......@@ -518,7 +518,7 @@ scg_select_all (SheetControlGUI *scg)
if (rangesel) {
scg_rangesel_bound (scg,
0, 0, gnm_sheet_get_max_cols (sheet) - 1, gnm_sheet_get_max_rows (sheet) - 1);
0, 0, gnm_sheet_get_last_col (sheet), gnm_sheet_get_last_row (sheet));
gnm_expr_entry_signal_update (
wbcg_get_entry_logical (scg->wbcg), TRUE);
} else if (wbc_gtk_get_guru (scg->wbcg) == NULL) {
......@@ -528,7 +528,7 @@ scg_select_all (SheetControlGUI *scg)
wbcg_edit_finish (scg->wbcg, WBC_EDIT_REJECT, NULL);
sv_selection_reset (sv);
sv_selection_add_full (sv, sv->edit_pos.col, sv->edit_pos.row,
0, 0, gnm_sheet_get_max_cols (sheet) - 1, gnm_sheet_get_max_rows (sheet) - 1);
0, 0, gnm_sheet_get_last_col (sheet), gnm_sheet_get_last_row (sheet));
}
sheet_update (sheet);
}
......@@ -563,24 +563,24 @@ scg_colrow_select (SheetControlGUI *scg, gboolean is_cols,
if (rangesel) {
if (is_cols)
scg_rangesel_bound (scg,
index, 0, index, gnm_sheet_get_max_rows (sv->sheet) - 1);
index, 0, index, gnm_sheet_get_last_row (sv->sheet));
else
scg_rangesel_bound (scg,
0, index, gnm_sheet_get_max_cols (sv->sheet) - 1, index);
0, index, gnm_sheet_get_last_col (sv->sheet), index);
} else if (is_cols) {
GnmPane *pane =
scg_pane (scg, scg->pane[3] ? 3 : 0);
sv_selection_add_full (sv,
index, pane->first.row,
index, 0,
index, gnm_sheet_get_max_rows (sv->sheet) - 1);
index, gnm_sheet_get_last_row (sv->sheet));
} else {
GnmPane *pane =
scg_pane (scg, scg->pane[1] ? 1 : 0);
sv_selection_add_full (sv,
pane->first.col, index,
0, index,
gnm_sheet_get_max_cols (sv->sheet) - 1, index);
gnm_sheet_get_last_col (sv->sheet), index);
}
}
......@@ -777,7 +777,7 @@ scg_set_left_col (SheetControlGUI *scg, int col)
if (col < bound->start.col)
col = bound->start.col;
else if (col >= gnm_sheet_get_max_cols (sheet))
col = gnm_sheet_get_max_cols (sheet) - 1;
col = gnm_sheet_get_last_col (sheet);
else if (col > bound->end.col)
col = bound->end.col;
......@@ -841,7 +841,7 @@ scg_set_top_row (SheetControlGUI *scg, int row)
if (row < bound->start.row)
row = bound->start.row;
else if (row >= gnm_sheet_get_max_rows (sheet))
row = gnm_sheet_get_max_rows (sheet) - 1;
row = gnm_sheet_get_last_row (sheet);
else if (row > bound->end.row)
row = bound->end.row;
......@@ -1091,7 +1091,7 @@ scg_set_panes (SheetControl *sc)
gnm_pane_bound_set (scg->pane[0],
br->col, br->row,
gnm_sheet_get_max_cols (sv->sheet) - 1, gnm_sheet_get_max_rows (sv->sheet) - 1);
gnm_sheet_get_last_col (sv->sheet), gnm_sheet_get_last_row (sv->sheet));
if (freeze_h) {
scg->active_panes = 2;
......@@ -1111,7 +1111,7 @@ scg_set_panes (SheetControl *sc)
0, 0);
}
gnm_pane_bound_set (scg->pane[1],
tl->col, br->row, br->col - 1, gnm_sheet_get_max_rows (sv->sheet) - 1);
tl->col, br->row, br->col - 1, gnm_sheet_get_last_row (sv->sheet));
}
if (freeze_h && freeze_v) {
scg->active_panes = 4;
......@@ -1145,7 +1145,7 @@ scg_set_panes (SheetControl *sc)
0, 0);
}
gnm_pane_bound_set (scg->pane[3],
br->col, tl->row, gnm_sheet_get_max_cols (sv->sheet) - 1, br->row - 1);
br->col, tl->row, gnm_sheet_get_last_col (sv->sheet), br->row - 1);
}
} else {
int i;
......@@ -1157,7 +1157,7 @@ scg_set_panes (SheetControl *sc)
scg->active_panes = 1;
gnm_pane_bound_set (scg->pane[0],
0, 0, gnm_sheet_get_max_cols (sv->sheet) - 1, gnm_sheet_get_max_rows (sv->sheet) - 1);
0, 0, gnm_sheet_get_last_col (sv->sheet), gnm_sheet_get_last_row (sv->sheet));
}
gtk_widget_show_all (GTK_WIDGET (scg->inner_table));
......@@ -1906,10 +1906,10 @@ scg_context_menu (SheetControlGUI *scg, GdkEventButton *event,
for (l = scg_view (scg)->selections; l != NULL; l = l->next) {
GnmRange const *r = l->data;
if (r->start.row == 0 && r->end.row == gnm_sheet_get_max_rows (sheet) - 1)
if (r->start.row == 0 && r->end.row == gnm_sheet_get_last_row (sheet))
sensitivity_filter |= CONTEXT_DISABLE_FOR_ROWS;
if (r->start.col == 0 && r->end.col == gnm_sheet_get_max_cols (sheet) - 1)
if (r->start.col == 0 && r->end.col == gnm_sheet_get_last_col (sheet))
sensitivity_filter |= CONTEXT_DISABLE_FOR_COLS;
if (!has_link && sheet_style_region_contains_link (sheet, r))
......@@ -2807,12 +2807,12 @@ scg_rangesel_extend_to (SheetControlGUI *scg, int col, int row)
if (col < 0) {
base_col = 0;
col = gnm_sheet_get_max_cols (scg_sheet (scg)) - 1;
col = gnm_sheet_get_last_col (scg_sheet (scg));
} else
base_col = scg->rangesel.base_corner.col;
if (row < 0) {
base_row = 0;
row = gnm_sheet_get_max_rows (scg_sheet (scg)) - 1;
row = gnm_sheet_get_last_row (scg_sheet (scg));
} else
base_row = scg->rangesel.base_corner.row;
......
......@@ -830,7 +830,7 @@ static gboolean
sheet_cell_or_one_below_is_not_empty (Sheet *sheet, int col, int row)
{
return !sheet_is_cell_empty (sheet, col, row) ||
(row < (gnm_sheet_get_max_rows (sheet) - 1) &&
(row < gnm_sheet_get_last_row (sheet) &&
!sheet_is_cell_empty (sheet, col, row+1));
}
......
......@@ -1520,7 +1520,7 @@ sheet_style_apply_border (Sheet *sheet,
/* 2.2 bottom outer */
r.end.row++;
if (r.end.row < (gnm_sheet_get_max_rows (sheet)-1)) {
if (r.end.row < gnm_sheet_get_last_row (sheet)) {
r.start.row = r.end.row;
apply_border (sheet, &r, GNM_STYLE_BORDER_TOP,
gnm_style_border_none ());
......@@ -1552,7 +1552,7 @@ sheet_style_apply_border (Sheet *sheet,
/* 4.2 right outer */
r.end.col++;
if (r.end.col < (gnm_sheet_get_max_cols (sheet)-1)) {
if (r.end.col < gnm_sheet_get_last_col (sheet)) {
r.start.col = r.end.col;
apply_border (sheet, &r, GNM_STYLE_BORDER_LEFT,
gnm_style_border_none ());
......@@ -1788,7 +1788,7 @@ sheet_style_find_conflicts (Sheet const *sheet, GnmRange const *r,
}
/* merge the top of the next row */
if (r->end.row < (gnm_sheet_get_max_rows (sheet)-1)) {
if (r->end.row < gnm_sheet_get_last_row (sheet)) {
sr.row = r->end.row + 1;
sheet_style_get_row (sheet, &sr);
}
......@@ -1852,7 +1852,7 @@ sheet_style_insert_colrow (GnmExprRelocateInfo const *rinfo)
col = 0;
corner.row = 0;
styles = sheet_style_get_list (rinfo->origin_sheet,
range_init (&r, col, 0, col, gnm_sheet_get_max_rows (rinfo->origin_sheet)-1));
range_init (&r, col, 0, col, gnm_sheet_get_last_row (rinfo->origin_sheet)));
if (o > 0)
for (ptr = styles ; ptr != NULL ; ptr = ptr->next)
((GnmStyleRegion *)ptr->data)->range.end.col = o;
......@@ -1953,7 +1953,7 @@ cb_style_extent (GnmStyle *style,
*
* A simple implementation that finds the smallest range containing all visible styles
* and containing res. x If @most_common_in_cols is specified it finds the most common
* style for each column (0..gnm_sheet_get_max_cols (sheet)-1) and ignores that style in
* style for each column (0..gnm_sheet_get_last_col (sheet)) and ignores that style in
* boundary calculations.
*/
void
......@@ -2028,13 +2028,13 @@ cb_style_list_add_node (GnmStyle *style,
if (sheet->partial_col) {
if (corner_col >= gnm_sheet_get_max_cols (sheet))
return;
range.end.col = MIN (range.end.col, gnm_sheet_get_max_cols (sheet) - 1);
range.end.col = MIN (range.end.col, gnm_sheet_get_last_col (sheet));
}
if (sheet->partial_row) {
if (corner_row >= gnm_sheet_get_max_rows (sheet))
return;
range.end.row = MIN (range.end.row, gnm_sheet_get_max_rows (sheet) - 1);
range.end.row = MIN (range.end.row, gnm_sheet_get_last_row (sheet));
}
if (apply_to) {
......
......@@ -729,8 +729,8 @@ sv_freeze_panes (SheetView *sv,
g_return_if_fail (unfrozen->row >= frozen->row);
/* Just in case */
if (unfrozen->col != (gnm_sheet_get_max_cols (sv->sheet)-1) &&
unfrozen->row != (gnm_sheet_get_max_rows (sv->sheet)-1) &&
if (unfrozen->col != gnm_sheet_get_last_col (sv->sheet) &&
unfrozen->row != gnm_sheet_get_last_row (sv->sheet) &&
!gnm_cellpos_equal (frozen, unfrozen)) {
sv->frozen_top_left = *frozen;
sv->unfrozen_top_left = *unfrozen;
......
......@@ -333,13 +333,13 @@ sheet_scale_changed (Sheet *sheet, gboolean cols_rescaled, gboolean rows_rescale
colrow_compute_pixels_from_pts (&sheet->cols.default_style, sheet, TRUE);
closure.sheet = sheet;
closure.is_cols = TRUE;
colrow_foreach (&sheet->cols, 0, gnm_sheet_get_max_cols (sheet) - 1,
colrow_foreach (&sheet->cols, 0, gnm_sheet_get_last_col (sheet),
(ColRowHandler)&cb_colrow_compute_pixels_from_pts, &closure);
}
if (rows_rescaled) {
colrow_compute_pixels_from_pts (&sheet->rows.default_style, sheet, FALSE);
closure.is_cols = FALSE;
colrow_foreach (&sheet->rows, 0<