]> git.lyx.org Git - lyx.git/blobdiff - src/output_latex.cpp
Less expensive OP first as this might be called often.
[lyx.git] / src / output_latex.cpp
index 358aae5b3fa001853c6a9f5d27e1d98d82aabd88..c24a5320e117cdebdb48711c67772be31a5ae8a2 100644 (file)
@@ -462,10 +462,10 @@ void TeXEnvironment(Buffer const & buf, Text const & text,
                // Do not output empty environments if the whole paragraph has
                // been deleted with ct and changes are not output.
                bool output_changes;
-               if (runparams.for_search == OutputParams::NoSearch)
+               if (!runparams.find_effective())
                        output_changes = buf.params().output_changes;
                else
-                       output_changes = ((runparams.for_search & OutputParams::SearchWithDeleted) != 0);
+                       output_changes = runparams.find_with_deleted();
                if (size_t(pit + 1) < paragraphs.size()) {
                        ParagraphList::const_iterator nextpar = paragraphs.iterator_at(pit + 1);
                        Paragraph const & cpar = paragraphs.at(pit);
@@ -578,7 +578,7 @@ void getArgInsets(otexstream & os, OutputParams const & runparams, Layout::LaTeX
                        }
                }
        }
-       if ((runparams.for_search != OutputParams::NoSearch) && argnr > 1) {
+       if (runparams.find_effective() && argnr > 1) {
                // Mark end of arguments for findadv() only
                os << "\\endarguments{}";
        }
@@ -746,7 +746,7 @@ void parStartCommand(Paragraph const & par, otexstream & os,
                break;
        case LATEX_ITEM_ENVIRONMENT:
        case LATEX_LIST_ENVIRONMENT:
-               if (runparams.for_search != OutputParams::NoSearch) {
+               if (runparams.find_effective()) {
                        os << "\\" + style.itemcommand() << "{" << style.latexname() << "}";
                }
                else {
@@ -758,7 +758,7 @@ void parStartCommand(Paragraph const & par, otexstream & os,
                }
                break;
        case LATEX_ENVIRONMENT:
-               if (runparams.for_search != OutputParams::NoSearch) {
+               if (runparams.find_effective()) {
                        os << "\\latexenvironment{" << style.latexname() << "}{";
                }
                break;
@@ -796,7 +796,7 @@ void TeXOnePar(Buffer const & buf,
 
        // Do not output empty commands if the whole paragraph has
        // been deleted with ct and changes are not output.
-       if (((runparams_in.for_search & OutputParams::SearchWithDeleted) == 0) && style.latextype != LATEX_ENVIRONMENT
+       if (!runparams_in.find_with_deleted() && style.latextype != LATEX_ENVIRONMENT
            && !par.empty() && par.isDeleted(0, par.size()) && !bparams.output_changes)
                return;
 
@@ -936,7 +936,7 @@ void TeXOnePar(Buffer const & buf,
        bool const have_prior_nptpar =
                        prior_nontitle_par && !prior_nontitle_par->isPassThru();
        Language const * const prev_language =
-               runparams_in.for_search != OutputParams::NoSearch
+               runparams_in.find_effective()
                        ? languages.getLanguage("ignore")
                        : (have_prior_nptpar)
                                ? (use_prev_env_language 
@@ -988,7 +988,7 @@ void TeXOnePar(Buffer const & buf,
                && !(have_prior_nptpar
                     && (prev_language->rightToLeft() != par_language->rightToLeft()));
        bool const localswitch =
-                       (runparams_in.for_search != OutputParams::NoSearch
+                       (runparams_in.find_effective()
                        || text.inset().forceLocalFontSwitch()
                        || (using_begin_end && text.inset().forcePlainLayout())
                        || in_polyglossia_rtl_env)
@@ -1003,7 +1003,7 @@ void TeXOnePar(Buffer const & buf,
        bool const localswitch_needed = localswitch && par_lang != outer_lang;
 
        // localswitches need to be closed and reopened at each par
-       if ((runparams_in.for_search != OutputParams::NoSearch) || ((par_lang != prev_lang || localswitch_needed)
+       if (runparams_in.find_effective() || ((par_lang != prev_lang || localswitch_needed)
             // check if we already put language command in TeXEnvironment()
             && !(style.isEnvironment()
                  && (pit == 0 || (priorpar->layout() != par.layout()
@@ -1063,7 +1063,7 @@ void TeXOnePar(Buffer const & buf,
                                else if (outer_language->lang() == "arabic_arabi")
                                        os << "\\textLR{";
                                // remaining RTL languages currently is hebrew
-                               else if (par_language->rightToLeft())
+                               else if (par_language->rightToLeft() && !runparams.isFullUnicode())
                                        os << "\\R{";
                                else
                                        os << "\\L{";
@@ -1071,7 +1071,7 @@ void TeXOnePar(Buffer const & buf,
                        // With CJK, the CJK tag has to be closed first (see below)
                        if ((runparams.encoding->package() != Encoding::CJK
                                 || bparams.useNonTeXFonts
-                                || (runparams.for_search != OutputParams::NoSearch))
+                                || runparams.find_effective())
                            && (par_lang != openLanguageName(state) || localswitch || intitle_command)
                            && !par_lang.empty()) {
                                string bc = use_polyglossia ?
@@ -1174,7 +1174,7 @@ void TeXOnePar(Buffer const & buf,
                                && (pit == 0 || !priorpar->hasSameLayout(par)))
                        {
                                os << from_ascii(par.params().spacing().writeEnvirBegin(useSetSpace))
-                                   << '\n';
+                                  << '\n';
                        }
 
                        if (style.isCommand()) {
@@ -1312,7 +1312,7 @@ void TeXOnePar(Buffer const & buf,
                // when the paragraph uses CJK, the language has to be closed earlier
                if ((font.language()->encoding()->package() != Encoding::CJK)
                        || bparams.useNonTeXFonts
-                       || (runparams_in.for_search != OutputParams::NoSearch)) {
+                       || runparams_in.find_effective()) {
                        if (lang_end_command.empty()) {
                                // If this is a child, we should restore the
                                // master language after the last paragraph.
@@ -1499,21 +1499,22 @@ void TeXOnePar(Buffer const & buf,
                Layout const & next_layout = nextpar->layout();
                if (!next_layout.isCommand()) {
                        // Here we now try to avoid spurious empty lines by
-                       // outputting a paragraph break only if: (case 1) the
-                       // paragraph style allows parbreaks and no \begin, \end
-                       // or \item tags are going to follow (i.e., if the next
-                       // isn't the first or the current isn't the last
-                       // paragraph of an environment or itemize) and the
-                       // depth and alignment of the following paragraph is
-                       // unchanged, or (case 2) the following is a
-                       // non-environment paragraph whose depth is increased
-                       // but whose alignment is unchanged, or (case 3) the
-                       // paragraph is not an environment and the next one is a
-                       // non-itemize-like env at lower depth, or (case 4) the
-                       // paragraph is a command not followed by an environment
-                       // and the alignment of the current and next paragraph
-                       // is unchanged, or (case 5) the current alignment is
-                       // changed and a standard paragraph follows.
+                       // outputting a paragraph break only if: 
+                       // (case 1) the paragraph style allows parbreaks and
+                       // no \begin, \end or \item tags are going to follow
+                       // (i.e., if the next isn't the first or the current
+                       // isn't the last paragraph of an environment or itemize)
+                       // and the depth and alignment of the following paragraph is
+                       // unchanged, or 
+                       // (case 2) the following is a non-environment paragraph
+                       // whose depth is increased but whose alignment is unchanged, or
+                       // (case 3) the paragraph is not an environment and the next one
+                       // is a non-itemize-like env at lower depth, or
+                       // (case 4) the paragraph is a command not followed by an
+                       // environment and the alignment of the current and next
+                       // paragraph is unchanged, or
+                       // (case 5) the current alignment is changed and a
+                       // standard paragraph follows.
                        DocumentClass const & tclass = bparams.documentClass();
                        if ((style == next_layout
                             && !style.parbreak_is_newline
@@ -1523,7 +1524,8 @@ void TeXOnePar(Buffer const & buf,
                             && style.latextype != LATEX_LIST_ENVIRONMENT
                             && style.align == par.getAlign(bparams)
                             && nextpar->getDepth() == par.getDepth()
-                            && nextpar->getAlign(bparams) == par.getAlign(bparams))
+                            && (nextpar->getAlign(bparams) == par.getAlign(bparams)
+                                || par.params().spacing() != nextpar->params().spacing()))
                            || (!next_layout.isEnvironment()
                                && nextpar->getDepth() > par.getDepth()
                                && nextpar->getAlign(bparams) == next_layout.align)
@@ -1708,10 +1710,10 @@ void latexParagraphs(Buffer const & buf,
                // Do not output empty environments if the whole paragraph has
                // been deleted with ct and changes are not output.
                bool output_changes;
-               if (runparams.for_search == OutputParams::NoSearch)
+               if (!runparams.find_effective())
                        output_changes = bparams.output_changes;
                else
-                       output_changes = ((runparams.for_search & OutputParams::SearchWithDeleted) != 0);
+                       output_changes = runparams.find_with_deleted();
                bool const lastpar = size_t(pit + 1) >= paragraphs.size();
                if (!lastpar) {
                        ParagraphList::const_iterator nextpar = paragraphs.iterator_at(pit + 1);
@@ -1854,7 +1856,7 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
                || oldEnc.package() == Encoding::japanese
                || oldEnc.package() == Encoding::none
                || newEnc.package() == Encoding::none
-               || (runparams.for_search != OutputParams::NoSearch))
+               || runparams.find_effective())
                return make_pair(false, 0);
        // FIXME We ignore encoding switches from/to encodings that do
        // neither support the inputenc package nor the CJK package here.