]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
Fix glitch in drawing fractions
[lyx.git] / src / BufferParams.cpp
index f6e7f50fd04c521850969f0a589c0b56603247bf..2736c26977f78df08e9c7504803f5e13f674ce48 100644 (file)
@@ -849,13 +849,13 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                biblio_style = lex.getString();
        } else if (token == "\\biblio_options") {
                lex.eatLine();
-               biblio_opts = lex.getString();
+               biblio_opts = trim(lex.getString());
        } else if (token == "\\biblatex_bibstyle") {
                lex.eatLine();
-               biblatex_bibstyle = lex.getString();
+               biblatex_bibstyle = trim(lex.getString());
        } else if (token == "\\biblatex_citestyle") {
                lex.eatLine();
-               biblatex_citestyle = lex.getString();
+               biblatex_citestyle = trim(lex.getString());
        } else if (token == "\\use_bibtopic") {
                lex >> use_bibtopic;
        } else if (token == "\\use_indices") {
@@ -3355,14 +3355,42 @@ vector<CitationStyle> BufferParams::citeStyles() const
 }
 
 
-string const BufferParams::bibtexCommand() const
+string const BufferParams::bibtexCommand() const
 {
+       // Return document-specific setting if available
        if (bibtex_command != "default")
                return bibtex_command;
-       else if (encoding().package() == Encoding::japanese)
-               return lyxrc.jbibtex_command;
-       else
+
+       // If we have "default" in document settings, consult the prefs
+       // 1. Japanese (uses a specific processor)
+       if (encoding().package() == Encoding::japanese) {
+               if (lyxrc.jbibtex_command != "automatic")
+                       // Return the specified program, if "automatic" is not set
+                       return lyxrc.jbibtex_command;
+               else if (!useBiblatex()) {
+                       // With classic BibTeX, return pbibtex, jbibtex, bibtex
+                       if (lyxrc.jbibtex_alternatives.find("pbibtex") != lyxrc.jbibtex_alternatives.end())
+                               return "pbibtex";
+                       if (lyxrc.jbibtex_alternatives.find("jbibtex") != lyxrc.jbibtex_alternatives.end())
+                               return "jbibtex";
+                       return "bibtex";
+               }
+       }
+       // 2. All other languages
+       else if (lyxrc.bibtex_command != "automatic")
+               // Return the specified program, if "automatic" is not set
                return lyxrc.bibtex_command;
+
+       // 3. Automatic: find the most suitable for the current cite framework
+       if (useBiblatex()) {
+               // For Biblatex, we prefer biber (also for Japanese)
+               // and fall back to bibtex8 and, as last resort, bibtex
+               if (lyxrc.bibtex_alternatives.find("biber") != lyxrc.bibtex_alternatives.end())
+                       return "biber";
+               else if (lyxrc.bibtex_alternatives.find("bibtex8") != lyxrc.bibtex_alternatives.end())
+                       return "bibtex8";
+       }
+       return "bibtex";
 }