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;
31 /* I've just moved this code here and written a few comments.
32 still to complete it. ARRae 20000518 */
34 void fl_print_range_filter(FL_OBJECT * ob,
35 char const * not_used,
39 /* Started life as changes to PrintApplyCB by Stephan Witt
40 (stephan.witt@beusen.de), 19-Jan-99
41 User may give a page (range) list */
43 if (strchr("0123456789", c)) {
44 /* Numerals are always valid */
46 } else if (strchr("-,", c)) {
47 /* make sure that the character can go there */
49 /* final test before handing contents to app
50 make sure the last char isn't a "-,"
51 That might be acceptable if there was a "to_page"
52 entry however if you start making a page range in the "from"
53 field you can do it all in the "from" field. That is, a
54 range in the "from" field immmediately blanks the "to"
57 return FL_INVALID|FL_RINGBELL;
59 /* The code above should do the same sort of checking as the
62 string pages = subst(fl_get_input(fd_form_print->input_pages), ';',',');
63 pages = subst(pages, '+',',');
64 pages = frontStrip(strip(pages)) ;
65 while (!pages.empty()) { // a page range was given
67 pages = split (pages, piece, ',') ;
68 piece = strip(piece) ;
69 piece = frontStrip(piece) ;
70 if ( !stringOnlyContains (piece, "0123456789-") ) {
71 WriteAlert(_("ERROR! Unable to print!"),
72 _("Check 'range of pages'!"));
75 if (piece.find('-') == string::npos) { // not found
76 pageflag += lyxrc.print_pagerange_flag + piece + '-' + piece + ' ' ;
77 } else if (suffixIs(piece, "-") ) { // missing last page
78 pageflag += lyxrc.print_pagerange_flag + piece + "1000 ";
79 } else if (prefixIs(piece, "-") ) { // missing first page
80 pageflag += lyxrc.print_pagerange_flag + '1' + piece + ' ' ;
82 pageflag += lyxrc.print_pagerange_flag + piece + ' ' ;
88 #if defined(__cplusplus)