X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2Fxforms_helpers.C;h=50fb6409d4fb85485fd65cbb49a8008bd56552fa;hb=37e82a546392d43f787826b85481a11f2a27af15;hp=2bc499d256f8ead1dd6afdbebbdbb9ef9b16381d;hpb=5c4bfd0354f15285f573e19f520ffd65d43aad4b;p=lyx.git diff --git a/src/frontends/xforms/xforms_helpers.C b/src/frontends/xforms/xforms_helpers.C index 2bc499d256..50fb6409d4 100644 --- a/src/frontends/xforms/xforms_helpers.C +++ b/src/frontends/xforms/xforms_helpers.C @@ -12,7 +12,9 @@ #include "xforms_helpers.h" +#include "debug.h" #include "gettext.h" +#include "lengthcommon.h" #include "lyxgluelength.h" #include "lyxlex.h" @@ -28,17 +30,33 @@ #include -using lyx::support::AbsolutePath; -using lyx::support::FileInfo; -using lyx::support::isStrDbl; -using lyx::support::OnlyPath; -using lyx::support::subst; -using lyx::support::trim; - using std::make_pair; using std::ofstream; using std::vector; +using std::string; + +namespace lyx { + +using support::AbsolutePath; +using support::FileInfo; +using support::isStrDbl; +using support::OnlyPath; +using support::subst; +using support::trim; + +namespace frontend { + +std::string const buildChoiceLengthString() +{ + string data; + for (int i = 0; i != num_units; ++i) { + if (i != 0) + data += "|"; + data += subst(unit_name_gui[i], "%", "%%"); + } + return data; +} bool isActive(FL_OBJECT * ob) @@ -177,6 +195,10 @@ void updateWidgetsFromLengthString(FL_OBJECT * input, FL_OBJECT * choice, string const & str, string const & default_unit) { + // Paranoia check + 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()); @@ -197,7 +219,7 @@ void updateWidgetsFromLength(FL_OBJECT * input, FL_OBJECT * choice, { // Paranoia check BOOST_ASSERT(input && input->objclass == FL_INPUT && - choice && choice->objclass == FL_CHOICE); + choice && choice->objclass == FL_CHOICE); if (len.empty()) { fl_set_input(input, ""); @@ -314,9 +336,13 @@ const int xformCount = sizeof(xformTags) / sizeof(keyword_item); bool XformsColor::read(string const & filename) { + FileInfo const f(filename); LyXLex lexrc(xformTags, xformCount); - if (!lexrc.setFile(filename)) + if (f.readable() && !lexrc.setFile(filename)) { + lyxerr << "XformsColor::read(" << filename << ")\n" + << _("Failed to open file.") << std::endl; return false; + } while (lexrc.isOK()) { int const le = lexrc.lex(); @@ -357,8 +383,11 @@ bool XformsColor::read(string const & filename) bool XformsColor::write(string const & filename) { ofstream os(filename.c_str()); - if (!os) + if (!os) { + lyxerr << "XformsColor::write(" << filename << ")\n" + << _("Failed to open file.") << std::endl; return false; + } os << "###" << "### file " << filename << "\n\n" @@ -531,3 +560,6 @@ bool RWInfo::ReadableFile(string const & name) return true; } + +} // namespace frontend +} // namespace lyx