]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathEnsureMath.cpp
Remove profiling.py
[lyx.git] / src / mathed / InsetMathEnsureMath.cpp
1 /**
2  * \file InsetMathEnsureMath.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  * \author Enrico Forestieri
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "InsetMathEnsureMath.h"
15
16 #include "MathData.h"
17 #include "MathStream.h"
18 #include "MathSupport.h"
19
20 #include "LaTeXFeatures.h"
21 #include "MetricsInfo.h"
22
23 #include <ostream>
24
25
26 namespace lyx {
27
28 InsetMathEnsureMath::InsetMathEnsureMath(Buffer * buf)
29         : InsetMathGrid(buf, 1, 1)
30 {}
31
32
33 Inset * InsetMathEnsureMath::clone() const
34 {
35         return new InsetMathEnsureMath(*this);
36 }
37
38
39 void InsetMathEnsureMath::metrics(MetricsInfo & mi, Dimension & dim) const
40 {
41         Changer dummy = mi.base.changeEnsureMath();
42         cell(0).metrics(mi, dim);
43 }
44
45
46 void InsetMathEnsureMath::draw(PainterInfo & pi, int x, int y) const
47 {
48         Changer dummy = pi.base.changeEnsureMath();
49         cell(0).draw(pi, x, y);
50 }
51
52
53 void InsetMathEnsureMath::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
54 {
55         cell(0).metricsT(mi, dim);
56 }
57
58
59 void InsetMathEnsureMath::drawT(TextPainter & pain, int x, int y) const
60 {
61         cell(0).drawT(pain, x, y);
62 }
63
64
65 void InsetMathEnsureMath::write(TeXMathStream & os) const
66 {
67         ModeSpecifier specifier(os, MATH_MODE);
68         os << "\\ensuremath{" << cell(0) << "}";
69 }
70
71
72 void InsetMathEnsureMath::mathmlize(MathMLStream & ms) const
73 {
74         SetMode mathmode(ms, false);
75         ms << MTag("mstyle", "class='math'")
76            << cell(0)
77            << ETag("mstyle");
78 }
79
80
81 void InsetMathEnsureMath::htmlize(HtmlStream & os) const
82 {
83         SetHTMLMode mathmode(os, false);
84         os << MTag("span", "class='math'")
85            << cell(0)
86            << ETag("span");
87 }
88
89
90 void InsetMathEnsureMath::infoize(odocstream & os) const
91 {
92         os << "EnsureMath";
93 }
94
95
96 void InsetMathEnsureMath::validate(LaTeXFeatures & features) const
97 {
98         // FIXME XHTML
99         // It'd be better to be able to get this from an InsetLayout, but at present
100         // InsetLayouts do not seem really to work for things that aren't InsetTexts.
101         if (features.runparams().math_flavor == OutputParams::MathAsMathML)
102                 features.addCSSSnippet("mstyle.math { font-style: italic; }");
103         else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
104                 features.addCSSSnippet("span.mathbox { font-style: italic; }");
105
106         InsetMathNest::validate(features);
107 }
108
109 } // namespace lyx