]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
(finishing patch -- question was restored, but there were still problems)
[lyx.git] / src / BufferParams.cpp
index f191ba5e4b377a5446c15c9f9eb74977795ff872..2a3841f85dd976b9999fd834588cc4654589fc30 100644 (file)
@@ -363,6 +363,7 @@ BufferParams::BufferParams()
        use_amsmath = package_auto;
        use_esint = package_auto;
        use_mhchem = package_auto;
+       use_mathdots = package_auto;
        cite_engine_ = ENGINE_BASIC;
        use_bibtopic = false;
        use_indices = false;
@@ -414,6 +415,7 @@ BufferParams::BufferParams()
        html_math_img_scale = 1.0;
 
        output_sync = false;
+       use_refstyle = true;
 }
 
 
@@ -532,6 +534,8 @@ VSpace const & BufferParams::getDefSkip() const
 
 void BufferParams::setDefSkip(VSpace const & vs)
 {
+       // DEFSKIP will cause an infinite loop
+       LASSERT(vs.kind() != VSpace::DEFSKIP, return);
        pimpl_->defskip = vs;
 }
 
@@ -555,19 +559,19 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                // We assume that a tex class exists for local or unknown layouts so this warning
                // will only be given for system layouts.
                if (!baseClass()->isTeXClassAvailable()) {
-                       docstring desc = 
+                       docstring const desc = 
                                translateIfPossible(from_utf8(baseClass()->description()));
+                       docstring const prereqs = from_utf8(baseClass()->prerequisites());
                        docstring const msg =
                                bformat(_("The selected document class\n"
                                                 "\t%1$s\n"
                                                 "requires external files that are not available.\n"
-                                                "The document class can still be used, but LyX\n"
-                                                "will not be able to produce output until the\n"
-                                                "following prerequisites are installed:\n"
+                                                "The document class can still be used, but the\n"
+                                                "document cannot be compiled until the following\n"
+                                                "prerequisites are installed:\n"
                                                 "\t%2$s\n"
                                                 "See section 3.1.2.2 of the User's Guide for\n"
-                                                "more information."), 
-                                                desc, from_utf8(baseClass()->prerequisites()));
+                                                "more information."), desc, prereqs);
                        frontend::Alert::warning(_("Document class not available"),
                                       msg);
                }
@@ -643,11 +647,11 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                pimpl_->indentation = HSpace(indentation);
        } else if (token == "\\defskip") {
                lex.next();
-               string defskip = lex.getString();
-               if (defskip == "defskip")
-                       // this is invalid
-                       defskip = "medskip";
+               string const defskip = lex.getString();
                pimpl_->defskip = VSpace(defskip);
+               if (pimpl_->defskip.kind() == VSpace::DEFSKIP)
+                       // that is invalid
+                       pimpl_->defskip = VSpace(VSpace::MEDSKIP);
        } else if (token == "\\quotes_language") {
                string quotes_lang;
                lex >> quotes_lang;
@@ -670,6 +674,10 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                int usemhchem;
                lex >> usemhchem;
                use_mhchem = packagetranslator().find(usemhchem);
+       } else if (token == "\\use_mathdots") {
+               int usemathdots;
+               lex >> usemathdots;
+               use_mathdots = packagetranslator().find(usemathdots);
        } else if (token == "\\cite_engine") {
                string engine;
                lex >> engine;
@@ -848,6 +856,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                lex >> output_sync;
        } else if (token == "\\output_sync_macro") {
                lex >> output_sync_macro;
+       } else if (token == "\\use_refstyle") {
+               lex >> use_refstyle;
        } else {
                lyxerr << "BufferParams::readToken(): Unknown token: " << 
                        token << endl;
@@ -969,11 +979,13 @@ void BufferParams::writeFile(ostream & os) const
           << "\n\\use_amsmath " << use_amsmath
           << "\n\\use_esint " << use_esint
           << "\n\\use_mhchem " << use_mhchem
+          << "\n\\use_mathdots " << use_mathdots
           << "\n\\cite_engine " << citeenginetranslator().find(cite_engine_)
           << "\n\\use_bibtopic " << convert<string>(use_bibtopic)
           << "\n\\use_indices " << convert<string>(use_indices)
           << "\n\\paperorientation " << string_orientation[orientation]
           << "\n\\suppress_date " << convert<string>(suppress_date)
+                << "\n\\use_refstyle " << use_refstyle
           << '\n';
        if (isbackgroundcolor == true)
                os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
@@ -1135,6 +1147,8 @@ void BufferParams::validate(LaTeXFeatures & features) const
                features.require("esint");
        if (use_mhchem == package_on)
                features.require("mhchem");
+       if (use_mathdots == package_on)
+               features.require("mathdots");
 
        // Document-level line spacing
        if (spacing().getSpace() != Spacing::Single && !spacing().isDefault())
@@ -1288,7 +1302,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                features.useLanguage(default_language);
 
        ostringstream language_options;
-       bool const use_babel = features.useBabel();
+       bool const use_babel = features.useBabel() && !tclass.provides("babel");
        if (use_babel) {
                language_options << features.getLanguages();
                if (!language->babel().empty()) {
@@ -1934,12 +1948,14 @@ DocumentClass const & BufferParams::documentClass() const
 }
 
 
-DocumentClass const * BufferParams::documentClassPtr() const {
+DocumentClass const * BufferParams::documentClassPtr() const
+{
        return doc_class_;
 }
 
 
-void BufferParams::setDocumentClass(DocumentClass const * const tc) {
+void BufferParams::setDocumentClass(DocumentClass const * const tc)
+{
        // evil, but this function is evil
        doc_class_ = const_cast<DocumentClass *>(tc);
 }