GUI: Move .ui files from goffice resources to glib resources
[gnumeric.git] / src / search.h
blob879088f6b8ca9881452afd269403ad3a4bf7066d
1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 #ifndef _GNM_SEARCH_H_
3 # define _GNM_SEARCH_H_
5 #include <gnumeric.h>
6 #include <position.h>
7 #include <numbers.h>
8 #include <goffice/goffice.h>
10 G_BEGIN_DECLS
12 char *gnm_search_normalize (const char *txt);
14 #define GNM_SEARCH_REPLACE_TYPE (gnm_search_replace_get_type ())
15 #define GNM_SEARCH_REPLACE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNM_SEARCH_REPLACE_TYPE, GnmSearchReplace))
16 #define GNM_IS_SEARCH_REPLACE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNM_SEARCH_REPLACE_TYPE))
18 typedef enum {
19 GNM_SRE_FAIL = 0,
20 GNM_SRE_SKIP,
21 GNM_SRE_QUERY,
22 GNM_SRE_ERROR,
23 GNM_SRE_STRING
24 } GnmSearchReplaceError;
26 typedef enum {
27 GNM_SRS_WORKBOOK = 0,
28 GNM_SRS_SHEET,
29 GNM_SRS_RANGE
30 } GnmSearchReplaceScope;
31 GType gnm_search_replace_scope_get_type (void);
32 #define GNM_SEARCH_REPLACE_SCOPE_TYPE (gnm_search_replace_scope_get_type ())
34 typedef enum {
35 GNM_SRQ_FAIL,
36 GNM_SRQ_QUERY,
37 GNM_SRQ_QUERY_COMMENT
38 } GnmSearchReplaceQuery;
40 typedef enum {
41 GNM_SRL_CONTENTS,
42 GNM_SRL_VALUE,
43 GNM_SRL_COMMENT
44 } GnmSearchReplaceLocus;
46 typedef int (*GnmSearchReplaceQueryFunc) (GnmSearchReplaceQuery q, GnmSearchReplace *sr, ...);
48 struct _GnmSearchReplace {
49 GOSearchReplace base;
51 GnmSearchReplaceScope scope;
52 char *range_text;
55 * This is the default sheet for the range and used also to locate
56 * a workbook.
58 Sheet *sheet;
60 gboolean query; /* Ask before each change. */
62 gboolean is_number; /* Search for specific number. */
63 gnm_float low_number, high_number; /* protected. */
65 /* The following identify what kinds of cells are the target. */
66 gboolean search_strings;
67 gboolean search_other_values;
68 gboolean search_expressions;
69 gboolean search_expression_results;
70 gboolean search_comments;
71 gboolean search_scripts;
72 gboolean invert;
74 GnmSearchReplaceError error_behaviour;
75 gboolean replace_keep_strings;
78 * If true: A1,B1,...,A2,B2,...
79 * If false: A1,A2,...,B1,B2,...
81 gboolean by_row;
84 * Query and info function.
86 * GNM_SRQ_FAIL (..., GnmCell *cell, char const *old, char const *new)
87 * Inform the user that an error occurred in GNM_SRE_FAIL mode.
89 * GNM_SRQ_QUERY (..., GnmCell *cell, char const *old, char const *new)
90 * Ask user whether to change. GTK_RESPONSE_(YES|NO|CANCEL)
92 * GNM_SRQ_QUERY_COMMENT (..., Sheet *sheet, CellPos *cp,
93 * char const *old, char const *new)
94 * Ask user whether to change. GTK_RESPONSE_(YES|NO|CANCEL)
96 GnmSearchReplaceQueryFunc query_func;
97 void *user_data;
100 GType gnm_search_replace_get_type (void);
102 char *gnm_search_replace_verify (GnmSearchReplace *sr, gboolean repl);
104 GPtrArray *gnm_search_collect_cells (GnmSearchReplace *sr);
105 void gnm_search_collect_cells_free (GPtrArray *cells);
107 typedef struct {
108 GnmEvalPos ep;
109 GnmSearchReplaceLocus locus;
110 } GnmSearchFilterResult;
111 GPtrArray *gnm_search_filter_matching (GnmSearchReplace *sr, GPtrArray const *cells);
112 void gnm_search_filter_matching_free (GPtrArray *matches);
114 typedef struct {
115 GnmComment *comment;
116 char const *old_text;
117 char *new_text; /* Caller must free if replacing and found. */
118 } GnmSearchReplaceCommentResult;
119 gboolean gnm_search_replace_comment (GnmSearchReplace *sr,
120 GnmEvalPos const *ep,
121 gboolean repl,
122 GnmSearchReplaceCommentResult *res);
124 typedef struct {
125 GnmCell *cell;
126 char *old_text; /* Caller must free. */
127 char *new_text; /* Caller must free if replacing and found. */
128 } GnmSearchReplaceCellResult;
129 gboolean gnm_search_replace_cell (GnmSearchReplace *sr,
130 GnmEvalPos const *ep,
131 gboolean repl,
132 GnmSearchReplaceCellResult *res);
134 void gnm_search_replace_query_fail (GnmSearchReplace *sr,
135 const GnmSearchReplaceCellResult *res);
137 int gnm_search_replace_query_cell (GnmSearchReplace *sr,
138 const GnmSearchReplaceCellResult *res);
140 int gnm_search_replace_query_comment (GnmSearchReplace *sr,
141 const GnmEvalPos *ep,
142 const GnmSearchReplaceCommentResult *res);
144 G_END_DECLS
146 #endif /* _GNM_SEARCH_H_ */