2 * A collection of input filtering and validating functions for use in
3 * XForms popups. 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 "input_validators.h"
11 #if defined(__cplusplus)
16 int fl_unsigned_int_filter(FL_OBJECT * ob,
17 char const * not_used,
21 if (c == 0 /* final test before handing contents to app */
22 || strchr("0123456789", c)) {
23 /* since we only accept numerals then it must be valid */
26 return FL_INVALID|FL_RINGBELL;
30 int fl_lowercase_filter(FL_OBJECT * ob,
31 char const * not_used,
35 if (c == 0 /* final test before handing contents to app */
36 || strchr("abcdefghijklmnopqrstuvwxyz", c)) {
37 /* since we only accept numerals then it must be valid */
40 return FL_INVALID|FL_RINGBELL;
45 /* I've just moved this code here and written a few comments.
46 still to complete it. ARRae 20000518 */
48 void fl_print_range_filter(FL_OBJECT * ob,
49 char const * not_used,
53 /* Started life as changes to PrintApplyCB by Stephan Witt
54 (stephan.witt@beusen.de), 19-Jan-99
55 User may give a page (range) list */
57 if (strchr("0123456789", c)) {
58 /* Numerals are always valid */
60 } else if (strchr("-,", c)) {
61 /* make sure that the character can go there */
63 /* final test before handing contents to app
64 make sure the last char isn't a "-,"
65 That might be acceptable if there was a "to_page"
66 entry however if you start making a page range in the "from"
67 field you can do it all in the "from" field. That is, a
68 range in the "from" field immmediately blanks the "to"
71 return FL_INVALID|FL_RINGBELL;
73 /* The code above should do the same sort of checking as the
76 string pages = subst(fl_get_input(fd_form_print->input_pages), ';',',');
77 pages = subst(pages, '+',',');
78 pages = frontStrip(strip(pages)) ;
79 while (!pages.empty()) { // a page range was given
81 pages = split (pages, piece, ',') ;
82 piece = strip(piece) ;
83 piece = frontStrip(piece) ;
84 if ( !stringOnlyContains (piece, "0123456789-") ) {
85 WriteAlert(_("ERROR! Unable to print!"),
86 _("Check 'range of pages'!"));
89 if (piece.find('-') == string::npos) { // not found
90 pageflag += lyxrc.print_pagerange_flag + piece + '-' + piece + ' ' ;
91 } else if (suffixIs(piece, "-") ) { // missing last page
92 pageflag += lyxrc.print_pagerange_flag + piece + "1000 ";
93 } else if (prefixIs(piece, "-") ) { // missing first page
94 pageflag += lyxrc.print_pagerange_flag + '1' + piece + ' ' ;
96 pageflag += lyxrc.print_pagerange_flag + piece + ' ' ;
102 #if defined(__cplusplus)