2008-09-04 22:24:07 +00:00
|
|
|
/**
|
|
|
|
* \file InsetMathEnsureMath.cpp
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2008-09-04 22:24:07 +00:00
|
|
|
* \author Enrico Forestieri
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "InsetMathEnsureMath.h"
|
|
|
|
|
2011-04-01 22:34:40 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2009-12-31 15:46:39 +00:00
|
|
|
#include "MathData.h"
|
Index: src/mathed/InsetMathEnsureMath.cpp
===================================================================
--- src/mathed/InsetMathEnsureMath.cpp (revisione 34304)
+++ src/mathed/InsetMathEnsureMath.cpp (copia locale)
@@ -13,8 +13,9 @@
#include "InsetMathEnsureMath.h"
-#include "MathStream.h"
#include "MathData.h"
+#include "MathStream.h"
+#include "MathSupport.h"
#include <ostream>
@@ -34,7 +35,8 @@ Inset * InsetMathEnsureMath::clone() con
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);
}
@@ -42,7 +44,8 @@ void InsetMathEnsureMath::metrics(Metric
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);
}
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34321 a592a061-630c-0410-9148-cb99ea01b6c8
2010-04-28 01:58:11 +00:00
|
|
|
#include "MathStream.h"
|
|
|
|
#include "MathSupport.h"
|
2008-09-04 22:24:07 +00:00
|
|
|
|
|
|
|
#include <ostream>
|
|
|
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathEnsureMath::InsetMathEnsureMath(Buffer * buf)
|
|
|
|
: InsetMathNest(buf, 1)
|
2008-09-04 22:24:07 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
Inset * InsetMathEnsureMath::clone() const
|
|
|
|
{
|
|
|
|
return new InsetMathEnsureMath(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathEnsureMath::metrics(MetricsInfo & mi, Dimension & dim) const
|
|
|
|
{
|
Index: src/mathed/InsetMathEnsureMath.cpp
===================================================================
--- src/mathed/InsetMathEnsureMath.cpp (revisione 34304)
+++ src/mathed/InsetMathEnsureMath.cpp (copia locale)
@@ -13,8 +13,9 @@
#include "InsetMathEnsureMath.h"
-#include "MathStream.h"
#include "MathData.h"
+#include "MathStream.h"
+#include "MathSupport.h"
#include <ostream>
@@ -34,7 +35,8 @@ Inset * InsetMathEnsureMath::clone() con
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);
}
@@ -42,7 +44,8 @@ void InsetMathEnsureMath::metrics(Metric
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);
}
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34321 a592a061-630c-0410-9148-cb99ea01b6c8
2010-04-28 01:58:11 +00:00
|
|
|
bool really_change_font = isTextFont(from_ascii(mi.base.fontname));
|
2016-05-23 21:30:23 +00:00
|
|
|
Changer dummy = mi.base.changeFontSet("mathnormal", really_change_font);
|
2008-09-04 22:24:07 +00:00
|
|
|
cell(0).metrics(mi, dim);
|
|
|
|
metricsMarkers(dim);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathEnsureMath::draw(PainterInfo & pi, int x, int y) const
|
|
|
|
{
|
Index: src/mathed/InsetMathEnsureMath.cpp
===================================================================
--- src/mathed/InsetMathEnsureMath.cpp (revisione 34304)
+++ src/mathed/InsetMathEnsureMath.cpp (copia locale)
@@ -13,8 +13,9 @@
#include "InsetMathEnsureMath.h"
-#include "MathStream.h"
#include "MathData.h"
+#include "MathStream.h"
+#include "MathSupport.h"
#include <ostream>
@@ -34,7 +35,8 @@ Inset * InsetMathEnsureMath::clone() con
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);
}
@@ -42,7 +44,8 @@ void InsetMathEnsureMath::metrics(Metric
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);
}
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34321 a592a061-630c-0410-9148-cb99ea01b6c8
2010-04-28 01:58:11 +00:00
|
|
|
bool really_change_font = isTextFont(from_ascii(pi.base.fontname));
|
2016-05-23 21:30:23 +00:00
|
|
|
Changer dummy = pi.base.changeFontSet("mathnormal", really_change_font);
|
2008-09-04 22:24:07 +00:00
|
|
|
cell(0).draw(pi, x, y);
|
|
|
|
drawMarkers(pi, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathEnsureMath::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
|
|
|
|
{
|
|
|
|
cell(0).metricsT(mi, dim);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathEnsureMath::drawT(TextPainter & pain, int x, int y) const
|
|
|
|
{
|
|
|
|
cell(0).drawT(pain, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathEnsureMath::write(WriteStream & os) const
|
|
|
|
{
|
|
|
|
ModeSpecifier specifier(os, MATH_MODE);
|
|
|
|
os << "\\ensuremath{" << cell(0) << "}";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 15:46:39 +00:00
|
|
|
void InsetMathEnsureMath::mathmlize(MathStream & os) const
|
2009-12-26 15:01:03 +00:00
|
|
|
{
|
2011-04-01 21:18:37 +00:00
|
|
|
SetMode mathmode(os, false);
|
2011-04-01 22:34:40 +00:00
|
|
|
os << MTag("mstyle", "class='math'")
|
|
|
|
<< cell(0)
|
|
|
|
<< ETag("mstyle");
|
2011-04-01 21:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathEnsureMath::htmlize(HtmlStream & os) const
|
|
|
|
{
|
|
|
|
SetHTMLMode mathmode(os, false);
|
2011-04-01 22:34:40 +00:00
|
|
|
os << MTag("span", "class='math'")
|
|
|
|
<< cell(0)
|
|
|
|
<< ETag("span");
|
2009-12-26 15:01:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-04 22:24:07 +00:00
|
|
|
void InsetMathEnsureMath::infoize(odocstream & os) const
|
|
|
|
{
|
|
|
|
os << "EnsureMath";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-01 22:34:40 +00:00
|
|
|
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)
|
2011-12-06 22:17:13 +00:00
|
|
|
features.addCSSSnippet("mstyle.math { font-style: italic; }");
|
2011-04-01 22:34:40 +00:00
|
|
|
else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
|
2011-12-06 22:17:13 +00:00
|
|
|
features.addCSSSnippet("span.mathbox { font-style: italic; }");
|
2011-04-01 22:34:40 +00:00
|
|
|
|
|
|
|
InsetMathNest::validate(features);
|
|
|
|
}
|
|
|
|
|
2008-09-04 22:24:07 +00:00
|
|
|
} // namespace lyx
|