]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathRoot.cpp
typo
[lyx.git] / src / mathed / InsetMathRoot.cpp
index 6661d8555556074a8a013eed8845bfee10489251..6de085fc222c0aab283e2ffa7a01975c4b270eae 100644 (file)
@@ -23,6 +23,7 @@
 #include "frontends/Painter.h"
 
 #include "support/lassert.h"
+#include "support/lstrings.h"
 
 using namespace std;
 
@@ -100,13 +101,13 @@ void mathed_draw_root(PainterInfo & pi, int x, int y, MathData const & nucleus,
        int const a = dim.ascent();
        int const d = dim.descent();
        int const t = pi.base.solidLineThickness();
-       Dimension const dimn = nucleus.dimension(*pi.base.bv);
+       Dimension const dimn = nucleus.dimension(*pi.base.bv);
        // the width of the left part of the root
        int const wl = dim.width() - dimn.width();
        // the "exponent"
        if (root) {
                Changer script = pi.base.font.changeStyle(SCRIPTSCRIPT_STYLE);
-               Dimension const dimr = root->dimension(*pi.base.bv);
+               Dimension const dimr = root->dimension(*pi.base.bv);
                int const root_offset = wl - 3 * w / 8 - dimr.width();
                root->draw(pi, x + root_offset, y + (d - a)/2);
        }
@@ -132,10 +133,14 @@ void InsetMathRoot::draw(PainterInfo & pi, int x, int y) const
 }
 
 
-void InsetMathRoot::write(WriteStream & os) const
+void InsetMathRoot::write(TeXMathStream & os) const
 {
        MathEnsurer ensurer(os);
-       os << "\\sqrt[" << cell(1) << "]{" << cell(0) << '}';
+       if (os.latex() && !cell(1).empty() && !cell(1).front()->asBraceInset()
+           && support::contains(asString(cell(1)), '['))
+               os << "\\sqrt[{" << cell(1) << "}]{" << cell(0) << '}';
+       else
+               os << "\\sqrt[" << cell(1) << "]{" << cell(0) << '}';
 }
 
 
@@ -147,7 +152,7 @@ void InsetMathRoot::normalize(NormalStream & os) const
 
 bool InsetMathRoot::idxUpDown(Cursor & cur, bool up) const
 {
-       Cursor::idx_type const target = up; //up ? 1 : 0;
+       idx_type const target = up; //up ? 1 : 0;
        if (cur.idx() == target)
                return false;
        cur.idx() = target;
@@ -216,9 +221,9 @@ void InsetMathRoot::octave(OctaveStream & os) const
 }
 
 
-void InsetMathRoot::mathmlize(MathStream & os) const
+void InsetMathRoot::mathmlize(MathMLStream & ms) const
 {
-       os << MTag("mroot") << cell(0) << cell(1) << ETag("mroot");
+       ms << MTag("mroot") << cell(0) << cell(1) << ETag("mroot");
 }