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 CommandInfo const * InsetLabel::findInfo(std::string const & /* cmdName */)
36 static const char * const paramnames[] = {"name", ""};
37 static const bool isoptional[] = {false};
38 static const CommandInfo info = {1, paramnames, isoptional};
43 Inset * InsetLabel::clone() const
45 return new InsetLabel(params());
49 void InsetLabel::getLabelList(Buffer const &, std::vector<docstring> & list) const
51 list.push_back(getParam("name"));
55 docstring const InsetLabel::getScreenLabel(Buffer const &) const
57 return getParam("name");
61 void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd)
65 case LFUN_INSET_MODIFY: {
66 InsetCommandParams p(LABEL_CODE);
68 InsetCommandMailer::string2params("label", to_utf8(cmd.argument()), p);
69 if (p.getCmdName().empty()) {
73 if (p["name"] != params()["name"])
74 cur.bv().buffer().changeRefsIfUnique(params()["name"],
81 InsetCommand::doDispatch(cur, cmd);
87 int InsetLabel::latex(Buffer const &, odocstream & os,
88 OutputParams const &) const
90 os << support::escape(getCommand());
95 int InsetLabel::plaintext(Buffer const &, odocstream & os,
96 OutputParams const &) const
98 docstring const str = getParam("name");
99 os << '<' << str << '>';
100 return 2 + str.size();
104 int InsetLabel::docbook(Buffer const & buf, odocstream & os,
105 OutputParams const & runparams) const
107 os << "<!-- anchor id=\""
108 << sgml::cleanID(buf, runparams, getParam("name"))