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