Bug 90299 - External links don't saved as relative in xls
Summary: External links don't saved as relative in xls
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
3.5.0 release
Hardware: All All
: high normal
Assignee: Łukasz Leszko
URL:
Whiteboard: target:7.5.0
Keywords: difficultyBeginner, easyHack, filter:xls, skillCpp
Depends on:
Blocks: XLS
  Show dependency treegraph
 
Reported: 2015-03-28 17:56 UTC by geeker
Modified: 2023-07-24 09:32 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments
example files (13.05 KB, application/x-7z-compressed)
2015-03-28 17:56 UTC, geeker
Details
test with 4.4.1.2 (320.39 KB, image/jpeg)
2015-03-30 16:48 UTC, geeker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description geeker 2015-03-28 17:56:03 UTC
Created attachment 114420 [details]
example files

When saving the .xls spreadsheet external links are not stored as relative. If file is moved external links not update nor in the LO or in MSO. 
When you open the spreadsheet created in MSO external links updating succeeds. 
For .xlsx the problem does not occur.

In attachment:
lo_master.xls - the spreadsheet with external link created in LO.
mso_master.xls - the spreadsheet with external link created in MSO.
down/slave.xls - the spreadsheet for external link.
lo_master.xlsx - the .xlsx spreadsheet with external link created in LO.
Comment 1 raal 2015-03-28 19:15:57 UTC
Hello geeker,
thanks for reporting bug.
Please try following:

- In down/slave.xls rename name of the sheet "Лист1" - new name for example "list1". No cyrillic characters.
- in lo_master.xls delete all formulas and create new link to slave.xls.

Let me know if it works for you and set to bug to unconfirmed.
Thank you

(ref.85617)
Comment 2 m_a_riosv 2015-03-28 21:54:51 UTC
There is an option for save with relative/absolute paths.

Menu/Tools/Options/Load-Save/General - Save URLs relative to file system.

