[gnumeric] Cleanup: use gnm_sheet_get_last_(col|row) where appropriate.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] Cleanup: use gnm_sheet_get_last_(col|row) where appropriate.
- Date: Sat, 18 Apr 2009 20:23:31 -0400 (EDT)
commit abb3aeca9a2dd6bf95461eafb6af7afea4c0533f
Author: Morten Welinder <terra gnome org>
Date: Sat Apr 18 20:23:56 2009 -0400
Cleanup: use gnm_sheet_get_last_(col|row) where appropriate.
---
ChangeLog | 4 +++
plugins/fn-lookup/functions.c | 4 +-
plugins/lotus-123/lotus.c | 6 ++--
plugins/mps/mps.c | 2 +-
src/cmd-edit.c | 8 +++---
src/colrow.c | 16 ++++++------
src/commands.c | 16 ++++++------
src/dependent.c | 2 +-
src/gnm-pane.c | 32 +++++++++++++-------------
src/item-bar.c | 4 +-
src/item-edit.c | 2 +-
src/preview-grid.c | 4 +-
src/print.c | 4 +-
src/selection.c | 30 ++++++++++++------------
src/sheet-control-gui.c | 32 +++++++++++++-------------
src/sheet-filter.c | 2 +-
src/sheet-style.c | 14 ++++++------
src/sheet-view.c | 4 +-
src/sheet.c | 44 ++++++++++++++++++------------------
src/tools/dao.c | 6 ++--
src/tools/data-shuffling.c | 12 +++++-----
src/tools/tabulate.c | 8 +++---
src/widgets/gnumeric-expr-entry.c | 4 +-
src/xml-sax-write.c | 6 ++--
24 files changed, 135 insertions(+), 131 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index beb3079..1eaf23a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+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
diff --git a/plugins/fn-lookup/functions.c b/plugins/fn-lookup/functions.c
index d2f75df..669de9f 100644
--- a/plugins/fn-lookup/functions.c
+++ b/plugins/fn-lookup/functions.c
@@ -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);
}
diff --git a/plugins/lotus-123/lotus.c b/plugins/lotus-123/lotus.c
index b1d96f6..06cad5e 100644
--- a/plugins/lotus-123/lotus.c
+++ b/plugins/lotus-123/lotus.c
@@ -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;
diff --git a/plugins/mps/mps.c b/plugins/mps/mps.c
index 5a0d9ec..b5bec8f 100644
--- a/plugins/mps/mps.c
+++ b/plugins/mps/mps.c
@@ -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);
diff --git a/src/cmd-edit.c b/src/cmd-edit.c
index 1d25faf..e9b12d5 100644
--- a/src/cmd-edit.c
+++ b/src/cmd-edit.c
@@ -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;
diff --git a/src/colrow.c b/src/colrow.c
index 44b9eff..280ed52 100644
--- a/src/colrow.c
+++ b/src/colrow.c
@@ -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);
}
diff --git a/src/commands.c b/src/commands.c
index 4286e73..e93696d 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -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);
diff --git a/src/dependent.c b/src/dependent.c
index c9d5742..2be0101 100644
--- a/src/dependent.c
+++ b/src/dependent.c
@@ -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))
diff --git a/src/gnm-pane.c b/src/gnm-pane.c
index 443cbed..285a8dd 100644
--- a/src/gnm-pane.c
+++ b/src/gnm-pane.c
@@ -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;
}
}
diff --git a/src/item-bar.c b/src/item-bar.c
index 03dd607..c0de235 100644
--- a/src/item-bar.c
+++ b/src/item-bar.c
@@ -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);
diff --git a/src/item-edit.c b/src/item-edit.c
index e72829e..b2487bf 100644
--- a/src/item-edit.c
+++ b/src/item-edit.c
@@ -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);
diff --git a/src/preview-grid.c b/src/preview-grid.c
index 68e6a5d..e47a077 100644
--- a/src/preview-grid.c
+++ b/src/preview-grid.c
@@ -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
diff --git a/src/print.c b/src/print.c
index 136fc10..7bf8557 100644
--- a/src/print.c
+++ b/src/print.c
@@ -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,
diff --git a/src/selection.c b/src/selection.c
index eaa2233..bdf416e 100644
--- a/src/selection.c
+++ b/src/selection.c
@@ -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;
diff --git a/src/sheet-control-gui.c b/src/sheet-control-gui.c
index c7a014d..04b21b4 100644
--- a/src/sheet-control-gui.c
+++ b/src/sheet-control-gui.c
@@ -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;
diff --git a/src/sheet-filter.c b/src/sheet-filter.c
index c7c53b0..7380f54 100644
--- a/src/sheet-filter.c
+++ b/src/sheet-filter.c
@@ -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));
}
diff --git a/src/sheet-style.c b/src/sheet-style.c
index 9f990c2..df79c45 100644
--- a/src/sheet-style.c
+++ b/src/sheet-style.c
@@ -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) {
diff --git a/src/sheet-view.c b/src/sheet-view.c
index 33ced18..757628b 100644
--- a/src/sheet-view.c
+++ b/src/sheet-view.c
@@ -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;
diff --git a/src/sheet.c b/src/sheet.c
index af99333..cfd73dd 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -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, gnm_sheet_get_max_rows (sheet) - 1,
+ colrow_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet),
(ColRowHandler)&cb_colrow_compute_pixels_from_pts, &closure);
}
@@ -1537,7 +1537,7 @@ sheet_update_only_grid (Sheet const *sheet)
(p->recompute_visibility ?
SPANCALC_NO_DRAW : GNM_SPANCALC_SIMPLE));
#endif
- sheet_queue_respan (sheet, 0, gnm_sheet_get_max_rows (sheet) - 1);
+ sheet_queue_respan (sheet, 0, gnm_sheet_get_last_row (sheet));
}
if (p->reposition_objects.row < gnm_sheet_get_max_rows (sheet) ||
@@ -2149,7 +2149,7 @@ sheet_recompute_spans_for_col (Sheet *sheet, int col)
closure.sheet = sheet;
closure.col = col;
- colrow_foreach (&sheet->rows, 0, gnm_sheet_get_max_rows (sheet) - 1,
+ colrow_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet),
&cb_recalc_spans_in_col, &closure);
}
@@ -2566,7 +2566,7 @@ sheet_find_boundary_horizontal (Sheet *sheet, int start_col, int move_row,
{
gboolean find_nonblank = sheet_is_cell_empty (sheet, start_col, move_row);
gboolean keep_looking = FALSE;
- int new_col, prev_col, lagged_start_col, max_col = gnm_sheet_get_max_cols (sheet) - 1;
+ int new_col, prev_col, lagged_start_col, max_col = gnm_sheet_get_last_col (sheet);
int iterations = 0;
GnmRange check_merge;
GnmRange const * const bound = &sheet->priv->unhidden_region;
@@ -2666,7 +2666,7 @@ sheet_find_boundary_vertical (Sheet *sheet, int move_col, int start_row,
{
gboolean find_nonblank = sheet_is_cell_empty (sheet, move_col, start_row);
gboolean keep_looking = FALSE;
- int new_row, prev_row, lagged_start_row, max_row = gnm_sheet_get_max_rows (sheet) - 1;
+ int new_row, prev_row, lagged_start_row, max_row = gnm_sheet_get_last_row (sheet);
int iterations = 0;
GnmRange check_merge;
GnmRange const * const bound = &sheet->priv->unhidden_region;
@@ -3588,7 +3588,7 @@ sheet_col_destroy (Sheet *sheet, int const col, gboolean free_cells)
if (free_cells)
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_NONEXISTENT,
- col, 0, col, gnm_sheet_get_max_rows (sheet) - 1,
+ col, 0, col, gnm_sheet_get_last_row (sheet),
&cb_free_cell, NULL);
(*segment)->info[sub] = NULL;
@@ -3625,7 +3625,7 @@ sheet_row_destroy (Sheet *sheet, int const row, gboolean free_cells)
if (free_cells)
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_NONEXISTENT,
- 0, row, gnm_sheet_get_max_cols (sheet) - 1, row,
+ 0, row, gnm_sheet_get_last_col (sheet), row,
&cb_free_cell, NULL);
/* Rows have span lists, destroy them too */
@@ -4206,7 +4206,7 @@ sheet_insert_cols (Sheet *sheet, int col, int count,
/* 0. Check displaced region and ensure arrays aren't divided. */
if (count < gnm_sheet_get_max_cols (sheet)) {
- range_init (®ion, col, 0, gnm_sheet_get_max_cols (sheet) - 1-count, gnm_sheet_get_max_rows (sheet) - 1);
+ range_init (®ion, col, 0, gnm_sheet_get_last_col (sheet)-count, gnm_sheet_get_last_row (sheet));
if (sheet_range_splits_array (sheet, ®ion, NULL,
cc, _("Insert Columns")))
return TRUE;
@@ -4220,8 +4220,8 @@ sheet_insert_cols (Sheet *sheet, int col, int count,
reloc_info.reloc_type = GNM_EXPR_RELOCATE_COLS;
reloc_info.origin.start.col = col;
reloc_info.origin.start.row = 0;
- reloc_info.origin.end.col = gnm_sheet_get_max_cols (sheet) - 1;
- reloc_info.origin.end.row = gnm_sheet_get_max_rows (sheet) - 1;
+ reloc_info.origin.end.col = gnm_sheet_get_last_col (sheet);
+ reloc_info.origin.end.row = gnm_sheet_get_last_row (sheet);
reloc_info.origin_sheet = reloc_info.target_sheet = sheet;
reloc_info.col_offset = count;
reloc_info.row_offset = 0;
@@ -4231,7 +4231,7 @@ sheet_insert_cols (Sheet *sheet, int col, int count,
/* 3. Move the columns to their new location (from right to left) */
for (i = sheet->cols.max_used; i >= col ; --i)
- colrow_move (sheet, i, 0, i, gnm_sheet_get_max_rows (sheet) - 1,
+ colrow_move (sheet, i, 0, i, gnm_sheet_get_last_row (sheet),
&sheet->cols, i, i + count);
solver_insert_cols (sheet, col, count);
@@ -4279,7 +4279,7 @@ sheet_delete_cols (Sheet *sheet, int col, int count,
reloc_info.origin.start.col = col;
reloc_info.origin.start.row = 0;
reloc_info.origin.end.col = col + count - 1;
- reloc_info.origin.end.row = gnm_sheet_get_max_rows (sheet) - 1;
+ reloc_info.origin.end.row = gnm_sheet_get_last_row (sheet);
reloc_info.origin_sheet = reloc_info.target_sheet = sheet;
reloc_info.col_offset = gnm_sheet_get_max_cols (sheet); /* force invalidation */
reloc_info.row_offset = 0;
@@ -4309,14 +4309,14 @@ sheet_delete_cols (Sheet *sheet, int col, int count,
/* 3. Fix references to and from the cells which are moving */
reloc_info.origin.start.col = col + count;
- reloc_info.origin.end.col = gnm_sheet_get_max_cols (sheet) - 1;
+ reloc_info.origin.end.col = gnm_sheet_get_last_col (sheet);
reloc_info.col_offset = -count;
reloc_info.row_offset = 0;
combine_undo (pundo, dependents_relocate (&reloc_info));
/* 4. Move the columns to their new location (from left to right) */
for (i = col + count ; i <= sheet->cols.max_used; ++i)
- colrow_move (sheet, i, 0, i, gnm_sheet_get_max_rows (sheet) - 1,
+ colrow_move (sheet, i, 0, i, gnm_sheet_get_last_row (sheet),
&sheet->cols, i, i - count);
solver_delete_cols (sheet, col, count);
@@ -4364,7 +4364,7 @@ sheet_insert_rows (Sheet *sheet, int row, int count,
/* 0. Check displaced region and ensure arrays aren't divided. */
if (count < gnm_sheet_get_max_rows (sheet)) {
- range_init (®ion, 0, row, gnm_sheet_get_max_cols (sheet) - 1, gnm_sheet_get_max_rows (sheet) - 1-count);
+ range_init (®ion, 0, row, gnm_sheet_get_last_col (sheet), gnm_sheet_get_last_row (sheet)-count);
if (sheet_range_splits_array (sheet, ®ion, NULL,
cc, _("Insert Rows")))
return TRUE;
@@ -4378,8 +4378,8 @@ sheet_insert_rows (Sheet *sheet, int row, int count,
reloc_info.reloc_type = GNM_EXPR_RELOCATE_ROWS;
reloc_info.origin.start.col = 0;
reloc_info.origin.start.row = row;
- reloc_info.origin.end.col = gnm_sheet_get_max_cols (sheet) - 1;
- reloc_info.origin.end.row = gnm_sheet_get_max_rows (sheet) - 1;
+ reloc_info.origin.end.col = gnm_sheet_get_last_col (sheet);
+ reloc_info.origin.end.row = gnm_sheet_get_last_row (sheet);
reloc_info.origin_sheet = reloc_info.target_sheet = sheet;
reloc_info.col_offset = 0;
reloc_info.row_offset = count;
@@ -4389,7 +4389,7 @@ sheet_insert_rows (Sheet *sheet, int row, int count,
/* 3. Move the rows to their new location (from last to first) */
for (i = sheet->rows.max_used; i >= row ; --i)
- colrow_move (sheet, 0, i, gnm_sheet_get_max_cols (sheet) - 1, i,
+ colrow_move (sheet, 0, i, gnm_sheet_get_last_col (sheet), i,
&sheet->rows, i, i + count);
solver_insert_rows (sheet, row, count);
@@ -4436,7 +4436,7 @@ sheet_delete_rows (Sheet *sheet, int row, int count,
reloc_info.reloc_type = GNM_EXPR_RELOCATE_ROWS;
reloc_info.origin.start.col = 0;
reloc_info.origin.start.row = row;
- reloc_info.origin.end.col = gnm_sheet_get_max_cols (sheet) - 1;
+ reloc_info.origin.end.col = gnm_sheet_get_last_col (sheet);
reloc_info.origin.end.row = row + count - 1;
reloc_info.origin_sheet = reloc_info.target_sheet = sheet;
reloc_info.col_offset = 0;
@@ -4467,14 +4467,14 @@ sheet_delete_rows (Sheet *sheet, int row, int count,
/* 3. Fix references to and from the cells which are moving */
reloc_info.origin.start.row = row + count;
- reloc_info.origin.end.row = gnm_sheet_get_max_rows (sheet) - 1;
+ reloc_info.origin.end.row = gnm_sheet_get_last_row (sheet);
reloc_info.col_offset = 0;
reloc_info.row_offset = -count;
combine_undo (pundo, dependents_relocate (&reloc_info));
/* 4. Move the rows to their new location (from first to last) */
for (i = row + count ; i <= sheet->rows.max_used; ++i)
- colrow_move (sheet, 0, i, gnm_sheet_get_max_cols (sheet) - 1, i,
+ colrow_move (sheet, 0, i, gnm_sheet_get_last_col (sheet), i,
&sheet->rows, i, i - count);
solver_delete_rows (sheet, row, count);
diff --git a/src/tools/dao.c b/src/tools/dao.c
index a3ddaec..a14ea97 100644
--- a/src/tools/dao.c
+++ b/src/tools/dao.c
@@ -368,9 +368,9 @@ dao_set_array_expr (data_analysis_output_t *dao,
return;
}
if (col_end >= gnm_sheet_get_max_cols (dao->sheet))
- col_end = gnm_sheet_get_max_cols (dao->sheet) - 1;
+ col_end = gnm_sheet_get_last_col (dao->sheet);
if (row_end >= gnm_sheet_get_max_rows (dao->sheet))
- row_end = gnm_sheet_get_max_rows (dao->sheet) - 1;
+ row_end = gnm_sheet_get_last_row (dao->sheet);
texpr = gnm_expr_top_new (expr);
gnm_cell_set_array_formula (dao->sheet,
@@ -651,7 +651,7 @@ dao_autofit_column (data_analysis_output_t *dao, int col)
actual_col = dao->start_col + col;
ideal_size = sheet_col_size_fit_pixels (dao->sheet, actual_col,
- 0, gnm_sheet_get_max_rows (dao->sheet) - 1,
+ 0, gnm_sheet_get_last_row (dao->sheet),
FALSE);
if (ideal_size == 0)
return;
diff --git a/src/tools/data-shuffling.c b/src/tools/data-shuffling.c
index 3a11aa1..c08a7ef 100644
--- a/src/tools/data-shuffling.c
+++ b/src/tools/data-shuffling.c
@@ -231,8 +231,8 @@ run_shuffling_tool (data_shuffling_t *st)
if (st->type == SHUFFLE_COLS) {
/* Find empty space. */
- for (i = gnm_sheet_get_max_cols (st->sheet) - 1; i >= 0; i--)
- for (j = gnm_sheet_get_max_rows (st->sheet) - 1; j >= 0; j--) {
+ for (i = gnm_sheet_get_last_col (st->sheet); i >= 0; i--)
+ for (j = gnm_sheet_get_last_row (st->sheet); j >= 0; j--) {
cell = sheet_cell_get (st->sheet, i, j);
if (cell != NULL)
break;
@@ -247,8 +247,8 @@ run_shuffling_tool (data_shuffling_t *st)
do_swap_cols (st, (swap_t *) cur->data);
} else if (st->type == SHUFFLE_ROWS) {
/* Find empty space. */
- for (i = gnm_sheet_get_max_rows (st->sheet) - 1; i >= 0; i--)
- for (j = gnm_sheet_get_max_cols (st->sheet) - 1; j >= 0; j--) {
+ for (i = gnm_sheet_get_last_row (st->sheet); i >= 0; i--)
+ for (j = gnm_sheet_get_last_col (st->sheet); j >= 0; j--) {
cell = sheet_cell_get (st->sheet, j, i);
if (cell != NULL)
break;
@@ -264,8 +264,8 @@ run_shuffling_tool (data_shuffling_t *st)
} else {
/* SHUFFLE_AREA */
/* Find empty space. */
- for (i = gnm_sheet_get_max_cols (st->sheet) - 1; i >= 0; i--)
- for (j = gnm_sheet_get_max_rows (st->sheet) - 1; j >= 0; j--) {
+ for (i = gnm_sheet_get_last_col (st->sheet); i >= 0; i--)
+ for (j = gnm_sheet_get_last_row (st->sheet); j >= 0; j--) {
cell = sheet_cell_get (st->sheet, i, j);
if (cell == NULL)
goto area_out;
diff --git a/src/tools/tabulate.c b/src/tools/tabulate.c
index ef3fdc1..8c70965 100644
--- a/src/tools/tabulate.c
+++ b/src/tools/tabulate.c
@@ -101,10 +101,10 @@ do_tabulation (WorkbookControl *wbc,
counts[i] = 1 + gnm_fake_floor ((data->maxima[i] - data->minima[i]) / data->steps[i]);
/* Silently truncate at the edges. */
- if (!data->with_coordinates && i == 0 && counts[i] > gnm_sheet_get_max_cols (old_sheet) - 1) {
- counts[i] = gnm_sheet_get_max_cols (old_sheet) - 1;
- } else if (!data->with_coordinates && i == 1 && counts[i] > gnm_sheet_get_max_rows (old_sheet) - 1) {
- counts[i] = gnm_sheet_get_max_rows (old_sheet) - 1;
+ if (!data->with_coordinates && i == 0 && counts[i] > gnm_sheet_get_last_col (old_sheet)) {
+ counts[i] = gnm_sheet_get_last_col (old_sheet);
+ } else if (!data->with_coordinates && i == 1 && counts[i] > gnm_sheet_get_last_row (old_sheet)) {
+ counts[i] = gnm_sheet_get_last_row (old_sheet);
}
}
}
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index 2bf5f44..f65ea5e 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -773,11 +773,11 @@ gee_prepare_range (GnmExprEntry const *gee, GnmRangeRef *dst)
dst->a.sheet = gee->sheet;
if (gee->flags & GNM_EE_FULL_ROW) {
dst->a.col = 0;
- dst->b.col = gnm_sheet_get_max_cols (gee->sheet) - 1;
+ dst->b.col = gnm_sheet_get_last_col (gee->sheet);
}
if (gee->flags & GNM_EE_FULL_COL) {
dst->a.row = 0;
- dst->b.row = gnm_sheet_get_max_rows (gee->sheet) - 1;
+ dst->b.row = gnm_sheet_get_last_row (gee->sheet);
}
/* special case a single merge to be only corner */
diff --git a/src/xml-sax-write.c b/src/xml-sax-write.c
index 2cf7fc7..9c05e11 100644
--- a/src/xml-sax-write.c
+++ b/src/xml-sax-write.c
@@ -691,7 +691,7 @@ xml_write_cols_rows (GnmOutputXML *state)
closure.prev = NULL;
closure.prev_pos = -1;
closure.rle_count = 0;
- colrow_foreach (&state->sheet->cols, 0, gnm_sheet_get_max_cols (state->sheet)-1,
+ colrow_foreach (&state->sheet->cols, 0, gnm_sheet_get_last_col (state->sheet),
(ColRowHandler)&xml_write_colrow_info, &closure);
xml_write_colrow_info (NULL, &closure); /* flush */
gsf_xml_out_end_element (state->output); /* </gnm:Cols> */
@@ -704,7 +704,7 @@ xml_write_cols_rows (GnmOutputXML *state)
closure.prev = NULL;
closure.prev_pos = -1;
closure.rle_count = 0;
- colrow_foreach (&state->sheet->rows, 0, gnm_sheet_get_max_rows (state->sheet)-1,
+ colrow_foreach (&state->sheet->rows, 0, gnm_sheet_get_last_row (state->sheet),
(ColRowHandler)&xml_write_colrow_info, &closure);
xml_write_colrow_info (NULL, &closure); /* flush */
gsf_xml_out_end_element (state->output); /* </gnm:Rows> */
@@ -816,7 +816,7 @@ xml_write_cells (GnmOutputXML *state)
{
gsf_xml_out_start_element (state->output, GNM "Cells");
sheet_foreach_cell_in_range ((Sheet *)state->sheet, CELL_ITER_IGNORE_NONEXISTENT,
- 0, 0, gnm_sheet_get_max_cols (state->sheet)-1, gnm_sheet_get_max_rows (state->sheet)-1,
+ 0, 0, gnm_sheet_get_last_col (state->sheet), gnm_sheet_get_last_row (state->sheet),
(CellIterFunc) cb_write_cell, state);
gsf_xml_out_end_element (state->output); /* </gnm:Cells> */
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]