MathML: use the right has_limits_ in InsetMathScripts.

Fixes #12295. Details in the ticket.
This commit is contained in:
Thibaut Cuvelier 2021-05-31 23:25:11 +02:00
parent 6201d1e29f
commit 7e7f9ebae8
4 changed files with 29 additions and 5 deletions

View File

@ -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);

View File

@ -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;

View File

@ -26,6 +26,7 @@
#include <algorithm>
#include <cstring>
#include <ostream>
#include <FontInfo.h>
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()

View File

@ -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;
};