]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathFactory.cpp
Fix bug 5802 (http://bugzilla.lyx.org/show_bug.cgi?id=5802)
[lyx.git] / src / mathed / MathFactory.cpp
index d12ac0aa565f41d4d56737cfac28d9a32e3820fe..16b6a2e28d7ca4fd7a37c12accae2ea816b93170 100644 (file)
@@ -52,6 +52,7 @@
 #include "MathSupport.h"
 
 #include "insets/InsetCommand.h"
+#include "insets/InsetSpace.h"
 
 #include "support/debug.h"
 #include "support/docstream.h"
@@ -61,7 +62,9 @@
 
 #include "frontends/FontLoader.h"
 
+#include "Encoding.h"
 #include "LyX.h" // use_gui
+#include "OutputParams.h"
 
 using namespace std;
 using namespace lyx::support;
@@ -317,7 +320,7 @@ MathAtom createInsetMath(docstring const & s)
                if (inset == "decoration")
                        return MathAtom(new InsetMathDecoration(l));
                if (inset == "space")
-                       return MathAtom(new InsetMathSpace(l->name));
+                       return MathAtom(new InsetMathSpace(to_ascii(l->name), ""));
                if (inset == "dots")
                        return MathAtom(new InsetMathDots(l));
                if (inset == "mbox")
@@ -444,6 +447,8 @@ MathAtom createInsetMath(docstring const & s)
                return MathAtom(new InsetMathColor(true));
        if (s == "textcolor")
                return MathAtom(new InsetMathColor(false));
+       if (s == "cfrac")
+               return MathAtom(new InsetMathCFrac);
        if (s == "dfrac")
                return MathAtom(new InsetMathDFrac);
        if (s == "tfrac")
@@ -477,13 +482,28 @@ bool createInsetMath_fromDialogStr(docstring const & str, MathData & ar)
        docstring name;
        docstring body = split(str, name, ' ');
 
-       if (name != "ref" )
+       if (name == "ref") {
+               InsetCommandParams icp(REF_CODE);
+               // FIXME UNICODE
+               InsetCommand::string2params("ref", to_utf8(str), icp);
+               mathed_parse_cell(ar, icp.getCommand());
+       } else if (name == "mathspace") {
+               InsetSpaceParams isp(true);
+               InsetSpace::string2params(to_utf8(str), isp);
+               InsetSpace is(isp);
+               odocstringstream os;
+               Encoding const * const ascii = encodings.fromLyXName("ascii");
+               OutputParams op(ascii);
+               is.latex(os, op);
+               mathed_parse_cell(ar, os.str());
+               if (ar.size() == 2) {
+                       // remove "{}"
+                       if (ar[1].nucleus()->asBraceInset())
+                               ar.pop_back();
+               }
+       } else
                return false;
 
-       InsetCommandParams icp(REF_CODE);
-       // FIXME UNICODE
-       InsetCommand::string2params("ref", to_utf8(str), icp);
-       mathed_parse_cell(ar, icp.getCommand());
        if (ar.size() != 1)
                return false;