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> 2018-04-25 Morten Welinder <terra@gnome.org>
* src/xml-sax-read.c (xml_sax_cell_content): Read shared array * 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 ...@@ -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); gboolean *fonts = g_new0 (gboolean, G_UNICODE_SCRIPT_MANDAIC + 1);
sheet_foreach_cell_in_range sheet_foreach_cell_in_range
(sheet, CELL_ITER_IGNORE_BLANK | CELL_ITER_IGNORE_HIDDEN, (sheet, CELL_ITER_IGNORE_BLANK | CELL_ITER_IGNORE_HIDDEN, range,
range->start.col, range->start.row,
range->end.col, range->end.row,
(CellIterFunc)&cb_find_font_encodings, fonts); (CellIterFunc)&cb_find_font_encodings, fonts);
if (fonts[G_UNICODE_SCRIPT_CYRILLIC]) if (fonts[G_UNICODE_SCRIPT_CYRILLIC])
......
...@@ -312,9 +312,7 @@ sylk_write_sheet (SylkWriter *state) ...@@ -312,9 +312,7 @@ sylk_write_sheet (SylkWriter *state)
// Cell styles // Cell styles
state->cur_row = -1; state->cur_row = -1;
sheet_foreach_cell_in_range (sheet, 0, sheet_foreach_cell_in_range (sheet, 0, &extent,
extent.start.col, extent.start.row,
extent.end.col, extent.end.row,
(CellIterFunc) cb_sylk_write_cell_style, state); (CellIterFunc) cb_sylk_write_cell_style, state);
// Column widths // Column widths
...@@ -363,10 +361,8 @@ sylk_write_sheet (SylkWriter *state) ...@@ -363,10 +361,8 @@ sylk_write_sheet (SylkWriter *state)
/* dump content */ /* dump content */
state->cur_row = -1; state->cur_row = -1;
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK, sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK, &extent,
extent.start.col, extent.start.row, (CellIterFunc) cb_sylk_write_cell, state);
extent.end.col, extent.end.row,
(CellIterFunc) cb_sylk_write_cell, state);
g_free (col_defs); g_free (col_defs);
} }
......
...@@ -1079,7 +1079,7 @@ gnm_cell_convert_expr_to_value (GnmCell *cell) ...@@ -1079,7 +1079,7 @@ gnm_cell_convert_expr_to_value (GnmCell *cell)
gnm_expr_top_get_array_size (texpr, &cols, &rows); 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, cell->pos.row,
cell->pos.col + cols - 1, cell->pos.col + cols - 1,
cell->pos.row + rows - 1, cell->pos.row + rows - 1,
......
...@@ -738,10 +738,9 @@ clipboard_copy_range (Sheet *sheet, GnmRange const *r) ...@@ -738,10 +738,9 @@ clipboard_copy_range (Sheet *sheet, GnmRange const *r)
cr->row_state = colrow_get_states (sheet, cr->row_state = colrow_get_states (sheet,
FALSE, r->start.row, r->end.row); FALSE, r->start.row, r->end.row);
sheet_foreach_cell_in_range ( sheet, CELL_ITER_IGNORE_NONEXISTENT, sheet_foreach_cell_in_range ( sheet, CELL_ITER_IGNORE_NONEXISTENT, r,
r->start.col, r->start.row, (CellIterFunc) cb_clipboard_prepend_cell,
r->end.col, r->end.row, cr);
(CellIterFunc) cb_clipboard_prepend_cell, cr);
objects = sheet_objects_get (sheet, r, G_TYPE_NONE); objects = sheet_objects_get (sheet, r, G_TYPE_NONE);
g_slist_foreach (objects, (GFunc)cb_dup_objects, cr); g_slist_foreach (objects, (GFunc)cb_dup_objects, cr);
g_slist_free (objects); g_slist_free (objects);
......
...@@ -183,52 +183,6 @@ colrow_free (ColRowInfo *cri) ...@@ -183,52 +183,6 @@ colrow_free (ColRowInfo *cri)
g_slice_free1 (sizeof (*cri), 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: * colrow_state_list_foreach:
...@@ -637,19 +591,19 @@ colrow_set_sizes (Sheet *sheet, gboolean is_cols, ...@@ -637,19 +591,19 @@ colrow_set_sizes (Sheet *sheet, gboolean is_cols,
if (is_cols) { if (is_cols) {
rles->state.size_pts = sheet_col_get_default_size_pts (sheet); rles->state.size_pts = sheet_col_get_default_size_pts (sheet);
sheet_col_set_default_size_pixels (sheet, new_size); 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); &cb_set_colrow_size, &closure);
} else { } else {
rles->state.size_pts = sheet_row_get_default_size_pts (sheet); rles->state.size_pts = sheet_row_get_default_size_pts (sheet);
sheet_row_set_default_size_pixels (sheet, new_size); 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); &cb_set_colrow_size, &closure);
} }
/* force a re-render of cells with expanding formats */ /* force a re-render of cells with expanding formats */
if (is_cols) if (is_cols)
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK, sheet_foreach_cell_in_region (sheet, CELL_ITER_IGNORE_BLANK,
0, 0, gnm_sheet_get_last_col (sheet), gnm_sheet_get_last_row (sheet), 0, 0, -1, -1,
(CellIterFunc) &cb_clear_variable_width_content, NULL); (CellIterFunc) &cb_clear_variable_width_content, NULL);
/* Result is a magic 'default' record + >= 1 normal */ /* Result is a magic 'default' record + >= 1 normal */
...@@ -658,8 +612,8 @@ colrow_set_sizes (Sheet *sheet, gboolean is_cols, ...@@ -658,8 +612,8 @@ colrow_set_sizes (Sheet *sheet, gboolean is_cols,
if (is_cols) { if (is_cols) {
/* force a re-render of cells with expanding formats */ /* force a re-render of cells with expanding formats */
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK, sheet_foreach_cell_in_region (sheet, CELL_ITER_IGNORE_BLANK,
index->first, 0, index->last, gnm_sheet_get_last_row (sheet), index->first, 0, index->last, -1,
(CellIterFunc) &cb_clear_variable_width_content, NULL); (CellIterFunc) &cb_clear_variable_width_content, NULL);
/* In order to properly reposition cell comments in /* In order to properly reposition cell comments in
...@@ -818,8 +772,8 @@ colrow_restore_state_group (Sheet *sheet, gboolean is_cols, ...@@ -818,8 +772,8 @@ colrow_restore_state_group (Sheet *sheet, gboolean is_cols,
colrow_set_states (sheet, is_cols, index->first, ptr->data); colrow_set_states (sheet, is_cols, index->first, ptr->data);
/* force a re-render of cells with expanding formats */ /* force a re-render of cells with expanding formats */
if (is_cols) if (is_cols)
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK, sheet_foreach_cell_in_region (sheet, CELL_ITER_IGNORE_BLANK,
index->first, 0, index->last, gnm_sheet_get_last_row (sheet), index->first, 0, index->last, -1,
(CellIterFunc) &cb_clear_variable_width_content, NULL); (CellIterFunc) &cb_clear_variable_width_content, NULL);
selection = selection->prev; selection = selection->prev;
} }
...@@ -936,7 +890,6 @@ colrow_autofit (Sheet *sheet, const GnmRange *range, gboolean is_cols, ...@@ -936,7 +890,6 @@ colrow_autofit (Sheet *sheet, const GnmRange *range, gboolean is_cols,
{ {
struct cb_autofit data; struct cb_autofit data;
int a, b; int a, b;
ColRowCollection *crs;
ColRowHandler handler; ColRowHandler handler;
data.sheet = sheet; data.sheet = sheet;
...@@ -948,12 +901,10 @@ colrow_autofit (Sheet *sheet, const GnmRange *range, gboolean is_cols, ...@@ -948,12 +901,10 @@ colrow_autofit (Sheet *sheet, const GnmRange *range, gboolean is_cols,
if (is_cols) { if (is_cols) {
a = range->start.col; a = range->start.col;
b = range->end.col; b = range->end.col;
crs = &sheet->cols;
handler = cb_autofit_col; handler = cb_autofit_col;
} else { } else {
a = range->start.row; a = range->start.row;
b = range->end.row; b = range->end.row;
crs = &sheet->rows;
handler = cb_autofit_row; handler = cb_autofit_row;
} }
...@@ -966,7 +917,7 @@ colrow_autofit (Sheet *sheet, const GnmRange *range, gboolean is_cols, ...@@ -966,7 +917,7 @@ colrow_autofit (Sheet *sheet, const GnmRange *range, gboolean is_cols,
stuff that caches sub-computations see the whole thing instead stuff that caches sub-computations see the whole thing instead
of clearing between cells. */ of clearing between cells. */
gnm_app_recalc_start (); 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 (); gnm_app_recalc_finish ();
} }
...@@ -980,11 +931,11 @@ colrow_autofit_col (Sheet *sheet, GnmRange *r) ...@@ -980,11 +931,11 @@ colrow_autofit_col (Sheet *sheet, GnmRange *r)
{ {
colrow_autofit (sheet, r, TRUE, TRUE, colrow_autofit (sheet, r, TRUE, TRUE,
TRUE, FALSE, NULL, NULL); TRUE, FALSE, NULL, NULL);
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK, sheet_foreach_cell_in_region (sheet, CELL_ITER_IGNORE_BLANK,
r->start.col, 0, r->start.col, 0,
r->end.col, gnm_sheet_get_last_row (sheet), r->end.col, -1,
(CellIterFunc) &cb_clear_variable_width_content, (CellIterFunc) &cb_clear_variable_width_content,
NULL); NULL);
} }
/** /**
...@@ -1375,21 +1326,3 @@ colrow_get_global_outline (Sheet const *sheet, gboolean is_cols, int depth, ...@@ -1375,21 +1326,3 @@ colrow_get_global_outline (Sheet const *sheet, gboolean is_cols, int depth,
*show = g_slist_reverse (*show); *show = g_slist_reverse (*show);
*hide = g_slist_reverse (*hide); *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 { ...@@ -26,13 +26,6 @@ struct _ColRowInfo {
}; };
GType col_row_info_get_type (void); 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 /* We never did get around to support 'thick' borders so these are effectively
* unitless (margins do not scale) constants . */ * unitless (margins do not scale) constants . */
#define GNM_COL_MARGIN 2 #define GNM_COL_MARGIN 2
...@@ -88,13 +81,6 @@ typedef struct { ...@@ -88,13 +81,6 @@ typedef struct {
} GnmColRowIter; } GnmColRowIter;
typedef gboolean (*ColRowHandler)(GnmColRowIter const *iter, gpointer user_data); 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) #define colrow_index_list_destroy(l) g_list_free_full ((l), g_free)
GString *colrow_index_list_to_string (ColRowIndexList *list, GString *colrow_index_list_to_string (ColRowIndexList *list,
......
...@@ -863,9 +863,7 @@ cmd_set_text_full (WorkbookControl *wbc, GSList *selection, GnmEvalPos *ep, ...@@ -863,9 +863,7 @@ cmd_set_text_full (WorkbookControl *wbc, GSList *selection, GnmEvalPos *ep,
GnmRange *r = l->data; GnmRange *r = l->data;
GnmValue *val = GnmValue *val =
sheet_foreach_cell_in_range sheet_foreach_cell_in_range
(sheet, CELL_ITER_ALL, (sheet, CELL_ITER_ALL, r,
r->start.col, r->start.row,
r->end.col, r->end.row,
(CellIterFunc) cmd_set_text_full_check_texpr, (CellIterFunc) cmd_set_text_full_check_texpr,
(gpointer) texpr); (gpointer) texpr);
...@@ -934,9 +932,7 @@ cmd_set_text_full (WorkbookControl *wbc, GSList *selection, GnmEvalPos *ep, ...@@ -934,9 +932,7 @@ cmd_set_text_full (WorkbookControl *wbc, GSList *selection, GnmEvalPos *ep,
GnmRange *r = l->data; GnmRange *r = l->data;
GnmValue *val = GnmValue *val =
sheet_foreach_cell_in_range sheet_foreach_cell_in_range
(sheet, CELL_ITER_ALL, (sheet, CELL_ITER_ALL, r,
r->start.col, r->start.row,
r->end.col, r->end.row,
(CellIterFunc) cmd_set_text_full_check_text, (CellIterFunc) cmd_set_text_full_check_text,
(gpointer) corrected); (gpointer) corrected);
...@@ -957,9 +953,7 @@ cmd_set_text_full (WorkbookControl *wbc, GSList *selection, GnmEvalPos *ep, ...@@ -957,9 +953,7 @@ cmd_set_text_full (WorkbookControl *wbc, GSList *selection, GnmEvalPos *ep,
GnmRange *r = l->data; GnmRange *r = l->data;
GnmValue *val = GnmValue *val =
sheet_foreach_cell_in_range sheet_foreach_cell_in_range
(sheet, CELL_ITER_IGNORE_BLANK, (sheet, CELL_ITER_IGNORE_BLANK, r,
r->start.col, r->start.row,
r->end.col, r->end.row,
(CellIterFunc) cmd_set_text_full_check_markup, (CellIterFunc) cmd_set_text_full_check_markup,
(gpointer) markup); (gpointer) markup);
...@@ -1582,8 +1576,11 @@ cmd_selection_clear (WorkbookControl *wbc, int clear_flags) ...@@ -1582,8 +1576,11 @@ cmd_selection_clear (WorkbookControl *wbc, int clear_flags)
filter = gnm_sheet_filter_intersect_rows filter = gnm_sheet_filter_intersect_rows
(sheet, data.r->start.row, data.r->end.row); (sheet, data.r->start.row, data.r->end.row);
if (filter) { if (filter) {
col_row_collection_foreach (&sheet->rows, data.r->start.row, data.r->end.row, sheet_colrow_foreach (sheet, FALSE,
(ColRowHandler) cmd_selection_clear_row_handler, &data); data.r->start.row,
data.r->end.row,
(ColRowHandler) cmd_selection_clear_row_handler,
&data);
g_free (ranges->data); g_free (ranges->data);
ranges->data = NULL; ranges->data = NULL;
} }
...@@ -1990,11 +1987,10 @@ cmd_selection_format_toggle_font_style (WorkbookControl *wbc, ...@@ -1990,11 +1987,10 @@ cmd_selection_format_toggle_font_style (WorkbookControl *wbc,
csftfs closure; csftfs closure;
closure.undo = NULL; closure.undo = NULL;
closure.pt = pt; closure.pt = pt;
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK, sheet_foreach_cell_in_range
sr->range.start.col, sr->range.start.row, (sheet, CELL_ITER_IGNORE_BLANK, &sr->range,
sr->range.end.col, sr->range.end.row, (CellIterFunc) cmd_selection_format_toggle_font_style_cb,
(CellIterFunc) cmd_selection_format_toggle_font_style_cb, &closure);
&closure);
redo = go_undo_combine (redo, closure.undo); redo = go_undo_combine (redo, closure.undo);
} }
} }
...@@ -7157,9 +7153,7 @@ cmd_hyperlink_redo (GnmCommand *cmd, WorkbookControl *wbc) ...@@ -7157,9 +7153,7 @@ cmd_hyperlink_redo (GnmCommand *cmd, WorkbookControl *wbc)
} }
if (me->opt_content) { if (me->opt_content) {
sheet_foreach_cell_in_range (sheet, CELL_ITER_ALL, sheet_foreach_cell_in_range (sheet, CELL_ITER_ALL, r,
r->start.col, r->start.row,
r->end.col, r->end.row,
cb_hyperlink_set_text, cb_hyperlink_set_text,
me); me);
} }
......
...@@ -2542,9 +2542,9 @@ fmt_dialog_selection_type (SheetView *sv, ...@@ -2542,9 +2542,9 @@ fmt_dialog_selection_type (SheetView *sv,
if ((state->conflicts & MSTYLE_FORMAT) == 0 && if ((state->conflicts & MSTYLE_FORMAT) == 0 &&
go_format_is_general (gnm_style_get_format (state->style))) { go_format_is_general (gnm_style_get_format (state->style))) {
sheet_foreach_cell_in_range (state->sheet, CELL_ITER_IGNORE_BLANK, sheet_foreach_cell_in_range (state->sheet,
r.start.col, r.start.row, CELL_ITER_IGNORE_BLANK,
r.end.col, r.end.row, &r,
cb_check_cell_format, cb_check_cell_format,
state); state);
} }
......
...@@ -703,8 +703,7 @@ make_expr_example (Sheet *sheet, const char *text, ...@@ -703,8 +703,7 @@ make_expr_example (Sheet *sheet, const char *text,
} }
g_free (tmp_text); g_free (tmp_text);
if (fmt) go_format_unref (fmt);
go_format_unref (fmt);
return res; return res;
} }
......
...@@ -724,9 +724,10 @@ gnm_go_data_vector_load_values (GODataVector *dat) ...@@ -724,9 +724,10 @@ gnm_go_data_vector_load_values (GODataVector *dat)
(CellIterFunc)cb_assign_val, (CellIterFunc)cb_assign_val,
&closure); &closure);
else else
sheet_foreach_cell_in_range (start_sheet, CELL_ITER_IGNORE_FILTERED, sheet_foreach_cell_in_range
r.start.col, r.start.row, r.end.col, r.end.row, (start_sheet, CELL_ITER_IGNORE_FILTERED,
(CellIterFunc)cb_assign_val, &closure); &r,
(CellIterFunc)cb_assign_val, &closure);
dat->len = closure.last + 1; /* clip */ dat->len = closure.last + 1; /* clip */
minimum = closure.minimum; minimum = closure.minimum;
maximum = closure.maximum; maximum = closure.maximum;
...@@ -774,9 +775,10 @@ gnm_go_data_vector_load_values (GODataVector *dat) ...@@ -774,9 +775,10 @@ gnm_go_data_vector_load_values (GODataVector *dat)
(CellIterFunc)cb_assign_val, (CellIterFunc)cb_assign_val,
&closure); &closure);
else else
sheet_foreach_cell_in_range (start_sheet, CELL_ITER_IGNORE_FILTERED, sheet_foreach_cell_in_range (start_sheet,
r.start.col, r.start.row, r.end.col, r.end.row, CELL_ITER_IGNORE_FILTERED,
(CellIterFunc)cb_assign_val, &closure); &r,
(CellIterFunc)cb_assign_val, &closure);
last = dat->len = closure.last + 1; /* clip */ last = dat->len = closure.last + 1; /* clip */
if (minimum > closure.minimum) if (minimum > closure.minimum)
minimum = closure.minimum; minimum = closure.minimum;
...@@ -937,9 +939,10 @@ gnm_go_data_vector_get_str (GODataVector *dat, unsigned i) ...@@ -937,9 +939,10 @@ gnm_go_data_vector_get_str (GODataVector *dat, unsigned i)
r.end.col = start_sheet->cols.max_used; r.end.col = start_sheet->cols.max_used;
if (r.start.col <= r.end.col && r.start.row <= r.end.row) if (r.start.col <= r.end.col && r.start.row <= r.end.row)
sheet_foreach_cell_in_range (start_sheet, CELL_ITER_IGNORE_FILTERED, sheet_foreach_cell_in_range (start_sheet,
r.start.col, r.start.row, r.end.col, r.end.row, CELL_ITER_IGNORE_FILTERED,
(CellIterFunc)cb_assign_string, &closure); &r,
(CellIterFunc)cb_assign_string, &closure);
} }
} }
} }
...@@ -966,9 +969,10 @@ gnm_go_data_vector_get_str (GODataVector *dat, unsigned i) ...@@ -966,9 +969,10 @@ gnm_go_data_vector_get_str (GODataVector *dat, unsigned i)
r.end.col = start_sheet->cols.max_used; r.end.col = start_sheet->cols.max_used;
if (r.start.col <= r.end.col && r.start.row <= r.end.row) if (r.start.col <= r.end.col && r.start.row <= r.end.row)
sheet_foreach_cell_in_range (start_sheet, CELL_ITER_IGNORE_FILTERED, sheet_foreach_cell_in_range (start_sheet,
r.start.col, r.start.row, r.end.col, r.end.row, CELL_ITER_IGNORE_FILTERED,
(CellIterFunc)cb_assign_string, &closure); &r,
(CellIterFunc)cb_assign_string, &closure);
} }
if (vec->strs && vec->strs->len > i) if (vec->strs && vec->strs->len > i)
ret = g_ptr_array_index (vec->strs, i); ret = g_ptr_array_index (vec->strs, i);
...@@ -1038,9 +1042,10 @@ gnm_go_data_vector_get_markup (GODataVector *dat, unsigned i) ...@@ -1038,9 +1042,10 @@ gnm_go_data_vector_get_markup (GODataVector *dat, unsigned i)
/* In case the sheet is empty */ /* In case the sheet is empty */
if (r.start.col <= r.end.col && r.start.row <= r.end.row) { if (r.start.col <= r.end.col && r.start.row <= r.end.row) {
sheet_foreach_cell_in_range (start_sheet, CELL_ITER_ALL, sheet_foreach_cell_in_range (start_sheet,
r.start.col, r.start.row, r.end.col, r.end.row, CELL_ITER_ALL,
(CellIterFunc)cb_assign_markup, vec->markup); &r,
(CellIterFunc)cb_assign_markup, vec->markup);
} }
break; break;
...@@ -1064,9 +1069,10 @@ gnm_go_data_vector_get_markup (GODataVector *dat, unsigned i) ...@@ -1064,9 +1069,10 @@ gnm_go_data_vector_get_markup (GODataVector *dat, unsigned i)
r.end.col = start_sheet->cols.max_used; r.end.col = start_sheet->cols.max_used;
if (r.start.col <= r.end.col && r.start.row <= r.end.row) if (r.start.col <= r.end.col && r.start.row <= r.end.row)
sheet_foreach_cell_in_range (start_sheet, CELL_ITER_ALL, sheet_foreach_cell_in_range (start_sheet,
r.start.col, r.start.row, r.end.col, r.end.row, CELL_ITER_ALL,
(CellIterFunc)cb_assign_markup, vec->markup); &r,
(CellIterFunc)cb_assign_markup, vec->markup);
} }
} }
break; break;
...@@ -1333,7 +1339,7 @@ gnm_go_data_matrix_load_values (GODataMatrix *dat) ...@@ -1333,7 +1339,7 @@ gnm_go_data_matrix_load_values (GODataMatrix *dat)
closure.first_col = closure.last_col = -1; closure.first_col = closure.last_col = -1;
closure.row = closure.col = 0; closure.row = closure.col = 0;
closure.columns = dat->size.columns; 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, r.start.row,
r.start.col + dat->size.columns - 1, r.start.col + dat->size.columns - 1,
r.start.row + dat->size.rows - 1, r.start.row + dat->size.rows - 1,
......
...@@ -483,7 +483,7 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet) ...@@ -483,7 +483,7 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
if (cond->op[1] != GNM_FILTER_UNUSED) if (cond->op[1] != GNM_FILTER_UNUSED)
filter_expr_init (&data, 1, cond, filter); filter_expr_init (&data, 1, cond, filter);
sheet_foreach_cell_in_range (filter->sheet, sheet_foreach_cell_in_region (filter->sheet,
iter_flags, iter_flags,
col, start_row, col, end_row, col, start_row, col, end_row,
(CellIterFunc) cb_filter_expr, &data); (CellIterFunc) cb_filter_expr, &data);
...@@ -492,12 +492,12 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet) ...@@ -492,12 +492,12 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
if (cond->op[1] != GNM_FILTER_UNUSED) if (cond->op[1] != GNM_FILTER_UNUSED)
filter_expr_release (&data, 1); filter_expr_release (&data, 1);
} else if (cond->op[0] == GNM_FILTER_OP_BLANKS) } 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, CELL_ITER_IGNORE_HIDDEN,
col, start_row, col, end_row, col, start_row, col, end_row,
(CellIterFunc) cb_filter_blanks, target_sheet); (CellIterFunc) cb_filter_blanks, target_sheet);
else if (cond->op[0] == GNM_FILTER_OP_NON_BLANKS) 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, CELL_ITER_IGNORE_HIDDEN,
col, start_row, col, end_row, col, start_row, col, end_row,
(CellIterFunc) cb_filter_non_blanks, target_sheet); (CellIterFunc) cb_filter_non_blanks, target_sheet);
...@@ -511,12 +511,12 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet) ...@@ -511,12 +511,12 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
if (data.count < 1) if (data.count < 1)
data.count = 1; data.count = 1;
data.vals = g_new (GnmValue const *, data.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, CELL_ITER_IGNORE_HIDDEN | CELL_ITER_IGNORE_BLANK,
col, start_row, col, end_row, col, start_row, col, end_row,
(CellIterFunc) cb_filter_find_items, &data); (CellIterFunc) cb_filter_find_items, &data);
data.target_sheet = target_sheet; data.target_sheet = target_sheet;
sheet_foreach_cell_in_range (filter->sheet, sheet_foreach_cell_in_region (filter->sheet,
CELL_ITER_IGNORE_HIDDEN, CELL_ITER_IGNORE_HIDDEN,
col, start_row, col, end_row, col, start_row, col, end_row,
(CellIterFunc) cb_hide_unwanted_items, &data); (CellIterFunc) cb_hide_unwanted_items, &data);
...@@ -527,7 +527,7 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet) ...@@ -527,7 +527,7 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
data.find_max = (cond->op[0] & 0x1) ? FALSE : TRUE; data.find_max = (cond->op[0] & 0x1) ? FALSE : TRUE;
data.initialized = FALSE; 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, CELL_ITER_IGNORE_HIDDEN | CELL_ITER_IGNORE_BLANK,
col, start_row, col, end_row, col, start_row, col, end_row,
(CellIterFunc) cb_filter_find_percentage, &data); (CellIterFunc) cb_filter_find_percentage, &data);
...@@ -535,7 +535,7 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet) ...@@ -535,7 +535,7 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
data.high -= offset; data.high -= offset;
data.low += offset; data.low += offset;
data.target_sheet = target_sheet; data.target_sheet = target_sheet;
sheet_foreach_cell_in_range (filter->sheet, sheet_foreach_cell_in_region (filter->sheet,
CELL_ITER_IGNORE_HIDDEN, CELL_ITER_IGNORE_HIDDEN,
col, start_row, col, end_row, col, start_row, col, end_row,
(CellIterFunc) cb_hide_unwanted_percentage, &data); (CellIterFunc) cb_hide_unwanted_percentage, &data);
...@@ -547,12 +547,12 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet) ...@@ -547,12 +547,12 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
data.count = cond->count; data.count = cond->count;
data.vals = g_new (GnmValue const *, data.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, CELL_ITER_IGNORE_HIDDEN | CELL_ITER_IGNORE_BLANK,
col, start_row, col, end_row, col, start_row, col, end_row,
(CellIterFunc) cb_filter_find_items, &data); (CellIterFunc) cb_filter_find_items, &data);
data.target_sheet = target_sheet; data.target_sheet = target_sheet;
sheet_foreach_cell_in_range (filter->sheet, sheet_foreach_cell_in_region (filter->sheet,
CELL_ITER_IGNORE_HIDDEN, CELL_ITER_IGNORE_HIDDEN,
col, start_row, col, end_row, col, start_row, col, end_row,
(CellIterFunc) cb_hide_unwanted_items, &data); (CellIterFunc) cb_hide_unwanted_items, &data);
......
...@@ -155,6 +155,24 @@ static void gnm_sheet_finalize (GObject *obj); ...@@ -155,6 +155,24 @@ static void gnm_sheet_finalize (GObject *obj);
static GObjectClass *parent_class; 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;