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"
19 #include "InsetList.h"
21 #include "paragraph.h"
22 #include "pariterator.h"
25 #include "support/lstrings.h"
26 #include "support/lyxalgo.h"
27 #include "support/std_ostream.h"
32 using support::escape;
39 InsetLabel::InsetLabel(InsetCommandParams const & p)
40 : InsetCommand(p, "label")
44 std::auto_ptr<InsetBase> InsetLabel::doClone() const
46 return std::auto_ptr<InsetBase>(new InsetLabel(params()));
50 void InsetLabel::getLabelList(Buffer const &, std::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(LCursor & cur, FuncRequest & cmd)
66 case LFUN_INSET_MODIFY: {
67 InsetCommandParams p("label");
68 InsetCommandMailer::string2params("label", to_utf8(cmd.argument()), p);
69 if (p.getCmdName().empty()) {
73 if (p["name"] != params()["name"])
75 cur.bv().buffer()->changeRefsIfUnique(to_utf8(params()["name"]),
76 to_utf8(p["name"]), InsetBase::REF_CODE);
82 InsetCommand::doDispatch(cur, cmd);
88 int InsetLabel::latex(Buffer const &, odocstream & os,
89 OutputParams const &) const
91 os << escape(getCommand());
96 int InsetLabel::plaintext(Buffer const &, odocstream & os,
97 OutputParams const &) const
99 os << '<' << getParam("name") << '>';
104 int InsetLabel::docbook(Buffer const & buf, odocstream & os,
105 OutputParams const & runparams) const
108 os << "<!-- anchor id=\""
109 << from_ascii(sgml::cleanID(buf, runparams, lyx::to_ascii(getParam("name"))))