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"
28 using support::escape;
34 InsetLabel::InsetLabel(InsetCommandParams const & p)
35 : InsetCommand(p, "label")
39 std::auto_ptr<Inset> InsetLabel::doClone() const
41 return std::auto_ptr<Inset>(new InsetLabel(params()));
45 void InsetLabel::getLabelList(Buffer const &, std::vector<docstring> & list) const
47 list.push_back(getParam("name"));
51 docstring const InsetLabel::getScreenLabel(Buffer const &) const
53 return getParam("name");
57 void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd)
61 case LFUN_INSET_MODIFY: {
62 InsetCommandParams p("label");
64 InsetCommandMailer::string2params("label", to_utf8(cmd.argument()), p);
65 if (p.getCmdName().empty()) {
69 if (p["name"] != params()["name"])
70 cur.bv().buffer().changeRefsIfUnique(params()["name"],
71 p["name"], Inset::REF_CODE);
77 InsetCommand::doDispatch(cur, cmd);
83 int InsetLabel::latex(Buffer const &, odocstream & os,
84 OutputParams const &) const
86 os << escape(getCommand());
91 int InsetLabel::plaintext(Buffer const &, odocstream & os,
92 OutputParams const &) const
94 docstring const str = getParam("name");
95 os << '<' << str << '>';
96 return 2 + str.size();
100 int InsetLabel::docbook(Buffer const & buf, odocstream & os,
101 OutputParams const & runparams) const
103 os << "<!-- anchor id=\""
104 << sgml::cleanID(buf, runparams, getParam("name"))