2 # define _GNM_SEARCH_H_
7 #include <goffice/goffice.h>
11 char *gnm_search_normalize (const char *txt
);
13 #define GNM_SEARCH_REPLACE_TYPE (gnm_search_replace_get_type ())
14 #define GNM_SEARCH_REPLACE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNM_SEARCH_REPLACE_TYPE, GnmSearchReplace))
15 #define GNM_IS_SEARCH_REPLACE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNM_SEARCH_REPLACE_TYPE))
23 } GnmSearchReplaceError
;
29 } GnmSearchReplaceScope
;
30 GType
gnm_search_replace_scope_get_type (void);
31 #define GNM_SEARCH_REPLACE_SCOPE_TYPE (gnm_search_replace_scope_get_type ())
37 } GnmSearchReplaceQuery
;
43 } GnmSearchReplaceLocus
;
45 typedef int (*GnmSearchReplaceQueryFunc
) (GnmSearchReplaceQuery q
, GnmSearchReplace
*sr
, ...);
47 struct _GnmSearchReplace
{
50 GnmSearchReplaceScope scope
;
54 * This is the default sheet for the range and used also to locate
59 gboolean query
; /* Ask before each change. */
61 gboolean is_number
; /* Search for specific number. */
62 gnm_float low_number
, high_number
; /* protected. */
64 /* The following identify what kinds of cells are the target. */
65 gboolean search_strings
;
66 gboolean search_other_values
;
67 gboolean search_expressions
;
68 gboolean search_expression_results
;
69 gboolean search_comments
;
70 gboolean search_scripts
;
73 GnmSearchReplaceError error_behaviour
;
74 gboolean replace_keep_strings
;
77 * If true: A1,B1,...,A2,B2,...
78 * If false: A1,A2,...,B1,B2,...
83 * Query and info function.
85 * GNM_SRQ_FAIL (..., GnmCell *cell, char const *old, char const *new)
86 * Inform the user that an error occurred in GNM_SRE_FAIL mode.
88 * GNM_SRQ_QUERY (..., GnmCell *cell, char const *old, char const *new)
89 * Ask user whether to change. GTK_RESPONSE_(YES|NO|CANCEL)
91 * GNM_SRQ_QUERY_COMMENT (..., Sheet *sheet, CellPos *cp,
92 * char const *old, char const *new)
93 * Ask user whether to change. GTK_RESPONSE_(YES|NO|CANCEL)
95 GnmSearchReplaceQueryFunc query_func
;
99 GType
gnm_search_replace_get_type (void);
101 char *gnm_search_replace_verify (GnmSearchReplace
*sr
, gboolean repl
);
103 GPtrArray
*gnm_search_collect_cells (GnmSearchReplace
*sr
);
104 void gnm_search_collect_cells_free (GPtrArray
*cells
);
108 GnmSearchReplaceLocus locus
;
109 } GnmSearchFilterResult
;
110 GPtrArray
*gnm_search_filter_matching (GnmSearchReplace
*sr
, GPtrArray
const *cells
);
111 void gnm_search_filter_matching_free (GPtrArray
*matches
);
115 char const *old_text
;
116 char *new_text
; /* Caller must free if replacing and found. */
117 } GnmSearchReplaceCommentResult
;
118 gboolean
gnm_search_replace_comment (GnmSearchReplace
*sr
,
119 GnmEvalPos
const *ep
,
121 GnmSearchReplaceCommentResult
*res
);
125 char *old_text
; /* Caller must free. */
126 char *new_text
; /* Caller must free if replacing and found. */
127 } GnmSearchReplaceCellResult
;
128 gboolean
gnm_search_replace_cell (GnmSearchReplace
*sr
,
129 GnmEvalPos
const *ep
,
131 GnmSearchReplaceCellResult
*res
);
133 void gnm_search_replace_query_fail (GnmSearchReplace
*sr
,
134 const GnmSearchReplaceCellResult
*res
);
136 int gnm_search_replace_query_cell (GnmSearchReplace
*sr
,
137 const GnmSearchReplaceCellResult
*res
);
139 int gnm_search_replace_query_comment (GnmSearchReplace
*sr
,
140 const GnmEvalPos
*ep
,
141 const GnmSearchReplaceCommentResult
*res
);
145 #endif /* _GNM_SEARCH_H_ */