]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathEnsureMath.cpp
Fix external middle-mouse pasting with Qt5/X11.
[lyx.git] / src / mathed / InsetMathEnsureMath.cpp
index 149bae7d2cb247fbc5fd8871066f3df866d13d11..cab5e7730e053d8ca2b853cd46d5788accde2fbc 100644 (file)
 
 #include "InsetMathEnsureMath.h"
 
-#include "MathExtern.h"
+#include "LaTeXFeatures.h"
 #include "MathData.h"
 #include "MathStream.h"
+#include "MathSupport.h"
 
 #include <ostream>
 
@@ -35,7 +36,8 @@ Inset * InsetMathEnsureMath::clone() const
 
 void InsetMathEnsureMath::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       FontSetChanger dummy(mi.base, "mathnormal");
+       bool really_change_font = isTextFont(from_ascii(mi.base.fontname));
+       FontSetChanger dummy(mi.base, "mathnormal", really_change_font);
        cell(0).metrics(mi, dim);
        metricsMarkers(dim);
 }
@@ -43,7 +45,8 @@ void InsetMathEnsureMath::metrics(MetricsInfo & mi, Dimension & dim) const
 
 void InsetMathEnsureMath::draw(PainterInfo & pi, int x, int y) const
 {
-       FontSetChanger dummy(pi.base, "mathnormal");
+       bool really_change_font = isTextFont(from_ascii(pi.base.fontname));
+       FontSetChanger dummy(pi.base, "mathnormal", really_change_font);
        cell(0).draw(pi, x, y);
        drawMarkers(pi, x, y);
 }
@@ -68,9 +71,21 @@ void InsetMathEnsureMath::write(WriteStream & os) const
 }
 
 
-docstring InsetMathEnsureMath::mathmlize(MathStream & os) const
+void InsetMathEnsureMath::mathmlize(MathStream & os) const
 {
-       return lyx::mathmlize(cell(0), os);
+       SetMode mathmode(os, false);
+       os << MTag("mstyle", "class='math'")
+          << cell(0)
+          << ETag("mstyle");
+}
+
+
+void InsetMathEnsureMath::htmlize(HtmlStream & os) const
+{
+       SetHTMLMode mathmode(os, false);
+       os << MTag("span", "class='math'")
+          << cell(0)
+          << ETag("span");
 }
 
 
@@ -80,4 +95,17 @@ void InsetMathEnsureMath::infoize(odocstream & os) const
 }
 
 
+void InsetMathEnsureMath::validate(LaTeXFeatures & features) const
+{
+       // FIXME XHTML
+       // It'd be better to be able to get this from an InsetLayout, but at present
+       // InsetLayouts do not seem really to work for things that aren't InsetTexts.
+       if (features.runparams().math_flavor == OutputParams::MathAsMathML)
+               features.addCSSSnippet("mstyle.math { font-style: italic; }");
+       else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
+               features.addCSSSnippet("span.mathbox { font-style: italic; }");
+
+       InsetMathNest::validate(features);
+}
+
 } // namespace lyx