From 128e34919148b0d4f92cc8ca415c04055a421235 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Sun, 18 Oct 2009 21:48:13 +0000 Subject: [PATCH] Restore the master language at the end of an included child document instead of the child document language. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31665 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/OutputParams.cpp | 3 ++- src/OutputParams.h | 5 +++++ src/insets/InsetInclude.cpp | 4 ++++ src/output_latex.cpp | 11 +++++++++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/OutputParams.cpp b/src/OutputParams.cpp index ce5ad870e3..3528e5e98a 100644 --- a/src/OutputParams.cpp +++ b/src/OutputParams.cpp @@ -20,7 +20,8 @@ namespace lyx { OutputParams::OutputParams(Encoding const * enc) : flavor(LATEX), nice(false), moving_arg(false), inulemcmd(false), - local_font(0), encoding(enc), free_spacing(false), use_babel(false), + local_font(0), master_language(0), encoding(enc), + free_spacing(false), use_babel(false), use_indices(false), use_japanese(false), linelen(0), depth(0), exportdata(new ExportData), inComment(false), inTableCell(NO), inFloat(NONFLOAT), diff --git a/src/OutputParams.h b/src/OutputParams.h index a368f9f81d..48603476b7 100644 --- a/src/OutputParams.h +++ b/src/OutputParams.h @@ -25,6 +25,7 @@ namespace lyx { class Encoding; class ExportData; class Font; +class Language; class OutputParams { @@ -91,6 +92,10 @@ public: */ mutable std::string document_language; + /** The master language. Non-null only for child documents. + */ + mutable Language const * master_language; + /** Current stream encoding. Only used for LaTeX. This must be set to the document encoding (via the constructor) before output starts. Afterwards it must be kept up to date for diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 1169dff4ce..a963f073a8 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -540,12 +540,16 @@ int InsetInclude::latex(odocstream & os, OutputParams const & runparams) const // argument. Should we set it to string(), or should makeLaTeXFile // make use of it somehow? (JMarc 20031002) // The included file might be written in a different encoding + // and language. Encoding const * const oldEnc = runparams.encoding; + Language const * const oldLang = runparams.master_language; runparams.encoding = &tmp->params().encoding(); + runparams.master_language = masterBuffer->params().language; tmp->makeLaTeXFile(writefile, masterFileName(buffer()).onlyPath().absFilename(), runparams, false); runparams.encoding = oldEnc; + runparams.master_language = oldLang; } else { // In this case, it's not a LyX file, so we copy the file // to the temp dir, so that .aux files etc. are not created diff --git a/src/output_latex.cpp b/src/output_latex.cpp index d40874e041..a87416d7b7 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -671,11 +671,18 @@ ParagraphList::const_iterator TeXOnePar(Buffer const & buf, // when the paragraph uses CJK, the language has to be closed earlier if (font.language()->encoding()->package() != Encoding::CJK) { if (lyxrc.language_command_end.empty()) { - if (!prev_language->babel().empty()) { + // If this is a child, we should restore the + // master language after the last paragraph. + Language const * const current_language = + (nextpit == paragraphs.end() + && runparams.master_language) + ? runparams.master_language + : prev_language; + if (!current_language->babel().empty()) { os << from_ascii(subst( lyxrc.language_command_begin, "$$lang", - prev_language->babel())); + current_language->babel())); pending_newline = true; } } else if (!par_language->babel().empty()) {