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"
30 InsetLabel::InsetLabel(InsetCommandParams const & p)
31 : InsetCommand(p, "label")
35 CommandInfo const * InsetLabel::findInfo(string const & /* cmdName */)
37 static const char * const paramnames[] = {"name", ""};
38 static const bool isoptional[] = {false};
39 static const CommandInfo info = {1, paramnames, isoptional};
44 Inset * InsetLabel::clone() const
46 return new InsetLabel(params());
50 void InsetLabel::getLabelList(Buffer const &, vector<docstring> & list) const
52 list.push_back(getParam("name"));
56 docstring const InsetLabel::getScreenLabel(Buffer const &) const
58 return getParam("name");
62 void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd)
66 case LFUN_INSET_MODIFY: {
67 InsetCommandParams p(LABEL_CODE);
69 InsetCommandMailer::string2params("label", to_utf8(cmd.argument()), p);
70 if (p.getCmdName().empty()) {
74 if (p["name"] != params()["name"])
75 cur.bv().buffer().changeRefsIfUnique(params()["name"],
82 InsetCommand::doDispatch(cur, cmd);
88 int InsetLabel::latex(Buffer const &, odocstream & os,
89 OutputParams const &) const
91 os << support::escape(getCommand());
96 int InsetLabel::plaintext(Buffer const &, odocstream & os,
97 OutputParams const &) const
99 docstring const str = getParam("name");
100 os << '<' << str << '>';
101 return 2 + str.size();
105 int InsetLabel::docbook(Buffer const & buf, odocstream & os,
106 OutputParams const & runparams) const
108 os << "<!-- anchor id=\""
109 << sgml::cleanID(buf, runparams, getParam("name"))