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"
29 InsetLabel::InsetLabel(InsetCommandParams const & p)
30 : InsetCommand(p, "label")
34 Inset * InsetLabel::clone() const
36 return new InsetLabel(params());
40 void InsetLabel::getLabelList(Buffer const &, std::vector<docstring> & list) const
42 list.push_back(getParam("name"));
46 docstring const InsetLabel::getScreenLabel(Buffer const &) const
48 return getParam("name");
52 void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd)
56 case LFUN_INSET_MODIFY: {
57 InsetCommandParams p(LABEL_CODE);
59 InsetCommandMailer::string2params("label", to_utf8(cmd.argument()), p);
60 if (p.getCmdName().empty()) {
64 if (p["name"] != params()["name"])
65 cur.bv().buffer().changeRefsIfUnique(params()["name"],
72 InsetCommand::doDispatch(cur, cmd);
78 int InsetLabel::latex(Buffer const &, odocstream & os,
79 OutputParams const &) const
81 os << support::escape(getCommand());
86 int InsetLabel::plaintext(Buffer const &, odocstream & os,
87 OutputParams const &) const
89 docstring const str = getParam("name");
90 os << '<' << str << '>';
91 return 2 + str.size();
95 int InsetLabel::docbook(Buffer const & buf, odocstream & os,
96 OutputParams const & runparams) const
98 os << "<!-- anchor id=\""
99 << sgml::cleanID(buf, runparams, getParam("name"))