Commit 74ede8cf authored by Morten Welinder's avatar Morten Welinder

Code cleanups.

parent 13b26449
2018-04-26 Morten Welinder <terra@gnome.org>
* src/colrow.c (col_row_collection_foreach): move to...
* src/sheet.c (sheet_colrow_foreach): ...here. Allow -1 to mean
last column or row.
(sheet_foreach_cell_in_range): Change to take a range.
(sheet_foreach_cell_in_region): Preserve the old
sheet_foreach_cell_in_range api. Most callers changed. Allow -1
to mean last column or row.
2018-04-25 Morten Welinder <terra@gnome.org>
* src/xml-sax-read.c (xml_sax_cell_content): Read shared array
......
......@@ -456,9 +456,7 @@ latex2e_write_font_encodings (GsfOutput *output, Sheet *sheet, GnmRange const *r
gboolean *fonts = g_new0 (gboolean, G_UNICODE_SCRIPT_MANDAIC + 1);
sheet_foreach_cell_in_range
(sheet, CELL_ITER_IGNORE_BLANK | CELL_ITER_IGNORE_HIDDEN,
range->start.col, range->start.row,
range->end.col, range->end.row,
(sheet, CELL_ITER_IGNORE_BLANK | CELL_ITER_IGNORE_HIDDEN, range,
(CellIterFunc)&cb_find_font_encodings, fonts);
if (fonts[G_UNICODE_SCRIPT_CYRILLIC])
......
......@@ -312,9 +312,7 @@ sylk_write_sheet (SylkWriter *state)
// Cell styles
state->cur_row = -1;
sheet_foreach_cell_in_range (sheet, 0,
extent.start.col, extent.start.row,
extent.end.col, extent.end.row,
sheet_foreach_cell_in_range (sheet, 0, &extent,
(CellIterFunc) cb_sylk_write_cell_style, state);
// Column widths
......@@ -363,10 +361,8 @@ sylk_write_sheet (SylkWriter *state)
/* dump content */
state->cur_row = -1;
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK,
extent.start.col, extent.start.row,
extent.end.col, extent.end.row,
(CellIterFunc) cb_sylk_write_cell, state);
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK, &extent,
(CellIterFunc) cb_sylk_write_cell, state);
g_free (col_defs);
}
......
......@@ -1079,7 +1079,7 @@ gnm_cell_convert_expr_to_value (GnmCell *cell)
gnm_expr_top_get_array_size (texpr, &cols, &rows);
sheet_foreach_cell_in_range (cell->base.sheet, CELL_ITER_ALL,
sheet_foreach_cell_in_region (cell->base.sheet, CELL_ITER_ALL,
cell->pos.col, cell->pos.row,
cell->pos.col + cols - 1,
cell->pos.row + rows - 1,
......
......@@ -738,10 +738,9 @@ clipboard_copy_range (Sheet *sheet, GnmRange const *r)
cr->row_state = colrow_get_states (sheet,
FALSE, r->start.row, r->end.row);
sheet_foreach_cell_in_range ( sheet, CELL_ITER_IGNORE_NONEXISTENT,
r->start.col, r->start.row,
r->end.col, r->end.row,
(CellIterFunc) cb_clipboard_prepend_cell, cr);
sheet_foreach_cell_in_range ( sheet, CELL_ITER_IGNORE_NONEXISTENT, r,
(CellIterFunc) cb_clipboard_prepend_cell,
cr);
objects = sheet_objects_get (sheet, r, G_TYPE_NONE);
g_slist_foreach (objects, (GFunc)cb_dup_objects, cr);
g_slist_free (objects);
......
......@@ -183,52 +183,6 @@ colrow_free (ColRowInfo *cri)
g_slice_free1 (sizeof (*cri), cri);
}
/**
* col_row_collection_foreach:
* @infos: The Row or Column collection.
* @first: start position (inclusive)
* @last: stop column (inclusive)
* @callback: (scope call): A callback function which should return %TRUE to stop
* the iteration.
* @user_data: A baggage pointer.
*
* Iterates through the existing rows or columns within the range supplied.
* Currently only support left -> right iteration. If a callback returns
* %TRUE iteration stops.
**/
gboolean
col_row_collection_foreach (ColRowCollection const *infos, int first, int last,
ColRowHandler callback, gpointer user_data)
{
GnmColRowIter iter;
ColRowSegment const *segment;
int sub, inner_last, i;
/* TODO : Do we need to support right -> left as an option */
/* clip */
if (last > infos->max_used)
last = infos->max_used;
for (i = first; i <= last ; ) {
segment = COLROW_GET_SEGMENT (infos, i);
sub = COLROW_SUB_INDEX(i);
inner_last = (COLROW_SEGMENT_INDEX (last) == COLROW_SEGMENT_INDEX (i))
? COLROW_SUB_INDEX (last)+1 : COLROW_SEGMENT_SIZE;
iter.pos = i;
i += COLROW_SEGMENT_SIZE - sub;
if (segment == NULL)
continue;
for (; sub < inner_last; sub++, iter.pos++) {
iter.cri = segment->info[sub];
if (iter.cri != NULL && (*callback)(&iter, user_data))
return TRUE;
}
}
return FALSE;
}
/**
* colrow_state_list_foreach:
......@@ -637,19 +591,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);
col_row_collection_foreach (&sheet->cols, 0, gnm_sheet_get_last_col (sheet),
sheet_colrow_foreach (sheet, TRUE, 0, -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);
col_row_collection_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet),
sheet_colrow_foreach (sheet, FALSE, 0, -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, gnm_sheet_get_last_col (sheet), gnm_sheet_get_last_row (sheet),
sheet_foreach_cell_in_region (sheet, CELL_ITER_IGNORE_BLANK,
0, 0, -1, -1,
(CellIterFunc) &cb_clear_variable_width_content, NULL);
/* Result is a magic 'default' record + >= 1 normal */
......@@ -658,8 +612,8 @@ 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_last_row (sheet),
sheet_foreach_cell_in_region (sheet, CELL_ITER_IGNORE_BLANK,
index->first, 0, index->last, -1,
(CellIterFunc) &cb_clear_variable_width_content, NULL);
/* In order to properly reposition cell comments in
......@@ -818,8 +772,8 @@ colrow_restore_state_group (Sheet *sheet, gboolean is_cols,
colrow_set_states (sheet, is_cols, index->first, ptr->data);
/* 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_last_row (sheet),
sheet_foreach_cell_in_region (sheet, CELL_ITER_IGNORE_BLANK,
index->first, 0, index->last, -1,
(CellIterFunc) &cb_clear_variable_width_content, NULL);
selection = selection->prev;
}
......@@ -936,7 +890,6 @@ colrow_autofit (Sheet *sheet, const GnmRange *range, gboolean is_cols,
{
struct cb_autofit data;
int a, b;
ColRowCollection *crs;
ColRowHandler handler;
data.sheet = sheet;
......@@ -948,12 +901,10 @@ colrow_autofit (Sheet *sheet, const GnmRange *range, gboolean is_cols,
if (is_cols) {
a = range->start.col;
b = range->end.col;
crs = &sheet->cols;
handler = cb_autofit_col;
} else {
a = range->start.row;
b = range->end.row;
crs = &sheet->rows;
handler = cb_autofit_row;
}
......@@ -966,7 +917,7 @@ colrow_autofit (Sheet *sheet, const GnmRange *range, gboolean is_cols,
stuff that caches sub-computations see the whole thing instead
of clearing between cells. */
gnm_app_recalc_start ();
col_row_collection_foreach (crs, a, b, handler, &data);
sheet_colrow_foreach (sheet, is_cols, a, b, handler, &data);
gnm_app_recalc_finish ();
}
......@@ -980,11 +931,11 @@ colrow_autofit_col (Sheet *sheet, GnmRange *r)
{
colrow_autofit (sheet, r, TRUE, TRUE,
TRUE, FALSE, NULL, NULL);
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK,
r->start.col, 0,
r->end.col, gnm_sheet_get_last_row (sheet),
(CellIterFunc) &cb_clear_variable_width_content,
NULL);
sheet_foreach_cell_in_region (sheet, CELL_ITER_IGNORE_BLANK,
r->start.col, 0,
r->end.col, -1,
(CellIterFunc) &cb_clear_variable_width_content,
NULL);
}
/**
......@@ -1375,21 +1326,3 @@ colrow_get_global_outline (Sheet const *sheet, gboolean is_cols, int depth,
*show = g_slist_reverse (*show);
*hide = g_slist_reverse (*hide);
}
void
col_row_collection_resize (ColRowCollection *infos, int size)
{
int end_idx = COLROW_SEGMENT_INDEX (size);
int i = infos->info->len - 1;
while (i >= end_idx) {
ColRowSegment *segment = g_ptr_array_index (infos->info, i);
if (segment) {
g_free (segment);
g_ptr_array_index (infos->info, i) = NULL;
}
i--;
}
g_ptr_array_set_size (infos->info, end_idx);
}
......@@ -26,13 +26,6 @@ struct _ColRowInfo {
};
GType col_row_info_get_type (void);
struct _ColRowCollection {
int max_used;
ColRowInfo default_style;
GPtrArray * info;
int max_outline_level;
};
/* We never did get around to support 'thick' borders so these are effectively
* unitless (margins do not scale) constants . */
#define GNM_COL_MARGIN 2
......@@ -88,13 +81,6 @@ typedef struct {
} GnmColRowIter;
typedef gboolean (*ColRowHandler)(GnmColRowIter const *iter, gpointer user_data);
gboolean col_row_collection_foreach (ColRowCollection const *infos,
int first, int last,
ColRowHandler callback,
gpointer user_data);
void col_row_collection_resize (ColRowCollection *infos, int size);
#define colrow_index_list_destroy(l) g_list_free_full ((l), g_free)
GString *colrow_index_list_to_string (ColRowIndexList *list,
......
......@@ -863,9 +863,7 @@ cmd_set_text_full (WorkbookControl *wbc, GSList *selection, GnmEvalPos *ep,
GnmRange *r = l->data;
GnmValue *val =
sheet_foreach_cell_in_range
(sheet, CELL_ITER_ALL,
r->start.col, r->start.row,
r->end.col, r->end.row,
(sheet, CELL_ITER_ALL, r,
(CellIterFunc) cmd_set_text_full_check_texpr,
(gpointer) texpr);
......@@ -934,9 +932,7 @@ cmd_set_text_full (WorkbookControl *wbc, GSList *selection, GnmEvalPos *ep,
GnmRange *r = l->data;
GnmValue *val =
sheet_foreach_cell_in_range
(sheet, CELL_ITER_ALL,
r->start.col, r->start.row,
r->end.col, r->end.row,
(sheet, CELL_ITER_ALL, r,
(CellIterFunc) cmd_set_text_full_check_text,
(gpointer) corrected);
......@@ -957,9 +953,7 @@ cmd_set_text_full (WorkbookControl *wbc, GSList *selection, GnmEvalPos *ep,
GnmRange *r = l->data;
GnmValue *val =
sheet_foreach_cell_in_range
(sheet, CELL_ITER_IGNORE_BLANK,
r->start.col, r->start.row,
r->end.col, r->end.row,
(sheet, CELL_ITER_IGNORE_BLANK, r,
(CellIterFunc) cmd_set_text_full_check_markup,
(gpointer) markup);
......@@ -1582,8 +1576,11 @@ cmd_selection_clear (WorkbookControl *wbc, int clear_flags)
filter = gnm_sheet_filter_intersect_rows
(sheet, data.r->start.row, data.r->end.row);
if (filter) {
col_row_collection_foreach (&sheet->rows, data.r->start.row, data.r->end.row,
(ColRowHandler) cmd_selection_clear_row_handler, &data);
sheet_colrow_foreach (sheet, FALSE,
data.r->start.row,
data.r->end.row,
(ColRowHandler) cmd_selection_clear_row_handler,
&data);
g_free (ranges->data);
ranges->data = NULL;
}
......@@ -1990,11 +1987,10 @@ cmd_selection_format_toggle_font_style (WorkbookControl *wbc,
csftfs closure;
closure.undo = NULL;
closure.pt = pt;
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK,
sr->range.start.col, sr->range.start.row,
sr->range.end.col, sr->range.end.row,
(CellIterFunc) cmd_selection_format_toggle_font_style_cb,
&closure);
sheet_foreach_cell_in_range
(sheet, CELL_ITER_IGNORE_BLANK, &sr->range,
(CellIterFunc) cmd_selection_format_toggle_font_style_cb,
&closure);
redo = go_undo_combine (redo, closure.undo);
}
}
......@@ -7157,9 +7153,7 @@ cmd_hyperlink_redo (GnmCommand *cmd, WorkbookControl *wbc)
}
if (me->opt_content) {
sheet_foreach_cell_in_range (sheet, CELL_ITER_ALL,
r->start.col, r->start.row,
r->end.col, r->end.row,
sheet_foreach_cell_in_range (sheet, CELL_ITER_ALL, r,
cb_hyperlink_set_text,
me);
}
......
......@@ -2542,9 +2542,9 @@ fmt_dialog_selection_type (SheetView *sv,
if ((state->conflicts & MSTYLE_FORMAT) == 0 &&
go_format_is_general (gnm_style_get_format (state->style))) {
sheet_foreach_cell_in_range (state->sheet, CELL_ITER_IGNORE_BLANK,
r.start.col, r.start.row,
r.end.col, r.end.row,
sheet_foreach_cell_in_range (state->sheet,
CELL_ITER_IGNORE_BLANK,
&r,
cb_check_cell_format,
state);
}
......
......@@ -703,8 +703,7 @@ make_expr_example (Sheet *sheet, const char *text,
}
g_free (tmp_text);
if (fmt)
go_format_unref (fmt);
go_format_unref (fmt);
return res;
}
......
......@@ -724,9 +724,10 @@ gnm_go_data_vector_load_values (GODataVector *dat)
(CellIterFunc)cb_assign_val,
&closure);
else
sheet_foreach_cell_in_range (start_sheet, CELL_ITER_IGNORE_FILTERED,
r.start.col, r.start.row, r.end.col, r.end.row,
(CellIterFunc)cb_assign_val, &closure);
sheet_foreach_cell_in_range
(start_sheet, CELL_ITER_IGNORE_FILTERED,
&r,
(CellIterFunc)cb_assign_val, &closure);
dat->len = closure.last + 1; /* clip */
minimum = closure.minimum;
maximum = closure.maximum;
......@@ -774,9 +775,10 @@ gnm_go_data_vector_load_values (GODataVector *dat)
(CellIterFunc)cb_assign_val,
&closure);
else
sheet_foreach_cell_in_range (start_sheet, CELL_ITER_IGNORE_FILTERED,
r.start.col, r.start.row, r.end.col, r.end.row,
(CellIterFunc)cb_assign_val, &closure);
sheet_foreach_cell_in_range (start_sheet,
CELL_ITER_IGNORE_FILTERED,
&r,
(CellIterFunc)cb_assign_val, &closure);
last = dat->len = closure.last + 1; /* clip */
if (minimum > closure.minimum)
minimum = closure.minimum;
......@@ -937,9 +939,10 @@ gnm_go_data_vector_get_str (GODataVector *dat, unsigned i)
r.end.col = start_sheet->cols.max_used;
if (r.start.col <= r.end.col && r.start.row <= r.end.row)
sheet_foreach_cell_in_range (start_sheet, CELL_ITER_IGNORE_FILTERED,
r.start.col, r.start.row, r.end.col, r.end.row,
(CellIterFunc)cb_assign_string, &closure);
sheet_foreach_cell_in_range (start_sheet,
CELL_ITER_IGNORE_FILTERED,
&r,
(CellIterFunc)cb_assign_string, &closure);
}
}
}
......@@ -966,9 +969,10 @@ gnm_go_data_vector_get_str (GODataVector *dat, unsigned i)
r.end.col = start_sheet->cols.max_used;
if (r.start.col <= r.end.col && r.start.row <= r.end.row)
sheet_foreach_cell_in_range (start_sheet, CELL_ITER_IGNORE_FILTERED,
r.start.col, r.start.row, r.end.col, r.end.row,
(CellIterFunc)cb_assign_string, &closure);
sheet_foreach_cell_in_range (start_sheet,
CELL_ITER_IGNORE_FILTERED,
&r,
(CellIterFunc)cb_assign_string, &closure);
}
if (vec->strs && vec->strs->len > i)
ret = g_ptr_array_index (vec->strs, i);
......@@ -1038,9 +1042,10 @@ gnm_go_data_vector_get_markup (GODataVector *dat, unsigned i)
/* In case the sheet is empty */
if (r.start.col <= r.end.col && r.start.row <= r.end.row) {
sheet_foreach_cell_in_range (start_sheet, CELL_ITER_ALL,
r.start.col, r.start.row, r.end.col, r.end.row,
(CellIterFunc)cb_assign_markup, vec->markup);
sheet_foreach_cell_in_range (start_sheet,
CELL_ITER_ALL,
&r,
(CellIterFunc)cb_assign_markup, vec->markup);
}
break;
......@@ -1064,9 +1069,10 @@ gnm_go_data_vector_get_markup (GODataVector *dat, unsigned i)
r.end.col = start_sheet->cols.max_used;
if (r.start.col <= r.end.col && r.start.row <= r.end.row)
sheet_foreach_cell_in_range (start_sheet, CELL_ITER_ALL,
r.start.col, r.start.row, r.end.col, r.end.row,
(CellIterFunc)cb_assign_markup, vec->markup);
sheet_foreach_cell_in_range (start_sheet,
CELL_ITER_ALL,
&r,
(CellIterFunc)cb_assign_markup, vec->markup);
}
}
break;
......@@ -1333,7 +1339,7 @@ gnm_go_data_matrix_load_values (GODataMatrix *dat)
closure.first_col = closure.last_col = -1;
closure.row = closure.col = 0;
closure.columns = dat->size.columns;
sheet_foreach_cell_in_range (start_sheet, CELL_ITER_ALL,
sheet_foreach_cell_in_region (start_sheet, CELL_ITER_ALL,
r.start.col, r.start.row,
r.start.col + dat->size.columns - 1,
r.start.row + dat->size.rows - 1,
......
......@@ -483,7 +483,7 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
if (cond->op[1] != GNM_FILTER_UNUSED)
filter_expr_init (&data, 1, cond, filter);
sheet_foreach_cell_in_range (filter->sheet,
sheet_foreach_cell_in_region (filter->sheet,
iter_flags,
col, start_row, col, end_row,
(CellIterFunc) cb_filter_expr, &data);
......@@ -492,12 +492,12 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
if (cond->op[1] != GNM_FILTER_UNUSED)
filter_expr_release (&data, 1);
} else if (cond->op[0] == GNM_FILTER_OP_BLANKS)
sheet_foreach_cell_in_range (filter->sheet,
sheet_foreach_cell_in_region (filter->sheet,
CELL_ITER_IGNORE_HIDDEN,
col, start_row, col, end_row,
(CellIterFunc) cb_filter_blanks, target_sheet);
else if (cond->op[0] == GNM_FILTER_OP_NON_BLANKS)
sheet_foreach_cell_in_range (filter->sheet,
sheet_foreach_cell_in_region (filter->sheet,
CELL_ITER_IGNORE_HIDDEN,
col, start_row, col, end_row,
(CellIterFunc) cb_filter_non_blanks, target_sheet);
......@@ -511,12 +511,12 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
if (data.count < 1)
data.count = 1;
data.vals = g_new (GnmValue const *, data.count);
sheet_foreach_cell_in_range (filter->sheet,
sheet_foreach_cell_in_region (filter->sheet,
CELL_ITER_IGNORE_HIDDEN | CELL_ITER_IGNORE_BLANK,
col, start_row, col, end_row,
(CellIterFunc) cb_filter_find_items, &data);
data.target_sheet = target_sheet;
sheet_foreach_cell_in_range (filter->sheet,
sheet_foreach_cell_in_region (filter->sheet,
CELL_ITER_IGNORE_HIDDEN,
col, start_row, col, end_row,
(CellIterFunc) cb_hide_unwanted_items, &data);
......@@ -527,7 +527,7 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
data.find_max = (cond->op[0] & 0x1) ? FALSE : TRUE;
data.initialized = FALSE;
sheet_foreach_cell_in_range (filter->sheet,
sheet_foreach_cell_in_region (filter->sheet,
CELL_ITER_IGNORE_HIDDEN | CELL_ITER_IGNORE_BLANK,
col, start_row, col, end_row,
(CellIterFunc) cb_filter_find_percentage, &data);
......@@ -535,7 +535,7 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
data.high -= offset;
data.low += offset;
data.target_sheet = target_sheet;
sheet_foreach_cell_in_range (filter->sheet,
sheet_foreach_cell_in_region (filter->sheet,
CELL_ITER_IGNORE_HIDDEN,
col, start_row, col, end_row,
(CellIterFunc) cb_hide_unwanted_percentage, &data);
......@@ -547,12 +547,12 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
data.count = cond->count;
data.vals = g_new (GnmValue const *, data.count);
sheet_foreach_cell_in_range (filter->sheet,
sheet_foreach_cell_in_region (filter->sheet,
CELL_ITER_IGNORE_HIDDEN | CELL_ITER_IGNORE_BLANK,
col, start_row, col, end_row,
(CellIterFunc) cb_filter_find_items, &data);
data.target_sheet = target_sheet;
sheet_foreach_cell_in_range (filter->sheet,
sheet_foreach_cell_in_region (filter->sheet,
CELL_ITER_IGNORE_HIDDEN,
col, start_row, col, end_row,
(CellIterFunc) cb_hide_unwanted_items, &data);
......
......@@ -155,6 +155,24 @@ static void gnm_sheet_finalize (GObject *obj);
static GObjectClass *parent_class;
static void
col_row_collection_resize (ColRowCollection *infos, int size)
{
int end_idx = COLROW_SEGMENT_INDEX (size);
int i = infos->info->len - 1;
while (i >= end_idx) {
ColRowSegment *segment = g_ptr_array_index (infos->info, i);
if (segment) {
g_free (segment);
g_ptr_array_index (infos->info, i) = NULL;
}
i--;
}
g_ptr_array_set_size (infos->info, end_idx);
}
static void
sheet_set_direction (Sheet *sheet, gboolean text_is_rtl)
{
......@@ -332,8 +350,9 @@ struct resize_colrow {
static gboolean
cb_colrow_compute_pixels_from_pts (GnmColRowIter const *iter,
struct resize_colrow *data)
gpointer data_)
{
struct resize_colrow *data = data_;
colrow_compute_pixels_from_pts ((ColRowInfo *)iter->cri,
data->sheet, data->is_cols,
data->scale);
......@@ -364,9 +383,9 @@ sheet_scale_changed (Sheet *sheet, gboolean cols_rescaled, gboolean rows_rescale
colrow_compute_pixels_from_pts (&sheet->cols.default_style,
sheet, TRUE, closure.scale);
col_row_collection_foreach (&sheet->cols,
0, gnm_sheet_get_last_col (sheet),
(ColRowHandler)&cb_colrow_compute_pixels_from_pts, &closure);
sheet_colrow_foreach (sheet, TRUE, 0, -1,
cb_colrow_compute_pixels_from_pts,
&closure);
}
if (rows_rescaled) {
struct resize_colrow closure;
......@@ -377,8 +396,9 @@ sheet_scale_changed (Sheet *sheet, gboolean cols_rescaled, gboolean rows_rescale
colrow_compute_pixels_from_pts (&sheet->rows.default_style,
sheet, FALSE, closure.scale);
col_row_collection_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet),
(ColRowHandler)&cb_colrow_compute_pixels_from_pts, &closure);
sheet_colrow_foreach (sheet, FALSE, 0, -1,
cb_colrow_compute_pixels_from_pts,
&closure);
}
sheet_cell_foreach (sheet, (GHFunc)&cb_clear_rendered_cells, NULL);
......@@ -1563,9 +1583,9 @@ void
sheet_range_calc_spans (Sheet *sheet, GnmRange const *r, GnmSpanCalcFlags flags)
{
if (flags & GNM_SPANCALC_RE_RENDER)
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_NONEXISTENT,
r->start.col, r->start.row, r->end.col, r->end.row,
cb_clear_rendered_values, NULL);
sheet_foreach_cell_in_range
(sheet, CELL_ITER_IGNORE_NONEXISTENT, r,
cb_clear_rendered_values, NULL);
sheet_queue_respan (sheet, r->start.row, r->end.row);
/* Redraw the new region in case the span changes */
......@@ -1915,8 +1935,9 @@ sheet_flag_recompute_spans (Sheet const *sheet)
}
static gboolean
cb_outline_level (GnmColRowIter const *iter, int *outline_level)
cb_outline_level (GnmColRowIter const *iter, gpointer data)
{
int *outline_level = data;
if (*outline_level < iter->cri->outline_level)
*outline_level = iter->cri->outline_level;
return FALSE;
......@@ -1933,9 +1954,8 @@ static int
sheet_colrow_fit_gutter (Sheet const *sheet, gboolean is_cols)
{
int outline_level = 0;
col_row_collection_foreach (is_cols ? &sheet->cols : &sheet->rows,
0, colrow_max (is_cols, sheet) - 1,
(ColRowHandler)cb_outline_level, &outline_level);
sheet_colrow_foreach (sheet, is_cols, 0, -1,
cb_outline_level, &outline_level);
return outline_level;
}
......@@ -2499,7 +2519,7 @@ sheet_col_size_fit_pixels (Sheet *sheet, int col, int srow, int erow,
data.max = -1;
data.ignore_strings = ignore_strings;
sheet_foreach_cell_in_range (sheet,
sheet_foreach_cell_in_region (sheet,
CELL_ITER_IGNORE_NONEXISTENT |
CELL_ITER_IGNORE_HIDDEN |
CELL_ITER_IGNORE_FILTERED,
......@@ -2585,7 +2605,7 @@ sheet_row_size_fit_pixels (Sheet *sheet, int row, int scol, int ecol,
data.max = -1;
data.ignore_strings = ignore_strings;
sheet_foreach_cell_in_range (sheet,
sheet_foreach_cell_in_region (sheet,
CELL_ITER_IGNORE_NONEXISTENT |
CELL_ITER_IGNORE_HIDDEN |
CELL_ITER_IGNORE_FILTERED,
......@@ -2650,8 +2670,8 @@ sheet_recompute_spans_for_col (Sheet *sheet, int col)
closure.sheet = sheet;
closure.col = col;
col_row_collection_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet),
&cb_recalc_spans_in_col, &closure);
sheet_colrow_foreach (sheet, FALSE, 0, -1,
&cb_recalc_spans_in_col, &closure);
}
/****************************************************************************/
......@@ -2736,18 +2756,14 @@ sheet_range_set_expr_cb (GnmSheetRange const *sr, GnmExprTop const *texpr)
sheet_region_queue_recalc (sr->sheet, &sr->range);
/* Store the parsed result creating any cells necessary */
sheet_foreach_cell_in_range
(sr->sheet, CELL_ITER_ALL,
sr->range.start.col, sr->range.start.row,
sr->range.end.col, sr->range.end.row,
(sr->sheet, CELL_ITER_ALL, &sr->range,
(CellIterFunc)&cb_set_cell_content, &closure);
merged = gnm_sheet_merge_get_overlap (sr->sheet, &sr->range);
for (ptr = merged ; ptr != NULL ; ptr = ptr->next) {
GnmRange const *tmp = ptr->data;
sheet_foreach_cell_in_range
(sr->sheet, CELL_ITER_IGNORE_BLANK,
tmp->start.col, tmp->start.row,
tmp->end.col, tmp->end.row,
(sr->sheet, CELL_ITER_IGNORE_BLANK, tmp,
(CellIterFunc)&cb_clear_non_corner,
(gpointer)tmp);
}
......@@ -2810,16 +2826,13 @@ sheet_range_set_text (GnmParsePos const *pos, GnmRange const *r, char const *str
&closure.expr_bound);
/* Store the parsed result creating any cells necessary */
sheet_foreach_cell_in_range (sheet, CELL_ITER_ALL,
r->start.col, r->start.row, r->end.col, r->end.row,
sheet_foreach_cell_in_range (sheet, CELL_ITER_ALL, r,
(CellIterFunc)&cb_set_cell_content, &closure);
merged = gnm_sheet_merge_get_overlap (sheet, r);
for (ptr = merged ; ptr != NULL ; ptr = ptr->next) {
GnmRange const *tmp = ptr->data;
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK,
tmp->start.col, tmp->start.row,
tmp->end.col, tmp->end.row,
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK, tmp,
(CellIterFunc)&cb_clear_non_corner, (gpointer)tmp);
}
g_slist_free (merged);
......@@ -2896,9 +2909,7 @@ static void
sheet_range_set_markup_cb (GnmSheetRange const *sr, PangoAttrList *markup)
{
sheet_foreach_cell_in_range
(sr->sheet, CELL_ITER_ALL,
sr->range.start.col, sr->range.start.row,
sr->range.end.col, sr->range.end.row,
(sr->sheet, CELL_ITER_ALL, &sr->range,
(CellIterFunc)&cb_set_markup, markup);
sheet_region_queue_recalc (sr->sheet, &sr->range);
......@@ -3455,8 +3466,9 @@ typedef struct {
} ArrayCheckData;
static gboolean
cb_check_array_horizontal (GnmColRowIter const *iter, ArrayCheckData *data)
cb_check_array_horizontal (GnmColRowIter const *iter, gpointer data_)
{
ArrayCheckData *data = data_;
gboolean is_array = FALSE;
if (data->flags & CHECK_AND_LOAD_START && /* Top */
......@@ -3481,8 +3493,9 @@ cb_check_array_horizontal (GnmColRowIter const *iter, ArrayCheckData *data)
}
static gboolean
cb_check_array_vertical (GnmColRowIter const *iter, ArrayCheckData *data)
cb_check_array_vertical (GnmColRowIter const *iter, gpointer data_)
{
ArrayCheckData *data = data_;
gboolean is_array = FALSE;
if (data->flags & CHECK_AND_LOAD_START && /* Left */
......@@ -3547,8 +3560,9 @@ sheet_range_splits_array (Sheet const *sheet,
closure.flags = CHECK_AND_LOAD_START;
if (closure.flags &&
col_row_collection_foreach (&sheet->cols, r->start.col, r->end.col,
(ColRowHandler) cb_check_array_horizontal, &closure)) {
sheet_colrow_foreach (sheet, TRUE,