for (; pit <= lastpit; ++pit) {
if (pars_[pit].layout() != lay)
break;
- InsetList::const_iterator it = pars_[pit].insetList().begin();
- InsetList::const_iterator end = pars_[pit].insetList().end();
- for (; it != end; ++it) {
- if (it->inset->lyxCode() == ARG_CODE) {
- InsetArgument const * ins =
- static_cast<InsetArgument const *>(it->inset);
+ for (auto const & table : pars_[pit].insetList())
+ if (InsetArgument const * ins = table.inset->asInsetArgument())
if (ins->name() == arg) {
// we have this already
enable = false;
break;
}
- }
- }
}
} else
enable = false;
#include "Paragraph.h"
#include "TextClass.h"
-#include "insets/InsetText.h"
+#include "insets/InsetArgument.h"
#include "support/debug.h"
#include "support/docstream.h"
// FIXME: This is supposed to accomplish the same as the body of
// InsetText::iterateForToc(), probably
Paragraph & par = toc_item->dit().paragraph();
- InsetList::const_iterator it = par.insetList().begin();
- InsetList::const_iterator end = par.insetList().end();
- for (; it != end; ++it) {
- Inset & inset = *it->inset;
- if (inset.lyxCode() == ARG_CODE) {
+ for (auto const & table : par.insetList())
+ if (InsetArgument const * arg = table.inset->asInsetArgument()) {
tocstring = par.labelString();
if (!tocstring.empty())
tocstring += ' ';
- inset.asInsetText()->text().forOutliner(tocstring,TOC_ENTRY_LENGTH);
+ arg->text().forOutliner(tocstring,TOC_ENTRY_LENGTH);
break;
}
- }
int const toclevel = toc_item->dit().text()->
getTocLevel(toc_item->dit().pit());
class DocIterator;
class FuncRequest;
class FuncStatus;
+class InsetArgument;
class InsetCollapsable;
class InsetCommand;
class InsetIterator;
virtual InsetCommand * asInsetCommand() { return 0; }
/// is this inset based on the InsetCommand class?
virtual InsetCommand const * asInsetCommand() const { return 0; }
+ /// is this inset based on the InsetArgument class?
+ virtual InsetArgument const * asInsetArgument() const { return nullptr; }
/// the real dispatcher
void dispatch(Cursor & cur, FuncRequest & cmd);
Layout::LaTeXArgMap::const_iterator const lait = args.find(type);
if (lait != args.end()) {
flag.setEnabled(true);
- InsetList::const_iterator it = cur.paragraph().insetList().begin();
- InsetList::const_iterator end = cur.paragraph().insetList().end();
- for (; it != end; ++it) {
- if (it->inset->lyxCode() == ARG_CODE) {
- InsetArgument const * ins =
- static_cast<InsetArgument const *>(it->inset);
+ for (auto const & table : cur.paragraph().insetList())
+ if (InsetArgument const * ins = table.inset->asInsetArgument())
if (ins->name() == type) {
// we have this already
flag.setEnabled(false);
return true;
}
- }
- }
} else
flag.setEnabled(false);
return true;
///
InsetArgument(Buffer *, std::string const &);
+ ///
+ InsetArgument const * asInsetArgument() const { return this; }
+
/// Outputting the parameter of a LaTeX command
void latexArgument(otexstream & os, OutputParams const & runparams_in,
docstring const & ldelim, docstring const & rdelim,
Layout::LaTeXArgMap::const_iterator const lait = args.find(arg);
if (lait != args.end()) {
status.setEnabled(true);
- ParagraphList::const_iterator pit = paragraphs().begin();
- for (; pit != paragraphs().end(); ++pit) {
- InsetList::const_iterator it = pit->insetList().begin();
- InsetList::const_iterator end = pit->insetList().end();
- for (; it != end; ++it) {
- if (it->inset->lyxCode() == ARG_CODE) {
- InsetArgument const * ins =
- static_cast<InsetArgument const *>(it->inset);
+ for (Paragraph const & par : paragraphs())
+ for (auto const & table : par.insetList())
+ if (InsetArgument const * ins = table.inset->asInsetArgument())
if (ins->name() == arg) {
// we have this already
status.setEnabled(false);
return true;
}
- }
- }
- }
} else
status.setEnabled(false);
return true;
}
// if we find an optarg, we'll save it for use later.
- InsetText const * arginset = 0;
- InsetList::const_iterator it = par.insetList().begin();
- InsetList::const_iterator end = par.insetList().end();
- for (; it != end; ++it) {
- Inset & inset = *it->inset;
- dit.pos() = it->pos;
- //lyxerr << (void*)&inset << " code: " << inset.lyxCode() << std::endl;
- inset.addToToc(dit, doing_output, utype, backend);
- if (inset.lyxCode() == ARG_CODE)
- arginset = inset.asInsetText();
+ InsetArgument const * arginset = nullptr;
+ for (auto const & table : par.insetList()) {
+ dit.pos() = table.pos;
+ table.inset->addToToc(dit, doing_output, utype, backend);
+ if (InsetArgument const * x = table.inset->asInsetArgument())
+ arginset = x;
}
// End custom AddToToc in paragraph layouts
InsetList::const_iterator it = par.insetList().begin();
InsetList::const_iterator end = par.insetList().end();
for (; it != end; ++it) {
- if (it->inset->lyxCode() == ARG_CODE) {
- InsetArgument const * ins =
- static_cast<InsetArgument const *>(it->inset);
+ if (InsetArgument const * ins = it->inset->asInsetArgument()) {
if (ins->name().empty())
LYXERR0("Error: Unnamed argument inset!");
else {
getArgInsets(os, runparams, latexargs, ilist, required, prefix);
}
+
namespace {
// output the proper paragraph start according to latextype.