3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
14 #include "insetcommand.h"
16 #include "BufferView.h"
17 #include "funcrequest.h"
19 #include "metricsinfo.h"
21 #include "support/std_sstream.h"
25 using std::istringstream;
27 using std::ostringstream;
30 InsetCommand::InsetCommand(InsetCommandParams const & p)
31 : p_(p.getCmdName(), p.getContents(), p.getOptions()),
36 void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
40 button_.update(getScreenLabel(*mi.base.bv->buffer()),
41 editable() != NOT_EDITABLE);
43 button_.metrics(mi, dim);
48 void InsetCommand::draw(PainterInfo & pi, int x, int y) const
50 button_.draw(pi, x, y);
54 void InsetCommand::setParams(InsetCommandParams const & p)
61 int InsetCommand::latex(Buffer const &, ostream & os,
62 LatexRunParams const &) const
69 int InsetCommand::ascii(Buffer const &, ostream &, int) const
75 int InsetCommand::linuxdoc(Buffer const &, ostream &) const
81 int InsetCommand::docbook(Buffer const &, ostream &, bool) const
88 InsetCommand::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
91 case LFUN_INSET_MODIFY: {
93 InsetCommandMailer::string2params(cmd.argument, p);
94 if (p.getCmdName().empty())
98 cmd.view()->updateInset(this);
102 case LFUN_INSET_DIALOG_UPDATE:
103 InsetCommandMailer(cmd.argument, *this).updateDialog(cmd.view());
106 case LFUN_MOUSE_RELEASE:
107 return dispatch(FuncRequest(cmd.view(), LFUN_INSET_EDIT));
116 InsetCommandMailer::InsetCommandMailer(string const & name,
117 InsetCommand & inset)
118 : name_(name), inset_(inset)
122 string const InsetCommandMailer::inset2string(Buffer const &) const
124 return params2string(name(), inset_.params());
128 void InsetCommandMailer::string2params(string const & in,
129 InsetCommandParams & params)
131 params = InsetCommandParams();
136 istringstream data(in);
142 string const name = lex.getString();
145 // This is part of the inset proper that is usually swallowed
146 // by Buffer::readInset
149 string const token = lex.getString();
150 if (token != "LatexCommand")
159 string const InsetCommandMailer::params2string(string const & name,
160 InsetCommandParams const & params)
165 data << "\\end_inset\n";