Fix bug #7044: Better error messages when modules are unavailable. Patch

from Julien Rioux, modified by me.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37207 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2011-01-13 21:19:14 +00:00
parent 1b263187cd
commit 28e08b23e2
3 changed files with 25 additions and 6 deletions

View File

@ -45,6 +45,17 @@ LyXModule::LyXModule(string const & n, string const & i,
}
vector<string> LyXModule::prerequisites() const {
#ifdef TEX2LYX
return vector<string>();
#else
if (!checked_)
isAvailable();
return prerequisites_;
#endif
}
bool LyXModule::isAvailable() const {
#ifdef TEX2LYX
return true;
@ -54,16 +65,16 @@ bool LyXModule::isAvailable() const {
if (checked_)
return available_;
checked_ = true;
available_ = true;
//check whether all of the required packages are available
vector<string>::const_iterator it = package_list_.begin();
vector<string>::const_iterator end = package_list_.end();
for (; it != end; ++it) {
if (!LaTeXFeatures::isAvailable(*it)) {
available_ = false;
return available_;
prerequisites_.push_back(*it);
}
}
available_ = true;
return available_;
#endif
}

View File

@ -58,6 +58,8 @@ public:
std::string const & catgy);
/// whether the required packages are available
bool isAvailable() const;
/// the missing prerequisites, if any
std::vector<std::string> prerequisites() const;
///
std::string const & getName() const { return name_; }
///
@ -108,6 +110,8 @@ private:
mutable bool checked_;
///
mutable bool available_;
///
mutable std::vector<std::string> prerequisites_;
};
typedef std::vector<LyXModule> LyXModuleList;

View File

@ -1308,11 +1308,15 @@ DocumentClass & DocumentClassBundle::makeDocumentClass(
continue;
}
if (!lm->isAvailable()) {
docstring const prereqs = from_utf8(getStringFromVector(lm->prerequisites(), "\n\t"));
docstring const msg =
bformat(_("The module %1$s requires a package that is\n"
"not available in your LaTeX installation, or a converter\n"
"you have not installed. LaTeX output may not be possible.\n"),
from_utf8(modName));
bformat(_("The module %1$s requires a package that is not\n"
"available in your LaTeX installation, or a converter that\n"
"you have not installed. LaTeX output may not be possible.\n"
"Missing prerequisites:\n"
"\t%2$s\n"
"See section 3.1.2.3 of the User's Guide for more information."),
from_utf8(modName), prereqs);
frontend::Alert::warning(_("Package not available"), msg);
}
FileName layout_file = libFileSearch("layouts", lm->getFilename());