]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
Fix build with GNU libstdc++ C++11 ABI
[lyx.git] / src / BufferParams.cpp
index 47c65cea2666a091684304b9cd31486f87de3ce0..a12a2860dc037d4c7d87a068b998180c278e5ded 100644 (file)
@@ -634,7 +634,7 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                                                 "See section 3.1.2.2 (Class Availability) of the\n"
                                                 "User's Guide for more information."), desc, prereqs);
                        frontend::Alert::warning(_("Document class not available"),
-                                      msg);
+                                      msg, true);
                }
        } else if (token == "\\begin_preamble") {
                readPreamble(lex);
@@ -1326,6 +1326,11 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        // are doing!
        if (features.mustProvide("fix-cm"))
                os << "\\RequirePackage{fix-cm}\n";
+       // Likewise for fixltx2e. If other packages conflict with this policy,
+       // treat it as a package bug (and report it!)
+       // See http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=latex/4407
+       if (features.mustProvide("fixltx2e"))
+               os << "\\RequirePackage{fixltx2e}\n";
 
        os << "\\documentclass";
 
@@ -1494,18 +1499,8 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        // XeTeX and LuaTeX (with OS fonts) do not need fontenc
        if (!useNonTeXFonts && !features.isProvided("fontenc")
            && font_encoding() != "default") {
-               vector<string> fontencs;
-               // primary language font encoding and default encoding
-               if (ascii_lowercase(language->fontenc()) != "none") {
-                       vector<string> fencs = getVectorFromString(font_encoding());
-                       fontencs.insert(fontencs.end(), fencs.begin(), fencs.end());
-                       fencs = getVectorFromString(language->fontenc());
-                       vector<string>::const_iterator fit = fencs.begin();
-                       for (; fit != fencs.end(); ++fit) {
-                               if (find(fontencs.begin(), fontencs.end(), *fit) == fontencs.end())
-                                       fontencs.push_back(*fit);
-                       }
-               }
+               // get main font encodings
+               vector<string> fontencs = font_encodings();
                // get font encodings of secondary languages
                features.getFontEncodings(fontencs);
                if (!fontencs.empty()) {
@@ -1952,7 +1947,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                        + atlyxpreamble + "\\makeatother\n\n";
 
        // We try to load babel late, in case it interferes with other packages.
-       // Jurabib, hyperref, varioref and listings (bug 8995) have to be
+       // Jurabib, hyperref, varioref, bicaption and listings (bug 8995) have to be
        // called after babel, though.
        if (use_babel && !features.isRequired("jurabib")
            && !features.isRequired("hyperref")
@@ -1965,6 +1960,8 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                                                   features.needBabelLangOptions())) + '\n';
                lyxpreamble += from_utf8(features.getBabelPostsettings());
        }
+       if (features.isRequired("bicaption"))
+               lyxpreamble += "\\usepackage{bicaption}\n";
        if (!listings_params.empty() || features.isRequired("listings"))
                lyxpreamble += "\\usepackage{listings}\n";
        if (!listings_params.empty()) {
@@ -2755,7 +2752,31 @@ string const BufferParams::dvips_options() const
 
 string const BufferParams::font_encoding() const
 {
-       return (fontenc == "global") ? lyxrc.fontenc : fontenc;
+       return font_encodings().empty() ? "default" : font_encodings().back();
+}
+
+
+vector<string> const BufferParams::font_encodings() const
+{
+       string doc_fontenc = (fontenc == "global") ? lyxrc.fontenc : fontenc;
+
+       vector<string> fontencs;
+
+       // "default" means "no explicit font encoding"
+       if (doc_fontenc != "default") {
+               fontencs = getVectorFromString(doc_fontenc);
+               if (!language->fontenc().empty()
+                   && ascii_lowercase(language->fontenc()) != "none") {
+                       vector<string> fencs = getVectorFromString(language->fontenc());
+                       vector<string>::const_iterator fit = fencs.begin();
+                       for (; fit != fencs.end(); ++fit) {
+                               if (find(fontencs.begin(), fontencs.end(), *fit) == fontencs.end())
+                                       fontencs.push_back(*fit);
+                       }
+               }
+       }
+
+       return fontencs;
 }
 
 
@@ -2825,7 +2846,8 @@ void BufferParams::writeEncodingPreamble(otexstream & os,
                // inputenc must be omitted.
                // see http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html
                if ((!encodings.empty() || package == Encoding::inputenc)
-                   && !features.isRequired("japanese")) {
+                   && !features.isRequired("japanese")
+                   && !features.isProvided("inputenc")) {
                        os << "\\usepackage[";
                        set<string>::const_iterator it = encodings.begin();
                        set<string>::const_iterator const end = encodings.end();
@@ -2856,7 +2878,9 @@ void BufferParams::writeEncodingPreamble(otexstream & os,
                        break;
                case Encoding::inputenc:
                        // do not load inputenc if japanese is used
-                       if (features.isRequired("japanese"))
+                       // or if the class provides inputenc
+                       if (features.isRequired("japanese")
+                           || features.isProvided("inputenc"))
                                break;
                        os << "\\usepackage[" << from_ascii(encoding().latexName())
                           << "]{inputenc}\n";