]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathStackrel.cpp
Reduce the number of accesses to coord cache when drawing a math row
[lyx.git] / src / mathed / InsetMathStackrel.cpp
index 4f9623e5e6d7d2e895f5762397bedfc5b0a17959..5c0c2dcd4b0238999a2464b88902f5f1ee8f722c 100644 (file)
@@ -19,6 +19,8 @@
 #include "LaTeXFeatures.h"
 #include "MetricsInfo.h"
 
+#include "support/lassert.h"
+
 using namespace std;
 
 namespace lyx {
@@ -54,6 +56,24 @@ bool InsetMathStackrel::idxUpDown(Cursor & cur, bool up) const
 }
 
 
+bool InsetMathStackrel::idxFirst(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 0;
+       cur.pos() = 0;
+       return true;
+}
+
+
+bool InsetMathStackrel::idxLast(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 0;
+       cur.pos() = cur.lastpos();
+       return true;
+}
+
+
 MathClass InsetMathStackrel::mathClass() const
 {
        // FIXME: update this when/if \stackbin is supported
@@ -66,7 +86,7 @@ void InsetMathStackrel::metrics(MetricsInfo & mi, Dimension & dim) const
        Changer dummy2 = mi.base.changeEnsureMath();
        Dimension dim0;
        cell(0).metrics(mi, dim0);
-       Changer dummy = mi.base.changeFrac();
+       Changer dummy = mi.base.changeScript();
        Dimension dim1;
        cell(1).metrics(mi, dim1);
        if (nargs() > 2) {
@@ -92,7 +112,7 @@ void InsetMathStackrel::draw(PainterInfo & pi, int x, int y) const
        int m  = x + dim.width() / 2;
        int yo = y - dim0.ascent() - dim1.descent() - 1;
        cell(0).draw(pi, m - dim0.width() / 2, y);
-       Changer dummy = pi.base.changeFrac();
+       Changer dummy = pi.base.changeScript();
        cell(1).draw(pi, m - dim1.width() / 2, yo);
        if (nargs() > 2) {
                Dimension const & dim2 = cell(2).dimension(*pi.base.bv);
@@ -102,7 +122,7 @@ void InsetMathStackrel::draw(PainterInfo & pi, int x, int y) const
 }
 
 
-void InsetMathStackrel::write(WriteStream & os) const
+void InsetMathStackrel::write(TeXMathStream & os) const
 {
        MathEnsurer ensurer(os);
        os << "\\stackrel";
@@ -121,12 +141,16 @@ void InsetMathStackrel::normalize(NormalStream & os) const
 }
 
 
-void InsetMathStackrel::mathmlize(MathStream & ms) const
+void InsetMathStackrel::mathmlize(MathMLStream & ms) const
 {
        if (nargs() > 2)
-               ms << "<munderover>" << cell(0) << cell(2) << cell(1) << "</munderover>";
+               ms << "<" << from_ascii(ms.namespacedTag("munderover")) << ">"
+                  << cell(0) << cell(2) << cell(1)
+                  << "</" << from_ascii(ms.namespacedTag("munderover")) << ">";
        else
-               ms << "<mover accent='false'>" << cell(0) << cell(1) << "</mover>";
+               ms << "<" << from_ascii(ms.namespacedTag("mover")) << " accent='false'>"
+                  << cell(0) << cell(1)
+                  << "</" << from_ascii(ms.namespacedTag("mover")) << ">";
 }