Bug 88918 - Edit→Hyperlink… is greyed out when an object with a hyperlink is selected in Draw
Summary: Edit→Hyperlink… is greyed out when an object with a hyperlink is selected in ...
Status: ASSIGNED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Draw (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Aditya Sahu
URL:
Whiteboard:
Keywords: difficultyBeginner, easyHack, skillCpp
Depends on:
Blocks: Hyperlink
  Show dependency treegraph
 
Reported: 2015-01-30 00:23 UTC by Reuben Thomas
Modified: 2024-11-20 16:42 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Several object types that have a hyperlink (19.90 KB, application/vnd.oasis.opendocument.graphics)
2024-11-05 21:24 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Reuben Thomas 2015-01-30 00:23:50 UTC
To reproduce:

1. Open a new Draw document.
2. Draw a filled rectangle using the rectangle tool.
3. Select the rectangle.
4. Insert→Hyperlink and add a link (I used a web link)
5. Select the rectangle.
6. Open the Edit menu, observe that "Hyperlink…" is greyed out.
7. Click the top toolbar's Hyperlink tool, observe that it lets you edit the hyperlink.
Comment 1 A (Andy) 2015-01-31 10:20:51 UTC
Reproducible with LO 4.4.0.3, Win 8.1.
Comment 2 QA Administrators 2016-02-21 08:35:09 UTC Comment hidden (obsolete)
Comment 3 Reuben Thomas 2016-02-21 21:34:49 UTC
I can reproduce in 5.0.5 on Ubuntu 14.04.

The "Hyperlink" toolbar button does not appear in the toolbar (any more?) so I right-clicked on the toolbar to get it.
Comment 4 QA Administrators 2017-03-06 15:09:18 UTC Comment hidden (obsolete)
Comment 5 Reuben Thomas 2017-03-06 19:30:26 UTC
I was able to reproduce this bug in LibreOffice 5.3.0.3 on GNU/Linux.

Some details appear to have changed, so I note the revised procedure to reproduce below:

1. Open a new Draw document.
2. Draw a filled rectangle using the rectangle tool.
3. Select the rectangle.
4. Insert→Link and add a link (I used a web link)
5. Select the rectangle.
6. Open the Edit menu, observe that "Link…" is greyed out.
7. Right click the toolbar's handle, Link, observe that it lets you edit the hyperlink. (You can also edit the link with Insert→Link, which is rather unintuitive.)

As last year, there is no "Link" or "Hyperlink" button on the toolbar any more, but I can find one by right-clicking on the toolbar handle.

The online documentation appears to be out of date: https://help.libreoffice.org/5.3/Draw/Insert still mentions "Insert→Hyperlink", while the actual Insert menu item is "Link".
Comment 6 QA Administrators 2018-08-22 02:36:22 UTC Comment hidden (obsolete)
Comment 7 Reuben Thomas 2018-08-22 09:51:16 UTC
I was able to reproduce in 6.0.6 on Ubuntu 18.04. I followed the instructions in Comment 5, except that "Link" is now once again called "Hyperlink".
Comment 8 QA Administrators 2019-09-02 09:25:08 UTC Comment hidden (obsolete)
Comment 9 Reuben Thomas 2019-09-02 22:33:14 UTC
Confirmed in 6.3.0.4 running in Ubuntu 18.04 (installed from snap), following the instructions as in Comment 7.
Comment 10 QA Administrators 2021-09-02 03:53:12 UTC Comment hidden (obsolete)
Comment 11 Reuben Thomas 2021-09-02 10:41:03 UTC
Reproduced in 6.4.7.2 in Ubuntu 20.04, with following updated procedure (same as for 6.3):

1. Open a new Draw document.
2. Draw a filled rectangle using the rectangle tool.
3. Select the rectangle.
4. Insert→Hyperlink and add a link (I used a web link)
5. Select the rectangle.
6. Open the Edit menu, observe that "Hyperlink" is greyed out.
7. Right click the toolbar's handle, Hyperlink, observe that it lets you edit the hyperlink. (You can also edit the link with Insert→Hyperlink, which is rather unintuitive.)
Comment 12 Stéphane Guillou (stragu) 2023-07-04 20:57:50 UTC
Same in OOo 3.3, so inherited.

Still present in a recent 24.2 master build.

Hossein, maybe an easyHack ?
Comment 13 Hossein 2023-07-31 14:33:24 UTC
(In reply to Stéphane Guillou (stragu) from comment #12)
> Hossein, maybe an easyHack ?
Yes.
The code pointers for this EasyHack is as follows:

Start from the menu, which is "Edit > Hyperlink". In fact, it is "~Hyperlink", as it has underline below H:

$ git grep -w ~Hyperlink

The search leads to this file:
officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu

Opening this xml file, one may find the command uno:EditHyperlink which is invoked by selection that menu option. Then, you can search for this command inside the code.

The opened dialog for editing the hyperlink as the text "Hyperlink Type" inside it. Searching for this text leads to the exact ui:

$ git grep "Hyperlink Type"
cui/uiconfig/ui/hyperlinkinternetpage.ui

Searching for EditHyperlink (instead of uno:EditHyperlink) in C++ files, leads to a few files:

$ git grep -l EditHyperlink *.cxx
sc/source/ui/view/editsh.cxx
sc/source/ui/view/gridwin.cxx
sc/source/ui/view/tabvwshe.cxx
sd/source/ui/view/drviews4.cxx
sd/source/ui/view/drviews7.cxx

Only the last 2 are related to Draw (sd). In the last file, the below method determines when the EditHyperlink menu item should be disabled:

sd/source/ui/view/drviews7.cxx:284
bool DrawViewShell::ShouldDisableEditHyperlink() const
{
...
}

The EasyHacker should change this method, so that it can also handle a shape with a hyperlink attached to it. The patch should modify the only "else" block and handle such a situation.
Comment 14 Stéphane Guillou (stragu) 2024-03-15 03:37:01 UTC
nicholaskhoi2, are you still hoping to work on this? If not, please un-assign yourself.
Comment 15 Aditya Sahu 2024-11-05 19:45:13 UTC
Since there has been no activity on this since 5 months, I'm assigning it under my name
Comment 16 Regina Henschel 2024-11-05 21:24:47 UTC
Created attachment 197424 [details]
Several object types that have a hyperlink

The document has several types of shapes, each one with hyperlink. To select an object do not click on the object but drag a selection rectangle that surrounds the object.

After the object is selected, you can call the hyperlink dialog with Ctrl+K.
Comment 17 Regina Henschel 2024-11-06 09:12:47 UTC
The task is not clear.
Is it intended, that 'Edit->Hyperlink' is always enabled, when the toolbar command 'Hyperlink' is enabled?
Or is it intended, that 'Edit->Hyperlink' is only enabled if the object has already a hyperlink?
Or is it intended, that 'Edit->Hyperlink' is enabled if the object is actually able to have a hyperlink?

The toolbar command 'Hyperlink' is enabled, even if the selected object is not able to have a hyperlink, e.g. a 3D-scene or a group are not able to have a hyperlink.
Comment 18 Aditya Sahu 2024-11-06 16:28:41 UTC
I feel like it's the third one. 

> Or is it intended, that 'Edit->Hyperlink' is enabled if the object is actually able to have a hyperlink?

Reason: User can press Ctrl+K after selecting objects that is actually able to have a hyperlink. Therefore, in the menu bar they should be allowed to click on it to open the hyperlink dialog upon selecting object that can have a hyperlink.

I am, of course, a beginner here so I will wait for your opinions on this before putting in the coding effort.
Comment 19 Regina Henschel 2024-11-06 17:55:03 UTC
I'm not sure about it. The place where ShouldDisableEditHyperlink() is called has the comment
1487      // Menuoption: Edit->Hyperlink
1488      // Disable, if there is no hyperlink
And the shortcut shown in the menu is not Ctrl+K but Alt+K and latter means uno:EditHyperlink.
That would fit to option 2. If you go with option 2, then you get the needed info by the getHyperlink() method from the selected object. That is easy to do.

The option 3 has the problem, that the ODF file format standard allows objects, for that a hyperlink is not implemented in LibreOffice or implemented so, that the hyperlink is written to file but does not work in LibreOffice.
In file format it is the <draw:a> element: https://docs.oasis-open.org/office/OpenDocument/v1.3/os/part3-schema/OpenDocument-v1.3-os-part3-schema.html#__RefHeading__1415880_253892949
You would get the info which kind of object is selected by the GetObjIdentifier() method of the selected object. That method returns a value of the enumeration enum class SdrObjKind. You find an idea about its use in https://opengrok.libreoffice.org/xref/core/sw/source/uibase/shells/drwbassh.cxx

Option 1 would mean to enable it always, at least I have not seen an example, where the 'Insert Hyperlink' command from the toolbar is not enabled. It is even enabled for 3D-scene and group, and for them a hyperlink does not work in LibreOffice.

I will add UX. They might decide, whether option 2 would be fine.
Comment 20 Heiko Tietze 2024-11-18 10:31:23 UTC
(In reply to Regina Henschel from comment #17)
> Is it intended, that 'Edit->Hyperlink' is always enabled, when the toolbar
> command 'Hyperlink' is enabled?

We have two commands, .uno:HyperlinkDialog for "Insert Hyperlink (Ctrl+K)" and .uno:EditHyperlink for "Edit Hyperlink".

The question whether this needs two commands is frequently discussed; and a consequence could be to edit a non-existent hyperlink and have Edit > Hyperlink always enabled. But for now we split the two, and edit should be possible only if the object has a link assigned.

In case of multi-selection we should either always block insert/edit or only if the hyperlinks are different.
Comment 21 Regina Henschel 2024-11-19 20:08:06 UTC
(In reply to Heiko Tietze from comment #20)

> In case of multi-selection we should either always block insert/edit or only
> if the hyperlinks are different.

Currently the method ShouldDisableEditHyperlink is designed to disable editHyperlink if more than one object is selected.
https://git.libreoffice.org/core/+/refs/heads/master/sd/source/ui/view/drviews7.cxx#294
Comment 22 Aditya Sahu 2024-11-19 21:24:02 UTC
(In reply to Regina Henschel from comment #21)
> (In reply to Heiko Tietze from comment #20)
> 
> > In case of multi-selection we should either always block insert/edit or only
> > if the hyperlinks are different.
> 
> Currently the method ShouldDisableEditHyperlink is designed to disable
> editHyperlink if more than one object is selected.

Should I work on it on this ticket or would it be a separate task?
Comment 23 Heiko Tietze 2024-11-20 08:56:20 UTC
(In reply to Aditya Sahu from comment #22)
> (In reply to Regina Henschel from comment #21)
> > (In reply to Heiko Tietze from comment #20)
> > 
> > > In case of multi-selection we should either always block insert/edit or only
> > > if the hyperlinks are different.
> > 
> > Currently the method ShouldDisableEditHyperlink is designed to disable
> > editHyperlink if more than one object is selected.
> 
> Should I work on it on this ticket or would it be a separate task?

As you like, you could also keep the status quo.
Comment 24 Aditya Sahu 2024-11-20 16:42:31 UTC
I've given it a crack, here:
https://gerrit.libreoffice.org/c/core/+/176095

Let me know if I'm headed in the right direction