1 #ifndef _GNM_VALIDATION_H_ 2 # define _GNM_VALIDATION_H_ 3 4 #include <gnumeric.h> 5 #include <dependent.h> 6 7 G_BEGIN_DECLS 8 9 typedef enum { 10 GNM_VALIDATION_STATUS_VALID, /* things validate */ 11 GNM_VALIDATION_STATUS_INVALID_DISCARD, /* things do not validate and should be discarded */ 12 GNM_VALIDATION_STATUS_INVALID_EDIT /* things do not validate and editing should continue */ 13 } ValidationStatus; 14 typedef enum { 15 GNM_VALIDATION_STYLE_NONE, 16 GNM_VALIDATION_STYLE_STOP, 17 GNM_VALIDATION_STYLE_WARNING, 18 GNM_VALIDATION_STYLE_INFO, 19 GNM_VALIDATION_STYLE_PARSE_ERROR 20 } ValidationStyle; 21 typedef enum { 22 GNM_VALIDATION_TYPE_ANY, 23 GNM_VALIDATION_TYPE_AS_INT, 24 GNM_VALIDATION_TYPE_AS_NUMBER, 25 GNM_VALIDATION_TYPE_IN_LIST, 26 GNM_VALIDATION_TYPE_AS_DATE, 27 GNM_VALIDATION_TYPE_AS_TIME, 28 GNM_VALIDATION_TYPE_TEXT_LENGTH, 29 GNM_VALIDATION_TYPE_CUSTOM 30 } ValidationType; 31 typedef enum { 32 GNM_VALIDATION_OP_NONE = -1, 33 GNM_VALIDATION_OP_BETWEEN, 34 GNM_VALIDATION_OP_NOT_BETWEEN, 35 GNM_VALIDATION_OP_EQUAL, 36 GNM_VALIDATION_OP_NOT_EQUAL, 37 GNM_VALIDATION_OP_GT, 38 GNM_VALIDATION_OP_LT, 39 GNM_VALIDATION_OP_GTE, 40 GNM_VALIDATION_OP_LTE 41 } ValidationOp; 42 43 struct _GnmValidation { 44 int ref_count; 45 46 GOString *title; 47 GOString *msg; 48 GnmDepManaged deps[2]; 49 ValidationStyle style; 50 ValidationType type; 51 ValidationOp op; 52 gboolean allow_blank; 53 gboolean use_dropdown; 54 }; 55 56 GType gnm_validation_type_get_type (void); 57 #define GNM_VALIDATION_TYPE_TYPE (gnm_validation_type_get_type ()) 58 59 GType gnm_validation_style_get_type (void); 60 #define GNM_VALIDATION_STYLE_TYPE (gnm_validation_style_get_type ()) 61 62 GType gnm_validation_op_get_type (void); 63 #define GNM_VALIDATION_OP_TYPE (gnm_validation_op_get_type ()) 64 65 66 GType gnm_validation_get_type (void); 67 GnmValidation *gnm_validation_new (ValidationStyle style, 68 ValidationType type, 69 ValidationOp op, 70 Sheet *sheet, 71 char const *title, char const *msg, 72 GnmExprTop const *texpr0, 73 GnmExprTop const *texpr1, 74 gboolean allow_blank, 75 gboolean use_dropdown); 76 GnmValidation *gnm_validation_dup_to(GnmValidation *v, Sheet *sheet); 77 gboolean gnm_validation_equal (GnmValidation const *a, 78 GnmValidation const *b, 79 gboolean relax_sheet); 80 81 GnmValidation *gnm_validation_ref (GnmValidation const *v); 82 void gnm_validation_unref (GnmValidation const *v); 83 84 void gnm_validation_set_expr (GnmValidation *v, 85 GnmExprTop const *texpr, unsigned indx); 86 GError *gnm_validation_is_ok (GnmValidation const *v); 87 88 Sheet *gnm_validation_get_sheet (GnmValidation const *v); 89 90 ValidationStatus gnm_validation_eval (WorkbookControl *wbc, 91 GnmStyle const *mstyle, 92 Sheet *sheet, GnmCellPos const *pos, 93 gboolean *showed_dialog); 94 ValidationStatus gnm_validation_eval_range (WorkbookControl *wbc, 95 Sheet *sheet, 96 GnmCellPos const *pos, 97 GnmRange const *r, 98 gboolean *showed_dialog); 99 100 G_END_DECLS 101 102 #endif /* _GNM_VALIDATION_H_ */ 103