Commit 4a21f479 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Use gnm_sheet_get_max_cols for SHEET_MAX_COLS and gnm_sheet_get_max_rows

2008-04-28  Morten Welinder  <terra@gnome.org>

	* */*.c: Use gnm_sheet_get_max_cols for SHEET_MAX_COLS and
	gnm_sheet_get_max_rows for SHEET_MAX_ROWS in most cases.  (Adapted
	from Jean's patch in #168875.)


svn path=/trunk/; revision=16531
parent 44014140
......@@ -3,6 +3,10 @@
* src/colrow.h (colrow_max): Take a sheet argument too. All
callers changed.
* */*.c: Use gnm_sheet_get_max_cols for SHEET_MAX_COLS and
gnm_sheet_get_max_rows for SHEET_MAX_ROWS in most cases. (Adapted
from Jean's patch in #168875.)
* src/wbc-gtk-actions.c (cb_calc_decs): Use rendered value, if
available.
......
......@@ -174,13 +174,13 @@ applix_parse_value (char *buf, char **follow)
static gboolean
valid_col (int c)
{
return c >= 0 && c < SHEET_MAX_COLS;
return c >= 0 && c < gnm_sheet_get_max_cols (NULL);
}
static gboolean
valid_row (int r)
{
return r >= 0 && r < SHEET_MAX_ROWS;
return r >= 0 && r < gnm_sheet_get_max_rows (NULL);
}
static gboolean
......
......@@ -11,6 +11,7 @@
#include <gnumeric-config.h>
#include <glib/gi18n-lib.h>
#include <gnumeric.h>
#include <libgnumeric.h>
#include <cell.h>
#include <sheet.h>
......@@ -173,7 +174,7 @@ dif_parse_data (DifInputContext *ctxt)
gnm_io_warning (ctxt->io_context,
_("Syntax error at line %d. Ignoring."),
ctxt->line_no);
else if (col > SHEET_MAX_COLS) {
else if (col > gnm_sheet_get_max_cols (ctxt->sheet)) {
too_many_columns = TRUE;
break;
} else {
......@@ -206,7 +207,7 @@ dif_parse_data (DifInputContext *ctxt)
} else if (val_type == 1) {
if (!dif_get_line (ctxt))
return FALSE;
if (col > SHEET_MAX_COLS) {
if (col > gnm_sheet_get_max_cols (ctxt->sheet)) {
too_many_columns = TRUE;
continue;
}
......@@ -224,7 +225,7 @@ dif_parse_data (DifInputContext *ctxt)
if (strcmp (ctxt->line, "BOT") == 0) {
col = 0;
row++;
if (row > SHEET_MAX_ROWS) {
if (row > gnm_sheet_get_max_rows (ctxt->sheet)) {
too_many_rows = TRUE;
break;
}
......@@ -249,11 +250,11 @@ dif_parse_data (DifInputContext *ctxt)
if (too_many_rows) {
g_warning (_("DIF file has more than the maximum number of rows %d. "
"Ignoring remaining rows."), SHEET_MAX_ROWS);
"Ignoring remaining rows."), gnm_sheet_get_max_rows (ctxt->sheet));
}
if (too_many_columns) {
g_warning (_("DIF file has more than the maximum number of columns %d. "
"Ignoring remaining columns."), SHEET_MAX_COLS);
"Ignoring remaining columns."), gnm_sheet_get_max_cols (ctxt->sheet));
}
return TRUE;
......
......@@ -318,7 +318,7 @@ xl_xml_col_start (GsfXMLIn *xin, xmlChar const **attrs)
r.start.col = state->pos.col;
r.end.col = state->pos.col + span - 1;
r.start.row = 0;
r.end.row = SHEET_MAX_ROWS - 1;
r.end.row = gnm_sheet_get_max_rows (state->sheet) - 1;
gnm_style_ref (style);
sheet_style_set_range (state->sheet, &r, style);
}
......@@ -373,7 +373,7 @@ xl_xml_row_start (GsfXMLIn *xin, xmlChar const **attrs)
r.start.row = state->pos.row;
r.end.row = state->pos.row + span - 1;
r.start.col = 0;
r.end.col = SHEET_MAX_COLS - 1;
r.end.col = gnm_sheet_get_max_cols (state->sheet) - 1;
gnm_style_ref (style);
sheet_style_set_range (state->sheet, &r, style);
}
......
......@@ -2379,7 +2379,7 @@ xlsx_CT_Row (GsfXMLIn *xin, xmlChar const **attrs)
GnmRange r;
r.start.row = r.end.row = row;
r.start.col = 0;
r.end.col = SHEET_MAX_COLS - 1;
r.end.col = gnm_sheet_get_max_cols (state->sheet) - 1;
gnm_style_ref (style);
sheet_style_set_range (state->sheet, &r, style);
}
......@@ -2426,8 +2426,8 @@ xlsx_CT_Col (GsfXMLIn *xin, xmlChar const **attrs)
}
if (last >= SHEET_MAX_COLS)
last = SHEET_MAX_COLS - 1;
if (last >= gnm_sheet_get_max_cols (state->sheet))
last = gnm_sheet_get_max_cols (state->sheet) - 1;
for (i = first; i <= last; i++) {
if (width > 4)
sheet_col_set_size_pts (state->sheet, i, width,
......@@ -2441,7 +2441,7 @@ xlsx_CT_Col (GsfXMLIn *xin, xmlChar const **attrs)
r.start.col = first;
r.end.col = last;
r.start.row = 0;
r.end.row = SHEET_MAX_ROWS - 1;
r.end.row = gnm_sheet_get_max_rows (state->sheet) - 1;
gnm_style_ref (style);
sheet_style_set_range (state->sheet, &r, style);
}
......
......@@ -557,9 +557,9 @@ gnumeric_address (GnmFuncEvalInfo *ei, GnmValue const * const *args)
if (err)
return value_new_error_VALUE (ei->pos);
}
if (col < 0 || col >= SHEET_MAX_COLS)
if (col < 0 || col >= gnm_sheet_get_max_cols (ei->pos->sheet))
return value_new_error_VALUE (ei->pos);
if (row < 0 || row >= SHEET_MAX_ROWS)
if (row < 0 || row >= gnm_sheet_get_max_rows (ei->pos->sheet))
return value_new_error_VALUE (ei->pos);
if (!out.convs->r1c1_addresses)
......@@ -1246,7 +1246,7 @@ gnumeric_offset (GnmFuncEvalInfo *ei, GnmValue const * const *args)
a.row += row_offset;
a.col += col_offset;
if (a.row < 0 || a.col < 0 ||
a.row >= SHEET_MAX_ROWS || a.col >= SHEET_MAX_COLS)
a.row >= gnm_sheet_get_max_rows (ei->pos->sheet) || a.col >= gnm_sheet_get_max_cols (ei->pos->sheet))
return value_new_error_REF (ei->pos);
if (args[3] != NULL) {
......@@ -1256,7 +1256,7 @@ gnumeric_offset (GnmFuncEvalInfo *ei, GnmValue const * const *args)
b.row = a.row + tmp - 1;
} else
b.row += row_offset;
if (b.col < 0 || b.row >= SHEET_MAX_ROWS)
if (b.col < 0 || b.row >= gnm_sheet_get_max_rows (ei->pos->sheet))
return value_new_error_REF (ei->pos);
if (args[4] != NULL) {
tmp = value_get_as_int (args[4]);
......@@ -1265,7 +1265,7 @@ gnumeric_offset (GnmFuncEvalInfo *ei, GnmValue const * const *args)
b.col = a.col + tmp - 1;
} else
b.col += col_offset;
if (b.col < 0 || b.col >= SHEET_MAX_COLS)
if (b.col < 0 || b.col >= gnm_sheet_get_max_cols (ei->pos->sheet))
return value_new_error_REF (ei->pos);
return value_new_cellrange_unsafe (&a, &b);
......
......@@ -157,7 +157,7 @@ display_recordset (GdaDataModel *recset, GnmFuncEvalInfo *ei)
if (rowcount <= 0)
return value_new_empty ();
if (rowcount >= SHEET_MAX_ROWS)
if (rowcount >= gnm_sheet_get_max_rows (ei->pos->sheet))
return value_new_error (ei->pos, _("Too much data returned"));
date_conv = workbook_date_conv (ei->pos->sheet->workbook);
......
......@@ -1157,26 +1157,26 @@ lotus_rldb_walk_3d (LotusRLDB *rldb3,
ci = 0;
for (r.range.start.col = 0;
r.range.start.col < SHEET_MAX_COLS;
r.range.start.col < gnm_sheet_get_max_cols (r.sheet);
r.range.start.col = r.range.end.col + 1) {
if (ci >= rldb2->lower->len)
break;
rldb1 = g_ptr_array_index (rldb2->lower, ci);
ci++;
r.range.end.col =
MIN (SHEET_MAX_COLS - 1,
MIN (gnm_sheet_get_max_cols (r.sheet) - 1,
r.range.start.col + (rldb1->rll - 1));
ri = 0;
for (r.range.start.row = 0;
r.range.start.row < SHEET_MAX_ROWS;
r.range.start.row < gnm_sheet_get_max_rows (r.sheet);
r.range.start.row = r.range.end.row + 1) {
if (ri >= rldb1->lower->len)
break;
rldb0 = g_ptr_array_index (rldb1->lower, ri);
ri++;
r.range.end.row =
MIN (SHEET_MAX_ROWS - 1,
MIN (gnm_sheet_get_max_rows (r.sheet) - 1,
r.range.start.row + (rldb0->rll - 1));
data = rldb0->datanode;
......@@ -1204,7 +1204,7 @@ lotus_rldb_walk_2d (LotusRLDB *rldb2,
guint si, cri;
LotusRLDB *rldb1, *rldb0;
const GString *data;
int max = iscol ? SHEET_MAX_COLS : SHEET_MAX_ROWS;
int max = iscol ? gnm_sheet_get_max_cols (NULL) : gnm_sheet_get_max_rows (NULL);
int start, end;
Sheet *sheet;
......@@ -1356,7 +1356,7 @@ lotus_set_colwidth_cb (LotusState *state,
: lotus_qmps_to_points (GSF_LE_GET_GUINT32 (data + 4));
value_set = (flags & 1) != 0;
if (end - start >= SHEET_MAX_COLS)
if (end - start >= gnm_sheet_get_max_cols (sheet))
sheet_col_set_default_size_pixels (sheet, size);
else {
int i;
......@@ -1401,7 +1401,7 @@ lotus_set_rowheight_cb (LotusState *state,
: lotus_qmps_to_points (GSF_LE_GET_GUINT32 (data + 4));
value_set = (flags & 1) != 0;
if (end - start >= SHEET_MAX_ROWS)
if (end - start >= gnm_sheet_get_max_rows (sheet))
sheet_row_set_default_size_pixels (sheet, size);
else {
int i;
......
......@@ -489,7 +489,7 @@ mps_create_sheet (MpsInputContext *ctxt, WorkbookView *wbv)
/* Autofit column A */
i = sheet_col_size_fit_pixels (sh, 0, 0, SHEET_MAX_ROWS - 1, FALSE);
i = sheet_col_size_fit_pixels (sh, 0, 0, gnm_sheet_get_max_rows (ctxt->sheet) - 1, FALSE);
if (i == 0)
return;
sheet_col_set_size_pixels (sh, 0, i, TRUE);
......
......@@ -593,15 +593,15 @@ oo_table_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
/* default cell styles are applied only to cells that are specified
* which is a performance nightmare. Instead we apply the styles to
* the entire column or row and clear the area beyond the extent here. */
if (state->extent_style.col < SHEET_MAX_COLS) {
if (state->extent_style.col < gnm_sheet_get_max_cols (NULL)) {
range_init (&r, state->extent_style.col, 0,
SHEET_MAX_COLS-1, SHEET_MAX_ROWS-1);
gnm_sheet_get_max_cols (NULL)-1, gnm_sheet_get_max_rows (NULL)-1);
sheet_style_set_range (state->pos.sheet, &r,
sheet_style_default (state->pos.sheet));
}
if (state->extent_style.row < SHEET_MAX_ROWS) {
if (state->extent_style.row < gnm_sheet_get_max_rows (NULL)) {
range_init (&r, 0, state->extent_style.row,
SHEET_MAX_COLS-1, SHEET_MAX_ROWS-1);
gnm_sheet_get_max_cols (NULL)-1, gnm_sheet_get_max_rows (NULL)-1);
sheet_style_set_range (state->pos.sheet, &r,
sheet_style_default (state->pos.sheet));
}
......@@ -669,7 +669,7 @@ oo_col_start (GsfXMLIn *xin, xmlChar const **attrs)
r.start.col = state->pos.eval.col;
r.end.col = state->pos.eval.col + repeat_count - 1;
r.start.row = 0;
r.end.row = SHEET_MAX_ROWS - 1;
r.end.row = gnm_sheet_get_max_rows (NULL) - 1;
gnm_style_ref (style);
sheet_style_set_range (state->pos.sheet, &r, style);
}
......@@ -700,8 +700,8 @@ oo_row_start (GsfXMLIn *xin, xmlChar const **attrs)
state->pos.eval.col = 0;
if (state->pos.eval.row >= SHEET_MAX_ROWS) {
oo_warning (xin, _("Content past the maxium number of rows supported in this build (%u). Please recompile with larger limits."), SHEET_MAX_ROWS);
if (state->pos.eval.row >= gnm_sheet_get_max_rows (NULL)) {
oo_warning (xin, _("Content past the maxium number of rows supported in this build (%u). Please recompile with larger limits."), gnm_sheet_get_max_rows (NULL));
state->row_inc = 0;
return;
}
......@@ -724,7 +724,7 @@ oo_row_start (GsfXMLIn *xin, xmlChar const **attrs)
r.start.row = state->pos.eval.row;
r.end.row = state->pos.eval.row + repeat_count - 1;
r.start.col = 0;
r.end.col = SHEET_MAX_COLS - 1;
r.end.col = gnm_sheet_get_max_cols (NULL) - 1;
gnm_style_ref (style);
sheet_style_set_range (state->pos.sheet, &r, style);
}
......
......@@ -401,8 +401,8 @@ odf_write_sheet (GnmOOExport *state, Sheet const *sheet)
{
GnmStyle *col_styles [SHEET_MAX_COLS];
GnmRange extent;
int max_cols = SHEET_MAX_COLS;
int max_rows = SHEET_MAX_ROWS;
int max_cols = gnm_sheet_get_max_cols (sheet);
int max_rows = gnm_sheet_get_max_rows (sheet);
int i, col, row;
int null_cell;
int covered_cell;
......
......@@ -489,8 +489,8 @@ pln_calc_font_width (guint16 cwidth, gboolean permit_default)
static ErrorInfo *
pln_parse_sheet (GsfInput *input, PlanPerfectImport *state)
{
int max_col = SHEET_MAX_COLS;
int max_row = SHEET_MAX_ROWS;
int max_col = gnm_sheet_get_max_cols (state->sheet);
int max_row = gnm_sheet_get_max_rows (state->sheet);
int i, rcode, rlength;
guint8 const *data;
GnmValue *v;
......@@ -498,7 +498,7 @@ pln_parse_sheet (GsfInput *input, PlanPerfectImport *state)
GnmParsePos pp;
GnmRange r;
range_init (&r, 0,0,0, SHEET_MAX_ROWS);
range_init (&r, 0,0,0, gnm_sheet_get_max_rows (state->sheet));
parse_pos_init_sheet (&pp, state->sheet);
data = gsf_input_read (input, 16, NULL);
......
......@@ -266,7 +266,7 @@ sc_row_parse (char const *str, int *res, unsigned char *relative)
row = strtol (ptr, (char **)&end, 10);
if (ptr != end &&
!g_unichar_isalnum (g_utf8_get_char (end)) && *end != '_' &&
0 <= row && row < SHEET_MAX_ROWS) {
0 <= row && row < gnm_sheet_get_max_rows (NULL)) {
*res = row;
return end;
} else
......
......@@ -621,7 +621,7 @@ sylk_rtd_f_parse (SylkReader *state, char *str)
int first, last, width;
if (3 == sscanf (str+1, "%d %d %d", &first, &last, &width)) {
/* width seems to be in characters */
if (first <= last && first < SHEET_MAX_COLS && last < SHEET_MAX_COLS)
if (first <= last && first < gnm_sheet_get_max_cols (NULL) && last < gnm_sheet_get_max_cols (NULL))
while (first <= last)
sheet_col_set_size_pts (state->pp.sheet,
first++ - 1, width*7.45, TRUE);
......
......@@ -204,12 +204,9 @@ xbase_file_open (GOFileOpener const *fo, IOContext *io_context,
record = record_new (file);
row = 1;
do {
if (row >= SHEET_MAX_ROWS) {
g_warning (_("This build of Gnumeric can only hold %d "
"rows. Ignoring the rest of this file. You "
"will need a custom build with SHEET_MAX_ROWS "
"increased to read this file."),
SHEET_MAX_ROWS);
if (row >= gnm_sheet_get_max_rows (sheet)) {
/* FIXME: either we need to add new rows, if posible
or create a larger sheet*/
break;
}
for (i = 0; i < file->fields ; i++) {
......
......@@ -2,10 +2,12 @@
#include <gnumeric-config.h>
#include <glib/gi18n-lib.h>
#include <gnumeric.h>
#include <libgnumeric.h>
#include "xbase.h"
#include <gnm-format.h>
#include <gutils.h>
#include <sheet.h>
#include <goffice/app/io-context.h>
#include <goffice/app/error-info.h>
......@@ -264,7 +266,7 @@ xbase_open (GsfInput *input, ErrorInfo **ret_error)
ans->fields = 0;
ans->format = NULL;
while (ans->fields < (SHEET_MAX_COLS-1) && (field = xbase_field_new (ans)) != NULL) {
while (ans->fields < (gnm_sheet_get_max_cols (NULL)-1) && (field = xbase_field_new (ans)) != NULL) {
ans->format = g_renew (XBfield *, ans->format, ans->fields + 1);
/* FIXME: allocate number of field formats from file size? */
ans->format[ans->fields++] = field;
......
......@@ -256,7 +256,7 @@ cell_calc_span (GnmCell const *cell, int *col1, int *col2)
gnm_sheet_merge_get_adjacent (sheet, &cell->pos, &merge_left, &merge_right);
min_col = (merge_left != NULL) ? merge_left->end.col : -1;
max_col = (merge_right != NULL) ? merge_right->start.col : SHEET_MAX_COLS;
max_col = (merge_right != NULL) ? merge_right->start.col : gnm_sheet_get_max_cols (sheet);
*col1 = *col2 = cell->pos.col;
switch (h_align) {
......
......@@ -420,8 +420,8 @@ clipboard_paste_region (GnmCellRegion const *cr,
return TRUE;
}
if ((pt->range.start.col + dst_cols) > SHEET_MAX_COLS ||
(pt->range.start.row + dst_rows) > SHEET_MAX_ROWS) {
if ((pt->range.start.col + dst_cols) > gnm_sheet_get_max_cols (pt->sheet) ||
(pt->range.start.row + dst_rows) > gnm_sheet_get_max_rows (pt->sheet)) {
go_cmd_context_error_invalid (cc,
_("Unable to paste"),
_("result passes the sheet boundary"));
......@@ -906,13 +906,13 @@ cellregion_to_string (GnmCellRegion const *cr,
next_row_check = i = 0;
while ((i += ((ColRowRLEState *)(row_state->data))->length) <= extent.start.row) {
if (NULL == (row_state = row_state->next)) {
next_row_check = SHEET_MAX_ROWS;
next_row_check = gnm_sheet_get_max_rows (cr->origin_sheet);
break;
}
next_row_check = i;
}
} else
next_row_check = SHEET_MAX_ROWS;
next_row_check = gnm_sheet_get_max_rows (cr->origin_sheet);
for (row = extent.start.row; row <= extent.end.row;) {
if (row >= next_row_check) {
......@@ -931,13 +931,13 @@ cellregion_to_string (GnmCellRegion const *cr,
next_col_check = i = 0;
while ((i += ((ColRowRLEState *)(col_state->data))->length) <= extent.start.col) {
if (NULL == (col_state = col_state->next)) {
next_col_check = SHEET_MAX_COLS;
next_col_check = gnm_sheet_get_max_cols (cr->origin_sheet);
break;
}
next_col_check = i;
}
} else
next_col_check = SHEET_MAX_COLS;
next_col_check = gnm_sheet_get_max_cols (cr->origin_sheet);
for (col = extent.start.col; col <= extent.end.col;) {
if (col == next_col_check) {
......
......@@ -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, SHEET_MAX_COLS-1, r.end.row);
0, r.start.row, gnm_sheet_get_max_cols (sv->sheet)-1, 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, SHEET_MAX_ROWS-1);
r.start.col, 0, r.end.col, gnm_sheet_get_max_rows (sv->sheet)-1);
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 = SHEET_MAX_COLS-1;
rinfo.origin.end.col = gnm_sheet_get_max_cols (sheet)-1;
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 = SHEET_MAX_ROWS-1;
rinfo.origin.end.row = gnm_sheet_get_max_rows (sheet)-1;
if (count > 0)
rinfo.origin.end.row -= count;
......
......@@ -442,19 +442,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, SHEET_MAX_COLS-1,
colrow_foreach (&sheet->cols, 0, gnm_sheet_get_max_cols (sheet)-1,
&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, SHEET_MAX_ROWS-1,
colrow_foreach (&sheet->rows, 0, gnm_sheet_get_max_rows (sheet)-1,
&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, SHEET_MAX_COLS-1, SHEET_MAX_ROWS-1,
0, 0, gnm_sheet_get_max_cols (sheet)-1, gnm_sheet_get_max_rows (sheet)-1,
(CellIterFunc) &cb_clear_variable_width_content, NULL);
/* Result is a magic 'default' record + >= 1 normal */
......@@ -464,7 +464,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, SHEET_MAX_ROWS-1,
index->first, 0, index->last, gnm_sheet_get_max_rows (sheet)-1,
(CellIterFunc) &cb_clear_variable_width_content, NULL);
/* In order to properly reposition cell comments in
......@@ -479,8 +479,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, SHEET_MAX_ROWS - 1, FALSE)
: sheet_row_size_fit_pixels (sheet, i, 0, SHEET_MAX_COLS - 1, FALSE);
? 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);
if (tmp > 0) {
if (is_cols)
......@@ -606,7 +606,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, SHEET_MAX_ROWS-1,
index->first, 0, index->last, gnm_sheet_get_max_rows (sheet)-1,
(CellIterFunc) &cb_clear_variable_width_content, NULL);
colrow_state_list_destroy (ptr->data);
selection = selection->prev;
......@@ -906,7 +906,7 @@ colrow_set_visibility_list (Sheet *sheet, gboolean is_cols,
}
if (is_cols)
sheet_queue_respan (sheet, 0, SHEET_MAX_ROWS-1);
sheet_queue_respan (sheet, 0, gnm_sheet_get_max_rows (sheet)-1);
if (list != NULL)
sheet_redraw_all (sheet, TRUE);
}
......
......@@ -1878,8 +1878,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 < SHEET_MAX_COLS-1) range.end.col++;
if (range.end.row < SHEET_MAX_ROWS-1) range.end.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++;
}
os = g_new (CmdFormatOldStyle, 1);
......@@ -2188,10 +2188,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, SHEET_MAX_ROWS - 1);
y, gnm_sheet_get_max_rows (sheet) - 1);
else
sv_selection_add_full (sv, y, x, 0, x,
SHEET_MAX_COLS - 1, x);
gnm_sheet_get_max_cols (sheet) - 1, x);
}
#endif
}
......@@ -2998,9 +2998,9 @@ cmd_paste_copy (WorkbookControl *wbc,
/* Before looking for tiling if we are not transposing,
* allow pasting a full col or row from a single cell */
n = range_width (r);
if (n == 1 && cr->cols == SHEET_MAX_COLS) {
if (n == 1 && cr->cols == gnm_sheet_get_max_cols (me->cmd.sheet)) {
r->start.col = 0;
r->end.col = SHEET_MAX_COLS-1;
r->end.col = gnm_sheet_get_max_cols (me->cmd.sheet)-1;
} else {
n /= cr->cols;
if (n < 1) n = 1;
......@@ -3008,9 +3008,9 @@ cmd_paste_copy (WorkbookControl *wbc,
}
n = range_height (r);
if (n == 1 && cr->rows == SHEET_MAX_ROWS) {
if (n == 1 && cr->rows == gnm_sheet_get_max_rows (me->cmd.sheet)) {
r->start.row = 0;
r->end.row = SHEET_MAX_ROWS-1;
r->end.row = gnm_sheet_get_max_rows (me->cmd.sheet)-1;
} else {
n /= cr->rows;
if (n < 1) n = 1;
......@@ -3388,8 +3388,8 @@ cmd_copyrel (WorkbookControl *wbc,
src.start.col = src.end.col = (target.start.col + dx);
}
if (src.start.col < 0 || src.start.col >= SHEET_MAX_COLS ||
src.start.row < 0 || src.start.row >= SHEET_MAX_ROWS)
if (src.start.col < 0 || src.start.col >= gnm_sheet_get_max_cols (sheet) ||
src.start.row < 0 || src.start.row >= gnm_sheet_get_max_rows (sheet))
return FALSE;
/* Check arrays or merged regions in src or target regions */
......@@ -3552,8 +3552,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 < SHEET_MAX_COLS-1) range.end.col++;
if (range.end.row < SHEET_MAX_ROWS-1) range.end.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++;
os = g_new (CmdFormatOldStyle, 1);
......
......@@ -6,7 +6,7 @@
* Miguel de Icaza (miguel@gnu.org)
*
* This is a pretty simple implementation, should be helpful
* to find performance hot-spots (if you bump SEARCH_STEPS to SHEET_MAX_ROWS/2)
* to find performance hot-spots (if you bump SEARCH_STEPS to gnm_sheet_get_max_rows (sheet)/2)
*
* (C) 2000-2001 Ximian, Inc.
*/
......
......@@ -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 (SHEET_MAX_ROWS - 1))
#define BUCKET_LAST (BUCKET_OF_ROW (gnm_sheet_get_max_rows (sheet) - 1))
#define BUCKET_START_ROW(b) ((b) * BUCKET_SIZE)
#define BUCKET_END_ROW(b) ((b) * BUCKET_SIZE + (BUCKET_SIZE - 1))
......@@ -2646,7 +2646,7 @@ dynamic_dep_free (DynamicDep *dyn)
}
GnmDepContainer *
gnm_dep_container_new (void)
gnm_dep_container_new (Sheet *sheet)
{
GnmDepContainer *deps = g_new (GnmDepContainer, 1);
......@@ -2810,6 +2810,7 @@ void
gnm_dep_container_dump (GnmDepContainer const *deps)
{
int i;
Sheet *sheet = NULL;
g_return_if_fail (deps != NULL);
......
......@@ -106,7 +106,7 @@ void dependents_workbook_destroy (Workbook *wb);
void dependents_revive_sheet (Sheet *sheet);
void workbook_queue_all_recalc (Workbook *wb);
GnmDepContainer *gnm_dep_container_new (void);
GnmDepContainer *gnm_dep_container_new (Sheet *sheet);
void gnm_dep_container_dump (GnmDepContainer const *deps);
void gnm_dep_container_sanity_check (GnmDepContainer const *deps);
......
......@@ -231,7 +231,7 @@ cb_merge_merge_clicked (G_GNUC_UNUSED GtkWidget *ignore,
GSList *data_list = NULL, *field_list = NULL;
GnmValue *v_zone;
gint field_problems = 0;
gint min_length = SHEET_MAX_ROWS;
gint min_length = gnm_sheet_get_max_rows (state->sheet);
gint max_length = 0;
v_zone = gnm_expr_entry_parse_as_value (state->zone, state->sheet);
......
......@@ -23,8 +23,10 @@
#include <gnumeric-config.h>
#include <glib/gi18n-lib.h>
#include <gnumeric.h>
#include <libgnumeric.h>
#include "dialog-stf.h"
#include <gnm-format.h>
#include <sheet.h>
#include <workbook.h>
#include <workbook-control.h>
#include <gui-util.h>
......@@ -175,7 +177,7 @@ cb_col_check_clicked (GtkToggleButton *togglebutton, gpointer _i)
pagedata->format.col_import_count--;
format_page_update_column_selection (pagedata);
} else {
if (pagedata->format.col_import_count < SHEET_MAX_COLS) {
if (pagedata->format.col_import_count < gnm_sheet_get_max_cols (NULL)) {
pagedata->format.col_import_array[i] = TRUE;
pagedata->format.col_import_count++;
format_page_update_column_selection (pagedata);
......@@ -183,8 +185,8 @@ cb_col_check_clicked (GtkToggleButton *togglebutton, gpointer _i)
char *msg = g_strdup_printf(
ngettext("A maximum of %d column can be imported.",
"A maximum of %d columns can be imported.",
SHEET_MAX_COLS),
SHEET_MAX_COLS);
gnm_sheet_get_max_cols (NULL)),
gnm_sheet_get_max_cols (NULL));
gtk_toggle_button_set_active (togglebutton, FALSE);
go_gtk_notice_dialog (GTK_WINDOW (pagedata->dialog),
GTK_MESSAGE_WARNING, msg);
......@@ -208,7 +210,7 @@ check_columns_for_import (StfDialogData *pagedata, int from, int to)
if (!pagedata->format.col_import_array[i]) {
GtkTreeViewColumn* column = stf_preview_get_column (pagedata->format.renderdata, i);
GtkWidget *w = g_object_get_data (G_OBJECT (column), "checkbox");
if (!(pagedata->format.col_import_count < SHEET_MAX_COLS))
if (!(pagedata->format.col_import_count < gnm_sheet_get_max_cols (NULL)))
return;
gtk_widget_hide (w);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);
...