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"
15 #include "BufferView.h"
17 #include "funcrequest.h"
20 #include "frontends/Painter.h"
22 #include "support/lstrings.h"
29 InsetCommand::InsetCommand(InsetCommandParams const & p)
30 : p_(p.getCmdName(), p.getContents(), p.getOptions())
34 InsetCommand::InsetCommand(InsetCommand const & ic)
40 void InsetCommand::setParams(InsetCommandParams const & p)
42 p_.setCmdName(p.getCmdName());
43 p_.setContents(p.getContents());
44 p_.setOptions(p.getOptions());
48 int InsetCommand::latex(Buffer const *, ostream & os,
49 LatexRunParams const &) const
56 int InsetCommand::ascii(Buffer const *, ostream &, int) const
62 int InsetCommand::linuxdoc(Buffer const *, ostream &) const
68 int InsetCommand::docbook(Buffer const *, ostream &, bool) const
74 dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd)
77 case LFUN_INSET_MODIFY: {
79 InsetCommandMailer::string2params(cmd.argument, p);
80 if (p.getCmdName().empty())
84 cmd.view()->updateInset(this);
88 case LFUN_INSET_DIALOG_UPDATE:
89 InsetCommandMailer(cmd.argument, *this).updateDialog(cmd.view());
92 case LFUN_MOUSE_RELEASE:
93 return localDispatch(FuncRequest(cmd.view(), LFUN_INSET_EDIT));
102 InsetCommandMailer::InsetCommandMailer(string const & name,
103 InsetCommand & inset)
104 : name_(name), inset_(inset)
108 string const InsetCommandMailer::inset2string() const
110 return params2string(name(), inset_.params());
114 void InsetCommandMailer::string2params(string const & in,
115 InsetCommandParams & params)
117 params.setCmdName(string());
118 params.setContents(string());
119 params.setOptions(string());
124 istringstream data(STRCONV(in));
130 string const name = lex.getString();
133 // This is part of the inset proper that is usually swallowed
134 // by Buffer::readInset
137 string const token = lex.getString();
138 if (token != "LatexCommand")
147 string const InsetCommandMailer::params2string(string const & name,
148 InsetCommandParams const & params)
153 data << "\\end_inset\n";
154 return STRCONV(data.str());