]> git.lyx.org Git - lyx.git/blobdiff - src/output_latex.cpp
* fix crashing special menu items on Mac after preferences have been changed.
[lyx.git] / src / output_latex.cpp
index 4dcab3d7cb88c88ac58854726be0fec2dfc7a88a..90af09a5dc5d2e247c33444e1d2b16e46ed2731e 100644 (file)
@@ -674,6 +674,9 @@ TeXOnePar(Buffer const & buf,
        if (nextpit == paragraphs.end() && !style.isEnvironment()) {
                switch (open_encoding_) {
                        case CJK: {
+                               // do nothing at the end of child documents
+                               if (maintext && buf.masterBuffer() != &buf)
+                                       break;
                                // end of main text
                                if (maintext) {
                                        os << '\n';
@@ -761,10 +764,13 @@ void latexParagraphs(Buffer const & buf,
        }
 
        bool const maintext = text.isMainText(buf);
+       bool const is_child = buf.masterBuffer() != &buf;
 
        // Open a CJK environment at the beginning of the main buffer
        // if the document's language is a CJK language
-       if (maintext && bparams.encoding().package() == Encoding::CJK) {
+       // (but not in child documents)
+       if (maintext && !is_child
+           && bparams.encoding().package() == Encoding::CJK) {
                os << "\\begin{CJK}{" << from_ascii(bparams.encoding().latexName())
                << "}{" << from_ascii(bparams.fontsCJK) << "}%\n";
                texrow.newline();
@@ -856,7 +862,7 @@ void latexParagraphs(Buffer const & buf,
 
        // If the last paragraph is an environment, we'll have to close
        // CJK at the very end to do proper nesting.
-       if (maintext && open_encoding_ == CJK) {
+       if (maintext && !is_child && open_encoding_ == CJK) {
                os << "\\end{CJK}\n";
                texrow.newline();
                open_encoding_ = none;
@@ -875,7 +881,7 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
                   OutputParams const & runparams, Encoding const & newEnc,
                   bool force)
 {
-       Encoding const oldEnc = *runparams.encoding;
+       Encoding const oldEnc = *runparams.encoding;
        bool moving_arg = runparams.moving_arg;
        if (!force && ((bparams.inputenc != "auto" && bparams.inputenc != "default")
                || moving_arg))