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