From b607d70eb4cf635a04df83da51de8ddc29f96b8a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Tue, 3 Jun 2008 07:51:14 +0000 Subject: [PATCH] * src/output_latex.cpp: - handle CJK nesting correctly with nested insets (bug 4913). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25093 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/output_latex.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/output_latex.cpp b/src/output_latex.cpp index 2f919f4fec..2166425f07 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -51,7 +51,7 @@ enum OpenEncoding { }; static int open_encoding_ = none; -static bool cjk_inherited_ = false; +static int cjk_inherited_ = 0; ParagraphList::const_iterator @@ -316,9 +316,11 @@ TeXOnePar(Buffer const & buf, runparams.moving_arg |= style.needprotect; bool const maintext = text.isMainText(buf); - // we are at the beginning of an inset and CJK is already open. - if (pit == paragraphs.begin() && !maintext && open_encoding_ == CJK) { - cjk_inherited_ = true; + // we are at the beginning of an inset and CJK is already open; + // we count inheritation levels to get the inset nesting right. + if (pit == paragraphs.begin() && !maintext + && (cjk_inherited_ > 0 || open_encoding_ == CJK)) { + cjk_inherited_ += 1; open_encoding_ = none; } @@ -449,7 +451,7 @@ TeXOnePar(Buffer const & buf, // the following is necessary after a CJK environment in a multilingual // context (nesting issue). if (par_language->encoding()->package() == Encoding::CJK && - open_encoding_ != CJK && !cjk_inherited_) { + open_encoding_ != CJK && cjk_inherited_ == 0) { os << "\\begin{CJK}{" << from_ascii(par_language->encoding()->latexName()) << "}{}%\n"; open_encoding_ = CJK; @@ -858,9 +860,10 @@ void latexParagraphs(Buffer const & buf, } // reset inherited encoding - if (cjk_inherited_) { - open_encoding_ = CJK; - cjk_inherited_ = false; + if (cjk_inherited_ > 0) { + cjk_inherited_ -= 1; + if (cjk_inherited_ == 0) + open_encoding_ = CJK; } } -- 2.39.5