mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
MathML: use the right has_limits_ in InsetMathScripts.
Fixes #12295. Details in the ticket.
This commit is contained in:
parent
6201d1e29f
commit
7e7f9ebae8
@ -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)
|
void InsetMathScript::removeScript(bool up)
|
||||||
{
|
{
|
||||||
if (nargs() == 2) {
|
if (nargs() == 2) {
|
||||||
@ -606,18 +614,18 @@ void InsetMathScript::mathmlize(MathMLStream & ms) const
|
|||||||
{
|
{
|
||||||
bool d = hasDown() && !down().empty();
|
bool d = hasDown() && !down().empty();
|
||||||
bool u = hasUp() && !up().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)
|
if (!d && !u)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const char * tag;
|
const char * tag;
|
||||||
if (u && d)
|
if (u && d)
|
||||||
tag = has_limits_ ? "munderover" : "msubsup";
|
tag = has_limits ? "munderover" : "msubsup";
|
||||||
else if (u)
|
else if (u)
|
||||||
tag = has_limits_ ? "mover" : "msup";
|
tag = has_limits ? "mover" : "msup";
|
||||||
else if (d)
|
else if (d)
|
||||||
tag = has_limits_ ? "munder" : "msub";
|
tag = has_limits ? "munder" : "msub";
|
||||||
|
|
||||||
ms << MTag(tag);
|
ms << MTag(tag);
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#define MATH_SCRIPTINSET_H
|
#define MATH_SCRIPTINSET_H
|
||||||
|
|
||||||
#include "InsetMathNest.h"
|
#include "InsetMathNest.h"
|
||||||
|
#include "FontEnums.h"
|
||||||
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
@ -135,6 +136,8 @@ private:
|
|||||||
int nker(BufferView const * bv) const;
|
int nker(BufferView const * bv) const;
|
||||||
/// do we we have to draw the scripts above/below nucleus?
|
/// do we we have to draw the scripts above/below nucleus?
|
||||||
bool hasLimits(FontInfo const &) const;
|
bool hasLimits(FontInfo const &) const;
|
||||||
|
///
|
||||||
|
bool hasLimits(MathStyle const &) const;
|
||||||
/// clean up empty cells and return true if a cell has been deleted.
|
/// clean up empty cells and return true if a cell has been deleted.
|
||||||
bool notifyCursorLeaves(Cursor const & old, Cursor & cur) override;
|
bool notifyCursorLeaves(Cursor const & old, Cursor & cur) override;
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
#include <FontInfo.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -289,7 +290,12 @@ TeXMathStream & operator<<(TeXMathStream & ws, unsigned int i)
|
|||||||
|
|
||||||
MathMLStream::MathMLStream(odocstream & os, std::string const & xmlns, bool xmlMode)
|
MathMLStream::MathMLStream(odocstream & os, std::string const & xmlns, bool xmlMode)
|
||||||
: os_(os), tab_(0), line_(0), in_text_(false), xmlns_(xmlns), xml_mode_(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()
|
void MathMLStream::cr()
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#define MATH_MATHMLSTREAM_H
|
#define MATH_MATHMLSTREAM_H
|
||||||
|
|
||||||
#include "InsetMath.h"
|
#include "InsetMath.h"
|
||||||
|
#include "FontInfo.h"
|
||||||
|
|
||||||
#include "TexRow.h"
|
#include "TexRow.h"
|
||||||
#include "texstream.h"
|
#include "texstream.h"
|
||||||
@ -402,6 +403,10 @@ public:
|
|||||||
std::string namespacedTag(std::string const & tag) const {
|
std::string namespacedTag(std::string const & tag) const {
|
||||||
return (xmlns().empty() ? "" : xmlns() + ":") + tag;
|
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:
|
private:
|
||||||
///
|
///
|
||||||
void setTextMode(bool t) { in_text_ = t; }
|
void setTextMode(bool t) { in_text_ = t; }
|
||||||
@ -419,6 +424,8 @@ private:
|
|||||||
std::string xmlns_;
|
std::string xmlns_;
|
||||||
///
|
///
|
||||||
bool xml_mode_;
|
bool xml_mode_;
|
||||||
|
/// The only important part of a FontInfo object.
|
||||||
|
MathStyle font_math_style_;
|
||||||
///
|
///
|
||||||
friend class SetMode;
|
friend class SetMode;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user