On Monday 21 October 2002 11:30 am, Angus Leeming wrote:
> On Monday 21 October 2002 11:28 am, Andre Poenitz wrote:
> > On Mon, Oct 21, 2002 at 11:17:46AM +0100, Angus Leeming wrote:
> > > I draw your attention to what happens after a "Paste"
> > > request. Note the different addresses of the newly created
> > > inset and of that sent to draw. It seems to me that the
> > > "wrong" inset is being added to the buffer.
> >
> > Funny.
> >
> > > It seems that this is the root of the problem. Is their a
> > > reason for things being the way they are. Would pasing the
> > > newly created inset into the second buffer (as opposed to
> > > the inset created by the copy operation) break undo/redo
> > > etc, etc...
> > >
> > > I'd value some insight from someone more familiar with the
> > > cut and paste stuff.
> >
> > I am not familiar with this code but I know a simple
> > solution for this kind of problem (and a few more): Do not
> > operate on lyx's internal structures for cut and paste.
> > Instead convert the selection to a string that resembles the
> > external file format on "cut", and read from this string as
> > if this were coming from a .lyx file on "paste"...
>
> Sure. That's what I'm going to do. But it would be nice if
> "draw" only drew....
>
> Angus
Here's the patch. Ok to apply?
Angus
? src/insets/insetgraphics.log
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.528
diff -u -p -r1.528 ChangeLog
--- src/insets/ChangeLog 16 Oct 2002 20:27:23 -0000 1.528
+++ src/insets/ChangeLog 21 Oct 2002 11:27:57 -0000
@@ -1,3 +1,9 @@
+2002-10-21 Angus Leeming <[EMAIL PROTECTED]>
+
+ * insetgraphics.C (draw): Fix the drawing of an inset with a relative
+ file path subdir/fig.eps when pasting it into a buffer in a different
+ directory.
+
2002-10-16 John Levon <[EMAIL PROTECTED]>
* insetspecialchar.C: remove \\protected_separator parsing
Index: src/insets/insetgraphics.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.C,v
retrieving revision 1.137
diff -u -p -r1.137 insetgraphics.C
--- src/insets/insetgraphics.C 25 Sep 2002 14:26:11 -0000 1.137
+++ src/insets/insetgraphics.C 21 Oct 2002 11:27:57 -0000
@@ -294,6 +294,18 @@ int InsetGraphics::width(BufferView *, L
void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
int baseline, float & x, bool) const
{
+ // MakeAbsPath returns params().filename unchanged if it absolute
+ // already.
+ string const file_with_path =
+ MakeAbsPath(params().filename, bv->buffer()->filePath());
+
+ // A 'paste' operation creates a new inset with the correct filepath,
+ // but then the 'old' inset stored in the 'copy' operation is actually
+ // added to the buffer.
+ // Thus, we should ensure that the filepath is correct.
+ if (file_with_path != cache_->loader.filename())
+ cache_->update(file_with_path);
+
cache_->view = bv->owner()->view();
int oasc = cache_->old_ascent;