2 * A collection of input filtering and validating functions for use in
3 * XForms dialogs. Mainly meant for filtering input boxes although may
4 * be extended to include other generally useful xforms-specific tools.
10 #pragma implementation
13 #include FORMS_H_LOCATION
14 #include "support/lstrings.h"
15 #include "input_validators.h"
17 #if defined(__cplusplus)
22 int fl_int_filter(FL_OBJECT * ob,
23 char const *, char const *, int c)
25 if (c == 0 /* final test before handing contents to app */
26 || strchr("0123456789+-", c)) {
27 if (isStrInt(fl_get_input(ob)))
30 return FL_INVALID|FL_RINGBELL;
34 int fl_unsigned_int_filter(FL_OBJECT * /*ob*/,
35 char const *, char const *, int c)
37 if (c == 0 /* final test before handing contents to app */
38 || strchr("0123456789", c)) {
39 /* since we only accept numerals then it must be valid */
42 return FL_INVALID|FL_RINGBELL;
46 int fl_float_filter(FL_OBJECT * ob,
47 char const *, char const *, int c)
49 if (c == 0 /* final test before handing contents to app */
50 || strchr("0123456789.+-", c)) {
51 if (isStrDbl(fl_get_input(ob)))
54 return FL_INVALID|FL_RINGBELL;
58 int fl_unsigned_float_filter(FL_OBJECT * ob,
59 char const * /*not_used*/,
60 char const * /*unused*/,
63 if (c == 0 /* final test before handing contents to app */
64 || strchr("0123456789.", c)) {
65 if (isStrDbl(fl_get_input(ob)))
68 return FL_INVALID|FL_RINGBELL;
72 int fl_lowercase_filter(FL_OBJECT * /*ob*/,
73 char const * /*not_used*/,
74 char const * /*unused*/,
77 if (c == 0 /* final test before handing contents to app */
78 || strchr("abcdefghijklmnopqrstuvwxyz0123456789", c)) {
79 /* since we only accept numerals then it must be valid */
82 return FL_INVALID|FL_RINGBELL;
87 /* I've just moved this code here and written a few comments.
88 still to complete it. ARRae 20000518 */
90 void fl_print_range_filter(FL_OBJECT * ob,
91 char const * not_used,
95 /* Started life as changes to PrintApplyCB by Stephan Witt
96 (stephan.witt@beusen.de), 19-Jan-99
97 User may give a page (range) list */
99 if (strchr("0123456789", c)) {
100 /* Numerals are always valid */
102 } else if (strchr("-,", c)) {
103 /* make sure that the character can go there */
105 /* final test before handing contents to app
106 make sure the last char isn't a "-,"
107 That might be acceptable if there was a "to_page"
108 entry however if you start making a page range in the "from"
109 field you can do it all in the "from" field. That is, a
110 range in the "from" field immmediately blanks the "to"
113 return FL_INVALID|FL_RINGBELL;
115 /* The code above should do the same sort of checking as the
118 string pages = subst(fl_get_input(fd_form_print->input_pages), ';',',');
119 pages = trim(subst(pages, '+', ','));
121 while (!pages.empty()) { // a page range was given
123 pages = split (pages, piece, ',') ;
125 if (!stringOnlyContains (piece, "0123456789-")) {
126 Alert::alert(_("ERROR! Unable to print!"),
127 _("Check 'range of pages'!"));
130 if (piece.find('-') == string::npos) { // not found
131 pageflag += lyxrc.print_pagerange_flag + piece + '-' + piece + ' ' ;
132 } else if (suffixIs(piece, "-")) { // missing last page
133 pageflag += lyxrc.print_pagerange_flag + piece + "1000 ";
134 } else if (prefixIs(piece, "-")) { // missing first page
135 pageflag += lyxrc.print_pagerange_flag + '1' + piece + ' ' ;
137 pageflag += lyxrc.print_pagerange_flag + piece + ' ' ;
143 #if defined(__cplusplus)