]> git.lyx.org Git - lyx.git/blobdiff - src/ModuleList.cpp
* Call metrics of the parameters with the correct font in MathMacros, for example
[lyx.git] / src / ModuleList.cpp
index b22f48d8e62972c51b9027afa7c1f7b27108a9bd..547f1f922072a74a4c5c19ed4b84f222bf9de0a1 100644 (file)
@@ -22,7 +22,6 @@
 #include "support/lstrings.h"
 
 #include <algorithm>
-#include <ostream>
        
 using namespace std;
 using namespace lyx::support;
@@ -65,6 +64,38 @@ bool LyXModule::isAvailable() {
 }
 
 
+bool LyXModule::isCompatible(string const & modName) const
+{
+       // do we exclude it?
+       if (find(excludedModules.begin(), excludedModules.end(), modName) !=
+                       excludedModules.end())
+               return false;
+
+       LyXModule const * const lm = moduleList[modName];
+       if (!lm)
+               return true;
+
+       // does it exclude us?
+       vector<string> const excMods = lm->getExcludedModules();
+       if (find(excMods.begin(), excMods.end(), name) != excMods.end())
+               return false;
+
+       return true;
+}
+
+
+bool LyXModule::areCompatible(string const & mod1, string const & mod2)
+{
+       LyXModule const * const lm1 = moduleList[mod1];
+       if (lm1)
+               return lm1->isCompatible(mod2);
+       LyXModule const * const lm2 = moduleList[mod2];
+       if (lm2)
+               return lm2->isCompatible(mod1);
+       // Can't check it either way.
+       return true;
+}
+
 // used when sorting the module list.
 class ModuleSorter
 {
@@ -83,27 +114,23 @@ bool ModuleList::load()
        LYXERR(Debug::TCLASS, "Reading modules from `" << real_file << '\'');
 
        if (real_file.empty()) {
-               lyxerr << "ModuleList::load(): unable to find "
-                               "modules file  `"
-                               << to_utf8(makeDisplayPath(real_file.absFilename(), 1000))
-                               << "'.\nNo modules will be available." << endl;
+               LYXERR0("unable to find modules file  `"
+                       << to_utf8(makeDisplayPath(real_file.absFilename(), 1000))
+                       << "'.\nNo modules will be available.");
                return false;
        }
 
        Lexer lex;
        if (!lex.setFile(real_file)) {
-               lyxerr << "ModuleList::load():"
-                               "lyxlex was not able to set file: "
-                               << real_file << ".\nNo modules will be available." << endl;
+               LYXERR0("lyxlex was not able to set file: "
+                       << real_file << ".\nNo modules will be available.");
                return false;
        }
 
        if (!lex.isOK()) {
-               lyxerr << "ModuleList::load():" <<
-                               "unable to open modules file  `"
-                               << to_utf8(makeDisplayPath(real_file.absFilename(), 1000))
-                               << "'\nNo modules will be available."
-                               << endl;
+               LYXERR0("unable to open modules file  `"
+                       << to_utf8(makeDisplayPath(real_file.absFilename(), 1000))
+                       << "'\nNo modules will be available.");
                return false;
        }
 
@@ -206,17 +233,6 @@ LyXModuleList::iterator ModuleList::end()
 }
 
 
-LyXModule * ModuleList::getModuleByName(string const & str)
-{
-       LyXModuleList::iterator it = modlist_.begin();
-       for (; it != modlist_.end(); ++it)
-               if (it->getName() == str) {
-                       LyXModule & mod = *it;
-                       return &mod;
-               }
-       return 0;
-}
-
 LyXModule * ModuleList::operator[](string const & str)
 {
        LyXModuleList::iterator it = modlist_.begin();