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