]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMath.C
Almost fix 'make check'. The only remaining problem is an undefined
[lyx.git] / src / mathed / InsetMath.C
1 /**
2  * \file InsetMath.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 "InsetMath.h"
15 #include "MathData.h"
16 #include "MathStream.h"
17 #include "gettext.h"
18 #include "debug.h"
19
20 #include "support/lstrings.h"
21
22 #include <boost/current_function.hpp>
23
24
25 namespace lyx {
26
27 using std::endl;
28
29
30 MathArray & InsetMath::cell(idx_type)
31 {
32         static MathArray dummyCell;
33         lyxerr << BOOST_CURRENT_FUNCTION << ": I don't have any cell" << endl;
34         return dummyCell;
35 }
36
37
38 MathArray const & InsetMath::cell(idx_type) const
39 {
40         static MathArray dummyCell;
41         lyxerr << BOOST_CURRENT_FUNCTION << ": I don't have any cell" << endl;
42         return dummyCell;
43 }
44
45
46 void InsetMath::dump() const
47 {
48         lyxerr << "---------------------------------------------" << endl;
49         odocstringstream os;
50         WriteStream wi(os, false, true);
51         write(wi);
52         lyxerr << to_utf8(os.str());
53         lyxerr << "\n---------------------------------------------" << endl;
54 }
55
56
57 void InsetMath::metricsT(TextMetricsInfo const &, Dimension &) const
58 {
59 #ifdef WITH_WARNINGS
60         lyxerr << "InsetMath::metricsT(Text) called directly!" << endl;
61 #endif
62 }
63
64
65 void InsetMath::drawT(TextPainter &, int, int) const
66 {
67 #ifdef WITH_WARNINGS
68         lyxerr << "InsetMath::drawT(Text) called directly!" << endl;
69 #endif
70 }
71
72
73
74 void InsetMath::write(WriteStream & os) const
75 {
76         docstring const s = name();
77         os << "\\" << s;
78         // We need an extra ' ' unless this is a single-char-non-ASCII name
79         // or anything non-ASCII follows
80         if (s.size() != 1 || isalpha(s[0]))
81                 os.pendingSpace(true);
82 }
83
84
85 int InsetMath::plaintext(Buffer const &, odocstream & os,
86                          OutputParams const &) const
87 {
88         // all math plain text output shall take place in InsetMathHull
89         BOOST_ASSERT(false);
90         return 0;
91 }
92
93
94 void InsetMath::normalize(NormalStream & os) const
95 {
96         os << '[' << name() << "] ";
97 }
98
99
100 void InsetMath::octave(OctaveStream & os) const
101 {
102         NormalStream ns(os.os());
103         normalize(ns);
104 }
105
106
107 void InsetMath::maple(MapleStream & os) const
108 {
109         NormalStream ns(os.os());
110         normalize(ns);
111 }
112
113
114 void InsetMath::maxima(MaximaStream & os) const
115 {
116         MapleStream ns(os.os());
117         maple(ns);
118 }
119
120
121 void InsetMath::mathematica(MathematicaStream & os) const
122 {
123         NormalStream ns(os.os());
124         normalize(ns);
125 }
126
127
128 void InsetMath::mathmlize(MathStream & os) const
129 {
130         NormalStream ns(os.os());
131         normalize(ns);
132 }
133
134
135 HullType InsetMath::getType() const
136 {
137         return hullNone;
138 }
139
140
141 docstring InsetMath::name() const
142 {
143         return from_ascii("unknown");
144 }
145
146
147 std::ostream & operator<<(std::ostream & os, MathAtom const & at)
148 {
149         odocstringstream oss;
150         WriteStream wi(oss, false, false);
151         at->write(wi);
152         return os << to_utf8(oss.str());
153 }
154
155
156 odocstream & operator<<(odocstream & os, MathAtom const & at)
157 {
158         WriteStream wi(os, false, false);
159         at->write(wi);
160         return os;
161 }
162
163
164 } // namespace lyx