Use application properties instead of ugly dual-use global variable
[gnumeric.git] / src / sheet-filter.h
blob2fe7af2c75f121952dbfae5b26f7498edb980924
1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 #ifndef _GNM_SHEET_FILTER_H_
3 # define _GNM_SHEET_FILTER_H_
5 #include "gnumeric.h"
6 #include <goffice/goffice.h>
8 G_BEGIN_DECLS
10 typedef enum {
11 GNM_FILTER_UNUSED = -1,
13 GNM_FILTER_OP_EQUAL = 0, /* exact match, no regecxp */
14 GNM_FILTER_OP_GT,
15 GNM_FILTER_OP_LT,
16 GNM_FILTER_OP_GTE,
17 GNM_FILTER_OP_LTE,
18 GNM_FILTER_OP_NOT_EQUAL, /* exact match, no regecxp */
20 GNM_FILTER_OP_BLANKS = 0x20,
21 GNM_FILTER_OP_NON_BLANKS = 0x21,
23 GNM_FILTER_OP_TOP_N = 0x30,
24 GNM_FILTER_OP_BOTTOM_N = 0x31,
25 GNM_FILTER_OP_TOP_N_PERCENT = 0x32,
26 GNM_FILTER_OP_BOTTOM_N_PERCENT = 0x33,
27 /* Next two added in 1.11.6 */
28 GNM_FILTER_OP_TOP_N_PERCENT_N = 0x34,
29 GNM_FILTER_OP_BOTTOM_N_PERCENT_N = 0x35,
30 GNM_FILTER_OP_BOTTOM_MASK = 0x01,
31 GNM_FILTER_OP_REL_N_MASK = 0x04,
32 GNM_FILTER_OP_PERCENT_MASK = 0x06,
34 /* Added in 1.7.7 */
35 GNM_FILTER_OP_GT_AVERAGE = 0x40,
36 GNM_FILTER_OP_LT_AVERAGE = 0x41,
37 GNM_FILTER_OP_WITHIN_STDDEV = 0x50,
38 GNM_FILTER_OP_OUTSIDE_STDDEV = 0x51,
40 GNM_FILTER_OP_MATCH = 0x60, /* regexp */
41 GNM_FILTER_OP_NO_MATCH = 0x61, /* regexp */
43 GNM_FILTER_OP_TYPE_OP = 0x00,
44 GNM_FILTER_OP_TYPE_BLANKS = 0x20,
45 GNM_FILTER_OP_TYPE_BUCKETS = 0x30,
46 GNM_FILTER_OP_TYPE_AVERAGE = 0x40,
47 GNM_FILTER_OP_TYPE_STDDEV = 0x50,
48 GNM_FILTER_OP_TYPE_MATCH = 0x60,
49 GNM_FILTER_OP_TYPE_MASK = 0x70
50 } GnmFilterOp;
52 struct _GnmFilterCondition {
53 GnmFilterOp op[2];
54 GnmValue *value[2];
55 gboolean is_and;
56 double count;
59 struct _GnmFilter {
60 int ref_count;
61 Sheet *sheet;
62 GnmRange r;
64 GPtrArray *fields;
65 gboolean is_active;
68 GType gnm_filter_condition_get_type (void);
69 GnmFilterCondition *gnm_filter_condition_dup (GnmFilterCondition const *src);
70 void gnm_filter_condition_free (GnmFilterCondition *cond);
71 GnmFilterCondition *gnm_filter_condition_new_single (GnmFilterOp op, GnmValue *v);
72 GnmFilterCondition *gnm_filter_condition_new_double (GnmFilterOp op0, GnmValue *v0,
73 gboolean join_with_and,
74 GnmFilterOp op1, GnmValue *v1);
75 GnmFilterCondition *gnm_filter_condition_new_bucket (gboolean top,
76 gboolean absolute,
77 gboolean rel_range,
78 double n);
80 GType gnm_filter_get_type (void);
81 GnmFilter *gnm_filter_new (Sheet *sheet, GnmRange const *r);
82 GnmFilter *gnm_filter_dup (GnmFilter const *src,
83 Sheet *sheet);
84 GnmFilter * gnm_filter_ref (GnmFilter *filter);
85 void gnm_filter_unref (GnmFilter *filter);
86 void gnm_filter_remove (GnmFilter *filter);
87 void gnm_filter_attach (GnmFilter *filter, Sheet *sheet);
88 GnmFilterCondition const *gnm_filter_get_condition (GnmFilter const *filter, unsigned i);
89 void gnm_filter_set_condition (GnmFilter *filter, unsigned i,
90 GnmFilterCondition *cond,
91 gboolean apply);
92 void gnm_filter_reapply (GnmFilter *filter);
94 GnmFilter *gnm_sheet_filter_at_pos (Sheet const *sheet, GnmCellPos const *pos);
95 GnmFilter *gnm_sheet_filter_intersect_rows (Sheet const *sheet,
96 int from, int to);
97 GnmRange *gnm_sheet_filter_can_be_extended (Sheet const *sheet,
98 GnmFilter const *f,
99 GnmRange const *r);
100 void gnm_sheet_filter_insdel_colrow (Sheet *sheet,
101 gboolean is_cols, gboolean is_insert,
102 int start, int count,
103 GOUndo **pundo);
105 G_END_DECLS
107 #endif /* _GNM_SHEET_FILTER_H_ */