Bug 137937

Summary: FILESAVE XLSX External cell reference path is extended by user home dirs path
Product: LibreOffice Reporter: NISZ LibreOffice Team <libreoffice>
Component: CalcAssignee: Attila Szűcs <attila.szucs>
Status: VERIFIED FIXED    
Severity: normal CC: attila.szucs, nemeth, srdosm
Priority: medium Keywords: bibisected, bisected, filter:xlsx, implementationError
Version: 4.4.0.3 release   
Hardware: All   
OS: All   
Whiteboard: target:7.2.0 target:7.1.1
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 108917    
Attachments: Example file from Calc with cell references to c:\TEMP
The original file saved by Calc
Screenshot of the original and exported document side by side in Calc
Example file used as cell reference target
Example file used as cell reference target
Example file from Excel 2013 with the same cell references

Description NISZ LibreOffice Team 2020-11-02 14:57:29 UTC
Created attachment 166941 [details]
Example file from Calc with cell references to c:\TEMP

Attached ODS file contains a cell reference to a file in C:\TEMP directory.
When this file is saved to XLSX format the path to the file is extended with the users home directory name, i.e. ='file:///C:/TEMP/EDATAE13_B.xlsx'#$Munka1.A1 becomes ='file:///C:/Users/kelemengabo/Documents/TEMP/EDATAE13_B.xlsx'#$Munka1.A1 
This is similar to the situation mentioned here for Linux:
https://bugs.documentfoundation.org/show_bug.cgi?id=121472#c5 

Steps to reproduce:
    1. Open attached file
    2. Save as XLSX
    3. Reopen

Actual results:
Cell reference path changed, now it contains thes users own directories path.

Expected results:
Correct cell references.

LibreOffice details:
Version: 7.1.0.0.alpha1+ (x64)
Build ID: ec1f4d3253963ac16d638734ac70dde033e82154
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: Skia/Raster; VCL: win
Locale: hu-HU (hu_HU); UI: en-US
Calc: CL

Also happens way back to:
Version: 4.4.0.3
Build ID: de093506bcdc5fafd9023ee680b8c60e3e0645d7
Locale: hu_HU

In 4.3 the exported reference was:
=['file:///c:/temp/edatae13_b.xlsx']munka1!a1
Which had a correct path, but it was otherwise incorrect and giving Err:509 error.

Additional Information: 

Bibisected using bibisect-win32-4.4 to:
https://cgit.freedesktop.org/libreoffice/core/log/?qt=range&q=5c37960d9507fac206f0b90d36f778db9fe2b6a5..41e4a607b00f446eeaebf8f59c957a1a580c9517

of which the most likely starting commit is the initial implementation of this feature:
https://cgit.freedesktop.org/libreoffice/core/commit/?id=8c23a767d926d8d08213f5e2f8e81775c653cbd7 

write OOXML externalReferences, externalLinks, fdo#45286
Comment 1 NISZ LibreOffice Team 2020-11-02 14:57:59 UTC
Created attachment 166942 [details]
The original file saved by Calc
Comment 2 NISZ LibreOffice Team 2020-11-02 14:58:13 UTC
Created attachment 166943 [details]
Screenshot of the original and exported document side by side in Calc
Comment 3 NISZ LibreOffice Team 2020-11-02 14:59:07 UTC
Created attachment 166944 [details]
Example file used as cell reference target
Comment 4 NISZ LibreOffice Team 2020-11-02 14:59:49 UTC
Created attachment 166945 [details]
Example file used as cell reference target
Comment 5 NISZ LibreOffice Team 2020-11-02 15:02:45 UTC
Created attachment 166946 [details]
Example file from Excel 2013 with the same cell references

This is opened correctly, but then it’s saved with the same error
Comment 6 Martin Srdoš 2020-11-16 18:03:48 UTC
Hello,

I don't know, if I can confirm my reproduction, because in the cell is not additioned of my user directory, but there is additioned path, where I save the XLSX file to. For example, I save the file from attachement 166941 (from your Description message) to "C:\users\[myName]\download\something\" and then, in the XLSX file, between "C:" and "\TEMP\" was added "\users\[myName]\download\something\". There is always added path, where I am saving the file to. Can you confirm that?
Comment 7 Commit Notification 2020-12-21 09:34:59 UTC
Attila Szűcs committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/107a20ee079ae852b3b33412f234aab2dc35168f

tdf#138824 tdf#137937 XLSX export: fix parent directory path

It will be available in 7.2.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 8 NISZ LibreOffice Team 2021-01-11 13:59:20 UTC
Verified in:

Version: 7.2.0.0.alpha0+ (x64)
Build ID: 96bafa464ebdbce3ef04bec9beae5e745bb37794
CPU threads: 4; OS: Windows 10.0 Build 17134; UI render: Skia/Raster; VCL: win
Locale: hu-HU (hu_HU); UI: hu-HU
Calc: threaded
Comment 9 Commit Notification 2021-01-18 09:40:04 UTC
Attila Szűcs committed a patch related to this issue.
It has been pushed to "libreoffice-7-1":

https://git.libreoffice.org/core/commit/ad3b51b5b383dc9c7302b6d1d2e7f6daad5d4d5b

tdf#138824 tdf#137937 XLSX export: fix parent directory path

It will be available in 7.1.1.

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.