]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathScript.cpp
Cmake export tests: Added sublabel handling also to revertedTests
[lyx.git] / src / mathed / InsetMathScript.cpp
index d080d0831f090e75fba5b6c48d9915f5f907f719..37f19654b789b289a9ce997cdbb28d94b24a04b7 100644 (file)
@@ -24,6 +24,7 @@
 #include "MathSupport.h"
 
 #include "support/debug.h"
+#include "support/gettext.h"
 
 #include "support/lassert.h"
 
@@ -46,7 +47,7 @@ InsetMathScript::InsetMathScript(Buffer * buf, bool up)
 InsetMathScript::InsetMathScript(Buffer * buf, MathAtom const & at, bool up)
        : InsetMathNest(buf, 2), cell_1_is_up_(up), limits_(0)
 {
-       LASSERT(nargs() >= 1, /**/);
+       LATTEST(nargs() >= 1);
        cell(0).push_back(at);
 }
 
@@ -89,7 +90,7 @@ MathData const & InsetMathScript::down() const
 {
        if (nargs() == 3)
                return cell(2);
-       LASSERT(nargs() > 1, /**/);
+       LBUFERR(nargs() > 1);
        return cell(1);
 }
 
@@ -98,21 +99,21 @@ MathData & InsetMathScript::down()
 {
        if (nargs() == 3)
                return cell(2);
-       LASSERT(nargs() > 1, /**/);
+       LBUFERR(nargs() > 1);
        return cell(1);
 }
 
 
 MathData const & InsetMathScript::up() const
 {
-       LASSERT(nargs() > 1, /**/);
+       LBUFERR(nargs() > 1);
        return cell(1);
 }
 
 
 MathData & InsetMathScript::up()
 {
-       LASSERT(nargs() > 1, /**/);
+       LBUFERR(nargs() > 1);
        return cell(1);
 }
 
@@ -221,7 +222,7 @@ int InsetMathScript::dy1(BufferView const & bv) const
 
 int InsetMathScript::dx0(BufferView const & bv) const
 {
-       LASSERT(hasDown(), /**/);
+       LASSERT(hasDown(), return 0);
        Dimension const dim = dimension(bv);
        return hasLimits() ? (dim.wid - down().dimension(bv).width()) / 2 : nwid(bv);
 }
@@ -229,7 +230,7 @@ int InsetMathScript::dx0(BufferView const & bv) const
 
 int InsetMathScript::dx1(BufferView const & bv) const
 {
-       LASSERT(hasUp(), /**/);
+       LASSERT(hasUp(), return 0);
        Dimension const dim = dimension(bv);
        return hasLimits() ? (dim.wid - up().dimension(bv).width()) / 2 : nwid(bv) + nker(&bv);
 }
@@ -438,9 +439,7 @@ Inset::idx_type InsetMathScript::idxOfScript(bool up) const
                return (cell_1_is_up_ == up) ? 1 : 0;
        if (nargs() == 3)
                return up ? 1 : 2;
-       LASSERT(false, /**/);
-       // Silence compiler
-       return 0;
+       LASSERT(false, return 0);
 }
 
 
@@ -596,21 +595,18 @@ void InsetMathScript::mathematica(MathematicaStream & os) const
 }
 
 
-// FIXME XHTML
-// It may be worth trying to output munder, mover, and munderover
-// in certain cases, e.g., for display formulas. But then we would
-// need to know if we're in a display formula.
 void InsetMathScript::mathmlize(MathStream & os) const
 {
        bool d = hasDown() && !down().empty();
        bool u = hasUp() && !up().empty();
+       bool l = hasLimits();
 
        if (u && d)
-               os << MTag("msubsup");
+               os << MTag(l ? "munderover" : "msubsup");
        else if (u)
-               os << MTag("msup");
+               os << MTag(l ? "mover" : "msup");
        else if (d)
-               os << MTag("msub");
+               os << MTag(l ? "munder" : "msub");
 
        if (!nuc().empty())
                os << MTag("mrow") << nuc() << ETag("mrow");
@@ -620,11 +616,11 @@ void InsetMathScript::mathmlize(MathStream & os) const
        if (u && d)
                os << MTag("mrow") << down() << ETag("mrow") 
                   << MTag("mrow") << up() << ETag("mrow") 
-                  << ETag("msubsup");
+                  << ETag(l ? "munderover" : "msubsup");
        else if (u)
-               os << MTag("mrow") << up() << ETag("mrow") << ETag("msup");
+               os << MTag("mrow") << up() << ETag("mrow") << ETag(l ? "mover" : "msup");
        else if (d)
-               os << MTag("mrow") << down() << ETag("mrow") << ETag("msub");
+               os << MTag("mrow") << down() << ETag("mrow") << ETag(l ? "munder" : "msub");
 }