]> git.lyx.org Git - lyx.git/blobdiff - src/output_latex.cpp
Remove special code for CJK that is no longer required (amends e665715fc4).
[lyx.git] / src / output_latex.cpp
index 23068de13186e7875d982c04aec59bee510e380c..7cc5b73e225a472af7d2ee53f6d6b56c20b23b99 100644 (file)
@@ -697,6 +697,11 @@ void parStartCommand(Paragraph const & par, otexstream & os,
                        os << " ";
                }
                break;
+       case LATEX_ENVIRONMENT:
+               if (runparams.for_search) {
+                       os << "\\latexenvironment{" << style.latexname() << "}{";
+               }
+               break;
        case LATEX_BIB_ENVIRONMENT:
                // ignore this, the inset will write itself
                break;
@@ -1031,6 +1036,8 @@ void TeXOnePar(Buffer const & buf,
        }
 
        runparams.moving_arg |= style.needprotect;
+       if (style.needmboxprotect)
+               ++runparams.inulemcmd;
        Encoding const * const prev_encoding = runparams.encoding;
 
        bool const useSetSpace = bparams.documentClass().provides("SetSpace");
@@ -1260,7 +1267,8 @@ void TeXOnePar(Buffer const & buf,
        // if this is a CJK-paragraph and the next isn't, close CJK
        // also if the next paragraph is a multilingual environment (because of nesting)
        if (nextpar
-               && (state->open_encoding_ == CJK && bparams.encoding().iconvName() != "UTF-8")
+               && (state->open_encoding_ == CJK && bparams.encoding().iconvName() != "UTF-8"
+                       && bparams.encoding().package() != Encoding::CJK )
                && (nextpar_language->encoding()->package() != Encoding::CJK
                   || (nextpar->layout().isEnvironment() && nextpar->isMultiLingual(bparams)))
                // inbetween environments, CJK has to be closed later (nesting!)
@@ -1412,7 +1420,7 @@ void latexParagraphs(Buffer const & buf,
                                && bparams.language->encoding()->package() == Encoding::CJK)
                                //  FIXME: should test if any language requires CJK
                                //  && LaTeXFeatures::mustProvide("CJK"))
-                               // error: cannot call member function ‘bool lyx::LaTeXFeatures::mustProvide(const string&) const’ without object 
+                               // error: cannot call member function ‘bool lyx::LaTeXFeatures::mustProvide(const string&) const’ without object
                   )) {
                docstring const cjkenc = bparams.encoding().iconvName() == "UTF-8"
                                                                 ? from_ascii("UTF8") : from_ascii(bparams.encoding().latexName());
@@ -1605,14 +1613,7 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
 
        Encoding const & oldEnc = *runparams.encoding;
        bool moving_arg = runparams.moving_arg;
-       // If we switch from/to CJK, we need to switch anyway, despite custom inputenc,
-       // except if we use CJKutf8 or explicitely set inputenc to a CJK encoding
-       bool const from_to_cjk =
-               ((oldEnc.package() == Encoding::CJK && newEnc.package() != Encoding::CJK)
-                || (oldEnc.package() != Encoding::CJK && newEnc.package() == Encoding::CJK))
-               && (bparams.encoding().name() != "utf8-cjk" && bparams.encoding().name() != "utf8")
-               && bparams.encoding().package() != Encoding::CJK;
-       if (!force && !from_to_cjk
+       if (!force
            && ((bparams.inputenc != "auto" && bparams.inputenc != "default") || moving_arg))
                return make_pair(false, 0);
 
@@ -1631,14 +1632,12 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
        if (oldEnc.package() == Encoding::none || newEnc.package() == Encoding::none)
                return make_pair(false, 0);
 
-       // change encoding (not required with UTF8)
-       if (bparams.encoding().iconvName() != "UTF-8") {
-               LYXERR(Debug::LATEX, "Changing LaTeX encoding from "
-                          << oldEnc.name() << " to " << newEnc.name());
-               os << setEncoding(newEnc.iconvName());
-               if (bparams.inputenc == "default")
-                 return make_pair(true, 0);
-       }
+       // change encoding
+       LYXERR(Debug::LATEX, "Changing LaTeX encoding from "
+                  << oldEnc.name() << " to " << newEnc.name());
+       os << setEncoding(newEnc.iconvName());
+       if (bparams.inputenc == "default")
+         return make_pair(true, 0);
 
        docstring const inputenc_arg(from_ascii(newEnc.latexName()));
        OutputState * state = getOutputState();
@@ -1688,9 +1687,8 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
                                os << "\\egroup";
                                count += 7;
                        }
-                       docstring const cjkenc = (bparams.encoding().iconvName() == "UTF-8"
-                                                                         ? from_ascii("UTF8") : from_ascii(newEnc.latexName()));
-                       os << "\\begin{CJK}{" << cjkenc << "}{"
+                       os << "\\begin{CJK}{"
+                          << from_ascii(newEnc.latexName()) << "}{"
                           << from_ascii(bparams.fonts_cjk) << "}";
                        state->open_encoding_ = CJK;
                        return make_pair(true, count + 15);