Bug 104674 - Relative file paths for external files in formulas
Summary: Relative file paths for external files in formulas
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Files-Linked
  Show dependency treegraph
 
Reported: 2016-12-14 11:18 UTC by Miklos Vajna
Modified: 2020-11-20 12:18 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Source document. (21.71 KB, application/vnd.oasis.opendocument.spreadsheet-flat-xml)
2018-07-11 14:25 UTC, Miklos Vajna
Details
Destination document. (22.06 KB, application/vnd.oasis.opendocument.spreadsheet-flat-xml)
2018-07-11 14:27 UTC, Miklos Vajna
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Miklos Vajna 2016-12-14 11:18:59 UTC
When I have two ODS files in the same directory, and a cell formula in file A refers to a cell in file B, then currently we create absolute paths to denote file B. (When creating the formula by switching to the other Calc window and clicking to the cell using the mouse.) This means if the file is checked into e.g. git, the external references can't be updated on an other machine if the git checkout has a different path.

Making the path relative would fix this. I'm not sure what is the best algorithm to decide what to make relative paths, but perhaps a conservative one would be using relative paths when the relative path would contain no "../" parts? Just an idea.
Comment 1 Jan Holesovsky 2016-12-15 09:58:32 UTC
The xls / xlsx filter builds relative links on save in XclExpHyperlink::BuildFileName() in sc/source/filter/excel/xecontent.cxx, would be great to do the same on save in ods / fods too :-)
Comment 2 Eike Rathke 2018-07-11 11:59:12 UTC
That is what Tools -> Options -> Load/Save -> General, "Save URLs relative to file system" is for. The absolute path of the external link is saved with the <table:table table:name="..."> attribute, but the <table:table-source xlink:href="..."> attribute contains a relative reference.

I guess this is notabug (nor rfe)?
Comment 3 Miklos Vajna 2018-07-11 14:25:00 UTC
Created attachment 143464 [details]
Source document.
Comment 4 Miklos Vajna 2018-07-11 14:27:50 UTC
Created attachment 143465 [details]
Destination document.

Perhaps I do something wrong. :-)

Steps to reproduce the problem I still see:

1) Create a new Calc document, type 1 2 3 in A1 A2 A3. (Attached here as source.fods). Save as FODS.

2) Create a second Calc document, type "=" in A1, then select the A1 of source.fods with the mouse. Save as FODS.

3) Close both documents.

4) Move them to an other directory.

5) Open dest.fods, click the "Enable content" button on the infobar.

Expected result: no error.

Actual result: the old path of source.fods is shown in an error dialog, saying it's not found.

Is this enough info to reproduce the problem? Thanks.