> I noticed there are some closed entries in the bug tracker about this > already, but I've had this problem for a long time and it still appears in > LyX 1.6.8 (I am using Mac OS X):
The problem is that it seems to occur only on MacOSX. > > 1) Insert a new graphic and select an image via the file selection dialog. > 2) The graphics dialog now shows a relative path to the image file. > 3) Close the graphics dialog, duplicate the image via copy'n'paste, and open > the duplicated image's graphics dialog. > 4) The filename is now an absolute path. > > This is of course a pain when sending the LyX document to your collaborators. > > I downloaded the source code of LyX 1.6.8 and was able to track it down: > > 1) When copying an image, the relative path is converted into an absolute > path. > 2) In pasteClipboardText (CutAndPaste.cpp, line 912), a temporary Buffer is > created (line 926) that holds the pasted LyX paragraphs. > 3) The paragraphs are parsed and new InsetGraphics are created from the > absolute paths supplied in the pasted text. > 4) The DocFileName class which holds the image filename thinks that it should > output absolute paths now because it was given an absolute path initially. Thanks for looking up, but I don't think the problem lies here. We make a relative path later. See InsetGraphics::prepareFile(): string const orig_file = params().filename.absFilename(); // this is for dryrun and display purposes, do not use latexFilename string const rel_file = params().filename.relFilename(buffer().filePath()); LYXERR0(orig_file); LYXERR0(buffer().filePath()); LYXERR0(rel_file); and GuiGraphics::paramsToDialog(): string const name = igp.filename.outputFilename(fromqstr(bufferFilepath())); LYXERR0(name); I put in some debugging macros you can use to output some debug info. If you can compile LyX you can try and see what they give you and why the copies don't get a relative filename. Stephan ? Can you check this ? > It might be sensible to add a checkbox "Save absolute path" to the graphics > dialog to let the user decide on a case-by-case basis. Also, the preferences > could contain a "Save absolute paths by default" checkbox. But this is > beyond my current Qt coding capabilities... > We are thinking about this in a slightly different context. When to use a relative path ? It is obvious for "C:\Documents\test.lyx" "C:\Documents\images\text.jpg" to represent the image path as "images\text.jpg", and for "C:\Documents\chapters\test.lyx" "C:\Documents\images\test.jpg" to represent the image path as "..\images\test.jpg", but what should we do for "C:\Documents\chapters\first\firstsection\test.lyx" "C:\UnrelatedPath\test\images\large\color\test.jpg" ? Should we now have a relative path "..\..\..\..\UnrelatedPath\test\images\large\color\texst.jpg" ? This doesn't really make sense. Vincent