]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetexternal.C
fix #832
[lyx.git] / src / insets / insetexternal.C
index fd5fe30017f1c40deb2e1380df6d4912eb95d9e1..fa27977806cde4790530e2b4a7290514338532fe 100644 (file)
@@ -10,7 +10,6 @@
 
 #include <config.h>
 
-
 #include "insetexternal.h"
 #include "ExternalTemplate.h"
 #include "BufferView.h"
@@ -21,6 +20,7 @@
 #include "gettext.h"
 #include "debug.h"
 #include "lyxlex.h"
+#include "Lsstream.h"
 
 #include "frontends/LyXView.h"
 #include "frontends/Dialogs.h"
@@ -34,7 +34,6 @@
 #include <cstdio>
 #include <utility>
 
-
 using std::ostream;
 using std::endl;
 
@@ -64,36 +63,30 @@ InsetExternal::Params const & InsetExternal::params() const
 
 dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd)
 {
-       dispatch_result result = UNDISPATCHED;
-
        switch (cmd.action) {
+
        case LFUN_INSET_MODIFY: {
                InsetExternal::Params p;
                InsetExternalMailer::string2params(cmd.argument, p);
-               if (p.filename.empty())
-                       break;
-
-               setFromParams(p);
-               cmd.view()->updateInset(this);
-               result = DISPATCHED;
+               if (!p.filename.empty()) {
+                       setFromParams(p);
+                       cmd.view()->updateInset(this);
+               }
+               return DISPATCHED;
        }
-       break;
 
-       case LFUN_INSET_DIALOG_UPDATE: {
-               InsetExternalMailer mailer(*this);
-               mailer.updateDialog(cmd.view());
-       }
-       break;
+       case LFUN_INSET_DIALOG_UPDATE:
+               InsetExternalMailer(*this).updateDialog(cmd.view());
+               return DISPATCHED;
 
        case LFUN_MOUSE_RELEASE:
-               edit(cmd.view(), cmd.x, cmd.y, cmd.button());
-               break;
+       case LFUN_INSET_EDIT:
+               InsetExternalMailer(*this).showDialog(cmd.view());
+               return DISPATCHED;
 
        default:
-               break;
+               return UNDISPATCHED;
        }
-
-       return result;
 }
 
 
@@ -111,19 +104,6 @@ string const InsetExternal::editMessage() const
 }
 
 
-void InsetExternal::edit(BufferView * bv, int, int, mouse_button::state)
-{
-       InsetExternalMailer mailer(*this);
-       mailer.showDialog(bv);
-}
-
-
-void InsetExternal::edit(BufferView * bv, bool)
-{
-       edit(bv, 0, 0, mouse_button::none);
-}
-
-
 void InsetExternal::write(Buffer const *, ostream & os) const
 {
        os << "External " << params_.templ.lyxName << ",\""
@@ -381,7 +361,10 @@ void InsetExternalMailer::string2params(string const & in,
 {
        params = InsetExternal::Params();
 
-       istringstream data(in);
+       if (in.empty())
+               return;
+
+       istringstream data(STRCONV(in));
        LyXLex lex(0,0);
        lex.setStream(data);
 
@@ -402,7 +385,7 @@ void InsetExternalMailer::string2params(string const & in,
        }
 
        if (lex.isOK()) {
-               InsetExternal inset;    
+               InsetExternal inset;
                inset.read(0, lex);
                params = inset.params();
        }
@@ -418,6 +401,5 @@ InsetExternalMailer::params2string(InsetExternal::Params const & params)
        data << name_ << ' ';
        inset.write(0, data);
        data << "\\end_inset\n";
-
-       return data.str();
+       return STRCONV(data.str());
 }