3 * A collection of input filtering and validating functions for use in
4 * XForms popups. Mainly meant for filtering input boxes although may
5 * be extended to include other generally useful xforms-specific tools.
9 #include FORMS_H_LOCATION
10 #include "input_validators.h"
12 #if defined(__cplusplus)
17 int fl_unsigned_int_filter(FL_OBJECT * ob,
18 char const * not_used,
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;
32 // I've just moved this code here and written a few comments.
33 // still to complete it. ARRae 20000518
35 void fl_print_range_filter(FL_OBJECT * ob,
36 char const * not_used,
40 // Started life as changes to PrintApplyCB by Stephan Witt
41 // (stephan.witt@beusen.de), 19-Jan-99
42 // User may give a page (range) list
44 if (strchr("0123456789", c)) {
45 // Numerals are always valid
47 } else if (strchr("-,", c)) {
48 // make sure that the character can go there
50 // final test before handing contents to app
51 // make sure the last char isn't a "-,"
52 // That might be acceptable if there was a "to_page"
53 // entry however if you start making a page range in the "from"
54 // field you can do it all in the "from" field. That is, a
55 // range in the "from" field immmediately blanks the "to"
58 return FL_INVALID|FL_RINGBELL;
60 // The code above should do the same sort of checking as the
63 string pages = subst(fl_get_input(fd_form_print->input_pages), ';',',');
64 pages = subst(pages, '+',',');
65 pages = frontStrip(strip(pages)) ;
66 while (!pages.empty()) { // a page range was given
68 pages = split (pages, piece, ',') ;
69 piece = strip(piece) ;
70 piece = frontStrip(piece) ;
71 if ( !stringOnlyContains (piece, "0123456789-") ) {
72 WriteAlert(_("ERROR! Unable to print!"),
73 _("Check 'range of pages'!"));
76 if (piece.find('-') == string::npos) { // not found
77 pageflag += lyxrc.print_pagerange_flag + piece + '-' + piece + ' ' ;
78 } else if (suffixIs(piece, "-") ) { // missing last page
79 pageflag += lyxrc.print_pagerange_flag + piece + "1000 ";
80 } else if (prefixIs(piece, "-") ) { // missing first page
81 pageflag += lyxrc.print_pagerange_flag + '1' + piece + ' ' ;
83 pageflag += lyxrc.print_pagerange_flag + piece + ' ' ;
89 #if defined(__cplusplus)