]> git.lyx.org Git - lyx.git/commitdiff
Add a buffer_path arg to InsetGraphicsMailer's params2string, string2params.
authorAngus Leeming <leeming@lyx.org>
Mon, 21 Jul 2003 21:51:17 +0000 (21:51 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 21 Jul 2003 21:51:17 +0000 (21:51 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7335 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/factory.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlGraphics.C
src/insets/ChangeLog
src/insets/insetgraphics.C
src/insets/insetgraphics.h

index 5943da39e87803b5118c51b52566c46eec8caefb..b01da8f178859aa506f1877558ab0384b2d4fb29 100644 (file)
@@ -1,3 +1,8 @@
+2003-07-21  Angus Leeming  <leeming@lyx.org>
+
+       * factory.C (createInset): pass a
+       buffer_path parameter to InsetGraphicsMailer's string2params.
+
 2003-07-21  Angus Leeming  <leeming@lyx.org>
 
        * BufferView_pimpl.C (buffer):
index e02a76b10e00eebf6421d13f20ee529fc4c5f705..e9a22511a99e5d773a7fe92e32c3ff07c2738fbc 100644 (file)
@@ -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;
index 15e27845d0d31ba03ec39d5a594a312c5cb4ab77..68cf1bb39c7a08bdacc3525ca33fd8496f2959b7 100644 (file)
@@ -1,6 +1,13 @@
 2003-07-21  Angus Leeming  <leeming@lyx.org>
 
-       * 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  <leeming@lyx.org>
+
+       * ControlGraphics.C (readBB): use namespace lyx::graphics rather
+       than grfx shortcut.
 
 2003-07-18  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
index cfd8f19ebe82401bdeb0a1ac9f3cb97d0e9c3730..05fca1d7716b2d74395a6b2627722db08c726347 100644 (file)
@@ -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));
 }
 
index ff812778f5fb20878f730e520e627e45a87f9af2..7ae35093456b1795444fec7d36c0a8fc8fb611f1 100644 (file)
@@ -1,3 +1,9 @@
+2003-07-21  Angus Leeming  <leeming@lyx.org>
+
+       * insetgraphics.[Ch] (string2params, params2string): passed a
+       buffer_path argument.
+       (view): new method.
+
 2003-07-21  Angus Leeming  <leeming@lyx.org>
 
        * insetexternal.C:
index 17923ea17474b0aa0b454e6815b84b349e44b7a6..cf6917c091473d8c1652009b22a5b9f6378fb57d 100644 (file)
@@ -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());
 }
index c90733520eb7e01f854424e6f3787e04d9b375d6..e20795410cb081b59901574f181041c658b47190 100644 (file)
@@ -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_;