Add UseModule tag for layout files. This allows the AMS files, in particular, to "require" the

theorems-ams module, which is what most users will want. A later commit will allow users also
to "exclude" this module, in case they wanted to do that.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25880 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2008-07-25 15:51:27 +00:00
parent c39644a26b
commit 56a35c2c61
7 changed files with 62 additions and 7 deletions

View File

@ -19,6 +19,7 @@ ClassOptions
FontSize 8|9|10|11|12
End
UseModule theorems-ams
Style Standard
Category MainText

View File

@ -20,6 +20,7 @@ ClassOptions
FontSize 8|9|10|11|12
End
UseModule theorems-ams
Style Standard
Category MainText

View File

@ -25,7 +25,10 @@ import os, re, string, sys
# Incremented to format 7, 24 March 2008 by rgh
# AddToPreamble tag added to layout files
currentFormat = 7
# Incremented to format 8, 25 July 2008 by rgh
# UseModule tag added to layout files
currentFormat = 8
def usage(prog_name):

View File

@ -1462,10 +1462,45 @@ void BufferParams::makeDocumentClass()
return;
doc_class_ = &(DocumentClassBundle::get().newClass(*baseClass()));
// add any required modules not already in use
set<string> const & mods = baseClass()->defaultModules();
set<string>::const_iterator mit = mods.begin();
set<string>::const_iterator men = mods.end();
for (; mit != men; mit++) {
string const & modName = *mit;
LayoutModuleList::const_iterator const fit =
find(layoutModules_.begin(), layoutModules_.end(), modName);
if (fit == layoutModules_.end()) {
// We need to make sure there's no module chosen that excludes this one
LayoutModuleList::const_iterator lit = layoutModules_.begin();
LayoutModuleList::const_iterator len = layoutModules_.end();
bool foundit = false;
// so iterate over the selected modules...
for (; lit != len; lit++) {
LyXModule * lm = moduleList[*lit];
if (!lm)
continue;
vector<string> const & exc = lm->getExcludedModules();
// ...and see if one of them excludes us.
if (find(exc.begin(), exc.end(), modName) != exc.end()) {
foundit = true;
LYXERR(Debug::TCLASS, "Default module `" << modName <<
"' not added because excluded by loaded module `" <<
*lit << "'.");
break;
}
}
if (!foundit) {
LYXERR(Debug::TCLASS, "Default module `" << modName << "' added.");
layoutModules_.push_back(modName);
}
}
}
//FIXME It might be worth loading the children's modules here,
//just as we load their bibliographies and such, instead of just
//doing a check in InsetInclude.
// FIXME It might be worth loading the children's modules here,
// just as we load their bibliographies and such, instead of just
// doing a check in InsetInclude.
LayoutModuleList::const_iterator it = layoutModules_.begin();
for (; it != layoutModules_.end(); it++) {
string const modName = *it;

View File

@ -18,6 +18,8 @@
#include <boost/noncopyable.hpp>
#include <set>
#include <string>
#include <vector>
@ -61,6 +63,8 @@ class LayoutFile : public TextClass, boost::noncopyable {
public:
/// check whether the TeX class is available
bool isTeXClassAvailable() const { return texClassAvail_; }
///
std::set<std::string> const & defaultModules() const { return usemod_; }
private:
/// Construct a layout with default values. Actual values loaded later.
explicit LayoutFile(std::string const & filename,

View File

@ -61,7 +61,7 @@ private:
};
int const FORMAT = 7;
int const FORMAT = 8;
bool layout2layout(FileName const & filename, FileName const & tempfile)
@ -182,7 +182,8 @@ enum TextClassTags {
TC_TITLELATEXNAME,
TC_TITLELATEXTYPE,
TC_FORMAT,
TC_ADDTOPREAMBLE
TC_ADDTOPREAMBLE,
TC_USEMODULE
};
@ -213,7 +214,8 @@ namespace {
{ "style", TC_STYLE },
{ "titlelatexname", TC_TITLELATEXNAME },
{ "titlelatextype", TC_TITLELATEXTYPE },
{ "tocdepth", TC_TOCDEPTH }
{ "tocdepth", TC_TOCDEPTH },
{ "usemodule", TC_USEMODULE }
};
} //namespace anon
@ -491,6 +493,13 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
break;
}
case TC_USEMODULE: {
lexrc.next();
string const module = lexrc.getString();
usemod_.insert(module);
break;
}
case TC_LEFTMARGIN: // left margin type
if (lexrc.next())
leftmargin_ = lexrc.getDocString();

View File

@ -246,6 +246,8 @@ protected:
std::set<std::string> provides_;
/// latex packages requested by document class.
std::set<std::string> requires_;
/// modules wanted by document class
std::set<std::string> usemod_;
///
unsigned int columns_;
///