X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetgraphics.C;h=bb4a0cdfd0e749ca75136b3f5a35ffd1296e098b;hb=357a3741c0655e174ad48ded68cca90b09a158e6;hp=949120d37b27956d817edeb0559c1e957ce0348b;hpb=de49e029348c639be64ec77cc9d292c0da6ddc3b;p=lyx.git diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 949120d37b..bb4a0cdfd0 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -58,6 +58,7 @@ TODO #include "buffer.h" #include "BufferView.h" #include "converter.h" +#include "cursor.h" #include "debug.h" #include "dispatchresult.h" #include "format.h" @@ -79,12 +80,11 @@ TODO #include "support/os.h" #include "support/systemcall.h" #include "support/tostr.h" +#include "support/std_sstream.h" #include #include -#include "support/std_sstream.h" - namespace support = lyx::support; using lyx::support::AbsolutePath; using lyx::support::bformat; @@ -191,38 +191,38 @@ void InsetGraphics::statusChanged() const } -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()); } @@ -235,6 +235,7 @@ void InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const void InsetGraphics::draw(PainterInfo & pi, int x, int y) const { + setPosCache(pi, x, y); graphic_->draw(pi, x, y); } @@ -631,9 +632,9 @@ int InsetGraphics::plaintext(Buffer const &, ostream & os, 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(); @@ -714,7 +715,6 @@ void InsetGraphicsMailer::string2params(string const & in, InsetGraphicsParams & params) { params = InsetGraphicsParams(); - if (in.empty()) return; @@ -722,18 +722,14 @@ void InsetGraphicsMailer::string2params(string const & in, 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(); }