+ case LFUN_ARGUMENT_INSERT: {
+ string const arg = cmd.getArg(0);
+ if (arg.empty()) {
+ status.setEnabled(false);
+ return true;
+ }
+ if (&buffer().inset() == this || !cur.paragraph().layout().args().empty())
+ return text_.getStatus(cur, cmd, status);
+
+ Layout::LaTeXArgMap args = getLayout().args();
+ 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);
+ if (ins->name() == arg) {
+ // we have this already
+ status.setEnabled(false);
+ return true;
+ }
+ }
+ }
+ }
+ } else
+ status.setEnabled(false);
+ return true;
+ }
+