- // FLOAT_CODE
-
- if (found) {
- Paragraph::inset_iterator it =
- par->inset_iterator_begin();
- Paragraph::inset_iterator end =
- par->inset_iterator_end();
-
- for (; it != end; ++it) {
- if ((*it)->lyxCode() == Inset::FLOAT_CODE) {
- InsetFloat * il =
- static_cast<InsetFloat*>(*it);
-
- string const type = il->type();
-
- // Now find the caption in the float...
- // We now tranverse the paragraphs of
- // the inset...
- Paragraph * tmp = il->inset.paragraph();
- while (tmp) {
- if (tmp->layout()->name() == layout) {
- string const str =
- tostr(toclist[type].size()+1) + ". " + tmp->asString(buf, false);
- TocItem const item(tmp, 0 , str);
- toclist[type].push_back(item);
- }
- tmp = tmp->next();
- }
- }
+ // 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);
+ break;
+ case InsetBase::OPTARG_CODE: {
+ if (!tocstring.empty())
+ break;
+ Paragraph const & par = *static_cast<InsetOptArg*>(it->inset)->paragraphs().begin();
+ if (!pit->getLabelstring().empty())
+ tocstring = pit->getLabelstring()
+ + ' ';
+ tocstring += par.asString(buf, false);
+ break;
+ }
+ default:
+ break;