diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp index 36e7ea70ea..aa99de2ab2 100644 --- a/src/mathed/InsetMathScript.cpp +++ b/src/mathed/InsetMathScript.cpp @@ -398,6 +398,14 @@ bool InsetMathScript::hasLimits(FontInfo const & font) const } +bool InsetMathScript::hasLimits(MathStyle const & style) const +{ + FontInfo font = sane_font; + font.setStyle(style); + return hasLimits(font); +} + + void InsetMathScript::removeScript(bool up) { if (nargs() == 2) { @@ -606,18 +614,18 @@ void InsetMathScript::mathmlize(MathMLStream & ms) const { bool d = hasDown() && !down().empty(); bool u = hasUp() && !up().empty(); - // FIXME: the MathMLStream should be able to give us has_limits_ + bool has_limits = hasLimits(ms.getFontMathStyle()); if (!d && !u) return; const char * tag; if (u && d) - tag = has_limits_ ? "munderover" : "msubsup"; + tag = has_limits ? "munderover" : "msubsup"; else if (u) - tag = has_limits_ ? "mover" : "msup"; + tag = has_limits ? "mover" : "msup"; else if (d) - tag = has_limits_ ? "munder" : "msub"; + tag = has_limits ? "munder" : "msub"; ms << MTag(tag); diff --git a/src/mathed/InsetMathScript.h b/src/mathed/InsetMathScript.h index 9615d19979..38761f04ec 100644 --- a/src/mathed/InsetMathScript.h +++ b/src/mathed/InsetMathScript.h @@ -13,6 +13,7 @@ #define MATH_SCRIPTINSET_H #include "InsetMathNest.h" +#include "FontEnums.h" namespace lyx { @@ -135,6 +136,8 @@ private: int nker(BufferView const * bv) const; /// do we we have to draw the scripts above/below nucleus? bool hasLimits(FontInfo const &) const; + /// + bool hasLimits(MathStyle const &) const; /// clean up empty cells and return true if a cell has been deleted. bool notifyCursorLeaves(Cursor const & old, Cursor & cur) override; diff --git a/src/mathed/MathStream.cpp b/src/mathed/MathStream.cpp index c42a43e3fa..a6d160ce32 100644 --- a/src/mathed/MathStream.cpp +++ b/src/mathed/MathStream.cpp @@ -26,6 +26,7 @@ #include #include #include +#include using namespace std; @@ -289,7 +290,12 @@ TeXMathStream & operator<<(TeXMathStream & ws, unsigned int i) MathMLStream::MathMLStream(odocstream & os, std::string const & xmlns, bool xmlMode) : os_(os), tab_(0), line_(0), in_text_(false), xmlns_(xmlns), xml_mode_(xmlMode) -{} +{ + if (in_text_) + font_math_style_ = TEXT_STYLE; + else + font_math_style_ = DISPLAY_STYLE; +} void MathMLStream::cr() diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h index e6238db36a..d55831de37 100644 --- a/src/mathed/MathStream.h +++ b/src/mathed/MathStream.h @@ -13,6 +13,7 @@ #define MATH_MATHMLSTREAM_H #include "InsetMath.h" +#include "FontInfo.h" #include "TexRow.h" #include "texstream.h" @@ -402,6 +403,10 @@ public: std::string namespacedTag(std::string const & tag) const { return (xmlns().empty() ? "" : xmlns() + ":") + tag; } + /// Returns the current math style in the stream. + const MathStyle & getFontMathStyle() const { return font_math_style_; } + /// Returns the current math style in the stream. + void setFontMathStyle(const MathStyle style) { font_math_style_ = style; } private: /// void setTextMode(bool t) { in_text_ = t; } @@ -419,6 +424,8 @@ private: std::string xmlns_; /// bool xml_mode_; + /// The only important part of a FontInfo object. + MathStyle font_math_style_; /// friend class SetMode; };