]> git.lyx.org Git - lyx.git/blobdiff - src/ModuleList.cpp
Fix compilation on win
[lyx.git] / src / ModuleList.cpp
index e53af9b7e9f98d12dc315eefdcc17571cdbb5641..4127c4d39c27390806b7d0d66ce351f4a1c70531 100644 (file)
@@ -45,6 +45,9 @@ LyXModule::LyXModule(string const & n, string const & i,
 
 
 bool LyXModule::isAvailable() {
+#ifdef TEX2LYX
+       return true;
+#else
        if (packageList.empty())
                return true;
        if (checked)
@@ -61,9 +64,42 @@ bool LyXModule::isAvailable() {
        }
        available = true;
        return available;
+#endif
 }
 
 
+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(), id) != 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
 {
@@ -76,7 +112,7 @@ public:
 
 
 //Much of this is borrowed from LayoutFileList::read()
-bool ModuleList::load()
+bool ModuleList::read()
 {
        FileName const real_file = libFileSearch("", "lyxmodules.lst");
        LYXERR(Debug::TCLASS, "Reading modules from `" << real_file << '\'');
@@ -118,7 +154,7 @@ bool ModuleList::load()
                                break;
                        string const fname = lex.getString();
                        LYXERR(Debug::TCLASS, "Filename: " << fname);
-                       if (!lex.next())
+                       if (!lex.next(true))
                                break;
                        string const desc = lex.getString();
                        LYXERR(Debug::TCLASS, "Description: " << desc);
@@ -201,17 +237,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();