]> git.lyx.org Git - lyx.git/blobdiff - src/TocBackend.cpp
Fix caption numbering of child documents.
[lyx.git] / src / TocBackend.cpp
index 984eb1ab65863b3f273e7c25ccdf4c60e46f2c8f..e4504c47b8fbebab5ff30129873f6a18ac6d52f0 100644 (file)
@@ -76,7 +76,9 @@ docstring const TocItem::asString() const
 
 FuncRequest TocItem::action() const
 {
-       return FuncRequest(LFUN_PARAGRAPH_GOTO, convert<string>(id()));
+       string const arg = convert<string>(dit_.paragraph().id())
+               + ' ' + convert<string>(dit_.pos());
+       return FuncRequest(LFUN_PARAGRAPH_GOTO, arg);
 }
 
 
@@ -174,6 +176,7 @@ void TocBackend::update()
                        case OPTARG_CODE: {
                                if (!tocstring.empty())
                                        break;
+                               pit.pos() = 0;
                                Paragraph const & par =
                                        *static_cast<InsetOptArg&>(inset).paragraphs().begin();
                                if (!pit->labelString().empty())
@@ -190,6 +193,7 @@ void TocBackend::update()
                int const toclevel = pit->layout().toclevel;
                if (toclevel != Layout::NOT_IN_TOC
                    && toclevel >= min_toclevel) {
+                       pit.pos() = 0;
                        // insert this into the table of contents
                        if (tocstring.empty())
                                tocstring = pit->asString(true);
@@ -215,20 +219,20 @@ TocIterator TocBackend::item(string const & type,
 
        --it;
 
-       ParConstIterator par_it_text(dit);
-       if (par_it_text.inMathed()) {
+       DocIterator dit_text = dit;
+       if (dit_text.inMathed()) {
                // We are only interested in text so remove the math CursorSlice.
-               while (par_it_text.inMathed())
-                       par_it_text.pop_back();
+               while (dit_text.inMathed())
+                       dit_text.pop_back();
        }
 
        for (; it != last; --it) {
                // We verify that we don't compare contents of two
                // different document. This happens when you
                // have parent and child documents.
-               if (&it->dit_[0].inset() != &par_it_text[0].inset())
+               if (&it->dit_[0].inset() != &dit_text[0].inset())
                        continue;
-               if (it->dit_ <= par_it_text)
+               if (it->dit_ <= dit_text)
                        return it;
        }