]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetLabel.cpp
InsetTabular.cpp: fix #6585 also for wrapped floats - thanks Vincent
[lyx.git] / src / insets / InsetLabel.cpp
index 3eaa89f3f9ab8519cd8164a7249213a5fe91b48f..9c41e602ca6b443de8f960600a1a64d23e552947 100644 (file)
@@ -24,7 +24,7 @@
 #include "FuncStatus.h"
 #include "InsetIterator.h"
 #include "Language.h"
-#include "LyXFunc.h"
+#include "LyX.h"
 #include "output_xhtml.h"
 #include "ParIterator.h"
 #include "sgml.h"
@@ -49,7 +49,7 @@ namespace lyx {
 
 
 InsetLabel::InsetLabel(Buffer * buf, InsetCommandParams const & p)
-       : InsetCommand(buf, p, "label")
+       : InsetCommand(buf, p)
 {}
 
 
@@ -86,21 +86,15 @@ void InsetLabel::updateCommand(docstring const & new_label, bool updaterefs)
                for (; it != end; ++it) {
                        buffer().undo().recordUndo(it->second);
                        if (it->first->lyxCode() == MATH_REF_CODE) {
-                               InsetMathHull * mi =
-                                       static_cast<InsetMathHull *>(it->first);
+                               InsetMathHull * mi = it->first->asInsetMath()->asHullInset();
                                mi->asRefInset()->changeTarget(label);
                        } else {
-                               InsetCommand * ref =
-                                       static_cast<InsetCommand *>(it->first);
+                               InsetCommand * ref = it->first->asInsetCommand();
                                ref->setParam("reference", label);
                        }
                }
        }
        buffer().undo().endUndoGroup();
-
-       // We need an update of the Buffer reference cache. This is achieved by
-       // updateLabels().
-       buffer().updateLabels();
 }
 
 
@@ -108,7 +102,8 @@ ParamInfo const & InsetLabel::findInfo(string const & /* cmdName */)
 {
        static ParamInfo param_info_;
        if (param_info_.empty())
-               param_info_.add("name", ParamInfo::LATEX_REQUIRED);
+               param_info_.add("name", ParamInfo::LATEX_REQUIRED,
+                               ParamInfo::HANDLING_ESCAPE);
        return param_info_;
 }
 
@@ -119,7 +114,7 @@ docstring InsetLabel::screenLabel() const
 }
 
 
-void InsetLabel::updateLabels(ParIterator const & par, UpdateType utype)
+void InsetLabel::updateBuffer(ParIterator const & par, UpdateType utype)
 {
        docstring const & label = getParam("name");
        if (buffer().insetLabel(label)) {
@@ -163,7 +158,7 @@ void InsetLabel::addToToc(DocIterator const & cpit)
                DocIterator const ref_pit(it->second);
                if (it->first->lyxCode() == MATH_REF_CODE)
                        toc.push_back(TocItem(ref_pit, 1,
-                               static_cast<InsetMathHull *>(it->first)->asRefInset()
+                               it->first->asInsetMath()->asHullInset()->asRefInset()
                                        ->screenLabel()));
                else
                        toc.push_back(TocItem(ref_pit, 1,
@@ -176,7 +171,7 @@ bool InsetLabel::getStatus(Cursor & cur, FuncRequest const & cmd,
                           FuncStatus & status) const
 {
        bool enabled;
-       switch (cmd.action) {
+       switch (cmd.action()) {
        case LFUN_LABEL_INSERT_AS_REF:
        case LFUN_LABEL_COPY_AS_REF:
                enabled = true;
@@ -192,18 +187,19 @@ bool InsetLabel::getStatus(Cursor & cur, FuncRequest const & cmd,
 
 void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
-       switch (cmd.action) {
+       switch (cmd.action()) {
 
        case LFUN_INSET_MODIFY: {
                InsetCommandParams p(LABEL_CODE);
                // FIXME UNICODE
-               InsetCommand::string2params("label", to_utf8(cmd.argument()), p);
+               InsetCommand::string2params(to_utf8(cmd.argument()), p);
                if (p.getCmdName().empty()) {
-                       cur.noUpdate();
+                       cur.noScreenUpdate();
                        break;
                }
                if (p["name"] != params()["name"])
                        updateCommand(p["name"]);
+               cur.forceBufferUpdate();
                break;
        }
 
@@ -218,7 +214,7 @@ void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_LABEL_INSERT_AS_REF: {
                InsetCommandParams p(REF_CODE, "ref");
                p["reference"] = getParam("name");
-               string const data = InsetCommand::params2string("ref", p);
+               string const data = InsetCommand::params2string(p);
                lyx::dispatch(FuncRequest(LFUN_INSET_INSERT, data));
                break;
        }
@@ -230,13 +226,6 @@ void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd)
 }
 
 
-int InsetLabel::latex(odocstream & os, OutputParams const &) const
-{
-       os << escape(getCommand());
-       return 0;
-}
-
-
 int InsetLabel::plaintext(odocstream & os, OutputParams const &) const
 {
        docstring const str = getParam("name");