1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 # define _GNM_SEARCH_H_
8 #include <goffice/goffice.h>
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))
24 } GnmSearchReplaceError
;
30 } GnmSearchReplaceScope
;
31 GType
gnm_search_replace_scope_get_type (void);
32 #define GNM_SEARCH_REPLACE_SCOPE_TYPE (gnm_search_replace_scope_get_type ())
38 } GnmSearchReplaceQuery
;
44 } GnmSearchReplaceLocus
;
46 typedef int (*GnmSearchReplaceQueryFunc
) (GnmSearchReplaceQuery q
, GnmSearchReplace
*sr
, ...);
48 struct _GnmSearchReplace
{
51 GnmSearchReplaceScope scope
;
55 * This is the default sheet for the range and used also to locate
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
;
74 GnmSearchReplaceError error_behaviour
;
75 gboolean replace_keep_strings
;
78 * If true: A1,B1,...,A2,B2,...
79 * If false: A1,A2,...,B1,B2,...
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
;
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
);
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
);
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
,
122 GnmSearchReplaceCommentResult
*res
);
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
,
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
);
146 #endif /* _GNM_SEARCH_H_ */