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"
15 #include "BufferView.h"
16 #include "dispatchresult.h"
17 #include "funcrequest.h"
19 #include "frontends/LyXView.h"
21 #include "support/lstrings.h"
23 #include "support/std_ostream.h"
25 using lyx::support::escape;
31 InsetLabel::InsetLabel(InsetCommandParams const & p)
32 : InsetCommand(p, "label")
36 std::auto_ptr<InsetBase> InsetLabel::clone() const
38 return std::auto_ptr<InsetBase>(new InsetLabel(params()));
42 void InsetLabel::getLabelList(Buffer const &, std::vector<string> & list) const
44 list.push_back(getContents());
48 string const InsetLabel::getScreenLabel(Buffer const &) const
55 InsetLabel::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
59 case LFUN_INSET_MODIFY: {
61 InsetCommandMailer::string2params("label", cmd.argument, p);
62 if (p.getCmdName().empty())
63 return DispatchResult(false);
65 if (p.getContents() != params().getContents())
66 clean = cur.bv().ChangeRefsIfUnique(params().getContents(),
70 return DispatchResult(true, true);
74 return InsetCommand::priv_dispatch(cur, cmd);
79 int InsetLabel::latex(Buffer const &, ostream & os,
80 OutputParams const &) const
82 os << escape(getCommand());
87 int InsetLabel::plaintext(Buffer const &, ostream & os,
88 OutputParams const &) const
90 os << '<' << getContents() << '>';
95 int InsetLabel::linuxdoc(Buffer const &, ostream & os,
96 OutputParams const &) const
98 os << "<label id=\"" << getContents() << "\" >";
103 int InsetLabel::docbook(Buffer const &, ostream & os,
104 OutputParams const &) const
106 os << "<anchor id=\"" << getContents() << "\">";