]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
BufferParams.h: add comment
[lyx.git] / src / Buffer.cpp
index 850882d958912c9503048de15ac0b185e1204a3c..b5125c34543e301e935c0ff848e6c32a11931468 100644 (file)
@@ -141,7 +141,7 @@ using std::string;
 
 namespace {
 
-int const LYX_FORMAT = 266;
+int const LYX_FORMAT = 268;
 
 } // namespace anon
 
@@ -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",
@@ -973,6 +974,16 @@ void Buffer::writeLaTeXSource(odocstream & os,
                texrow().newline();
        }
 
+       Encoding const & encoding = params().encoding();
+       if (encoding.package() == Encoding::CJK) {
+               // Open a CJK environment, since in contrast to the encodings
+               // handled by inputenc the document encoding is not set in
+               // the preamble if it is handled by CJK.sty.
+               os << "\\begin{CJK}{" << from_ascii(encoding.latexName())
+                  << "}{}\n";
+               texrow().newline();
+       }
+
        // if we are doing a real file with body, even if this is the
        // child of some other buffer, let's cut the link here.
        // This happens for example if only a child document is printed.
@@ -993,7 +1004,16 @@ void Buffer::writeLaTeXSource(odocstream & os,
        os << endl;
        texrow().newline();
 
-       if (!lyxrc.language_auto_end) {
+       if (encoding.package() == Encoding::CJK) {
+               // Close the open CJK environment.
+               // latexParagraphs will have opened one even if the last text
+               // was not CJK.
+               os << "\\end{CJK}\n";
+               texrow().newline();
+       }
+
+       if (!lyxrc.language_auto_end &&
+           !params().language->babel().empty()) {
                os << from_utf8(subst(lyxrc.language_command_end,
                                           "$$lang",
                                           params().language->babel()))