3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS.
13 #include "InsetLabel.h"
16 #include "BufferView.h"
17 #include "DispatchResult.h"
18 #include "FuncRequest.h"
22 #include "support/lstrings.h"
23 #include "support/lyxalgo.h"
26 using namespace lyx::support;
31 InsetLabel::InsetLabel(InsetCommandParams const & p)
32 : InsetCommand(p, "label")
36 ParamInfo const & InsetLabel::findInfo(string const & /* cmdName */)
38 static ParamInfo param_info_;
39 if (param_info_.empty()) {
40 param_info_.add("name", false);
46 Inset * InsetLabel::clone() const
48 return new InsetLabel(params());
52 void InsetLabel::getLabelList(Buffer const &, vector<docstring> & list) const
54 list.push_back(getParam("name"));
58 docstring const InsetLabel::getScreenLabel(Buffer const &) const
60 return getParam("name");
64 void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd)
68 case LFUN_INSET_MODIFY: {
69 InsetCommandParams p(LABEL_CODE);
71 InsetCommandMailer::string2params("label", to_utf8(cmd.argument()), p);
72 if (p.getCmdName().empty()) {
76 if (p["name"] != params()["name"])
77 cur.bv().buffer().changeRefsIfUnique(params()["name"],
84 InsetCommand::doDispatch(cur, cmd);
90 int InsetLabel::latex(Buffer const &, odocstream & os,
91 OutputParams const &) const
93 os << escape(getCommand());
98 int InsetLabel::plaintext(Buffer const &, odocstream & os,
99 OutputParams const &) const
101 docstring const str = getParam("name");
102 os << '<' << str << '>';
103 return 2 + str.size();
107 int InsetLabel::docbook(Buffer const & buf, odocstream & os,
108 OutputParams const & runparams) const
110 os << "<!-- anchor id=\""
111 << sgml::cleanID(buf, runparams, getParam("name"))