#include "BranchList.h"
#include "buffer_funcs.h"
#include "Bullet.h"
+#include "Color.h"
#include "debug.h"
#include "Encoding.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
#include "Messages.h"
#include "ModuleList.h"
-#include "Color.h"
#include "Font.h"
#include "Lexer.h"
#include "LyXRC.h"
#include "insets/InsetListingsParams.h"
#include "support/convert.h"
+#include "support/docstream.h"
#include "support/filetools.h"
#include "support/Translator.h"
#include "support/lstrings.h"
-#include <boost/array.hpp>
-
#include <algorithm>
#include <sstream>
using std::count;
using std::endl;
+using std::find;
using std::string;
using std::istringstream;
using std::ostream;
// Page sides
-typedef Translator<int, TextClass::PageSides> SidesTranslator;
+typedef Translator<int, PageSides> SidesTranslator;
SidesTranslator const init_sidestranslator()
{
- SidesTranslator translator(1, TextClass::OneSide);
- translator.addPair(2, TextClass::TwoSides);
+ SidesTranslator translator(1, OneSide);
+ translator.addPair(2, TwoSides);
return translator;
}
AuthorList authorlist;
BranchList branchlist;
- boost::array<Bullet, 4> temp_bullets;
- boost::array<Bullet, 4> user_defined_bullets;
+ Bullet temp_bullets[4];
+ Bullet user_defined_bullets[4];
Spacing spacing;
/** This is the amount of space used for paragraph_separation "skip",
* and for detached paragraphs in "indented" documents.
fontsTypewriterScale = 100;
inputenc = "auto";
graphicsDriver = "default";
- sides = TextClass::OneSide;
+ sides = OneSide;
columns = 1;
listings_params = string();
pagestyle = "default";
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);
// if needed
if (sides != tclass.sides()) {
switch (sides) {
- case TextClass::OneSide:
+ case OneSide:
clsoptions << "oneside,";
break;
- case TextClass::TwoSides:
+ case TwoSides:
clsoptions << "twoside,";
break;
}
language_options << ',';
language_options << language->babel();
}
- if (lyxrc.language_global_options && !language_options.str().empty())
+ // 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
+ 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)
clsoptions << language_options.str() << ',';
}
// The optional packages;
docstring lyxpreamble(from_ascii(features.getPackages()));
- // PDF support. Hyperref manual: "Make sure it comes last of your loaded
- // packages, to give it a fighting chance of not being over-written,
- // since its job is to redefine many LATEX commands."
- // Has to be put into lyxpreamble (preserving line-counting for error
- // parsing).
+ // We try to load babel late, in case it interferes
+ // with other packages. But some packages also need babel to be loaded
+ // before, e.g. jurabib has to be called after babel.
+ // So load babel after the optional packages but before the user-defined
+ // preamble. This allows the users to redefine babel commands, e.g. to
+ // 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 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,
+ // since its job is to redefine many LATEX commands."
+ // * Email from Heiko Oberdiek: "It is usually better to load babel
+ // before hyperref. Then hyperref has a chance to detect babel.
+ // * 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...
if (!bullets_def.empty())
lyxpreamble += bullets_def + "}\n\n";
- // We try to load babel late, in case it interferes
- // with other packages.
- // Jurabib has to be called after babel, though.
- if (use_babel && !features.isRequired("jurabib")) {
- // FIXME UNICODE
- lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n';
- lyxpreamble += from_utf8(features.getBabelOptions());
- }
-
lyxpreamble += "\\makeatother\n\n";
int const nlines =
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);
}
// other languages are used (lang_opts is then empty)
if (lang_opts.empty())
return string();
- if (!lyxrc.language_global_options)
+ // 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
+ 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}";
return lang_pack;
}
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();