- lyx::Assert(input && input->objclass == FL_INPUT &&
- choice && choice->objclass == FL_CHOICE);
-
- if (str.empty()) {
- fl_set_input(input, "");
- int unitpos = 1; // xforms has Fortran-style indexing
- for(int i = 0; i < fl_get_choice_maxitems(choice); ++i) {
- string const text = fl_get_choice_item_text(choice,i+1);
- if (default_unit ==
- lowercase(strip(frontStrip(text)))) {
- unitpos = i+1;
- break;
- }
- }
- fl_set_choice(choice, unitpos);
- return;
- }
-
- // The unit is presumed to begin at the first char a-z
- string const tmp = lowercase(strip(frontStrip(str)));
-
- string::const_iterator p = tmp.begin();
- for (; p != tmp.end(); ++p) {
- if (*p >= 'a' && *p <= 'z')
- break;
- }
-
- string len = "0";
- int unitpos = 1; // xforms has Fortran-style indexing
-
- if (p == tmp.end()) {
- if (isStrDbl(tmp))
- len = tmp;
-
+ BOOST_ASSERT(input && input->objclass == FL_INPUT &&
+ choice && choice->objclass == FL_CHOICE);
+
+ // use input field only for gluelengths
+ if (!isValidLength(str) && !isStrDbl(str)) {
+ fl_set_input(input, str.c_str());
+ // we assume that "default_unit" is in the choice as "we"
+ // have control over that!
+ // No need to check for its presence in the choice, therefore.
+ fl_set_choice_text(choice, default_unit.c_str());