#include "buffer.h"
#include "BufferView.h"
#include "converter.h"
+#include "cursor.h"
#include "debug.h"
#include "dispatchresult.h"
#include "format.h"
#include "support/os.h"
#include "support/systemcall.h"
#include "support/tostr.h"
+#include "support/std_sstream.h"
#include <boost/bind.hpp>
#include <boost/tuple/tuple.hpp>
-#include "support/std_sstream.h"
-
namespace support = lyx::support;
using lyx::support::AbsolutePath;
using lyx::support::bformat;
}
-DispatchResult
-InsetGraphics::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
+void InsetGraphics::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
{
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
- Buffer const & buffer = *cmd.view()->buffer();
+ Buffer const & buffer = *cur.bv().buffer();
InsetGraphicsParams p;
InsetGraphicsMailer::string2params(cmd.argument, buffer, p);
if (!p.filename.empty()) {
setParams(p);
- cmd.view()->update();
+ cur.bv().update();
}
- return DispatchResult(true, true);
+ break;
}
case LFUN_INSET_DIALOG_UPDATE:
- InsetGraphicsMailer(*this).updateDialog(cmd.view());
- return DispatchResult(true, true);
+ InsetGraphicsMailer(*this).updateDialog(&cur.bv());
+ break;
case LFUN_MOUSE_RELEASE:
- InsetGraphicsMailer(*this).showDialog(cmd.view());
- return DispatchResult(true, true);
+ InsetGraphicsMailer(*this).showDialog(&cur.bv());
+ break;
default:
- return DispatchResult(false);
+ InsetOld::priv_dispatch(cur, cmd);
+ break;
}
}
-void InsetGraphics::edit(BufferView * bv, bool)
+void InsetGraphics::edit(LCursor & cur, bool)
{
- InsetGraphicsMailer(*this).showDialog(bv);
+ InsetGraphicsMailer(*this).showDialog(&cur.bv());
}
void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
{
+ setPosCache(pi, x, y);
graphic_->draw(pi, x, y);
}
int InsetGraphics::linuxdoc(Buffer const & buf, ostream & os,
- OutputParams const &) const
+ OutputParams const & runparams) const
{
- string const file_name = buf.niceFile() ?
+ string const file_name = runparams.nice ?
params().filename.relFilename(buf.filePath()):
params().filename.absFilename();
InsetGraphicsParams & params)
{
params = InsetGraphicsParams();
-
if (in.empty())
return;
LyXLex lex(0,0);
lex.setStream(data);
- if (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
- if (token != name_)
- return;
- }
+ string name;
+ lex >> name;
+ if (!lex || name != name_)
+ return print_mailer_error("InsetGraphicsMailer", in, 1, name_);
- if (lex.isOK()) {
- InsetGraphics inset;
- inset.readInsetGraphics(lex, buffer.filePath());
- params = inset.params();
- }
+ InsetGraphics inset;
+ inset.readInsetGraphics(lex, buffer.filePath());
+ params = inset.params();
}