]> git.lyx.org Git - lyx.git/blobdiff - src/output_latex.cpp
Fix bug 4441. GuiRef: Ok button must be default.
[lyx.git] / src / output_latex.cpp
index bcc6d873dafe7f15fd62340c4770f2df697d1a9c..c9538ca9a66d723a8b9dc32fd5f238a233e0f156 100644 (file)
@@ -61,14 +61,6 @@ TeXEnvironment(Buffer const & buf,
               odocstream & os, TexRow & texrow,
               OutputParams const & runparams);
 
-ParagraphList::const_iterator
-TeXOnePar(Buffer const & buf,
-         Text const & text,
-         ParagraphList::const_iterator pit,
-         odocstream & os, TexRow & texrow,
-         OutputParams const & runparams,
-         string const & everypar = string());
-
 
 ParagraphList::const_iterator
 TeXDeeper(Buffer const & buf,
@@ -188,8 +180,9 @@ TeXEnvironment(Buffer const & buf,
        bool cjk_nested = false;
        if (par_language->encoding()->package() == Encoding::CJK &&
            open_encoding_ != CJK && pit->isMultiLingual(bparams)) {
-               os << "\\begin{CJK}{" << from_ascii(par_language->encoding()->latexName())
-                  << "}{" << from_ascii(bparams.fontsCJK) << "}%\n";
+               if (prev_par_language->encoding()->package() == Encoding::CJK)
+                       os << "\\begin{CJK}{" << from_ascii(par_language->encoding()->latexName())
+                          << "}{" << from_ascii(bparams.fontsCJK) << "}%\n";
                open_encoding_ = CJK;
                cjk_nested = true;
                texrow.newline();
@@ -277,16 +270,14 @@ int latexOptArgInsets(Paragraph const & par, odocstream & os,
        return lines;
 }
 
-
-namespace {
-
-ParagraphList::const_iterator
-TeXOnePar(Buffer const & buf,
+// FIXME: this should be anonymous
+ParagraphList::const_iterator TeXOnePar(Buffer const & buf,
          Text const & text,
          ParagraphList::const_iterator const pit,
          odocstream & os, TexRow & texrow,
          OutputParams const & runparams_in,
-         string const & everypar)
+         string const & everypar,
+         int start_pos, int end_pos)
 {
        LYXERR(Debug::LATEX, "TeXOnePar...     " << &*pit << " '"
                << everypar << "'");
@@ -312,7 +303,7 @@ TeXOnePar(Buffer const & buf,
                }
 
                /*bool need_par = */ pit->latex(bparams, outerfont,
-                       os, texrow, runparams);
+                       os, texrow, runparams, start_pos, end_pos);
                return nextpit;
        }
 
@@ -451,11 +442,8 @@ TeXOnePar(Buffer const & buf,
                        // With CJK, only add switch if we have CJK content at the beginning
                        // of the paragraph
                        if (encoding->package() != Encoding::CJK || i == 0) {
-                               OutputParams tmp_rp = runparams;
-                               runparams.moving_arg = false;
                                pair<bool, int> enc_switch = switchEncoding(os, bparams, runparams,
                                        *encoding);
-                               runparams = tmp_rp;
                                // the following is necessary after a CJK environment in a multilingual
                                // context (nesting issue).
                                if (par_language->encoding()->package() == Encoding::CJK &&
@@ -543,7 +531,7 @@ TeXOnePar(Buffer const & buf,
        // FIXME UNICODE
        os << from_utf8(everypar);
        bool need_par = pit->latex(bparams, outerfont,
-                                            os, texrow, runparams);
+                                            os, texrow, runparams, start_pos, end_pos);
 
        // Make sure that \\par is done with the font of the last
        // character if this has another size as the default.
@@ -589,7 +577,7 @@ TeXOnePar(Buffer const & buf,
                        break;
        }
 
-               // fall through possible
+       // fall through possible
        default:
                // we don't need it for the last paragraph!!!
                if (nextpit != paragraphs.end())
@@ -667,9 +655,9 @@ TeXOnePar(Buffer const & buf,
        // also if the next paragraph is a multilingual environment (because of nesting)
        if (nextpit != paragraphs.end() && open_encoding_ == CJK &&
            (nextpit->getParLanguage(bparams)->encoding()->package() != Encoding::CJK ||
-            nextpit->layout().isEnvironment() && nextpit->isMultiLingual(bparams))
-            // in environments, CJK has to be closed later (nesting!)
-            && !style.isEnvironment()) {
+            (nextpit->layout().isEnvironment() && nextpit->isMultiLingual(bparams)))
+            // inbetween environments, CJK has to be closed later (nesting!)
+            && (!style.isEnvironment() || !nextpit->layout().isEnvironment())) {
                os << "\\end{CJK}\n";
                open_encoding_ = none;
        }
@@ -747,8 +735,6 @@ TeXOnePar(Buffer const & buf,
        return nextpit;
 }
 
-} // anon namespace
-
 
 // LaTeX all paragraphs
 void latexParagraphs(Buffer const & buf,
@@ -809,8 +795,7 @@ void latexParagraphs(Buffer const & buf,
                // FIXME This check should not be needed. We should
                // perhaps issue an error if it is.
                Layout const & layout = par->forcePlainLayout() ?
-                               tclass.plainLayout() :
-                               par->layout();
+                               tclass.plainLayout() : par->layout();
 
                if (layout.intitle) {
                        if (already_title) {
@@ -943,7 +928,7 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
                                count += 7;
                        }
                        if (runparams.local_font != 0
-                           && oldEnc.package() == Encoding::CJK) {
+                           &&  oldEnc.package() == Encoding::CJK) {
                                // within insets, \inputenc switches need
                                // to be embraced within \bgroup...\egroup;
                                // else CJK fails.