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
This commit is contained in:
Enrico Forestieri 2009-10-18 21:48:13 +00:00
parent fbb0c219ca
commit 128e349191
4 changed files with 20 additions and 3 deletions

View File

@ -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),

View File

@ -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

View File

@ -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

View File

@ -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()) {