]> git.lyx.org Git - lyx.git/blobdiff - src/TocBackend.cpp
Fix caption numbering of child documents.
[lyx.git] / src / TocBackend.cpp
index f2fabd9bdca4fe06767653a15ca5ed3288215d73..e4504c47b8fbebab5ff30129873f6a18ac6d52f0 100644 (file)
@@ -176,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())
@@ -192,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);
@@ -217,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;
        }