Bug 115192 - FILESAVE XLSX Hyperlinks do not work from shapes after saving the file as XLSX
Summary: FILESAVE XLSX Hyperlinks do not work from shapes after saving the file as XLSX
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.0.0.0.beta1
Hardware: All All
: medium normal
Assignee: Tünde Tóth
URL:
Whiteboard: target:6.3.0
Keywords: filter:xlsx
: 123644 (view as bug list)
Depends on:
Blocks: XLSX-Hyperlink Hyperlink-Calc
  Show dependency treegraph
 
Reported: 2018-01-24 11:24 UTC by Gabor Kelemen (allotropia)
Modified: 2019-04-01 15:51 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file from Excel 2013 (17.41 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2018-01-24 11:24 UTC, Gabor Kelemen (allotropia)
Details
Same file saved from LO 6 (17.42 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2018-01-24 11:25 UTC, Gabor Kelemen (allotropia)
Details
The original file and the one saved by LO side by side (298.40 KB, image/png)
2018-01-24 11:33 UTC, Gabor Kelemen (allotropia)
Details
Opening the original in LO (143.34 KB, image/png)
2018-01-24 11:33 UTC, Gabor Kelemen (allotropia)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen (allotropia) 2018-01-24 11:24:46 UTC
Created attachment 139324 [details]
Example file from Excel 2013

If we create a shape with Microsoft Excel 2010/2013/2016 and we establish a link from the shape to a workbook, the link stops working after exporting the file as XLSX in Calc. The main problem here is the path. The target we set in the spreadsheet (Munka2!A1) gets transformed to a full path when the file is saved as XLSX in LibreOffice Calc: (file:///E:/Link-to-Workbook-from-Shapes/Link-To-Workbook_LO-60.xlsx#Munka2!A1). This issue can only be reproduced with links from shapes, internal links from simple cells work just fine.

Steps to reproduce:
1. Create a new spreadsheet with Microsoft Excel 2010/2013/2016.
2. Click on Insert-→Shapes-→select a shape (a rectangle) and insert it to the workbook.
3. Fill the shape with a text and create a hyperlink from the text/shape to an another sheet’s A1 cell.
4. Save the file as XLSX.
5. Open the file with LibreOffice Calc and test the link. (It will work, if you press the ‘CTRL’ and then click)
6. “Save as” the file *.XLSX and then reload. The link stops working.

Actual results:
After we export the XLSX file the hyperlink stops working. The target “Munka2!A1” was fine, but, because of the file path (file:///E:/Link-to-Workbook-from-Shapes/Link-To-Workbook_LO-60.xlsx) which was added to the hyperlink, the link did not work.

Expected results:
The internal links from shapes should work even after saving the file as XLSX and reloading it, just like links from cells do.

Version: 6.0.0.0.beta1+
Build ID: 29228e83df009cf76ac819ed024527be1092f065
CPU threads: 4; OS: Windows 6.1; UI render: default; 
TinderBox: Win-x86@42, Branch:libreoffice-6-0, Time: 2017-12-04_23:15:34
Locale: hu-HU (hu_HU); Calc: group threaded
Comment 1 Gabor Kelemen (allotropia) 2018-01-24 11:25:15 UTC
Created attachment 139325 [details]
Same file saved from LO 6
Comment 2 Gabor Kelemen (allotropia) 2018-01-24 11:33:28 UTC
Created attachment 139326 [details]
The original file and the one saved by LO side by side
Comment 3 Gabor Kelemen (allotropia) 2018-01-24 11:33:55 UTC
Created attachment 139327 [details]
Opening the original in LO
Comment 4 Bartosz 2018-02-08 21:40:03 UTC
Confirmed with LibreOffice 6.0.0.3 Ubuntu 16.04
Comment 5 Bartosz 2018-02-08 21:48:12 UTC
The root cause of problem is in file:
   drawing1.xml.rels

After saving by LO, TargetMode="External" is added:

<Relationships
    xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
    <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="#Munka2!A1" TargetMode="External"/>
</Relationships>

after deleting TargetMode="External", everything works as espected:

<Relationships
    xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
    <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="#Munka2!A1"/>
</Relationships>
Comment 6 Bartosz 2018-02-08 22:35:50 UTC
The code responsible for always evaluation to external is in:
 oox/source/export/shapes.cxx:803

                OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(),
                        oox::getRelationship(Relationship::HYPERLINK),
                        mpURLTransformer->getTransformedString(sURL),
                        mpURLTransformer->isExternalURL(sURL));

isExternalURL(sURL) is always returns true, and this function needs to be modified.
Comment 7 Xisco Faulí 2018-05-29 09:14:18 UTC
Dear Bartosz,
This bug has been in ASSIGNED status for more than 3 months without any
activity. Resetting it to NEW.
Please assigned it back to yourself if you're still working on this.
Comment 8 Gabor Kelemen (allotropia) 2019-02-26 14:51:17 UTC
*** Bug 123644 has been marked as a duplicate of this bug. ***
Comment 9 Commit Notification 2019-04-01 15:51:48 UTC
tundet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/186a9aae2d9612a9d6408e4871bc49963d4f9bb6%5E%21

tdf#115192 XLSX export: fix hyperlink inserted to shape

It will be available in 6.3.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.