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 "frontends/LyXView.h"
27 #include "support/lstrings.h"
28 #include "support/lyxalgo.h"
29 #include "support/std_ostream.h"
31 using lyx::support::escape;
38 InsetLabel::InsetLabel(InsetCommandParams const & p)
39 : InsetCommand(p, "label")
43 std::auto_ptr<InsetBase> InsetLabel::doClone() const
45 return std::auto_ptr<InsetBase>(new InsetLabel(params()));
49 void InsetLabel::getLabelList(Buffer const &, std::vector<string> & list) const
51 list.push_back(getContents());
55 string const InsetLabel::getScreenLabel(Buffer const &) const
61 void InsetLabel::doDispatch(LCursor & cur, FuncRequest & cmd)
65 case LFUN_INSET_MODIFY: {
67 InsetCommandMailer::string2params("label", lyx::to_utf8(cmd.argument()), p);
68 if (p.getCmdName().empty()) {
72 if (p.getContents() != params().getContents())
73 cur.bv().buffer()->changeRefsIfUnique(params().getContents(),
80 InsetCommand::doDispatch(cur, cmd);
86 int InsetLabel::latex(Buffer const &, ostream & os,
87 OutputParams const &) const
89 os << escape(getCommand());
94 int InsetLabel::plaintext(Buffer const &, ostream & os,
95 OutputParams const &) const
97 os << '<' << getContents() << '>';
102 int InsetLabel::docbook(Buffer const & buf, ostream & os,
103 OutputParams const & runparams) const
105 os << "<!-- anchor id=\"" << sgml::cleanID(buf, runparams, getContents()) << "\" -->";