]> git.lyx.org Git - lyx.git/blobdiff - src/Text.cpp
let the compiler do the maths to compute array size
[lyx.git] / src / Text.cpp
index 25f58d55dd89a1915e6a6592b12da989f90f8d7e..6c899a95e8f7f65d86210de687f785cd7dfa85ce 100644 (file)
@@ -1897,8 +1897,6 @@ docstring Text::getPossibleLabel(Cursor const & cur) const
        }
 
        if (!name.empty())
-               // FIXME refstyle
-               // We should allow customization of the separator or else change it
                text = name + ':' + text;
 
        return text;
@@ -1923,6 +1921,15 @@ docstring Text::asString(pit_type beg, pit_type end, int options) const
 }
 
 
+void Text::forToc(docstring & os, size_t maxlen, bool shorten) const
+{
+       LASSERT(maxlen > 10, maxlen = 30);
+       for (size_t i = 0; i != pars_.size() && os.length() < maxlen; ++i)
+               pars_[i].forToc(os, maxlen);
+       if (shorten && os.length() >= maxlen)
+               os = os.substr(0, maxlen - 3) + from_ascii("...");
+}
+
 
 void Text::charsTranspose(Cursor & cur)
 {