]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.C
and some mathed de-uglyfication
[lyx.git] / src / mathed / math_inset.C
1 /**
2  * \file math_inset.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "math_inset.h"
15 #include "math_data.h"
16 #include "math_mathmlstream.h"
17 #include "debug.h"
18
19 using std::string;
20 using std::ostream;
21 using std::endl;
22
23
24 MathInset::size_type MathInset::nargs() const
25 {
26         return 0;
27 }
28
29
30 MathArray dummyCell;
31
32 MathArray & MathInset::cell(idx_type)
33 {
34         lyxerr << "I don't have a cell 1" << endl;
35         return dummyCell;
36 }
37
38
39 MathArray const & MathInset::cell(idx_type) const
40 {
41         lyxerr << "I don't have a cell 2" << endl;
42         return dummyCell;
43 }
44
45
46 MathInset::idx_type MathInset::index(row_type row, col_type col) const
47 {
48         if (row != 0)
49                 lyxerr << "illegal row: " << row << endl;
50         if (col != 0)
51                 lyxerr << "illegal col: " << col << endl;
52         return 0;
53 }
54
55 void MathInset::substitute(MathMacro const &)
56 {}
57
58
59 bool MathInset::idxNext(LCursor &) const
60 {
61         return false;
62 }
63
64
65 bool MathInset::idxRight(LCursor &) const
66 {
67         return false;
68 }
69
70
71 bool MathInset::idxPrev(LCursor &) const
72 {
73         return false;
74 }
75
76
77 bool MathInset::idxLeft(LCursor &) const
78 {
79         return false;
80 }
81
82
83 bool MathInset::idxUpDown(LCursor &, bool, int) const
84 {
85         return false;
86 }
87
88
89 bool MathInset::idxUpDown2(LCursor &, bool, int) const
90 {
91         return false;
92 }
93
94
95 bool MathInset::idxFirst(LCursor &) const
96 {
97         return false;
98 }
99
100
101 bool MathInset::idxLast(LCursor &) const
102 {
103         return false;
104 }
105
106
107 bool MathInset::idxHome(LCursor &) const
108 {
109         return false;
110 }
111
112
113 bool MathInset::idxEnd(LCursor &) const
114 {
115         return false;
116 }
117
118
119 void MathInset::getScreenPos(idx_type, pos_type, int & x, int & y) const
120 {
121         lyxerr << "MathInset::getScreenPos() called directly!" << endl;
122         x = y = 0;
123 }
124
125
126 void MathInset::dump() const
127 {
128         lyxerr << "---------------------------------------------" << endl;
129         WriteStream wi(lyxerr, false, true);
130         write(wi);
131         lyxerr << "\n---------------------------------------------" << endl;
132 }
133
134
135 bool MathInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
136 {
137         return from <= idx && idx <= to;
138 }
139
140
141 void MathInset::drawSelection(PainterInfo &,
142         idx_type, pos_type, idx_type, pos_type) const
143 {
144         lyxerr << "MathInset::drawSelection() called directly!" << endl;
145 }
146
147
148 void MathInset::metricsT(TextMetricsInfo const &, Dimension &) const
149 {
150 #ifdef WITH_WARNINGS
151         lyxerr << "MathInset::metricsT(Text) called directly!" << endl;
152 #endif
153 }
154
155
156 void MathInset::drawT(TextPainter &, int, int) const
157 {
158 #ifdef WITH_WARNINGS
159         lyxerr << "MathInset::drawT(Text) called directly!" << endl;
160 #endif
161 }
162
163
164
165 void MathInset::write(WriteStream & os) const
166 {
167         os << '\\' << name().c_str();
168         os.pendingSpace(true);
169 }
170
171
172 void MathInset::normalize(NormalStream & os) const
173 {
174         os << '[' << name().c_str() << "] ";
175 }
176
177
178 void MathInset::octave(OctaveStream & os) const
179 {
180         NormalStream ns(os.os());
181         normalize(ns);
182 }
183
184
185 void MathInset::maple(MapleStream & os) const
186 {
187         NormalStream ns(os.os());
188         normalize(ns);
189 }
190
191
192 void MathInset::maxima(MaximaStream & os) const
193 {
194         MapleStream ns(os.os());
195         maple(ns);
196 }
197
198
199 void MathInset::mathematica(MathematicaStream & os) const
200 {
201         NormalStream ns(os.os());
202         normalize(ns);
203 }
204
205
206 void MathInset::mathmlize(MathMLStream & os) const
207 {
208         NormalStream ns(os.os());
209         normalize(ns);
210 }
211
212
213 int MathInset::plaintext(std::ostream &, OutputParams const &) const
214 {
215         return 0;
216 }
217
218
219 int MathInset::linuxdoc(std::ostream &, OutputParams const &) const
220 {
221         return 0;
222 }
223
224
225 int MathInset::docbook(std::ostream &, OutputParams const &) const
226 {
227         return 0;
228 }
229
230
231 string const & MathInset::getType() const
232 {
233         static string const t("none");
234         return t;
235 }
236
237
238 string MathInset::name() const
239 {
240         return "unknown";
241 }
242
243
244 ostream & operator<<(ostream & os, MathAtom const & at)
245 {
246         WriteStream wi(os, false, false);
247         at->write(wi);
248         return os;
249 }
250
251
252 string MathInset::fileInsetLabel() const
253 {
254         return "Formula";
255 }