From b249c0b0bb43b8c724e82412b22e9ac019bebb87 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Mon, 21 Jul 2003 21:51:17 +0000 Subject: [PATCH] Add a buffer_path arg to InsetGraphicsMailer's params2string, string2params. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7335 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 ++++ src/factory.C | 4 +++- src/frontends/controllers/ChangeLog | 9 ++++++- src/frontends/controllers/ControlGraphics.C | 13 ++++++----- src/insets/ChangeLog | 6 +++++ src/insets/insetgraphics.C | 26 ++++++++++++++------- src/insets/insetgraphics.h | 8 +++++-- 7 files changed, 53 insertions(+), 18 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 5943da39e8..b01da8f178 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-07-21 Angus Leeming + + * factory.C (createInset): pass a + buffer_path parameter to InsetGraphicsMailer's string2params. + 2003-07-21 Angus Leeming * BufferView_pimpl.C (buffer): diff --git a/src/factory.C b/src/factory.C index e02a76b10e..e9a22511a9 100644 --- a/src/factory.C +++ b/src/factory.C @@ -206,8 +206,10 @@ Inset * createInset(FuncRequest const & cmd) return inset; } else if (name == "graphics") { + string const fpath = cmd.view()->buffer()->filePath(); InsetGraphicsParams igp; - InsetGraphicsMailer::string2params(cmd.argument, igp); + InsetGraphicsMailer::string2params(cmd.argument, fpath, + igp); InsetGraphics * inset = new InsetGraphics; inset->setParams(igp); return inset; diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 15e27845d0..68cf1bb39c 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,6 +1,13 @@ 2003-07-21 Angus Leeming - * ControlGraphics.C (readBB): use namespace lyx::graphics rather than grfx shortcut. + * ControlGraphics.C (initialiseParams, dispatchParams): pass a + buffer_path parameter to InsetGraphicsMailer's string2params, + params2string. + +2003-07-21 Angus Leeming + + * ControlGraphics.C (readBB): use namespace lyx::graphics rather + than grfx shortcut. 2003-07-18 Lars Gullik Bjønnes diff --git a/src/frontends/controllers/ControlGraphics.C b/src/frontends/controllers/ControlGraphics.C index cfd8f19ebe..05fca1d771 100644 --- a/src/frontends/controllers/ControlGraphics.C +++ b/src/frontends/controllers/ControlGraphics.C @@ -50,12 +50,12 @@ ControlGraphics::ControlGraphics(Dialog & parent) bool ControlGraphics::initialiseParams(string const & data) { + string const bufpath = kernel().buffer()->filePath(); InsetGraphicsParams params; - InsetGraphicsMailer::string2params(data, params); + InsetGraphicsMailer::string2params(data, bufpath, params); params_.reset(new InsetGraphicsParams(params)); // make relative for good UI - params_->filename = MakeRelPath(params_->filename, - kernel().buffer()->filePath()); + params_->filename = MakeRelPath(params_->filename, bufpath); return true; } @@ -68,11 +68,12 @@ void ControlGraphics::clearParams() void ControlGraphics::dispatchParams() { + string const buffer_path = kernel().buffer()->filePath(); InsetGraphicsParams tmp_params(params()); // core requires absolute path during runtime - tmp_params.filename = MakeAbsPath(tmp_params.filename, - kernel().buffer()->filePath()); - string const lfun = InsetGraphicsMailer::params2string(tmp_params); + tmp_params.filename = MakeAbsPath(tmp_params.filename, buffer_path); + string const lfun = + InsetGraphicsMailer::params2string(tmp_params, buffer_path); kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun)); } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index ff812778f5..7ae3509345 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2003-07-21 Angus Leeming + + * insetgraphics.[Ch] (string2params, params2string): passed a + buffer_path argument. + (view): new method. + 2003-07-21 Angus Leeming * insetexternal.C: diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 17923ea174..cf6917c091 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -177,8 +177,9 @@ dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd) { switch (cmd.action) { case LFUN_INSET_MODIFY: { + string const bufpath = cmd.view()->buffer()->filePath(); InsetGraphicsParams p; - InsetGraphicsMailer::string2params(cmd.argument, p); + InsetGraphicsMailer::string2params(cmd.argument, bufpath, p); if (!p.filename.empty()) { setParams(p); cmd.view()->updateInset(this); @@ -606,6 +607,12 @@ InsetGraphicsParams const & InsetGraphics::params() const } +BufferView * InsetGraphics::view() const +{ + return graphic_->view(); +} + + string const InsetGraphicsMailer::name_("graphics"); InsetGraphicsMailer::InsetGraphicsMailer(InsetGraphics & inset) @@ -615,12 +622,16 @@ InsetGraphicsMailer::InsetGraphicsMailer(InsetGraphics & inset) string const InsetGraphicsMailer::inset2string() const { - return params2string(inset_.params()); + BufferView * bv = inset_.view(); + if (bv) + return params2string(inset_.params(), bv->buffer()->filePath()); + return string(); } void InsetGraphicsMailer::string2params(string const & in, - InsetGraphicsParams & params) + string const & buffer_path, + InsetGraphicsParams & params) { params = InsetGraphicsParams(); @@ -640,20 +651,19 @@ void InsetGraphicsMailer::string2params(string const & in, if (lex.isOK()) { InsetGraphics inset; -#warning FIXME not setting bufpath is dubious - inset.readInsetGraphics(lex, string()); + inset.readInsetGraphics(lex, buffer_path); params = inset.params(); } } string const -InsetGraphicsMailer::params2string(InsetGraphicsParams const & params) +InsetGraphicsMailer::params2string(InsetGraphicsParams const & params, + string const & buffer_path) { ostringstream data; data << name_ << ' '; -#warning FIXME not setting bufpath is dubious - params.Write(data, string()); + params.Write(data, buffer_path); data << "\\end_inset\n"; return STRCONV(data.str()); } diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index c90733520e..e20795410c 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -78,6 +78,7 @@ public: /// Get the inset parameters, used by the GUIndependent dialog. InsetGraphicsParams const & params() const; + virtual BufferView * view() const; private: /// friend class InsetGraphicsMailer; @@ -121,9 +122,12 @@ public: /// virtual string const inset2string() const; /// - static void string2params(string const &, InsetGraphicsParams &); + static void string2params(string const & data, + string const & buffer_path, + InsetGraphicsParams &); /// - static string const params2string(InsetGraphicsParams const &); + static string const params2string(InsetGraphicsParams const &, + string const & buffer_path); private: /// static string const name_; -- 2.39.2