]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetLabel.cpp
Remove all BufferParam arguments in InsetXXX methods (since insets know about their...
[lyx.git] / src / insets / InsetLabel.cpp
index 88d2f4f6c579986851b4a112a6d75b2df4aefd10..93ccc40b28abc591ef469875ba958b064e548d60 100644 (file)
@@ -22,6 +22,8 @@
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "InsetIterator.h"
+#include "LyXFunc.h"
+#include "output_xhtml.h"
 #include "ParIterator.h"
 #include "sgml.h"
 #include "Text.h"
@@ -140,7 +142,8 @@ bool InsetLabel::getStatus(Cursor & cur, FuncRequest const & cmd,
 {
        bool enabled;
        switch (cmd.action) {
-       case LFUN_COPY_LABEL_AS_REF:
+       case LFUN_LABEL_INSERT_AS_REF:
+       case LFUN_LABEL_COPY_AS_REF:
                enabled = true;
                break;
        default:
@@ -169,11 +172,19 @@ void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd)
                break;
        }
 
-       case LFUN_COPY_LABEL_AS_REF: {
+       case LFUN_LABEL_COPY_AS_REF: {
                InsetCommandParams p(REF_CODE, "ref");
                p["reference"] = getParam("name");
                cap::clearSelection();
-               cap::copyInset(cur, new InsetRef(cur.buffer(), p), getParam("name"));
+               cap::copyInset(cur, new InsetRef(buffer(), p), getParam("name"));
+               break;
+       }
+
+       case LFUN_LABEL_INSERT_AS_REF: {
+               InsetCommandParams p(REF_CODE, "ref");
+               p["reference"] = getParam("name");
+               string const data = InsetCommand::params2string("ref", p);
+               lyx::dispatch(FuncRequest(LFUN_INSET_INSERT, data));
                break;
        }
 
@@ -208,4 +219,10 @@ int InsetLabel::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
+docstring InsetLabel::xhtml(odocstream & os, OutputParams const &) const
+{
+       os << "<a name=\"" << html::htmlize(getParam("name")) << "\"></a>";
+       return docstring();
+}
+
 } // namespace lyx