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.
8 #include FORMS_H_LOCATION
9 #include "support/lstrings.h"
10 #include "input_validators.h"
12 #if defined(__cplusplus)
17 int fl_unsigned_int_filter(FL_OBJECT * /*ob*/,
18 char const * /*not_used*/,
19 char const * /*unused*/,
22 if (c == 0 /* final test before handing contents to app */
23 || strchr("0123456789", c)) {
24 /* since we only accept numerals then it must be valid */
27 return FL_INVALID|FL_RINGBELL;
31 int fl_unsigned_float_filter(FL_OBJECT * ob,
32 char const * /*not_used*/,
33 char const * /*unused*/,
36 if (c == 0 /* final test before handing contents to app */
37 || strchr("0123456789.", c)) {
38 if (isStrDbl(fl_get_input(ob)))
41 return FL_INVALID|FL_RINGBELL;
43 return FL_INVALID|FL_RINGBELL;
47 int fl_lowercase_filter(FL_OBJECT * /*ob*/,
48 char const * /*not_used*/,
49 char const * /*unused*/,
52 if (c == 0 /* final test before handing contents to app */
53 || strchr("abcdefghijklmnopqrstuvwxyz0123456789", c)) {
54 /* since we only accept numerals then it must be valid */
57 return FL_INVALID|FL_RINGBELL;
62 /* I've just moved this code here and written a few comments.
63 still to complete it. ARRae 20000518 */
65 void fl_print_range_filter(FL_OBJECT * ob,
66 char const * not_used,
70 /* Started life as changes to PrintApplyCB by Stephan Witt
71 (stephan.witt@beusen.de), 19-Jan-99
72 User may give a page (range) list */
74 if (strchr("0123456789", c)) {
75 /* Numerals are always valid */
77 } else if (strchr("-,", c)) {
78 /* make sure that the character can go there */
80 /* final test before handing contents to app
81 make sure the last char isn't a "-,"
82 That might be acceptable if there was a "to_page"
83 entry however if you start making a page range in the "from"
84 field you can do it all in the "from" field. That is, a
85 range in the "from" field immmediately blanks the "to"
88 return FL_INVALID|FL_RINGBELL;
90 /* The code above should do the same sort of checking as the
93 string pages = subst(fl_get_input(fd_form_print->input_pages), ';',',');
94 pages = subst(pages, '+',',');
95 pages = frontStrip(strip(pages)) ;
96 while (!pages.empty()) { // a page range was given
98 pages = split (pages, piece, ',') ;
99 piece = strip(piece) ;
100 piece = frontStrip(piece) ;
101 if (!stringOnlyContains (piece, "0123456789-")) {
102 WriteAlert(_("ERROR! Unable to print!"),
103 _("Check 'range of pages'!"));
106 if (piece.find('-') == string::npos) { // not found
107 pageflag += lyxrc.print_pagerange_flag + piece + '-' + piece + ' ' ;
108 } else if (suffixIs(piece, "-")) { // missing last page
109 pageflag += lyxrc.print_pagerange_flag + piece + "1000 ";
110 } else if (prefixIs(piece, "-")) { // missing first page
111 pageflag += lyxrc.print_pagerange_flag + '1' + piece + ' ' ;
113 pageflag += lyxrc.print_pagerange_flag + piece + ' ' ;
119 #if defined(__cplusplus)