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)
36 InsetLabel::~InsetLabel()
38 InsetCommandMailer("label", *this).hideDialog();
42 std::auto_ptr<InsetBase> InsetLabel::clone() const
44 return std::auto_ptr<InsetBase>(new InsetLabel(params()));
48 void InsetLabel::getLabelList(Buffer const &, std::vector<string> & list) const
50 list.push_back(getContents());
54 string const InsetLabel::getScreenLabel(Buffer const &) const
61 InsetLabel::priv_dispatch(FuncRequest const & cmd,
62 idx_type & idx, pos_type & pos)
64 BOOST_ASSERT(cmd.view());
65 BufferView * const bv = cmd.view();
70 InsetCommandMailer("label", *this).showDialog(bv);
71 return DispatchResult(DISPATCHED);
74 case LFUN_INSET_MODIFY: {
76 InsetCommandMailer::string2params(cmd.argument, p);
77 if (p.getCmdName().empty())
78 return DispatchResult(UNDISPATCHED);
81 if (bv && p.getContents() != params().getContents()) {
82 clean = bv->ChangeRefsIfUnique(params().getContents(),
87 bv->updateInset(this);
88 return DispatchResult(DISPATCHED);
92 return InsetCommand::priv_dispatch(cmd, idx, pos);
97 int InsetLabel::latex(Buffer const &, ostream & os,
98 LatexRunParams const &) const
100 os << escape(getCommand());
105 int InsetLabel::ascii(Buffer const &, ostream & os,
106 LatexRunParams const &) const
108 os << '<' << getContents() << '>';
113 int InsetLabel::linuxdoc(Buffer const &, ostream & os,
114 LatexRunParams const &) const
116 os << "<label id=\"" << getContents() << "\" >";
121 int InsetLabel::docbook(Buffer const &, ostream & os,
122 LatexRunParams const &) const
124 os << "<anchor id=\"" << getContents() << "\">";