]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathScript.cpp
Make undo action no-ops when the buffer is read-only
[lyx.git] / src / mathed / InsetMathScript.cpp
index aa99de2ab2b6d18d6af6501379a5ff73f8511f45..73e1ef9d91976a6eb793810fe09356de3226aca3 100644 (file)
@@ -289,7 +289,7 @@ MathClass InsetMathScript::mathClass() const
 void InsetMathScript::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        // we store this, because it is much easier
-       has_limits_ = hasLimits(mi.base.font);
+       has_limits_ = hasLimits(mi.base.font.style());
 
        // Compute metrics of the available cells
        Dimension dim0;
@@ -385,27 +385,19 @@ void InsetMathScript::drawT(TextPainter & pain, int x, int y) const
 }
 
 
-bool InsetMathScript::hasLimits(FontInfo const & font) const
+bool InsetMathScript::hasLimits(MathStyle const & style) const
 {
        if (nuc().empty())
                return false;
 
        Limits const lim = nuc().back()->limits() == AUTO_LIMITS
-               ? nuc().back()->defaultLimits(font.style() == DISPLAY_STYLE)
+               ? nuc().back()->defaultLimits(style == DISPLAY_STYLE)
                : nuc().back()->limits();
        LASSERT(lim != AUTO_LIMITS, return false);
        return lim == LIMITS;
 }
 
 
-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) {
@@ -619,7 +611,7 @@ void InsetMathScript::mathmlize(MathMLStream & ms) const
        if (!d && !u)
                return;
 
-       const char * tag;
+       const char * tag = nullptr;
        if (u && d)
                tag = has_limits ? "munderover" : "msubsup";
        else if (u)
@@ -632,12 +624,15 @@ void InsetMathScript::mathmlize(MathMLStream & ms) const
        if (!nuc().empty())
                ms << nuc();
        else
+               // TODO: is this empty <mrow> required?
                ms << CTag("mrow");
 
+       // No need to wrap these in an <mrow>, as it's done by MathExtern.
+       // More details in https://www.lyx.org/trac/ticket/12221#comment:10.
        if (d)
-               ms << MTag("mrow") << down() << ETag("mrow");
+               ms << down();
        if (u)
-               ms << MTag("mrow") << up() << ETag("mrow");
+               ms << up();
 
        ms << ETag(tag);
 }