]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFeatures.cpp
Add empty line after last \bibitem in bibliography (#12041)
[lyx.git] / src / LaTeXFeatures.cpp
index 3d67128f58069129dc7ed13364339a6e55971729..7c23a851cafa9fafdef18bf88e1bbeff9afbe393 100644 (file)
@@ -27,8 +27,8 @@
 #include "LaTeXFonts.h"
 #include "LaTeXPackages.h"
 #include "Layout.h"
-#include "Lexer.h"
 #include "LyXRC.h"
+#include "OutputParams.h"
 #include "TextClass.h"
 #include "TexRow.h"
 #include "texstream.h"
 
 #include "support/debug.h"
 #include "support/docstream.h"
-#include "support/FileName.h"
+#include "support/docstring.h"
 #include "support/filetools.h"
-#include "support/gettext.h"
 #include "support/lstrings.h"
-#include "support/regex.h"
 
 #include <algorithm>
+#include <regex>
 
 
 using namespace std;
@@ -834,15 +833,15 @@ TexString getSnippets(std::list<TexString> const & list)
 } // namespace
 
 
-void LaTeXFeatures::addPreambleSnippet(TexString ts, bool allow_dupes)
+void LaTeXFeatures::addPreambleSnippet(TexString snippet, bool allow_dupes)
 {
-       addSnippet(preamble_snippets_, move(ts), allow_dupes);
+       addSnippet(preamble_snippets_, move(snippet), allow_dupes);
 }
 
 
-void LaTeXFeatures::addPreambleSnippet(docstring const & str, bool allow_dupes)
+void LaTeXFeatures::addPreambleSnippet(docstring const & snippet, bool allow_dupes)
 {
-       addSnippet(preamble_snippets_, TexString(str), allow_dupes);
+       addSnippet(preamble_snippets_, TexString(snippet), allow_dupes);
 }
 
 
@@ -1163,10 +1162,6 @@ char const * bibliofeatures[] = {
        "named"
 };
 
-int const nb_bibliofeatures = sizeof(bibliofeatures) / sizeof(char const *);
-
-int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
-
 } // namespace
 
 
@@ -1258,9 +1253,9 @@ string const LaTeXFeatures::getPackages() const
 
        //  These are all the 'simple' includes.  i.e
        //  packages which we just \usepackage{package}
-       for (int i = 0; i < nb_simplefeatures; ++i) {
-               if (mustProvide(simplefeatures[i]))
-                       packages << "\\usepackage{" << simplefeatures[i] << "}\n";
+       for (char const * feature : simplefeatures) {
+               if (mustProvide(feature))
+                       packages << "\\usepackage{" << feature << "}\n";
        }
 
        // The rest of these packages are somewhat more complicated
@@ -1268,8 +1263,8 @@ string const LaTeXFeatures::getPackages() const
 
        if (mustProvide("changebar")) {
                packages << "\\usepackage";
-               if (runparams_.flavor == OutputParams::LATEX
-                   || runparams_.flavor == OutputParams::DVILUATEX)
+               if (runparams_.flavor == Flavor::LaTeX
+                   || runparams_.flavor == Flavor::DviLuaTeX)
                        packages << "[dvips]";
                packages << "{changebar}\n";
        }
@@ -1283,8 +1278,8 @@ string const LaTeXFeatures::getPackages() const
 
        // [pdf]lscape is used to rotate longtables
        if (mustProvide("lscape")) {
-               if (runparams_.flavor == OutputParams::LATEX
-                   || runparams_.flavor == OutputParams::DVILUATEX)
+               if (runparams_.flavor == Flavor::LaTeX
+                   || runparams_.flavor == Flavor::DviLuaTeX)
                        packages << "\\usepackage{lscape}\n";
                else
                        packages << "\\usepackage{pdflscape}\n";
@@ -1420,10 +1415,9 @@ string const LaTeXFeatures::getPackages() const
                packages << "\\usepackage{esint}\n";
 
        // Known bibliography packages (simple \usepackage{package})
-       for (int i = 0; i < nb_bibliofeatures; ++i) {
-               if (mustProvide(bibliofeatures[i]))
-                       packages << "\\usepackage{"
-                                << bibliofeatures[i] << "}\n";
+       for (char const * feature : bibliofeatures) {
+               if (mustProvide(feature))
+                       packages << "\\usepackage{" << feature << "}\n";
        }
 
        // Compatibility between achicago and natbib
@@ -1532,10 +1526,10 @@ TexString LaTeXFeatures::getMacros() const
                macros << "\\XeTeXdashbreakstate 0" << '\n';
 
        if (mustProvide("papersize")) {
-               if (runparams_.flavor == OutputParams::LATEX
-                   || runparams_.flavor == OutputParams::DVILUATEX)
+               if (runparams_.flavor == Flavor::LaTeX
+                   || runparams_.flavor == Flavor::DviLuaTeX)
                        macros << papersizedvi_def << '\n';
-               else if  (runparams_.flavor == OutputParams::LUATEX)
+               else if  (runparams_.flavor == Flavor::LuaTeX)
                        macros << papersizepdflua_def << '\n';
                else
                        macros << papersizepdf_def << '\n';
@@ -1661,13 +1655,13 @@ TexString LaTeXFeatures::getMacros() const
        if (mustProvide("textquotedbl"))
                macros << textquotedbl_def << '\n';
        if (mustProvide("textquotesinglep")) {
-               if (runparams_.flavor == OutputParams::XETEX)
+               if (runparams_.flavor == Flavor::XeTeX)
                        macros << textquotesinglep_xetex_def << '\n';
                else
                        macros << textquotesinglep_luatex_def << '\n';
        }
        if (mustProvide("textquotedblp")) {
-               if (runparams_.flavor == OutputParams::XETEX)
+               if (runparams_.flavor == Flavor::XeTeX)
                        macros << textquotedblp_xetex_def << '\n';
                else
                        macros << textquotedblp_luatex_def << '\n';
@@ -1695,7 +1689,7 @@ TexString LaTeXFeatures::getMacros() const
        if (mustProvide("lyxgreyedout")) {
                // We need different version for RTL (#8647)
                if (hasRTLLanguage()) {
-                       if (runparams_.flavor == OutputParams::LUATEX)
+                       if (runparams_.flavor == Flavor::LuaTeX)
                                if (useBabel())
                                        macros << lyxgreyedout_luartl_babel_def;
                                else
@@ -1944,8 +1938,8 @@ docstring const getFloatI18nPreamble(docstring const & type,
 {
        // Check whether name can be encoded in the buffer encoding
        bool encodable = true;
-       for (size_t i = 0; i < name.size(); ++i) {
-               if (!enc.encodable(name[i])) {
+       for (char_type c : name) {
+               if (!enc.encodable(c)) {
                        encodable = false;
                        break;
                }