[LyX/master] MathML: use the right has_limits_ in InsetMathScripts.
Thibaut Cuvelier
tcuvelier at lyx.org
Mon May 31 21:14:19 UTC 2021
commit 7e7f9ebae8a0deb2526422449d8d20fb6259bc03
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Mon May 31 23:25:11 2021 +0200
MathML: use the right has_limits_ in InsetMathScripts.
Fixes #12295. Details in the ticket.
---
src/mathed/InsetMathScript.cpp | 16 ++++++++++++----
src/mathed/InsetMathScript.h | 3 +++
src/mathed/MathStream.cpp | 8 +++++++-
src/mathed/MathStream.h | 7 +++++++
4 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp
index 36e7ea7..aa99de2 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 9615d19..38761f0 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 c42a43e..a6d160c 100644
--- a/src/mathed/MathStream.cpp
+++ b/src/mathed/MathStream.cpp
@@ -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()
diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h
index e6238db..d55831d 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;
};
More information about the lyx-cvs
mailing list