BufferParams const & bparams = buf.params();
- LyXLayout_ptr const & style = pit->layout();
+ Layout_ptr const & style = pit->layout();
Language const * const par_language = pit->getParLanguage(bparams);
Language const * const doc_language = bparams.language;
if (par_language->babel() != prev_par_language->babel()) {
if (!lyxrc.language_command_end.empty() &&
- prev_par_language->babel() != doc_language->babel()) {
+ prev_par_language->babel() != doc_language->babel() &&
+ !prev_par_language->babel().empty()) {
os << from_ascii(subst(
lyxrc.language_command_end,
"$$lang",
}
if (lyxrc.language_command_end.empty() ||
- par_language->babel() != doc_language->babel()) {
+ par_language->babel() != doc_language->babel() &&
+ !par_language->babel().empty()) {
os << from_ascii(subst(
lyxrc.language_command_begin,
"$$lang",
LYXERR(Debug::LATEX) << "TeXOnePar... " << &*pit << " '"
<< everypar << "'" << endl;
BufferParams const & bparams = buf.params();
- LyXLayout_ptr style;
+ Layout_ptr style;
// In an inset with unlimited length (all in one row),
// force layout to default
if (!pit->forceDefaultParagraphs())
style = pit->layout();
else
- style = bparams.getLyXTextClass().defaultLayout();
+ style = bparams.getTextClass().defaultLayout();
OutputParams runparams = runparams_in;
runparams.moving_arg |= style->needprotect;
|| boost::prior(pit)->getDepth() < pit->getDepth())))
{
if (!lyxrc.language_command_end.empty() &&
- prev_par_language->babel() != doc_language->babel())
+ prev_par_language->babel() != doc_language->babel() &&
+ !prev_par_language->babel().empty())
{
os << from_ascii(subst(lyxrc.language_command_end,
"$$lang",
}
if (lyxrc.language_command_end.empty() ||
- par_language->babel() != doc_language->babel())
+ par_language->babel() != doc_language->babel() &&
+ !par_language->babel().empty())
{
os << from_ascii(subst(
lyxrc.language_command_begin,
}
// Switch file encoding if necessary
- if (bparams.inputenc == "auto") {
+ if (bparams.inputenc == "auto" &&
+ runparams.encoding->package() == Encoding::inputenc) {
// Look ahead for future encoding changes.
// We try to output them at the beginning of the paragraph,
// since the \inputencoding command is not allowed e.g. in
// encoding to that required by the language of c.
Encoding const * const encoding =
pit->getFontSettings(bparams, i).language()->encoding();
- if (switchEncoding(os, bparams, false,
+ if (encoding->package() == Encoding::inputenc &&
+ switchEncoding(os, bparams, false,
*(runparams.encoding), *encoding) > 0) {
runparams.encoding = encoding;
os << '\n';
os << '\n';
texrow.newline();
}
- if (lyxrc.language_command_end.empty())
- os << from_ascii(subst(
- lyxrc.language_command_begin,
- "$$lang",
- doc_language->babel()));
- else
+ if (lyxrc.language_command_end.empty()) {
+ if (!doc_language->babel().empty()) {
+ os << from_ascii(subst(
+ lyxrc.language_command_begin,
+ "$$lang",
+ doc_language->babel()));
+ pending_newline = true;
+ }
+ } else if (!par_language->babel().empty()) {
os << from_ascii(subst(
lyxrc.language_command_end,
"$$lang",
par_language->babel()));
- pending_newline = true;
+ pending_newline = true;
+ }
}
if (pending_newline) {
{
bool was_title = false;
bool already_title = false;
- LyXTextClass const & tclass = buf.params().getLyXTextClass();
+ TextClass const & tclass = buf.params().getTextClass();
ParagraphList::const_iterator par = paragraphs.begin();
ParagraphList::const_iterator endpar = paragraphs.end();
// any environment other than the default layout of the
// text class to be valid!
if (!par->forceDefaultParagraphs()) {
- LyXLayout_ptr const & layout = par->layout();
+ Layout_ptr const & layout = par->layout();
if (layout->intitle) {
if (already_title) {
bool moving_arg, Encoding const & oldEnc,
Encoding const & newEnc)
{
- // FIXME thailatex does not support the inputenc package, so we
- // ignore switches from/to tis620-0 encoding here. This does of
- // course only work as long as the non-thai text contains ASCII
- // only, but it is the best we can do.
- // Since the \inputencoding command does not work inside sections
- // we ignore the encoding switch also in moving arguments.
- if (((bparams.inputenc == "auto" && !moving_arg) ||
- bparams.inputenc == "default") &&
- oldEnc.name() != newEnc.name() &&
- oldEnc.name() != "ascii" && newEnc.name() != "ascii" &&
- oldEnc.name() != "tis620-0" && newEnc.name() != "tis620-0") {
- LYXERR(Debug::LATEX) << "Changing LaTeX encoding from "
- << oldEnc.name() << " to "
- << newEnc.name() << endl;
- os << setEncoding(newEnc.iconvName());
- if (bparams.inputenc != "default") {
- docstring const inputenc(from_ascii(newEnc.latexName()));
+ if ((bparams.inputenc != "auto" || moving_arg)
+ && bparams.inputenc != "default")
+ return 0;
+
+ // Do nothing if the encoding is unchanged.
+ if (oldEnc.name() == newEnc.name())
+ return 0;
+
+ // FIXME We ignore encoding switches from/to encodings that do
+ // neither support the inputenc package nor the CJK package here.
+ // This does of course only work in special cases (e.g. switch from
+ // tis620-0 to latin1, but the text in latin1 contains ASCII only,
+ // but it is the best we can do
+ if (oldEnc.package() == Encoding::none
+ || newEnc.package() == Encoding::none)
+ return 0;
+
+ LYXERR(Debug::LATEX) << "Changing LaTeX encoding from "
+ << oldEnc.name() << " to "
+ << newEnc.name() << endl;
+ os << setEncoding(newEnc.iconvName());
+ if (bparams.inputenc == "default")
+ return 0;
+
+ docstring const inputenc(from_ascii(newEnc.latexName()));
+ switch (newEnc.package()) {
+ case Encoding::none:
+ return 0;
+ case Encoding::inputenc: {
+ int count = inputenc.length();
+ if (oldEnc.package() == Encoding::CJK) {
+ os << "\\end{CJK}";
+ count += 9;
+ }
os << "\\inputencoding{" << inputenc << '}';
- return 16 + inputenc.length();
+ return count + 16;
+ }
+ case Encoding::CJK: {
+ int count = inputenc.length();
+ if (oldEnc.package() == Encoding::CJK) {
+ os << "\\end{CJK}";
+ count += 9;
+ }
+ os << "\\begin{CJK}{" << inputenc << "}{}";
+ return count + 15;
}
}
+ // Dead code to avoid a warning:
return 0;
}