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"
29 using lyx::support::escape;
36 InsetLabel::InsetLabel(InsetCommandParams const & p)
37 : InsetCommand(p, "label")
41 std::auto_ptr<InsetBase> InsetLabel::doClone() const
43 return std::auto_ptr<InsetBase>(new InsetLabel(params()));
47 void InsetLabel::getLabelList(Buffer const &, std::vector<string> & list) const
49 list.push_back(getContents());
53 string const InsetLabel::getScreenLabel(Buffer const &) const
59 void InsetLabel::doDispatch(LCursor & cur, FuncRequest & cmd)
63 case LFUN_INSET_MODIFY: {
65 InsetCommandMailer::string2params("label", lyx::to_utf8(cmd.argument()), p);
66 if (p.getCmdName().empty()) {
70 if (p.getContents() != params().getContents())
71 cur.bv().buffer()->changeRefsIfUnique(params().getContents(),
78 InsetCommand::doDispatch(cur, cmd);
84 int InsetLabel::latex(Buffer const &, ostream & os,
85 OutputParams const &) const
87 os << escape(getCommand());
92 int InsetLabel::plaintext(Buffer const &, ostream & os,
93 OutputParams const &) const
95 os << '<' << getContents() << '>';
100 int InsetLabel::docbook(Buffer const & buf, ostream & os,
101 OutputParams const & runparams) const
103 os << "<!-- anchor id=\"" << sgml::cleanID(buf, runparams, getContents()) << "\" -->";