+
+
+// Convert the paragraph to a string.
+// Used for building the table of contents
+string LyXParagraph::String(bool label)
+{
+ string s;
+ if (label && !IsDummy())
+ s += labelstring + ' ';
+ string::size_type len = s.size();
+
+ for (LyXParagraph::size_type i = 0; i < size(); ++i) {
+ unsigned char c = GetChar(i);
+ if (IsPrintable(c))
+ s += c;
+ else if (c == META_INSET &&
+ GetInset(i)->LyxCode() == Inset::MATH_CODE) {
+#ifdef HAVE_SSTREAM
+ std::ostringstream ost;
+ GetInset(i)->Ascii(ost);
+#else
+ ostrstream ost;
+ GetInset(i)->Ascii(ost);
+ ost << '\0';
+#endif
+ s += subst(ost.str(),'\n',' ');
+ }
+ }
+
+ if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
+ s += NextAfterFootnote()->String(false);
+
+ if (!IsDummy()) {
+ if (isRightToLeftPar())
+ reverse(s.begin() + len,s.end());
+ }
+ return s;
+}
+
+
+string LyXParagraph::String(LyXParagraph::size_type beg,
+ LyXParagraph::size_type end)
+{
+ string s;
+
+ for (LyXParagraph::size_type i = beg; i < end; ++i) {
+ unsigned char c = GetChar(i);
+ if (IsPrintable(c))
+ s += c;
+ else if (c == META_INSET) {
+#ifdef HAVE_SSTREAM
+ std::ostringstream ost;
+ GetInset(i)->Ascii(ost);
+#else
+ ostrstream ost;
+ GetInset(i)->Ascii(ost);
+ ost << '\0';
+#endif
+ s += subst(ost.str(),'\n',' ');
+ }
+ }
+
+ if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
+ s += NextAfterFootnote()->String(false);
+
+ if (!IsDummy()) {
+ if (isRightToLeftPar())
+ reverse(s.begin(), s.end());
+ }
+ return s;
+}