]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetIndex.cpp
de.po
[lyx.git] / src / insets / InsetIndex.cpp
index 05da188678e31f0008f13186c8c9f0aad9a9e45b..f3fafce60b00d8af9d62813a074fa3314236634a 100644 (file)
@@ -59,11 +59,13 @@ InsetIndex::InsetIndex(Buffer * buf, InsetIndexParams const & params)
 {}
 
 
-void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
+void InsetIndex::latex(otexstream & ios, OutputParams const & runparams_in) const
 {
        OutputParams runparams(runparams_in);
        runparams.inIndexEntry = true;
 
+       otexstringstream os;
+
        if (buffer().masterBuffer()->params().use_indices && !params_.index.empty()
            && params_.index != "idx") {
                os << "\\sindex[";
@@ -74,14 +76,19 @@ void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
                os << '{';
        }
 
-       // get contents of InsetText as LaTeX and plaintext
        odocstringstream ourlatex;
-       // FIXME: do Tex/Row correspondence (I don't currently understand what is
-       // being generated from latexstr below)
        otexstream ots(ourlatex);
        InsetText::latex(ots, runparams);
+       if (runparams.for_search) {
+               // No need for special handling, if we are only searching for some patterns
+               os << ourlatex.str() << "}";
+               return;
+       }
+       // get contents of InsetText as LaTeX and plaintext
        odocstringstream ourplain;
        InsetText::plaintext(ourplain, runparams);
+       // FIXME: do Tex/Row correspondence (I don't currently understand what is
+       // being generated from latexstr below)
        docstring latexstr = ourlatex.str();
        docstring plainstr = ourplain.str();
 
@@ -165,6 +172,13 @@ void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
                os << "|" << cmd;
        }
        os << '}';
+
+       // In macros with moving arguments, such as \section,
+       // we store the index and output it after the macro (#2154)
+       if (runparams_in.postpone_fragile_stuff)
+               runparams_in.post_macro += os.str();
+       else
+               ios << os.release();
 }