]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
Further cleanup of InsetFlex, InsetCollapsable and InsetLayout:
[lyx.git] / src / BufferParams.cpp
index 2f1886b5e4f4569b7ecf682afeeb832c74d83ad6..66d94567d0d440c121f6dcc47543e6fe200eb608 100644 (file)
@@ -21,6 +21,7 @@
 #include "BranchList.h"
 #include "buffer_funcs.h"
 #include "Bullet.h"
+#include "Color.h"
 #include "debug.h"
 #include "Encoding.h"
 #include "gettext.h"
@@ -28,7 +29,6 @@
 #include "LaTeXFeatures.h"
 #include "Messages.h"
 #include "ModuleList.h"
-#include "Color.h"
 #include "Font.h"
 #include "Lexer.h"
 #include "LyXRC.h"
@@ -43,6 +43,7 @@
 #include "insets/InsetListingsParams.h"
 
 #include "support/convert.h"
+#include "support/docstream.h"
 #include "support/filetools.h"
 #include "support/Translator.h"
 #include "support/lstrings.h"
@@ -584,7 +585,7 @@ string const BufferParams::readToken(Lexer & lex, string const & token)
                                        branch_ptr->setColor(color);
                                // Update also the Color table:
                                if (color == "none")
-                                       color = lcolor.getX11Name(Color::background);
+                                       color = lcolor.getX11Name(Color_background);
                                // FIXME UNICODE
                                lcolor.setColor(to_utf8(branch), color);
 
@@ -903,7 +904,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                // when Vietnamese is used, babel must directly be loaded with the
                // language options, not in the class options, see
                // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129417.html
-               int viet = language_options.str().find("vietnam");
+               size_t viet = language_options.str().find("vietnam");
                // viet = string::npos when not found
                if (lyxrc.language_global_options && !language_options.str().empty()
                        && viet == string::npos)
@@ -1148,10 +1149,16 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
        }
 
        // When the language "japanese-plain" is used, the package "japanese" must
-       // be loaded behind babel (it provides babel support for Japanese)
-       // see http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html
-       if (language->lang() == "japanese-plain")
+       // be loaded behind babel (it provides babel support for Japanese) but before
+       // hyperref, see
+       // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html
+       if (language->lang() == "japanese-plain" &&
+               !getTextClass().provides("japanese")) {
+               //load babel in case it was not loaded due to an empty language list
+               if (language_options.str().empty())
+                       lyxpreamble += "\\usepackage{babel}\n";
                lyxpreamble += "\\usepackage{japanese}\n";
+       }
 
        // PDF support.
        // * Hyperref manual: "Make sure it comes last of your loaded
@@ -1162,7 +1169,8 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
        // * Has to be loaded before the "LyX specific LaTeX commands" to
        //   avoid errors with algorithm floats.
        odocstringstream oss;
-       pdfoptions().writeLaTeX(oss);
+       // use hyperref explicitely when it is required
+       pdfoptions().writeLaTeX(oss, features.isRequired("hyperref"));
        lyxpreamble += oss.str();
 
        // this might be useful...
@@ -1386,15 +1394,14 @@ void BufferParams::clearLayoutModules() {
 
 Font const BufferParams::getFont() const
 {
-       Font f = getTextClass().defaultfont();
-       f.setLanguage(language);
+       FontInfo f = getTextClass().defaultfont();
        if (fontsDefaultFamily == "rmdefault")
-               f.setFamily(Font::ROMAN_FAMILY);
+               f.setFamily(ROMAN_FAMILY);
        else if (fontsDefaultFamily == "sfdefault")
-               f.setFamily(Font::SANS_FAMILY);
+               f.setFamily(SANS_FAMILY);
        else if (fontsDefaultFamily == "ttdefault")
-               f.setFamily(Font::TYPEWRITER_FAMILY);
-       return f;
+               f.setFamily(TYPEWRITER_FAMILY);
+       return Font(f, language);
 }
 
 
@@ -1563,14 +1570,12 @@ string const BufferParams::babelCall(string const & lang_opts) const
        // suppress the babel call when there is no babel language defined
        // for the document language in the lib/languages file and if no
        // other languages are used (lang_opts is then empty)
-       // exception is the language "japanese-plain" where babel is needed anyway
-       // see http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html
-       if (lang_opts.empty() && language->lang() != "japanese-plain")
+       if (lang_opts.empty())
                return string();
        // when Vietnamese is used, babel must directly be loaded with the
        // language options, see
        // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129417.html
-       int viet = lang_opts.find("vietnam");
+       size_t viet = lang_opts.find("vietnam");
        // viet = string::npos when not found
        if (!lyxrc.language_global_options || viet != string::npos)
                return "\\usepackage[" + lang_opts + "]{babel}";