From b6bda827dd500adcbe0fbd8bdf0b54501d77ba08 Mon Sep 17 00:00:00 2001 From: Morten Welinder Date: Wed, 18 Apr 2018 21:01:54 -0400 Subject: [PATCH] Introspection: updates. --- README-introspection | 4 ++ plugins/excel/ms-excel-read.c | 4 +- plugins/excel/ms-excel-write.c | 6 +-- plugins/excel/xlsx-read.c | 4 +- plugins/excel/xlsx-write.c | 2 +- plugins/openoffice/openoffice-write.c | 8 ++-- src/colrow.c | 80 +++++++++++++++++++---------------- src/colrow.h | 20 ++++----- src/commands.c | 2 +- src/sheet-diff.c | 4 +- src/sheet.c | 44 +++++++++---------- src/tools/filter.c | 2 +- src/undo.c | 2 +- src/value.c | 46 ++++++++++++++++---- src/xml-sax-read.c | 4 +- src/xml-sax-write.c | 8 ++-- 16 files changed, 139 insertions(+), 101 deletions(-) diff --git a/README-introspection b/README-introspection index 34bed2760..a7af503b9 100644 --- a/README-introspection +++ b/README-introspection @@ -112,6 +112,10 @@ GnmCell: [Boxed structure] [2] pos +ColRowInfo: [Boxed structure] + is_default() + is_empty() + GnmSheetSize: [Simple structure] max_cols max_rows diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c index cbedb3527..f802fdd92 100644 --- a/plugins/excel/ms-excel-read.c +++ b/plugins/excel/ms-excel-read.c @@ -4309,7 +4309,7 @@ excel_read_ROW (BiffQuery *q, ExcelReadSheet *esheet) } if ((unsigned)(flags & 0x17) > 0) - colrow_set_outline (sheet_row_fetch (esheet->sheet, row), + col_row_info_set_outline (sheet_row_fetch (esheet->sheet, row), (unsigned)(flags & 0x7), flags & 0x10); } @@ -4422,7 +4422,7 @@ excel_read_COLINFO (BiffQuery *q, ExcelReadSheet *esheet) sheet_col_set_size_pts (esheet->sheet, i, width, customWidth && !bestFit); if (outline_level > 0 || collapsed) - colrow_set_outline (sheet_col_fetch (esheet->sheet, i), + col_row_info_set_outline (sheet_col_fetch (esheet->sheet, i), outline_level, collapsed); } diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c index 8e05c0410..d25255fc5 100644 --- a/plugins/excel/ms-excel-write.c +++ b/plugins/excel/ms-excel-write.c @@ -248,13 +248,13 @@ excel_sheet_extent (Sheet const *sheet, GnmRange *extent, GnmStyle **col_styles, /* include collapsed or hidden rows */ for (i = maxrows ; i-- > extent->end.row ; ) - if (!colrow_is_empty (sheet_row_get (sheet, i))) { + if (!col_row_info_is_empty (sheet_row_get (sheet, i))) { extent->end.row = i; break; } /* include collapsed or hidden rows */ for (i = maxcols ; i-- > extent->end.col ; ) - if (!colrow_is_empty (sheet_col_get (sheet, i))) { + if (!col_row_info_is_empty (sheet_col_get (sheet, i))) { extent->end.col = i; break; } @@ -3984,7 +3984,7 @@ excel_write_colinfos (BiffPut *bp, ExcelWriteSheet *esheet) for (i = 1; i < cols; i++) { ci = sheet_col_get (esheet->gnum_sheet, i); new_xf = esheet->col_xf [i]; - if (xf != new_xf || !colrow_equal (info, ci)) { + if (xf != new_xf || !col_row_info_equal (info, ci)) { excel_write_COLINFO (bp, esheet, info, first_col, i-1, xf); info = ci; xf = new_xf; diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c index 91c3da680..67c187173 100644 --- a/plugins/excel/xlsx-read.c +++ b/plugins/excel/xlsx-read.c @@ -1578,7 +1578,7 @@ xlsx_CT_Row (GsfXMLIn *xin, xmlChar const **attrs) if (hidden > 0) colrow_set_visibility (state->sheet, FALSE, FALSE, row, row); if (outline >= 0) - colrow_set_outline (sheet_row_fetch (state->sheet, row), + col_row_info_set_outline (sheet_row_fetch (state->sheet, row), outline, collapsed); if (NULL != style && cust_fmt) { @@ -1666,7 +1666,7 @@ xlsx_CT_Col (GsfXMLIn *xin, xmlChar const **attrs) sheet_col_set_size_pts (state->sheet, i, width, cust_width && !best_fit); if (outline > 0) - colrow_set_outline (sheet_col_fetch (state->sheet, i), + col_row_info_set_outline (sheet_col_fetch (state->sheet, i), outline, collapsed); } if (NULL != style) { diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c index 360947167..20d469e3f 100644 --- a/plugins/excel/xlsx-write.c +++ b/plugins/excel/xlsx-write.c @@ -2197,7 +2197,7 @@ xlsx_write_cols (XLSXWriteState *state, GsfXMLOut *xml, GnmStyle **styles) for (i = first_col + 1; i <= last_col; i++) { ColRowInfo const *ci = sheet_col_get_info (state->sheet, i); - if (!colrow_equal (info, ci) || styles[i] != styles[i - 1]) { + if (!col_row_info_equal (info, ci) || styles[i] != styles[i - 1]) { xlsx_write_col (state, xml, info, first_col, i - 1, styles[i - 1]); diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c index 305b78002..08fc19da6 100644 --- a/plugins/openoffice/openoffice-write.c +++ b/plugins/openoffice/openoffice-write.c @@ -1691,7 +1691,7 @@ odf_compare_ci (gconstpointer a, gconstpointer b) col_row_styles_t const *old_style = a; ColRowInfo const *new_style = b; - return !colrow_equal (new_style, old_style->ci); + return !col_row_info_equal (new_style, old_style->ci); } static void @@ -2020,7 +2020,7 @@ odf_write_column_styles (GnmOOExport *state) for (i = 1; i < max_cols; i++) { ColRowInfo const *this_ci = sheet_col_get (sheet, i); - if (!colrow_equal (last_ci, this_ci)) + if (!col_row_info_equal (last_ci, this_ci)) odf_find_col_style (state, (last_ci = this_ci), TRUE); } } @@ -2051,7 +2051,7 @@ odf_write_row_styles (GnmOOExport *state) for (i = 1; i < max_rows; i++) { ColRowInfo const *this_ci = sheet_row_get (sheet, i); - if (!colrow_equal (last_ci, this_ci)) + if (!col_row_info_equal (last_ci, this_ci)) odf_find_row_style (state, (last_ci = this_ci), TRUE); } } @@ -3704,7 +3704,7 @@ odf_write_formatted_columns (GnmOOExport *state, Sheet const *sheet, GnmStyle ** GnmStyle *this_col_style = filter_style (state->default_style_region->style, col_styles[i]); ColRowInfo const *this_ci = sheet_col_get (sheet, i); - if ((this_col_style == last_col_style) && colrow_equal (last_ci, this_ci)) + if ((this_col_style == last_col_style) && col_row_info_equal (last_ci, this_ci)) number_cols_rep++; else { if (number_cols_rep > 1) diff --git a/src/colrow.c b/src/colrow.c index 09521681d..ad31c5f36 100644 --- a/src/colrow.c +++ b/src/colrow.c @@ -37,7 +37,7 @@ #include /* Making ColRowInfo a boxed type to make introspection happy. using no-op - * functions for copy and free, and crossing fingers. + * functions for copy and free, and crossing fingers. */ static ColRowInfo * col_row_info_fake_copy (ColRowInfo *cri) @@ -100,21 +100,27 @@ colrow_compute_pts_from_pixels (ColRowInfo *cri, Sheet const *sheet, #endif } +/** + * col_row_info_is_default: + * @cri: #ColRowInfo + * + * %TRUE if @cri is the default style for columns or rows. + **/ gboolean -colrow_is_default (ColRowInfo const *cri) +col_row_info_is_default (ColRowInfo const *cri) { g_return_val_if_fail (cri != NULL, FALSE); return cri->is_default; } /** - * colrow_is_empty : + * col_row_info_is_empty: * @cri: #ColRowInfo * - * TRUE if there is no information in col/row @cri. + * %TRUE if there is no information in col/row @cri. **/ gboolean -colrow_is_empty (ColRowInfo const *cri) +col_row_info_is_empty (ColRowInfo const *cri) { if (cri == NULL) return TRUE; @@ -125,14 +131,14 @@ colrow_is_empty (ColRowInfo const *cri) } /** - * colrow_equal : - * @a: ColRowInfo #1 - * @b: ColRowInfo #2 + * col_row_info_equal: + * @a: First #ColRowInfo + * @b: Second #ColRowInfo * - * Returns true if the infos are equivalent. + * Returns %TRUE if the infos are equivalent. **/ gboolean -colrow_equal (ColRowInfo const *a, ColRowInfo const *b) +col_row_info_equal (ColRowInfo const *a, ColRowInfo const *b) { if (a == NULL) return b == NULL; @@ -147,14 +153,14 @@ colrow_equal (ColRowInfo const *a, ColRowInfo const *b) } /** - * colrow_copy : - * @dst: - * @src: + * col_row_info_copy: + * @dst: Destination #ColRowInfo + * @src: Source #ColRowInfo * - * Assign all content, except the position of @src to @dst + * Copy all content, except the position of @src to @dst. */ void -colrow_copy (ColRowInfo *dst, ColRowInfo const *src) +col_row_info_copy (ColRowInfo *dst, ColRowInfo const *src) { dst->size_pts = src->size_pts; dst->size_pixels = src->size_pixels; @@ -177,21 +183,21 @@ colrow_free (ColRowInfo *cri) } /** - * colrow_foreach: + * 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 + * @callback: (scope call): A callback function which should return %TRUE to stop * the iteration. * @user_data: A bagage 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. + * %TRUE iteration stops. **/ gboolean -colrow_foreach (ColRowCollection const *infos, int first, int last, - ColRowHandler callback, gpointer user_data) +col_row_collection_foreach (ColRowCollection const *infos, int first, int last, + ColRowHandler callback, gpointer user_data) { GnmColRowIter iter; ColRowSegment const *segment; @@ -250,7 +256,7 @@ colrow_vis_list_length (ColRowVisList *list) * colrow_state_group_destroy: * @set: (transfer full): the group to destroy. * - * Returns: (transfer none): %NULL. + * Returns: (transfer none) (nullable): %NULL. **/ ColRowStateGroup * colrow_state_group_destroy (ColRowStateGroup *group) @@ -275,7 +281,7 @@ colrow_index_compare (ColRowIndex const * a, ColRowIndex const * b) * * @list: The list * @is_cols: Column index list or row index list? - * @is_single: If non-null this will be set to TRUE if there's only a single col/row involved. + * @is_single: If non-null this will be set to %TRUE if there's only a single col/row involved. */ GString * colrow_index_list_to_string (ColRowIndexList *list, gboolean is_cols, gboolean *is_single) @@ -379,7 +385,7 @@ colrow_set_single_state (ColRowState *state, Sheet *sheet, int i, gboolean is_cols) { ColRowInfo const *info = sheet_colrow_get_info (sheet, i, is_cols); - state->is_default = colrow_is_default (info); + state->is_default = col_row_info_is_default (info); state->size_pts = info->size_pts; state->outline_level = info->outline_level; state->is_collapsed = info->is_collapsed; @@ -554,7 +560,7 @@ colrow_set_sizes (Sheet *sheet, gboolean is_cols, res = g_slist_prepend (res, colrow_get_states (sheet, is_cols, index->first, index->last)); - /* FIXME : + /* FIXME: * If we are changing the size of more than half of the rows/col to * something specific (not autosize) we should change the default * row/col size instead. However, it is unclear how to handle @@ -576,12 +582,12 @@ 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_last_col (sheet), + col_row_collection_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_last_row (sheet), + col_row_collection_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet), &cb_set_colrow_size, &closure); } @@ -689,7 +695,7 @@ colrow_set_states (Sheet *sheet, gboolean is_cols, cri->hard_size = state->hard_size; cri->size_pts = state->size_pts; colrow_compute_pixels_from_pts (cri, sheet, is_cols, scale); - colrow_set_outline (cri, state->outline_level, + col_row_info_set_outline (cri, state->outline_level, state->is_collapsed); } } @@ -843,7 +849,7 @@ cb_autofit_row (GnmColRowIter const *iter, gpointer data_) * colrow_autofit: * @sheet: the sheet to change * @range: the range to consider - * @is_cols: TRUE for columns, FALSE for rows. + * @is_cols: %TRUE for columns, %FALSE for rows. * @ignore_strings: Don't consider cells with string values. * @min_current: Don't shrink below current size. * @min_default: Don't shrink below default size. @@ -894,7 +900,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 (); - colrow_foreach (crs, a, b, handler, &data); + col_row_collection_foreach (crs, a, b, handler, &data); gnm_app_recalc_finish (); } @@ -1052,7 +1058,7 @@ colrow_get_visiblity_toggle (SheetView *sv, gboolean is_cols, } /* - * colrow_set_visibility_list : + * colrow_set_visibility_list: * * This is the high level command that is wrapped by undo and redo. * It should not be called by other commands. @@ -1080,24 +1086,24 @@ colrow_set_visibility_list (Sheet *sheet, gboolean is_cols, } /** - * colrow_set_outline : - * @cri: the col/row to tweak + * col_row_info_set_outline: + * @cri: #ColRowInfo to tweak * @outline_level: * @is_collapsed: * * Adjust the outline state of a col/row */ void -colrow_set_outline (ColRowInfo *cri, int outline_level, gboolean is_collapsed) +col_row_info_set_outline (ColRowInfo *cri, int outline_level, gboolean is_collapsed) { g_return_if_fail (outline_level >= 0); - cri->is_collapsed = (is_collapsed != 0); /* be anal */ + cri->is_collapsed = !!is_collapsed; cri->outline_level = outline_level; } /** - * colrow_find_outline_bound : + * colrow_find_outline_bound: * * find the next/prev col/row at the designated depth starting from the * supplied @index. @@ -1226,7 +1232,7 @@ colrow_set_visibility (Sheet *sheet, gboolean is_cols, } /** - * colrow_get_global_outline : + * colrow_get_global_outline: * @sheet: * @is_cols: * @depth: @@ -1293,7 +1299,7 @@ colrow_get_global_outline (Sheet const *sheet, gboolean is_cols, int depth, } void -colrow_resize (ColRowCollection *infos, int size) +col_row_collection_resize (ColRowCollection *infos, int size) { int end_idx = COLROW_SEGMENT_INDEX (size); int i = infos->info->len - 1; diff --git a/src/colrow.h b/src/colrow.h index 9e4bf5791..f35434554 100644 --- a/src/colrow.h +++ b/src/colrow.h @@ -75,10 +75,10 @@ void colrow_compute_pixels_from_pts (ColRowInfo *cri, Sheet const *sheet, void colrow_compute_pts_from_pixels (ColRowInfo *cri, Sheet const *sheet, gboolean horizontal, double scale); -gboolean colrow_is_default (ColRowInfo const *cri); -gboolean colrow_is_empty (ColRowInfo const *cri); -gboolean colrow_equal (ColRowInfo const *a, ColRowInfo const *b); -void colrow_copy (ColRowInfo *dst, ColRowInfo const *src); +gboolean col_row_info_is_default (ColRowInfo const *cri); +gboolean col_row_info_is_empty (ColRowInfo const *cri); +gboolean col_row_info_equal (ColRowInfo const *a, ColRowInfo const *b); +void col_row_info_copy (ColRowInfo *dst, ColRowInfo const *src); ColRowInfo *col_row_info_new (void); void colrow_free (ColRowInfo *cri); @@ -88,12 +88,12 @@ typedef struct { } GnmColRowIter; typedef gboolean (*ColRowHandler)(GnmColRowIter const *iter, gpointer user_data); -gboolean colrow_foreach (ColRowCollection const *infos, - int first, int last, - ColRowHandler callback, - gpointer user_data); +gboolean col_row_collection_foreach (ColRowCollection const *infos, + int first, int last, + ColRowHandler callback, + gpointer user_data); -void colrow_resize (ColRowCollection *infos, int size); +void col_row_collection_resize (ColRowCollection *infos, int size); #define colrow_index_list_destroy(l) g_list_free_full ((l), g_free) @@ -122,7 +122,7 @@ void colrow_restore_state_group (Sheet *sheet, gboolean is_cols, ColRowStateGroup *saved_state); /* Support for Col/Row visibility */ -void colrow_set_outline (ColRowInfo *cri, int outline_level, +void col_row_info_set_outline (ColRowInfo *cri, int outline_level, gboolean is_collapsed); int colrow_find_outline_bound (Sheet const *sheet, gboolean is_cols, int index, int depth, gboolean inc); diff --git a/src/commands.c b/src/commands.c index 4ecddd717..8b5751709 100644 --- a/src/commands.c +++ b/src/commands.c @@ -1582,7 +1582,7 @@ 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) { - colrow_foreach (&sheet->rows, data.r->start.row, data.r->end.row, + col_row_collection_foreach (&sheet->rows, data.r->start.row, data.r->end.row, (ColRowHandler) cmd_selection_clear_row_handler, &data); g_free (ranges->data); ranges->data = NULL; diff --git a/src/sheet-diff.c b/src/sheet-diff.c index c60392006..4703a4bfc 100644 --- a/src/sheet-diff.c +++ b/src/sheet-diff.c @@ -185,7 +185,7 @@ diff_sheets_colrow (GnmDiffIState *istate, gboolean is_cols) sheet_colrow_get_default (istate->new_sheet, is_cols); int i, U; - if (!colrow_equal (old_def, new_def)) { + if (!col_row_info_equal (old_def, new_def)) { istate->diff_found = TRUE; DISPATCH(colrow_changed) (istate->user, old_def, new_def, is_cols, -1); } @@ -203,7 +203,7 @@ diff_sheets_colrow (GnmDiffIState *istate, gboolean is_cols) continue; // Considered equal, even if defaults are different if (!ocr) ocr = old_def; if (!ncr) ncr = new_def; - if (!colrow_equal (ocr, ncr)) { + if (!col_row_info_equal (ocr, ncr)) { istate->diff_found = TRUE; DISPATCH(colrow_changed) (istate->user, ocr, ncr, is_cols, i); } diff --git a/src/sheet.c b/src/sheet.c index 5ae33b335..59470435c 100644 --- a/src/sheet.c +++ b/src/sheet.c @@ -364,7 +364,7 @@ sheet_scale_changed (Sheet *sheet, gboolean cols_rescaled, gboolean rows_rescale colrow_compute_pixels_from_pts (&sheet->cols.default_style, sheet, TRUE, closure.scale); - colrow_foreach (&sheet->cols, 0, gnm_sheet_get_last_col (sheet), + col_row_collection_foreach (&sheet->cols, 0, gnm_sheet_get_last_col (sheet), (ColRowHandler)&cb_colrow_compute_pixels_from_pts, &closure); } if (rows_rescaled) { @@ -376,7 +376,7 @@ sheet_scale_changed (Sheet *sheet, gboolean cols_rescaled, gboolean rows_rescale colrow_compute_pixels_from_pts (&sheet->rows.default_style, sheet, FALSE, closure.scale); - colrow_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet), + col_row_collection_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet), (ColRowHandler)&cb_colrow_compute_pixels_from_pts, &closure); } @@ -679,8 +679,8 @@ gnm_sheet_constructed (GObject *obj) /* Now sheet_type, max_cols, and max_rows have been set. */ sheet->being_constructed = FALSE; - colrow_resize (&sheet->cols, sheet->size.max_cols); - colrow_resize (&sheet->rows, sheet->size.max_rows); + col_row_collection_resize (&sheet->cols, sheet->size.max_cols); + col_row_collection_resize (&sheet->rows, sheet->size.max_rows); sheet->priv->reposition_objects.col = sheet->size.max_cols; sheet->priv->reposition_objects.row = sheet->size.max_rows; @@ -1288,8 +1288,8 @@ gnm_sheet_resize_main (Sheet *sheet, int cols, int rows, /* ---------------------------------------- */ /* Resize column and row containers. */ - colrow_resize (&sheet->cols, cols); - colrow_resize (&sheet->rows, rows); + col_row_collection_resize (&sheet->cols, cols); + col_row_collection_resize (&sheet->rows, rows); /* ---------------------------------------- */ /* Resize the dependency containers. */ @@ -1932,7 +1932,7 @@ static int sheet_colrow_fit_gutter (Sheet const *sheet, gboolean is_cols) { int outline_level = 0; - colrow_foreach (is_cols ? &sheet->cols : &sheet->rows, + col_row_collection_foreach (is_cols ? &sheet->cols : &sheet->rows, 0, colrow_max (is_cols, sheet) - 1, (ColRowHandler)cb_outline_level, &outline_level); return outline_level; @@ -2176,7 +2176,7 @@ sheet_colrow_group_ungroup (Sheet *sheet, GnmRange const *r, int const new_level = cri->outline_level + step; if (new_level >= 0) { - colrow_set_outline (cri, new_level, FALSE); + col_row_info_set_outline (cri, new_level, FALSE); if (new_max < new_level) new_max = new_level; } @@ -2649,7 +2649,7 @@ sheet_recompute_spans_for_col (Sheet *sheet, int col) closure.sheet = sheet; closure.col = col; - colrow_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet), + col_row_collection_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet), &cb_recalc_spans_in_col, &closure); } @@ -3546,7 +3546,7 @@ sheet_range_splits_array (Sheet const *sheet, closure.flags = CHECK_AND_LOAD_START; if (closure.flags && - colrow_foreach (&sheet->cols, r->start.col, r->end.col, + col_row_collection_foreach (&sheet->cols, r->start.col, r->end.col, (ColRowHandler) cb_check_array_horizontal, &closure)) { if (cc) gnm_cmd_context_error_splits_array (cc, @@ -3568,7 +3568,7 @@ sheet_range_splits_array (Sheet const *sheet, closure.flags = CHECK_AND_LOAD_START; if (closure.flags && - colrow_foreach (&sheet->rows, r->start.row, r->end.row, + col_row_collection_foreach (&sheet->rows, r->start.row, r->end.row, (ColRowHandler) cb_check_array_vertical, &closure)) { if (cc) gnm_cmd_context_error_splits_array (cc, @@ -3743,7 +3743,7 @@ sheet_colrow_optimize1 (int max, int max_used, ColRowCollection *collection) if (!info) continue; if (i + j >= first_unused && - colrow_equal (&collection->default_style, info)) { + col_row_info_equal (&collection->default_style, info)) { colrow_free (info); segment->info[j] = NULL; } else { @@ -4629,11 +4629,11 @@ sheet_destroy_contents (Sheet *sheet) sheet_row_destroy (sheet, i, FALSE); /* Free segments too */ - colrow_resize (&sheet->cols, 0); + col_row_collection_resize (&sheet->cols, 0); g_ptr_array_free (sheet->cols.info, TRUE); sheet->cols.info = NULL; - colrow_resize (&sheet->rows, 0); + col_row_collection_resize (&sheet->rows, 0); g_ptr_array_free (sheet->rows.info, TRUE); sheet->rows.info = NULL; @@ -5502,7 +5502,7 @@ sheet_col_get_distance_pts (Sheet const *sheet, int from, int to) g_return_val_if_fail (from >= 0, 1.); g_return_val_if_fail (to <= gnm_sheet_get_max_cols (sheet), 1.); - /* Do not use colrow_foreach, it ignores empties */ + /* Do not use col_row_collection_foreach, it ignores empties */ dflt = sheet->cols.default_style.size_pts; for (i = from ; i < to ; ++i) { if (NULL == (ci = sheet_col_get (sheet, i))) @@ -5542,7 +5542,7 @@ sheet_col_get_distance_pixels (Sheet const *sheet, int from, int to) g_return_val_if_fail (from >= 0, 1); g_return_val_if_fail (to <= gnm_sheet_get_max_cols (sheet), 1); - /* Do not use colrow_foreach, it ignores empties */ + /* Do not use col_row_collection_foreach, it ignores empties */ dflt = sheet_col_get_default_size_pixels (sheet); for (i = from ; i < to ; ++i) { if (NULL == (ci = sheet_col_get (sheet, i))) @@ -5685,7 +5685,7 @@ sheet_row_get_distance_pts (Sheet const *sheet, int from, int to) g_return_val_if_fail (from >= 0, 1.); g_return_val_if_fail (to <= gnm_sheet_get_max_rows (sheet), 1.); - /* Do not use colrow_foreach, it ignores empties. + /* Do not use col_row_collection_foreach, it ignores empties. * Optimize this so that long jumps are not quite so horrific * for performance. */ @@ -5735,7 +5735,7 @@ sheet_row_get_distance_pixels (Sheet const *sheet, int from, int to) g_return_val_if_fail (from >= 0, 1); g_return_val_if_fail (to <= gnm_sheet_get_max_rows (sheet), 1); - /* Do not use colrow_foreach, it ignores empties */ + /* Do not use col_row_collection_foreach, it ignores empties */ dflt = sheet_row_get_default_size_pixels (sheet); for (i = from ; i < to ; ++i) { if (NULL == (ci = sheet_row_get (sheet, i))) @@ -5878,7 +5878,7 @@ sheet_clone_colrow_info_item (GnmColRowIter const *iter, void *user_data) closure_clone_colrow const *closure = user_data; ColRowInfo *new_colrow = sheet_colrow_fetch (closure->sheet, iter->pos, closure->is_column); - colrow_copy (new_colrow, iter->cri); + col_row_info_copy (new_colrow, iter->cri); return FALSE; } @@ -5891,10 +5891,10 @@ sheet_dup_colrows (Sheet const *src, Sheet *dst) closure.sheet = dst; closure.is_column = TRUE; - colrow_foreach (&src->cols, 0, max_col - 1, + col_row_collection_foreach (&src->cols, 0, max_col - 1, &sheet_clone_colrow_info_item, &closure); closure.is_column = FALSE; - colrow_foreach (&src->rows, 0, max_row - 1, + col_row_collection_foreach (&src->rows, 0, max_row - 1, &sheet_clone_colrow_info_item, &closure); sheet_col_set_default_size_pixels (dst, @@ -6171,7 +6171,7 @@ cb_queue_respan (GnmColRowIter const *iter, void *user_data) void sheet_queue_respan (Sheet const *sheet, int start_row, int end_row) { - colrow_foreach (&sheet->rows, start_row, end_row, + col_row_collection_foreach (&sheet->rows, start_row, end_row, cb_queue_respan, NULL); } diff --git a/src/tools/filter.c b/src/tools/filter.c index cccd222d8..a1f9c76e0 100644 --- a/src/tools/filter.c +++ b/src/tools/filter.c @@ -175,7 +175,7 @@ filter_show_all (WorkbookControl *wbc) /* FIXME: This is slow. We should probably have a linked list * containing the filtered rows in the sheet structure. */ - colrow_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet), + col_row_collection_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet), (ColRowHandler) cb_show_all, sheet); sheet->has_filtered_rows = FALSE; sheet_redraw_all (sheet, TRUE); diff --git a/src/undo.c b/src/undo.c index 719d39f2f..0a6ad9d24 100644 --- a/src/undo.c +++ b/src/undo.c @@ -228,7 +228,7 @@ gnm_undo_filter_set_condition_undo (GOUndo *u, G_GNUC_UNUSED gpointer data) gnm_filter_condition_dup (ua->cond), TRUE); sheet_update (ua->filter->sheet); - colrow_foreach (&ua->filter->sheet->rows, + col_row_collection_foreach (&ua->filter->sheet->rows, ua->filter->r.start.row + 1, ua->filter->r.end.row, (ColRowHandler) cb_filter_set_condition_undo, diff --git a/src/value.c b/src/value.c index 90d43fb28..2e8633670 100644 --- a/src/value.c +++ b/src/value.c @@ -177,6 +177,13 @@ value_new_error_NA (GnmEvalPos const *pos) return value_new_error_str (pos, standard_errors[GNM_ERROR_NA].locale_name_str); } +/** + * value_error_name: + * @err: #GnmStdError + * @translated: If %TRUE, use localized name. + * + * Returns: (transfer none): the name of @err, possibly localized. + */ char const * value_error_name (GnmStdError err, gboolean translated) { @@ -195,6 +202,8 @@ value_error_name (GnmStdError err, gboolean translated) * @pos: * * Change the position of a ValueError. + * + * Returns: (transfer none): @err as a #GnmValue. */ GnmValue * value_error_set_pos (GnmValueErr *err, G_GNUC_UNUSED GnmEvalPos const *pos) @@ -624,9 +633,9 @@ value_release (GnmValue *value) /** * value_dup: - * @v: #GnmValue + * @v: (nullable): #GnmValue * - * Returns a copy of @v. @v == NULL will return NULL + * Returns: (transfer full) (nullable): a copy of @v. **/ GnmValue * value_dup (GnmValue const *src) @@ -1005,11 +1014,11 @@ value_get_as_gstring (GnmValue const *v, GString *target, /** * value_get_as_string: - * @v: + * @v: #GnmValue * - * simplistic value rendering + * Simplistic value rendering * - * Returns a string that must be freed. + * Returns: (transfer full): a string rendering of @v. **/ char * value_get_as_string (GnmValue const *v) @@ -1049,8 +1058,11 @@ value_peek_string (GnmValue const *v) } } -/* - * FIXME FIXME FIXME : Support errors +/** + * value_get_as_int: + * @v: (nullable): a #GnmValue + * + * Returns: @v interpreted as an integer. */ int value_get_as_int (GnmValue const *v) @@ -1087,8 +1099,11 @@ value_get_as_int (GnmValue const *v) return 0; } -/* - * FIXME FIXME FIXME : Support errors +/** + * value_get_as_float: + * @v: (nullable): a #GnmValue + * + * Returns: @v interpreted as a floating point value. */ gnm_float value_get_as_float (GnmValue const *v) @@ -1481,6 +1496,13 @@ value_compare_no_cache (GnmValue const *a, GnmValue const *b, return value_compare_real (a, b, case_sensitive, FALSE); } +/** + * value_set_format: + * @v: #GnmValue + * @fmt: (nullable): #GOFormat + * + * Sets @v's format. + */ void value_set_fmt (GnmValue *v, GOFormat const *fmt) { @@ -1513,6 +1535,9 @@ GnmValueErr const value_terminate_err = { VALUE_ERROR, NULL, NULL }; static GnmValueFloat const the_value_zero = { VALUE_FLOAT, NULL, 0 }; GnmValue const *value_zero = (GnmValue const *)&the_value_zero; +/** + * value_init: (skip) + */ void value_init (void) { @@ -1552,6 +1577,9 @@ value_init (void) #endif } +/** + * value_shutdown: (skip) + */ void value_shutdown (void) { diff --git a/src/xml-sax-read.c b/src/xml-sax-read.c index f0a626701..22f3224e8 100644 --- a/src/xml-sax-read.c +++ b/src/xml-sax-read.c @@ -1383,14 +1383,14 @@ xml_sax_colrow (GsfXMLIn *xin, xmlChar const **attrs) state->sheet->cols.max_outline_level = cri->outline_level; /* resize flags are already set only need to copy the sizes */ while (--count > 0) - colrow_copy (sheet_col_fetch (state->sheet, ++pos), cri); + col_row_info_copy (sheet_col_fetch (state->sheet, ++pos), cri); } else { sheet_row_set_size_pts (state->sheet, pos, size, cri->hard_size); if (state->sheet->rows.max_outline_level < cri->outline_level) state->sheet->rows.max_outline_level = cri->outline_level; /* resize flags are already set only need to copy the sizes */ while (--count > 0) - colrow_copy (sheet_row_fetch (state->sheet, ++pos), cri); + col_row_info_copy (sheet_row_fetch (state->sheet, ++pos), cri); } } diff --git a/src/xml-sax-write.c b/src/xml-sax-write.c index 9786b3b97..3e23c768c 100644 --- a/src/xml-sax-write.c +++ b/src/xml-sax-write.c @@ -741,10 +741,10 @@ xml_write_colrow_info (GnmColRowIter const *iter, closure_write_colrow *closure) closure->is_column); closure->rle_count++; - if (NULL != iter && colrow_equal (prev, iter->cri)) + if (NULL != iter && col_row_info_equal (prev, iter->cri)) return FALSE; - if (prev != NULL && !colrow_equal (prev, def)) { + if (prev != NULL && !col_row_info_equal (prev, def)) { if (closure->is_column) gsf_xml_out_start_element (output, GNM "ColInfo"); else @@ -787,7 +787,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_last_col (state->sheet), + col_row_collection_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); /* */ @@ -800,7 +800,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_last_row (state->sheet), + col_row_collection_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); /* */ -- 2.11.4.GIT