]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
* gcc does not like missing characters in keywords
[lyx.git] / src / BufferParams.cpp
index 40aba23a00d9c39545914461fc9a300ff78ff471..3fff39e20ba45f22d581697a12fef0695ac80c0f 100644 (file)
@@ -28,7 +28,6 @@
 #include "LaTeXFeatures.h"
 #include "Messages.h"
 #include "ModuleList.h"
-#include "Color.h"
 #include "Font.h"
 #include "Lexer.h"
 #include "LyXRC.h"
@@ -584,7 +583,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);
 
@@ -901,8 +900,9 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                        language_options << language->babel();
                }
                // when Vietnamese is used, babel must directly be loaded with the
-               // language options, not in the class options
-               int viet = language_options.str().find("vietnam");
+               // language options, not in the class options, see
+               // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129417.html
+               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)
@@ -1134,14 +1134,30 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
        // translate the word "Index" to the German "Stichwortverzeichnis".
        // For more infos why this place was chosen, see
        // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg128425.html
-       // if you encounter problem, you can shift babel to its old place behind
-       // the user-defined preamble
+       // If you encounter problems, you can shift babel to its old place behind
+       // the user-defined preamble. But in this case you must change the Vietnamese
+       // support from currently "\usepackage[vietnamese]{babel}" to:
+       // \usepackage{vietnamese}
+       // \usepackage{babel}
+       // because vietnamese must be loaded before hyperref
        if (use_babel && !features.isRequired("jurabib")) {
                // FIXME UNICODE
                lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n';
                lyxpreamble += from_utf8(features.getBabelOptions());
        }
 
+       // When the language "japanese-plain" is used, the package "japanese" must
+       // 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
        //   packages, to give it a fighting chance of not being over-written,
@@ -1151,7 +1167,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...
@@ -1375,15 +1392,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);
 }
 
 
@@ -1555,8 +1571,9 @@ string const BufferParams::babelCall(string const & lang_opts) const
        if (lang_opts.empty())
                return string();
        // when Vietnamese is used, babel must directly be loaded with the
-       // language options
-       int viet = lang_opts.find("vietnam");
+       // language options, see
+       // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129417.html
+       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}";
@@ -1578,6 +1595,13 @@ void BufferParams::writeEncodingPreamble(odocstream & os,
                std::set<string> encodings =
                        features.getEncodingSet(doc_encoding);
 
+               // When the encodings EUC-JP-plain, JIS-plain, or SJIS-plainare used, the
+               // package inputenc must be omitted. Therefore set the encoding to empty.
+               // see http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html
+               if (doc_encoding == "EUC-JP-plain" || doc_encoding == "JIS-plain" ||
+                       doc_encoding == "SJIS-plain")
+                       encodings.clear();
+
                if (!encodings.empty() || package == Encoding::inputenc) {
                        os << "\\usepackage[";
                        std::set<string>::const_iterator it = encodings.begin();