]> git.lyx.org Git - lyx.git/blobdiff - src/TextClass.cpp
Update my email and status.
[lyx.git] / src / TextClass.cpp
index ee4181c7de74d7a40118dab2baf0bb4cfc512ab2..e5d84c82e1d5fd34d9239bb89fe98fd1a1a2c6d2 100644 (file)
@@ -60,7 +60,7 @@ namespace lyx {
 // development/tools/updatelayouts.sh script, to update the format of
 // all of our layout files.
 //
-int const LAYOUT_FORMAT = 39; //sanda branch styling
+int const LAYOUT_FORMAT = 43; // spitz: extended InsetCaption format
 
 namespace {
 
@@ -222,50 +222,50 @@ enum TextClassTags {
 
 namespace {
 
-       LexerKeyword textClassTags[] = {
-               { "addtohtmlpreamble", TC_ADDTOHTMLPREAMBLE },
-               { "addtohtmlstyles",   TC_ADDTOHTMLSTYLES },
-               { "addtopreamble",     TC_ADDTOPREAMBLE },
-               { "citeengine",        TC_CITEENGINE },
-               { "citeenginetype",    TC_CITEENGINETYPE },
-               { "citeformat",        TC_CITEFORMAT },
-               { "classoptions",      TC_CLASSOPTIONS },
-               { "columns",           TC_COLUMNS },
-               { "counter",           TC_COUNTER },
-               { "defaultbiblio",     TC_DEFAULTBIBLIO },
-               { "defaultfont",       TC_DEFAULTFONT },
-               { "defaultmodule",     TC_DEFAULTMODULE },
-               { "defaultstyle",      TC_DEFAULTSTYLE },
-               { "excludesmodule",    TC_EXCLUDESMODULE },
-               { "float",             TC_FLOAT },
-               { "format",            TC_FORMAT },
-               { "fullauthorlist",    TC_FULLAUTHORLIST },
-               { "htmlpreamble",      TC_HTMLPREAMBLE },
-               { "htmlstyles",        TC_HTMLSTYLES },
-               { "htmltocsection",    TC_HTMLTOCSECTION },
-               { "ifcounter",         TC_IFCOUNTER },
-               { "ifstyle",           TC_IFSTYLE },
-               { "input",             TC_INPUT },
-               { "insetlayout",       TC_INSETLAYOUT },
-               { "leftmargin",        TC_LEFTMARGIN },
-               { "nocounter",         TC_NOCOUNTER },
-               { "nofloat",           TC_NOFLOAT },
-               { "nostyle",           TC_NOSTYLE },
-               { "outputformat",      TC_OUTPUTFORMAT },
-               { "outputtype",        TC_OUTPUTTYPE },
-               { "pagestyle",         TC_PAGESTYLE },
-               { "preamble",          TC_PREAMBLE },
-               { "provides",          TC_PROVIDES },
-               { "providesmodule",    TC_PROVIDESMODULE },
-               { "requires",          TC_REQUIRES },
-               { "rightmargin",       TC_RIGHTMARGIN },
-               { "secnumdepth",       TC_SECNUMDEPTH },
-               { "sides",             TC_SIDES },
-               { "style",             TC_STYLE },
-               { "titlelatexname",    TC_TITLELATEXNAME },
-               { "titlelatextype",    TC_TITLELATEXTYPE },
-               { "tocdepth",          TC_TOCDEPTH }
-       };
+LexerKeyword textClassTags[] = {
+       { "addtohtmlpreamble", TC_ADDTOHTMLPREAMBLE },
+       { "addtohtmlstyles",   TC_ADDTOHTMLSTYLES },
+       { "addtopreamble",     TC_ADDTOPREAMBLE },
+       { "citeengine",        TC_CITEENGINE },
+       { "citeenginetype",    TC_CITEENGINETYPE },
+       { "citeformat",        TC_CITEFORMAT },
+       { "classoptions",      TC_CLASSOPTIONS },
+       { "columns",           TC_COLUMNS },
+       { "counter",           TC_COUNTER },
+       { "defaultbiblio",     TC_DEFAULTBIBLIO },
+       { "defaultfont",       TC_DEFAULTFONT },
+       { "defaultmodule",     TC_DEFAULTMODULE },
+       { "defaultstyle",      TC_DEFAULTSTYLE },
+       { "excludesmodule",    TC_EXCLUDESMODULE },
+       { "float",             TC_FLOAT },
+       { "format",            TC_FORMAT },
+       { "fullauthorlist",    TC_FULLAUTHORLIST },
+       { "htmlpreamble",      TC_HTMLPREAMBLE },
+       { "htmlstyles",        TC_HTMLSTYLES },
+       { "htmltocsection",    TC_HTMLTOCSECTION },
+       { "ifcounter",         TC_IFCOUNTER },
+       { "ifstyle",           TC_IFSTYLE },
+       { "input",             TC_INPUT },
+       { "insetlayout",       TC_INSETLAYOUT },
+       { "leftmargin",        TC_LEFTMARGIN },
+       { "nocounter",         TC_NOCOUNTER },
+       { "nofloat",           TC_NOFLOAT },
+       { "nostyle",           TC_NOSTYLE },
+       { "outputformat",      TC_OUTPUTFORMAT },
+       { "outputtype",        TC_OUTPUTTYPE },
+       { "pagestyle",         TC_PAGESTYLE },
+       { "preamble",          TC_PREAMBLE },
+       { "provides",          TC_PROVIDES },
+       { "providesmodule",    TC_PROVIDESMODULE },
+       { "requires",          TC_REQUIRES },
+       { "rightmargin",       TC_RIGHTMARGIN },
+       { "secnumdepth",       TC_SECNUMDEPTH },
+       { "sides",             TC_SIDES },
+       { "style",             TC_STYLE },
+       { "titlelatexname",    TC_TITLELATEXNAME },
+       { "titlelatextype",    TC_TITLELATEXTYPE },
+       { "tocdepth",          TC_TOCDEPTH }
+};
 
 } //namespace anon
 
@@ -1228,15 +1228,16 @@ bool TextClass::readFloat(Lexer & lexrc)
 }
 
 
-string const & TextClass::prerequisites() const
+string const & TextClass::prerequisites(string const & sep) const
 {
        if (contains(prerequisites_, ',')) {
                vector<string> const pres = getVectorFromString(prerequisites_);
-               prerequisites_ = getStringFromVector(pres, "\n\t");
+               prerequisites_ = getStringFromVector(pres, sep);
        }
        return prerequisites_;
 }
 
+
 bool TextClass::hasLayout(docstring const & n) const
 {
        docstring const name = n.empty() ? defaultLayoutName() : n;
@@ -1431,41 +1432,14 @@ Layout TextClass::createBasicLayout(docstring const & name, bool unknown) const
 }
 
 
-/////////////////////////////////////////////////////////////////////////
-//
-// DocumentClassBundle
-//
-/////////////////////////////////////////////////////////////////////////
-
-DocumentClassBundle::~DocumentClassBundle()
-{
-       for (size_t i = 0; i != documentClasses_.size(); ++i)
-               delete documentClasses_[i];
-       documentClasses_.clear();
-}
-
-DocumentClass & DocumentClassBundle::newClass(LayoutFile const & baseClass)
-{
-       DocumentClass * dc = new DocumentClass(baseClass);
-       documentClasses_.push_back(dc);
-       return *documentClasses_.back();
-}
-
-
-DocumentClassBundle & DocumentClassBundle::get()
-{
-       static DocumentClassBundle singleton;
-       return singleton;
-}
-
-
-DocumentClass & DocumentClassBundle::makeDocumentClass(
+DocumentClassPtr getDocumentClass(
                LayoutFile const & baseClass, LayoutModuleList const & modlist)
 {
-       DocumentClass & doc_class = newClass(baseClass);
+       DocumentClassPtr doc_class =
+           DocumentClassPtr(new DocumentClass(baseClass));
        LayoutModuleList::const_iterator it = modlist.begin();
        LayoutModuleList::const_iterator en = modlist.end();
-       for (; it != en; it++) {
+       for (; it != en; ++it) {
                string const modName = *it;
                LyXModule * lm = theModuleList[modName];
                if (!lm) {
@@ -1490,7 +1464,7 @@ DocumentClass & DocumentClassBundle::makeDocumentClass(
                        frontend::Alert::warning(_("Package not available"), msg, true);
                }
                FileName layout_file = libFileSearch("layouts", lm->getFilename());
-               if (!doc_class.read(layout_file, TextClass::MODULE)) {
+               if (!doc_class->read(layout_file, TextClass::MODULE)) {
                        docstring const msg =
                                                bformat(_("Error reading module %1$s\n"), from_utf8(modName));
                        frontend::Alert::warning(_("Read Error"), msg);
@@ -1534,28 +1508,32 @@ bool DocumentClass::hasTocLevels() const
 }
 
 
-Layout const & DocumentClass::htmlTOCLayout() const
+Layout const & DocumentClass::getTOCLayout() const
 {
-       if (html_toc_section_.empty()) {
-               // we're going to look for the layout with the minimum toclevel
-               TextClass::LayoutList::const_iterator lit = begin();
-               TextClass::LayoutList::const_iterator const len = end();
-               int minlevel = 1000;
-               Layout const * lay = NULL;
-               for (; lit != len; ++lit) {
-                       int const level = lit->toclevel;
-                       // we don't want Part
-                       if (level == Layout::NOT_IN_TOC || level < 0 || level >= minlevel)
-                               continue;
-                       lay = &*lit;
-                       minlevel = level;
-               }
-               if (lay)
-                       html_toc_section_ = lay->name();
-               else
-                       // hmm. that is very odd, so we'll do our best
-                       html_toc_section_ = defaultLayoutName();
+       // we're going to look for the layout with the minimum toclevel
+       TextClass::LayoutList::const_iterator lit = begin();
+       TextClass::LayoutList::const_iterator const len = end();
+       int minlevel = 1000;
+       Layout const * lay = NULL;
+       for (; lit != len; ++lit) {
+               int const level = lit->toclevel;
+               // we don't want Part
+               if (level == Layout::NOT_IN_TOC || level < 0 || level >= minlevel)
+                       continue;
+               lay = &*lit;
+               minlevel = level;
        }
+       if (lay)
+               return *lay;
+       // hmm. that is very odd, so we'll do our best.
+       return operator[](defaultLayoutName());
+}
+
+
+Layout const & DocumentClass::htmlTOCLayout() const
+{
+       if (html_toc_section_.empty())
+               html_toc_section_ = getTOCLayout().name();
        return operator[](html_toc_section_);
 }