#include <config.h>
-
#include "insetexternal.h"
#include "ExternalTemplate.h"
#include "BufferView.h"
#include "gettext.h"
#include "debug.h"
#include "lyxlex.h"
+#include "Lsstream.h"
#include "frontends/LyXView.h"
#include "frontends/Dialogs.h"
#include <cstdio>
#include <utility>
-
using std::ostream;
using std::endl;
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());
- result = DISPATCHED;
- break;
+ case LFUN_INSET_EDIT:
+ InsetExternalMailer(*this).showDialog(cmd.view());
+ return DISPATCHED;
default:
- break;
+ return UNDISPATCHED;
}
-
- return result;
}
}
-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 << ",\""
{
params = InsetExternal::Params();
- istringstream data(in);
+ if (in.empty())
+ return;
+
+ istringstream data(STRCONV(in));
LyXLex lex(0,0);
lex.setStream(data);
}
if (lex.isOK()) {
- InsetExternal inset;
+ InsetExternal inset;
inset.read(0, lex);
params = inset.params();
}
data << name_ << ' ';
inset.write(0, data);
data << "\\end_inset\n";
-
- return data.str();
+ return STRCONV(data.str());
}