diff --git a/src/Buffer.cpp b/src/Buffer.cpp index e7a5d41bd7..2a23119d7b 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -964,7 +964,8 @@ void Buffer::writeLaTeXSource(odocstream & os, } // output_preamble LYXERR(Debug::INFO) << "preamble finished, now the body." << endl; - if (!lyxrc.language_auto_begin) { + if (!lyxrc.language_auto_begin && + !params().language->babel().empty()) { // FIXME UNICODE os << from_utf8(subst(lyxrc.language_command_begin, "$$lang", @@ -993,7 +994,8 @@ void Buffer::writeLaTeXSource(odocstream & os, os << endl; texrow().newline(); - if (!lyxrc.language_auto_end) { + if (!lyxrc.language_auto_end && + !params().language->babel().empty()) { os << from_utf8(subst(lyxrc.language_command_end, "$$lang", params().language->babel())) diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 052da14fd4..fc1b3ad9cf 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -846,7 +846,11 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, bool const use_babel = features.useBabel(); if (use_babel) { language_options << features.getLanguages(); - language_options << language->babel(); + if (!language->babel().empty()) { + if (!language_options.str().empty()) + language_options << ','; + language_options << language->babel(); + } if (lyxrc.language_global_options) clsoptions << language_options.str() << ','; } diff --git a/src/Cursor.cpp b/src/Cursor.cpp index 2589298f17..e0c507ecb1 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -1176,14 +1176,21 @@ docstring Cursor::selectionAsString(bool label) const if (startpit == endpit) return pars[startpit].asString(buffer, startpos, endpos, label); + odocstringstream ods; + ods << "\n"; + // only add blank line if we're not in an ERT inset + if (pars[startpit].ownerCode() != Inset::ERT_CODE) + ods << "\n"; + docstring const parbreak = ods.str(); + // First paragraph in selection docstring result = pars[startpit]. - asString(buffer, startpos, pars[startpit].size(), label) + "\n\n"; + asString(buffer, startpos, pars[startpit].size(), label) + parbreak; // The paragraphs in between (if any) for (pit_type pit = startpit + 1; pit != endpit; ++pit) { Paragraph const & par = pars[pit]; - result += par.asString(buffer, 0, par.size(), label) + "\n\n"; + result += par.asString(buffer, 0, par.size(), label) + parbreak; } // Last paragraph in selection diff --git a/src/Font.cpp b/src/Font.cpp index bf71d73c4c..ee6a8ca4e7 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -752,7 +752,7 @@ int Font::latexWriteStartChanges(odocstream & os, Font const & base, os << "\\L{"; count += 3; } - } else { + } else if (!language()->babel().empty()) { string const tmp = subst(lyxrc.language_command_local, "$$lang", language()->babel()); diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 5902106485..a20dc68392 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -191,7 +191,8 @@ LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p, bool LaTeXFeatures::useBabel() const { return lyxrc.language_use_babel || - bufferParams().language->lang() != lyxrc.default_language || + (bufferParams().language->lang() != lyxrc.default_language && + !bufferParams().language->babel().empty()) || this->hasLanguages(); } @@ -322,7 +323,8 @@ void LaTeXFeatures::useFloat(string const & name) void LaTeXFeatures::useLanguage(Language const * lang) { - UsedLanguages_.insert(lang); + if (!lang->babel().empty()) + UsedLanguages_.insert(lang); } diff --git a/src/output_latex.cpp b/src/output_latex.cpp index eeb4586c0e..d281feac0a 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -105,7 +105,8 @@ TeXEnvironment(Buffer const & buf, 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", @@ -115,7 +116,8 @@ TeXEnvironment(Buffer const & buf, } 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", @@ -271,7 +273,8 @@ TeXOnePar(Buffer const & buf, || 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", @@ -281,7 +284,8 @@ TeXOnePar(Buffer const & buf, } 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, @@ -456,12 +460,15 @@ TeXOnePar(Buffer const & buf, 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",