Bug 143736 - FILEOPEN ODT: Shape with hyperlink is lost when reopen file
Summary: FILEOPEN ODT: Shape with hyperlink is lost when reopen file
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.3.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Samuel Mehrbrodt (allotropia)
URL:
Whiteboard: target:7.3.0
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-04 23:34 UTC by Regina Henschel
Modified: 2021-09-14 08:41 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Several kind of shapes (11.26 KB, application/vnd.oasis.opendocument.text)
2021-08-04 23:34 UTC, Regina Henschel
Details
Further failing shapes (15.64 KB, application/vnd.oasis.opendocument.text)
2021-08-22 13:10 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Regina Henschel 2021-08-04 23:34:32 UTC
Created attachment 174092 [details]
Several kind of shapes

Open attached file. It contains some shapes of several kind (not all possible kinds).
For each of the shapes do:
    Click on shape so that it is selected.
    Press Ctrl+K to open Hyperlink dialog.
    Enter a valid web address, e.g. http://libreoffice.org. Click OK.
Save the document.
Verify for each shape, that the hyperlink works.
close the file.

Reopen the file.
severe error: only custom shape and text box are loaded. The other shapes are missing.
Further error: The text box has lost the hyperlink.

Adding a hyperlink to a shape is a new feature. In case it is intended, that it works only for custom shapes, then it should not be possible to add a hyperlink to another kind of shape. Of cause it would be better to improve the implementation, that setting an hyperlink works for all kind of shapes.

The shapes are written to file as content of an <draw:a> element. That syntax looks good to me and the validator finds no errors. So it is likely an import error.
Comment 1 Regina Henschel 2021-08-05 10:54:29 UTC
@Samuel: This is about your current work.
Comment 2 raal 2021-08-07 19:20:06 UTC
Confirm. Version: 7.3.0.0.alpha0+ / LibreOffice Community
Build ID: 36efb384a66b6dd645e0ae80fd7df68370a9dc8b
CPU threads: 4; OS: Linux 5.11; UI render: default; VCL: gtk3
Locale: cs-CZ (cs_CZ.UTF-8); UI: en-US
Calc: threaded
Comment 3 Commit Notification 2021-08-18 09:43:38 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7bd26828933a682b7bca86e4fb26f4cf99fa33e0

tdf#143736 Fix loading hyperlink from various shapes

It will be available in 7.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.
Comment 4 Commit Notification 2021-08-19 05:28:48 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "master":

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

tdf#143736 Fix loading hyperlink from textbox

It will be available in 7.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.
Comment 5 Commit Notification 2021-08-19 06:43:28 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/69f4abe1248f9919f242920b463c4d5f4965211f

tdf#143736 Add test

It will be available in 7.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.
Comment 6 Regina Henschel 2021-08-22 13:07:40 UTC
I thought you would automatically test and fix the other object types as well. This was obviously not the case. So I will attach a collection of other shape types. Do the same as in the original description.

I think, at least form-control shape (ODF <draw:control>) should be fixed so, that the user cannot add a hyperlink via Hyperlink-dialog.
The same might be a solution for connector shape (ODF <draw:connector>), measure line (ODF <draw:measure>, and 3D-scene (ODF <dr3d:scene>).

For the other shapes a hyperlink should be possible.

The shape type <draw:regular-polygon> is not implemented in LibreOffice.
The shape type <draw:page-thumbnail> is not implemented for Writer in LibreOffice.

For sub-types of <draw:frame>:
<draw:image> OK in odt and docx
<draw:object> tested with MathML. OK in odt, no link in docx
              tested with Chart. OK in odt, no link in docx
<draw:text-box> OK in odt and docx, both with Draw text-box and Writer frame
<draw:plugin> Cannot test it, LibreOffice 7.3 crashes (Add a sound from the Gallery and try to move or resize the shape.)
<draw:object-ole> Not tested
<draw:floating-frame> Not tested

All tests are done with Version: 7.3.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: bae2fbfd341b2cb5e5053c7977176f68b5d658dd
CPU threads: 8; OS: Windows 10.0 Build 19043; UI render: Skia/Raster; VCL: win
Locale: de-DE (en_US); UI: en-US
Calc: threaded
Comment 7 Regina Henschel 2021-08-22 13:10:55 UTC
Created attachment 174474 [details]
Further failing shapes

Add a hyperlink to the shape and save as odt. Reopen the saved document. The shapes are gone.
Comment 8 Regina Henschel 2021-08-22 21:11:58 UTC
Tested with daily build:
<draw:frame> sub-type <draw:plugin>.
odt: The media shape it there and plays the sound file. The hyperlink is lost.
docx: Word cannot open the saved file, neither with nor without hyperlink.

This shape type is another candidate for not allowing the Hyperlink-dialog.
Comment 9 Commit Notification 2021-08-23 09:59:13 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/75cd2b0fa71c73ae815b80d8e42328024ea63555

tdf#143736 Load hyperlink from more shapes

It will be available in 7.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.
Comment 10 Samuel Mehrbrodt (allotropia) 2021-08-23 10:03:34 UTC
(In reply to Regina Henschel from comment #6)
> I thought you would automatically test and fix the other object types as
> well. This was obviously not the case. So I will attach a collection of
> other shape types. Do the same as in the original description.
> 
> I think, at least form-control shape (ODF <draw:control>) should be fixed
> so, that the user cannot add a hyperlink via Hyperlink-dialog.
> The same might be a solution for connector shape (ODF <draw:connector>),
> measure line (ODF <draw:measure>, and 3D-scene (ODF <dr3d:scene>).
> 
> For the other shapes a hyperlink should be possible.
> 
> The shape type <draw:regular-polygon> is not implemented in LibreOffice.
> The shape type <draw:page-thumbnail> is not implemented for Writer in
> LibreOffice.
> 
> For sub-types of <draw:frame>:
> <draw:image> OK in odt and docx
> <draw:object> tested with MathML. OK in odt, no link in docx
>               tested with Chart. OK in odt, no link in docx
> <draw:text-box> OK in odt and docx, both with Draw text-box and Writer frame
> <draw:plugin> Cannot test it, LibreOffice 7.3 crashes (Add a sound from the
> Gallery and try to move or resize the shape.)
> <draw:object-ole> Not tested
> <draw:floating-frame> Not tested
> 
> All tests are done with Version: 7.3.0.0.alpha0+ (x64) / LibreOffice
> Community
> Build ID: bae2fbfd341b2cb5e5053c7977176f68b5d658dd
> CPU threads: 8; OS: Windows 10.0 Build 19043; UI render: Skia/Raster; VCL:
> win
> Locale: de-DE (en_US); UI: en-US
> Calc: threaded

Ok, I now added the import for all allowed child elements according to https://docs.oasis-open.org/office/OpenDocument/v1.3/cs02/part3-schema/OpenDocument-v1.3-cs02-part3-schema.html#__RefHeading__1415880_253892949
(excluding <draw:regular-polygon> which is not implemented as you already noticed).

For the shape types in LO, I am unsure which should be allowed to contain hyperlinks. I disabled adding hyperlinks by default, and only allowed it for a subset. See the changes in sw/source/uibase/shells/drwbassh.cxx in my patch: https://git.libreoffice.org/core/+/75cd2b0fa71c73ae815b80d8e42328024ea63555%5E%21

This list can easily be extended. Feel free to do so (or tell me if you think other shapes should be added as well).