]> git.lyx.org Git - lyx.git/blobdiff - src/Paragraph.cpp
Do not crash when entering math in ct mode with merge dialog open.
[lyx.git] / src / Paragraph.cpp
index 64870956cf8c88733a24ab2699d324f09e0194d0..d32c0be2f0ba95d1ddc315f10f4a4ef741c93d11 100644 (file)
@@ -3347,7 +3347,7 @@ docstring Paragraph::asString(int options) const
 }
 
 
-docstring Paragraph::asString(pos_type beg, pos_type end, int options, const OutputParams *p_runparams) const
+docstring Paragraph::asString(pos_type beg, pos_type end, int options) const
 {
        odocstringstream os;
 
@@ -3364,14 +3364,9 @@ docstring Paragraph::asString(pos_type beg, pos_type end, int options, const Out
                    || (c == '\n' && (options & AS_STR_NEWLINES)))
                        os.put(c);
                else if (c == META_INSET && (options & AS_STR_INSETS)) {
-                       if (options & AS_STR_PLAINTEXT) {
-                               LASSERT(p_runparams != 0, return docstring());
-                               getInset(i)->plaintext(os, *p_runparams);
-                       } else {
-                               getInset(i)->toString(os);
-                               if (getInset(i)->asInsetMath())
-                                       os << " ";
-                       }
+                       getInset(i)->toString(os);
+                       if (getInset(i)->asInsetMath())
+                               os << " ";
                }
        }
 
@@ -3397,6 +3392,33 @@ void Paragraph::forToc(docstring & os, size_t maxlen) const
 }
 
 
+docstring Paragraph::stringify(pos_type beg, pos_type end, int options,
+        OutputParams const & runparams) const
+{
+       odocstringstream os;
+
+       if (beg == 0
+               && options & AS_STR_LABEL
+               && !d->params_.labelString().empty())
+               os << d->params_.labelString() << ' ';
+
+       OutputParams op = runparams;
+       op.for_search = true;
+
+       for (pos_type i = beg; i < end; ++i) {
+               char_type const c = d->text_[i];
+               if (isPrintable(c) || c == '\t'
+                   || (c == '\n' && (options & AS_STR_NEWLINES)))
+                       os.put(c);
+               else if (c == META_INSET && (options & AS_STR_INSETS)) {
+                       getInset(i)->plaintext(os, op);
+               }
+       }
+
+       return os.str();
+}
+
+
 void Paragraph::setInsetOwner(Inset const * inset)
 {
        d->inset_owner_ = inset;