Is the option marked?
Comment 3 geeker 2015-03-29 19:55:52 UTC
(In reply to m.a.riosv from comment #2)
> There is an option for save with relative/absolute paths.
> 
> Menu/Tools/Options/Load-Save/General - Save URLs relative to file system.
> 
> Is the option marked?

Yes, it's marked.
Comment 4 geeker 2015-03-29 20:16:04 UTC
(In reply to raal from comment #1)
> Please try following:
> 
> - In down/slave.xls rename name of the sheet "Лист1" - new name for example
> "list1". No cyrillic characters.
> - in lo_master.xls delete all formulas and create new link to slave.xls.
> 
> Let me know if it works for you and set to bug to unconfirmed.
> Thank you
> 
> (ref.85617)

No, it don't work
Comment 5 raal 2015-03-30 08:02:57 UTC
Tested now with  4.4.1.2 ID build: 45e2de17089c24a1fa810c8f975a7171ba4cd432, win7 and can not confirm. I created new files. Please test with 4.4.1.2, https://www.libreoffice.org/download/libreoffice-fresh/
Comment 6 geeker 2015-03-30 16:48:29 UTC
Created attachment 114468 [details]
test with 4.4.1.2
Comment 7 geeker 2015-03-30 16:54:26 UTC
(In reply to raal from comment #5)
> Tested now with  4.4.1.2 ID build: 45e2de17089c24a1fa810c8f975a7171ba4cd432,
> win7 and can not confirm. I created new files. Please test with 4.4.1.2,
> https://www.libreoffice.org/download/libreoffice-fresh/

I tested with 4.4.1.2 yesterday. And repeated now (see "test with 4.4.1.2" attachment).
Can you load your new file?
Comment 8 raal 2015-03-30 17:29:48 UTC
I can reproduce with Version: 4.4.3.0.0+
Build ID: 3eba5eb1774ab621a1f0f4dcc7e82cce6c025b0a
TinderBox: Linux-rpm_deb-x86_64@46-TDF, Branch:libreoffice-4-4, Time: 2015-03-27_09:07:12

reproducible with LO 3.5
Comment 9 geeker 2015-08-26 15:58:16 UTC
It's reproduced in Version 5.0.0.5.
Comment 10 Cor Nouws 2015-12-02 16:40:15 UTC
version 3.5 per comment 8. 
Possibly inherited from OOo ?
Comment 11 Gunnar Eikman 2016-03-06 21:14:36 UTC Comment hidden (off-topic)
Comment 12 Gunnar Eikman 2016-03-06 21:27:59 UTC Comment hidden (off-topic)
Comment 13 Cor Nouws 2016-03-07 10:11:50 UTC
(to be honest, I get the feeling too that links tend to work not always reliable, in the various scenario's.. Have seen, tested and commented quite some issues about it.)
Comment 14 geeker 2016-03-10 17:42:34 UTC
Win7x64 Version: 5.1.1.3 (x64) Build ID: 89f508ef3ecebd2cfb8e1def0f0ba9a803b88a6d
Unfortunately, work with external links was broken also in xlsx.
Comment 15 QA Administrators 2017-11-30 06:27:31 UTC Comment hidden (obsolete)
Comment 16 QA Administrators 2021-03-24 05:55:31 UTC Comment hidden (obsolete)
Comment 17 geeker 2021-04-12 16:23:53 UTC
(In reply to geeker from comment #14)
> Win7x64 Version: 5.1.1.3 (x64) Build ID:
> 89f508ef3ecebd2cfb8e1def0f0ba9a803b88a6d
> Unfortunately, work with external links was broken also in xlsx.

Confirming the problem in the Version: 7.1.2.2 (x64) / LibreOffice Community
Build ID: 8a45595d069ef5570103caea1b71cc9d82b2aae4
Comment 18 Mike Kaganski 2021-09-10 10:50:19 UTC
Code pointer:

The path is saved in XclExpSupbook::WriteBody, using maUrlEncoded.

The encoding of the URL for storing to BIFF happens in lclEncodeDosUrl (sc/source/filter/excel/xehelper.cxx).

The latter *unconditionally* tries to store *drive* relative to base, but *does not* try to save directory path relatively.

There is XclImpUrlHelper::DecodeUrl in sc/source/filter/excel/xihelper.cxx, that does the opposite cf. to lclEncodeDosUrl.

Basically the task of the easy hack is: check with an Excel-generated XLS containing a relative reference, what arrives to XclImpUrlHelper::DecodeUrl; then implement passing the value of XclExpRoot::IsRelUrl() down to lclEncodeDosUrl; and then in the latter, implement proper generation of relative address depending on the passed IsRelUrl value.
Comment 19 Vaibhav Malik 2022-01-17 18:49:27 UTC Comment hidden (obsolete)
Comment 20 Vaibhav Malik 2022-01-17 18:56:27 UTC
(In reply to Mike Kaganski from comment #18)
> Code pointer:
> 
> The path is saved in XclExpSupbook::WriteBody, using maUrlEncoded.
> 
> The encoding of the URL for storing to BIFF happens in lclEncodeDosUrl
> (sc/source/filter/excel/xehelper.cxx).
> 
> The latter *unconditionally* tries to store *drive* relative to base, but
> *does not* try to save directory path relatively.
> 
> There is XclImpUrlHelper::DecodeUrl in sc/source/filter/excel/xihelper.cxx,
> that does the opposite cf. to lclEncodeDosUrl.
> 
> Basically the task of the easy hack is: check with an Excel-generated XLS
> containing a relative reference, what arrives to XclImpUrlHelper::DecodeUrl;
> then implement passing the value of XclExpRoot::IsRelUrl() down to
> lclEncodeDosUrl; and then in the latter, implement proper generation of
> relative address depending on the passed IsRelUrl value.

Sir, I am working on this bug, so far I could find that:
1. when XclImpUrlHelper::DecodeUrl is called using lo_master.xls doc, the value of rEncodedUrl is "\001\002down\003slave.xls".
2. when XclImpUrlHelper::DecodeUrl is called using mso_master.xls doc, the value of rEncodedUrl is "\001down\003slave.xls"
Comment 21 Vaibhav Malik 2022-01-19 07:33:14 UTC
(In reply to Mike Kaganski from comment #18)
> Code pointer:
> 
> The path is saved in XclExpSupbook::WriteBody, using maUrlEncoded.
> 
> The encoding of the URL for storing to BIFF happens in lclEncodeDosUrl
> (sc/source/filter/excel/xehelper.cxx).
> 
> The latter *unconditionally* tries to store *drive* relative to base, but
> *does not* try to save directory path relatively.
> 
> There is XclImpUrlHelper::DecodeUrl in sc/source/filter/excel/xihelper.cxx,
> that does the opposite cf. to lclEncodeDosUrl.
> 
> Basically the task of the easy hack is: check with an Excel-generated XLS
> containing a relative reference, what arrives to XclImpUrlHelper::DecodeUrl;
> then implement passing the value of XclExpRoot::IsRelUrl() down to
> lclEncodeDosUrl; and then in the latter, implement proper generation of
> relative address depending on the passed IsRelUrl value.

Sir, I use GDB to debug, but I do not know how to invoke XclExpRoot::IsRelUrl() and lclEncodeDosUrl methods. using "call lclEncodeDosUrl()" won't work until I step into the file "sc/source/filter/excel/xehelper.cxx" can you please provide some hint regarding this?
Comment 22 Mike Kaganski 2022-01-19 07:48:19 UTC
(In reply to Vaibhav Malik from comment #21)

Please use gerrit for discussion of code. Your task is to create a change, even if it doesn't work; it will show your code, and there you may include code comments, or post gerrit comments, explaining your ideas, the specific problems (including specific points, passed values, expected and actual results, call stacks etc.), and would enable review and advices.
Comment 23 Commit Notification 2022-08-30 04:34:43 UTC
Łukasz Leszko committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/59ddcb0445da12f2b912f1a8a876117fec112c41

tdf#90299 Fix saving external links as relative

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 24 Buovjaga 2023-07-23 06:15:11 UTC
Can this be closed as fixed?
Comment 25 Łukasz Leszko 2023-07-23 19:22:55 UTC
(In reply to Buovjaga from comment #24)
> Can this be closed as fixed?

I just checked if my patch still works, and it does, so I guess we can close it.