- if (it->inset->lyxCode() == InsetOld::FLOAT_CODE) {
- InsetFloat * il =
- static_cast<InsetFloat*>(it->inset);
- il->addToToc(toclist, buf);
- } else if (it->inset->lyxCode() == InsetOld::WRAP_CODE) {
- InsetWrap * il =
- static_cast<InsetWrap*>(it->inset);
-
- il->addToToc(toclist, buf);
+ 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;