]> git.lyx.org Git - lyx.git/commitdiff
Fix bug #7230. Changes at r36974 had not been done properly. But this is
authorRichard Heck <rgheck@comcast.net>
Wed, 12 Jan 2011 21:25:45 +0000 (21:25 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 12 Jan 2011 21:25:45 +0000 (21:25 +0000)
better than what we had, anyway, since we do not calculate the tocstring
unless we need it.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37190 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetText.cpp

index 05abde1d225f15ae49c38461517b7c17a13429ca..a71d25f623fac0c0fa0aa1944bc0129a5c973cec 100644 (file)
@@ -698,8 +698,8 @@ void InsetText::addToToc(DocIterator const & cdit)
        for (pit_type pit = 0; pit != pend; ++pit) {
                Paragraph const & par = pars[pit];
                dit.pit() = pit;
-               // the string that goes to the toc (could be the optarg)
-               docstring tocstring;
+               // if we find an optarg, we'll save it for use later.
+               InsetText * arginset = 0;
                InsetList::const_iterator it  = par.insetList().begin();
                InsetList::const_iterator end = par.insetList().end();
                for (; it != end; ++it) {
@@ -707,16 +707,22 @@ void InsetText::addToToc(DocIterator const & cdit)
                        dit.pos() = it->pos;
                        //lyxerr << (void*)&inset << " code: " << inset.lyxCode() << std::endl;
                        inset.addToToc(dit);
-                       if (inset.lyxCode() == ARG_CODE && tocstring.empty())
-                               inset.asInsetText()->text().forToc(tocstring, TOC_ENTRY_LENGTH);
+                       if (inset.lyxCode() == ARG_CODE)
+                               arginset = inset.asInsetText();
                }
                // now the toc entry for the paragraph
                int const toclevel = par.layout().toclevel;
                if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel) {
-                       dit.pos() = 0;
                        // insert this into the table of contents
-                       if (tocstring.empty())
+                       docstring tocstring;
+                       if (arginset) {
+                               tocstring = par.labelString();
+                               if (!tocstring.empty())
+                                       tocstring += ' ';
+                               arginset->text().forToc(tocstring, TOC_ENTRY_LENGTH);
+                       } else
                                par.forToc(tocstring, TOC_ENTRY_LENGTH);
+                       dit.pos() = 0;
                        toc.push_back(TocItem(dit, toclevel - min_toclevel,
                                tocstring, tocstring));
                }