// Is the module already present?
const_iterator it = begin();
const_iterator const en = end();
- for (; it != en; it++)
+ for (; it != en; ++it)
if (*it == modName)
return false;
- LyXModule const * const lm = moduleList[modName];
+ LyXModule const * const lm = theModuleList[modName];
if (!lm)
return true;
- // Is this module explicitly excluded by the document class?
- const_iterator const exclmodstart = lay->excludedModules().begin();
- const_iterator const exclmodend = lay->excludedModules().end();
- if (find(exclmodstart, exclmodend, modName) != exclmodend)
+ // Does this module conflict with the document class or any loaded modules?
+ if (moduleConflicts(modName, lay))
return false;
// Is this module already provided by the document class?
if (find(provmodstart, provmodend, modName) != provmodend)
return false;
- // Check for conflicts with used modules
- // first the provided modules...
- const_iterator provmodit = provmodstart;
- for (; provmodit != provmodend; ++provmodit) {
- if (!LyXModule::areCompatible(modName, *provmodit))
- return false;
- }
- // and then the selected modules
- const_iterator mit = begin();
- const_iterator const men = end();
- for (; mit != men; ++mit)
- if (!LyXModule::areCompatible(modName, *mit))
- return false;
-
// Check whether some required module is available
vector<string> const reqs = lm->getRequiredModules();
if (reqs.empty())
return true;
- mit = begin(); // reset
+ const_iterator mit = begin();
+ const_iterator const men = end();
vector<string>::const_iterator rit = reqs.begin();
vector<string>::const_iterator ren = reqs.end();
bool foundone = false;
}
+bool LayoutModuleList::moduleConflicts(string const & modName,
+ LayoutFile const * const lay) const
+{
+ // Is this module explicitly excluded by the document class?
+ const_iterator const exclmodstart = lay->excludedModules().begin();
+ const_iterator const exclmodend = lay->excludedModules().end();
+ if (find(exclmodstart, exclmodend, modName) != exclmodend)
+ return true;
+ // Check for conflicts with used modules
+ // first the provided modules...
+ const_iterator provmodit = lay->providedModules().begin();
+ const_iterator const provmodend = lay->providedModules().end();
+ for (; provmodit != provmodend; ++provmodit) {
+ if (!LyXModule::areCompatible(modName, *provmodit))
+ return true;
+ }
+ // and then the selected modules
+ const_iterator mit = begin();
+ const_iterator const men = end();
+ for (; mit != men; ++mit)
+ if (!LyXModule::areCompatible(modName, *mit))
+ return true;
+ return false;
+}
+
+
void LayoutModuleList::addDefaultModules(LayoutFile const * const lay,
std::list<string> removedModules)
{
iterator insertpos = begin();
int numinserts = 0;
- for (; mit != men; mit++) {
+ for (; mit != men; ++mit) {
string const & modName = *mit;
// make sure the user hasn't removed it
if (find(removedModules.begin(), removedModules.end(), modName) !=
for (; !excluded && pit != pen; ++pit) {
if (!LyXModule::areCompatible(modname, *pit)) {
LYXERR0("Module " << modname <<
- " dropped becuase it conflicts with provided module `" << *pit << "'.");
+ " dropped because it conflicts with provided module `" << *pit << "'.");
consistent = false;
excluded = true;
}
// determine whether some provided module or some prior module
// satisfies our requirements
- LyXModule const * const oldmod = moduleList[modname];
+ LyXModule const * const oldmod = theModuleList[modname];
if (!oldmod) {
LYXERR0("Default module " << modname <<
" added although it is unavailable and can't check requirements.");