]> git.lyx.org Git - lyx.git/blobdiff - src/lyxtextclass.C
add GuiView parent to QToc for proper memory management.
[lyx.git] / src / lyxtextclass.C
index 71e825483d993d742b959592f9816dc27229d15b..52ec9fdce849e06b9bf577893b6354a7a841722c 100644 (file)
@@ -65,7 +65,7 @@ private:
 };
 
 
-int const FORMAT = 2;
+int const FORMAT = 4;
 
 
 bool layout2layout(FileName const & filename, FileName const & tempfile)
@@ -83,7 +83,7 @@ bool layout2layout(FileName const & filename, FileName const & tempfile)
                << ' ' << quoteName(tempfile.toFilesystemEncoding());
        string const command_str = command.str();
 
-       lyxerr[Debug::TCLASS] << "Running `" << command_str << '\'' << endl;
+       LYXERR(Debug::TCLASS) << "Running `" << command_str << '\'' << endl;
 
        support::cmd_ret const ret =
                support::runCommand(command_str);
@@ -113,7 +113,6 @@ LyXTextClass::LyXTextClass(string const & fn, string const & cln,
        defaultfont_ = LyXFont(LyXFont::ALL_SANE);
        opt_fontsize_ = "10|11|12";
        opt_pagestyle_ = "empty|plain|headings|fancy";
-       provides_ = nothing;
        titletype_ = TITLE_COMMAND_AFTER;
        titlename_ = "maketitle";
        loaded_ = false;
@@ -128,7 +127,7 @@ bool LyXTextClass::isTeXClassAvailable() const
 
 bool LyXTextClass::do_readStyle(LyXLex & lexrc, LyXLayout & lay)
 {
-       lyxerr[Debug::TCLASS] << "Reading style " << lay.name() << endl;
+       LYXERR(Debug::TCLASS) << "Reading style " << lay.name() << endl;
        if (!lay.read(lexrc, *this)) {
                // Resolve fonts
                lay.resfont = lay.font;
@@ -158,10 +157,7 @@ enum TextClassTags {
        TC_TOCDEPTH,
        TC_CLASSOPTIONS,
        TC_PREAMBLE,
-       TC_PROVIDESAMSMATH,
-       TC_PROVIDESNATBIB,
-       TC_PROVIDESMAKEIDX,
-       TC_PROVIDESURL,
+       TC_PROVIDES,
        TC_LEFTMARGIN,
        TC_RIGHTMARGIN,
        TC_FLOAT,
@@ -199,10 +195,7 @@ bool LyXTextClass::read(FileName const & filename, bool merge)
                { "outputtype",      TC_OUTPUTTYPE },
                { "pagestyle",       TC_PAGESTYLE },
                { "preamble",        TC_PREAMBLE },
-               { "providesamsmath", TC_PROVIDESAMSMATH },
-               { "providesmakeidx", TC_PROVIDESMAKEIDX },
-               { "providesnatbib",  TC_PROVIDESNATBIB },
-               { "providesurl",     TC_PROVIDESURL },
+               { "provides",        TC_PROVIDES },
                { "rightmargin",     TC_RIGHTMARGIN },
                { "secnumdepth",     TC_SECNUMDEPTH },
                { "sides",           TC_SIDES },
@@ -213,11 +206,11 @@ bool LyXTextClass::read(FileName const & filename, bool merge)
        };
 
        if (!merge)
-               lyxerr[Debug::TCLASS] << "Reading textclass "
+               LYXERR(Debug::TCLASS) << "Reading textclass "
                                        << to_utf8(makeDisplayPath(filename.absFilename()))
                                        << endl;
        else
-               lyxerr[Debug::TCLASS] << "Reading input file "
+               LYXERR(Debug::TCLASS) << "Reading input file "
                                     << to_utf8(makeDisplayPath(filename.absFilename()))
                                     << endl;
 
@@ -383,25 +376,16 @@ bool LyXTextClass::read(FileName const & filename, bool merge)
                        preamble_ = from_utf8(lexrc.getLongString("EndPreamble"));
                        break;
 
-               case TC_PROVIDESAMSMATH:
-                       if (lexrc.next() && lexrc.getInteger())
-                               provides_ |= amsmath;
-                       break;
-
-               case TC_PROVIDESNATBIB:
-                       if (lexrc.next() && lexrc.getInteger())
-                               provides_ |= natbib;
-                       break;
-
-               case TC_PROVIDESMAKEIDX:
-                       if (lexrc.next() && lexrc.getInteger())
-                               provides_ |= makeidx;
-                       break;
-
-               case TC_PROVIDESURL:
-                       if (lexrc.next() && lexrc.getInteger())
-                               provides_ |= url;
+               case TC_PROVIDES: {
+                       lexrc.next();
+                       string const feature = lexrc.getString();
+                       lexrc.next();
+                       if (lexrc.getInteger())
+                               provides_.insert(feature);
+                       else
+                               provides_.erase(feature);
                        break;
+               }
 
                case TC_LEFTMARGIN:     // left margin type
                        if (lexrc.next())
@@ -443,7 +427,7 @@ bool LyXTextClass::read(FileName const & filename, bool merge)
        }
 
        if (format != FORMAT) {
-               lyxerr[Debug::TCLASS] << "Converting layout file from format "
+               LYXERR(Debug::TCLASS) << "Converting layout file from format "
                                      << format << " to " << FORMAT << endl;
                FileName const tempfile(support::tempName());
                error = !layout2layout(filename, tempfile);
@@ -454,7 +438,7 @@ bool LyXTextClass::read(FileName const & filename, bool merge)
        }
 
        if (!merge) { // we are at top level here.
-               lyxerr[Debug::TCLASS] << "Finished reading textclass "
+               LYXERR(Debug::TCLASS) << "Finished reading textclass "
                                      << to_utf8(makeDisplayPath(filename.absFilename()))
                                      << endl;
                if (defaultlayout_.empty()) {
@@ -479,12 +463,12 @@ bool LyXTextClass::read(FileName const & filename, bool merge)
                                                         toclevel);
                        }
                }
-               lyxerr[Debug::TCLASS]
+               LYXERR(Debug::TCLASS)
                        << "Minimum TocLevel is " << min_toclevel_
                        << ", maximum is " << max_toclevel_ <<endl;
 
        } else
-               lyxerr[Debug::TCLASS] << "Finished reading input file "
+               LYXERR(Debug::TCLASS) << "Finished reading input file "
                                      << to_utf8(makeDisplayPath(filename.absFilename()))
                                      << endl;
 
@@ -1067,9 +1051,9 @@ OutputType LyXTextClass::outputType() const
 }
 
 
-bool LyXTextClass::provides(LyXTextClass::Provides p) const
+bool LyXTextClass::provides(string const & p) const
 {
-       return provides_ & p;
+       return provides_.find(p) != provides_.end();
 }