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, bool)
30 : p_(p.getCmdName(), p.getContents(), p.getOptions())
34 void InsetCommand::setParams(InsetCommandParams const & p)
36 p_.setCmdName(p.getCmdName());
37 p_.setContents(p.getContents());
38 p_.setOptions(p.getOptions());
42 int InsetCommand::latex(Buffer const *, ostream & os,
43 bool /*fragile*/, bool/*fs*/) const
50 int InsetCommand::ascii(Buffer const *, ostream &, int) const
56 int InsetCommand::linuxdoc(Buffer const *, ostream &) const
62 int InsetCommand::docbook(Buffer const *, ostream &, bool) const
68 dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd)
70 lyxerr << "InsetCommand::localDispatch: " << cmd.action << "\n";
72 case LFUN_INSET_MODIFY: {
74 InsetCommandMailer::string2params(cmd.argument, p);
75 if (p.getCmdName().empty())
79 cmd.view()->updateInset(this);
83 case LFUN_INSET_DIALOG_UPDATE:
84 InsetCommandMailer(cmd.argument, *this).updateDialog(cmd.view());
87 case LFUN_MOUSE_RELEASE:
88 return localDispatch(FuncRequest(cmd.view(), LFUN_INSET_EDIT));
97 InsetCommandMailer::InsetCommandMailer(string const & name,
99 : name_(name), inset_(inset)
103 string const InsetCommandMailer::inset2string() const
105 return params2string(name(), inset_.params());
109 void InsetCommandMailer::string2params(string const & in,
110 InsetCommandParams & params)
112 params.setCmdName(string());
113 params.setContents(string());
114 params.setOptions(string());
119 istringstream data(STRCONV(in));
125 string const name = lex.getString();
128 // This is part of the inset proper that is usually swallowed
129 // by Buffer::readInset
132 string const token = lex.getString();
133 if (token != "LatexCommand")
142 string const InsetCommandMailer::params2string(string const & name,
143 InsetCommandParams const & params)
148 data << "\\end_inset\n";
149 return STRCONV(data.str());