]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathSpace.cpp
Do not throw exceptions here either. See r22806.
[lyx.git] / src / mathed / InsetMathSpace.cpp
index b2a321234df7366418156ade3ebf5af2004b3f90..1b045ed0ec943b8d85ad7475796ae50f3842dd8a 100644 (file)
@@ -104,12 +104,6 @@ InsetMathSpace::InsetMathSpace(Length const & length)
 }
 
 
-InsetMathSpace::~InsetMathSpace()
-{
-       hideDialogs("mathspace", this);
-}
-
-
 Inset * InsetMathSpace::clone() const
 {
        return new InsetMathSpace(*this);
@@ -192,11 +186,11 @@ void InsetMathSpace::octave(OctaveStream & os) const
 }
 
 
-docstring InsetMathSpace::mathmlize(MathStream & ms) const
+void InsetMathSpace::mathmlize(MathStream & ms) const
 {
        SpaceInfo const & si = space_info[space_];
        if (si.negative || !si.visible)
-               return docstring();
+               return;
        string l;
        if (si.custom)
                l = length_.asHTMLString();
@@ -210,7 +204,40 @@ docstring InsetMathSpace::mathmlize(MathStream & ms) const
        if (!l.empty())
                ms << " width=\"" << from_ascii(l) << "\"";
        ms << " />";
-       return docstring();
+}
+
+       
+void InsetMathSpace::htmlize(HtmlStream & ms) const
+{
+       SpaceInfo const & si = space_info[space_];
+       switch (si.kind) {
+       case InsetSpaceParams::THIN:
+               ms << from_ascii("&thinsp;");
+               break;
+       case InsetSpaceParams::MEDIUM:
+               ms << from_ascii("&nbsp;");
+               break;
+       case InsetSpaceParams::THICK:
+               ms << from_ascii("&emsp;");
+               break;
+       case InsetSpaceParams::ENSKIP:
+               ms << from_ascii("&ensp;");
+               break;
+       case InsetSpaceParams::QUAD:
+               ms << from_ascii("&emsp;");
+               break;
+       case InsetSpaceParams::QQUAD:
+               ms << from_ascii("&emsp;&emsp;");
+               break;
+       case InsetSpaceParams::CUSTOM: {
+               string l = length_.asHTMLString();
+               ms << MTag("span", "width='" + l + "'") 
+                  << from_ascii("&nbsp;") << ETag("span");
+               break;
+       }
+       default:
+               break;
+       }
 }
 
        
@@ -231,13 +258,13 @@ void InsetMathSpace::write(WriteStream & os) const
 }
 
 
-string const InsetMathSpace::createDialogStr() const
+InsetSpaceParams InsetMathSpace::params() const
 {
        LASSERT(space_info[space_].visible, /**/);
        InsetSpaceParams isp(true);
        isp.kind = space_info[space_].kind;
        isp.length = GlueLength(length_);
-       return InsetSpace::params2string(isp);
+       return isp;
 }
 
 
@@ -250,7 +277,7 @@ docstring InsetMathSpace::contextMenu(BufferView const &, int, int) const
 bool InsetMathSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
                                FuncStatus & status) const
 {
-       switch (cmd.action) {
+       switch (cmd.action()) {
        // we handle these
        case LFUN_INSET_MODIFY:
        case LFUN_INSET_DIALOG_UPDATE:
@@ -268,7 +295,7 @@ bool InsetMathSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
 
 void InsetMathSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
-       switch (cmd.action) {
+       switch (cmd.action()) {
        case LFUN_INSET_MODIFY:
                if (cmd.getArg(0) == "mathspace") {
                        MathData ar;
@@ -280,14 +307,9 @@ void InsetMathSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
                cur.undispatched();
                break;
 
-       case LFUN_INSET_DIALOG_UPDATE:
-               cur.bv().updateDialog("mathspace", createDialogStr());
-               break;
-
        case LFUN_MOUSE_RELEASE:
                if (cmd.button() == mouse_button::button1) {
-                       string const data = createDialogStr();
-                       cur.bv().showDialog("mathspace", data, this);
+                       showInsetDialog(&cur.bv());
                        break;
                }
                cur.undispatched();