- string const tmp = convert<string>(id_);
- lv_.dispatch(FuncRequest(LFUN_GOTO_PARAGRAPH, tmp));
-}
-
-
-FuncRequest TocItem::action() const
-{
- return FuncRequest(LFUN_GOTO_PARAGRAPH, convert<string>(id_));
-}
-
-
-string const getType(string const & cmdName)
-{
- // special case
- if (cmdName == "tableofcontents")
- return "TOC";
- else
- return cmdName;
-}
-
-
-TocList const getTocList(Buffer const & buf)
-{
- TocList toclist;
-
- BufferParams const & bufparams = buf.params();
- const int min_toclevel = bufparams.getLyXTextClass().min_toclevel();
-
- ParConstIterator pit = buf.par_iterator_begin();
- ParConstIterator end = buf.par_iterator_end();
- for (; pit != end; ++pit) {
-
- // the string that goes to the toc (could be the optarg)
- string tocstring;
-
- // For each paragraph, traverse its insets and look for
- // FLOAT_CODE or WRAP_CODE
- InsetList::const_iterator it = pit->insetlist.begin();
- InsetList::const_iterator end = pit->insetlist.end();
- for (; it != end; ++it) {
- switch (it->inset->lyxCode()) {
- case InsetBase::FLOAT_CODE:
- static_cast<InsetFloat*>(it->inset)
- ->addToToc(toclist, buf);
- break;
- case InsetBase::WRAP_CODE:
- static_cast<InsetWrap*>(it->inset)
- ->addToToc(toclist, buf);
+ Buffer * buf = & cur.buffer();
+ pit_type & pit = cur.pit();
+ ParagraphList & pars = buf->text().paragraphs();
+ ParagraphList::iterator bgn = pars.begin();
+ // The first paragraph of the area to be copied:
+ ParagraphList::iterator start = boost::next(bgn, pit);
+ // The final paragraph of area to be copied:
+ ParagraphList::iterator finish = start;
+ ParagraphList::iterator end = pars.end();
+
+ LyXTextClass::const_iterator lit =
+ buf->params().getLyXTextClass().begin();
+ LyXTextClass::const_iterator const lend =
+ buf->params().getLyXTextClass().end();
+
+ int const thistoclevel = start->layout()->toclevel;
+ int toclevel;
+ switch (mode) {
+ case Up: {
+ // Move out (down) from this section header
+ if (finish != end)
+ ++finish;
+ // Seek the one (on same level) below
+ for (; finish != end; ++finish) {
+ toclevel = finish->layout()->toclevel;
+ if (toclevel != LyXLayout::NOT_IN_TOC
+ && toclevel <= thistoclevel) {
+ break;
+ }
+ }
+ ParagraphList::iterator dest = start;
+ // Move out (up) from this header
+ if (dest != bgn)
+ --dest;
+ else