]> git.lyx.org Git - features.git/blob - src/insets/insetcommand.C
Hold on to your hats.
[features.git] / src / insets / insetcommand.C
1 /**
2  * \file insetcommand.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #include <config.h>
13
14
15 #include "insetcommand.h"
16 #include "debug.h"
17 #include "frontends/Painter.h"
18 #include "Lsstream.h"
19 #include "lyxlex.h"
20
21 using std::ostream;
22 using std::endl;
23
24
25 InsetCommand::InsetCommand(InsetCommandParams const & p, bool)
26         : p_(p.getCmdName(), p.getContents(), p.getOptions())
27 {}
28
29
30 void InsetCommand::setParams(InsetCommandParams const & p)
31 {
32         p_.setCmdName(p.getCmdName());
33         p_.setContents(p.getContents());
34         p_.setOptions(p.getOptions());
35 }
36
37
38 int InsetCommand::latex(Buffer const *, ostream & os,
39                         bool /*fragile*/, bool/*fs*/) const
40 {
41         os << getCommand();
42         return 0;
43 }
44
45
46 int InsetCommand::ascii(Buffer const *, ostream &, int) const
47 {
48         return 0;
49 }
50
51
52 int InsetCommand::linuxdoc(Buffer const *, ostream &) const
53 {
54         return 0;
55 }
56
57
58 int InsetCommand::docbook(Buffer const *, ostream &, bool) const
59 {
60         return 0;
61 }
62
63
64 InsetCommandMailer::InsetCommandMailer(string const & name,
65                                        InsetCommand & inset)
66         : name_(name), inset_(inset)
67 {}
68
69
70 string const InsetCommandMailer::inset2string() const
71 {
72         return params2string(inset_.params());
73 }
74
75
76 void InsetCommandMailer::string2params(string const & in,
77                                        InsetCommandParams & params)
78 {
79         params.setCmdName(string());
80         params.setContents(string());
81         params.setOptions(string());
82
83         if (in.empty())
84                 return;
85
86         istringstream data(in);
87         LyXLex lex(0,0);
88         lex.setStream(data);
89
90         params.read(lex);
91 }
92
93
94 string const
95 InsetCommandMailer::params2string(InsetCommandParams const & params)
96 {
97         ostringstream data;
98         params.write(data);
99         data << "\\end_inset\n";
100
101         return data.str();
102 }