+}
+
+
+// function sets an object as defined in FuncStatus.h:
+// states OK, Unknown, Disabled, On, Off.
+bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
+ FuncStatus & status) const
+{
+ switch (cmd.action()) {
+ case LFUN_INSET_MODIFY:
+ if (cmd.getArg(0) != "tabular")
+ break;
+ if (cmd.getArg(1) == "for-dialog") {
+ // The dialog is asking the status of a command
+ if (&cur.inset() != this)
+ break;
+ string action = cmd.getArg(2);
+ string arg = cmd.getLongArg(3);
+ return getFeatureStatus(cur, action, arg, status);
+ } else {
+ // We always enable the lfun if it is coming from the dialog
+ // because the dialog makes sure all the settings are valid,
+ // even though the first argument might not be valid now.
+ status.setEnabled(true);
+ return true;
+ }
+
+ case LFUN_TABULAR_FEATURE: {
+ if (&cur.inset() != this)
+ break;
+ string action = cmd.getArg(0);
+ string arg = cmd.getLongArg(1);
+ return getFeatureStatus(cur, action, arg, status);
+ }
+
+ case LFUN_CAPTION_INSERT: {
+ // caption is only allowed in caption cell of longtable
+ if (!tabular.ltCaption(tabular.cellRow(cur.idx()))) {
+ status.setEnabled(false);
+ return true;
+ }
+ // only standard caption is allowed
+ string arg = cmd.getArg(0);
+ if (!arg.empty() && arg != "Standard") {
+ status.setEnabled(false);
+ return true;
+ }
+ // check if there is already a caption
+ bool have_caption = false;
+ InsetTableCell itc = InsetTableCell(*tabular.cellInset(cur.idx()));
+ ParagraphList::const_iterator pit = itc.paragraphs().begin();
+ ParagraphList::const_iterator pend = itc.paragraphs().end();
+ for (; pit != pend; ++pit) {
+ InsetList::const_iterator it = pit->insetList().begin();
+ InsetList::const_iterator end = pit->insetList().end();
+ for (; it != end; ++it) {
+ if (it->inset->lyxCode() == CAPTION_CODE) {
+ have_caption = true;
+ break;
+ }
+ }
+ }
+ status.setEnabled(!have_caption);
+ return true;