Bug 158031 - Writer in editeng: right click doesn't edit hyperlink in when mouse over last half / cursor after hyperlink
Summary: Writer in editeng: right click doesn't edit hyperlink in when mouse over last...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:24.2.0
Keywords:
Depends on:
Blocks: Hyperlink
  Show dependency treegraph
 
Reported: 2023-11-01 19:14 UTC by Justin L
Modified: 2023-12-27 11:32 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
108318_copyHyperlink.odt: web link in textbox (55.81 KB, application/vnd.oasis.opendocument.text)
2023-11-01 19:14 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2023-11-01 19:14:10 UTC
Created attachment 190589 [details]
108318_copyHyperlink.odt: web link in textbox

Linux only. (I could not reproduce with SAL_USE_VCLPLUGIN=gen.

In an editeng textbox, the context menu for a hyperlink only opens the edit dialog when the mouse is over the first half of the hyperlink (when the right-click moves the cursor to the front).

I could not reproduce the right-click problem with native hyperlinks in Writer/Calc/Draw/Impress. It only happens with these editeng ones in Writer and Calc. 

This has always been true. The ability to right-click and get edit hyperlink in the context menu only came in LO 6.4 via
commit 86cb2a1f98c0585d2121e6ae34fe62f072ef9a63
Author: Samuel Mehrbrodt on Fri Jul 12 10:37:41 2019 +0200
    tdf#112543 Add Edit/Remove hyperlink to text boxes/shapes in Writer

Steps to reproduce:
-open 108318_copyHyperlink.odt and double click in the textbox to edit contents.
-notice where the cursor is. (ENSURE the hyperlink is NOT selected.)
-right click on over "https://de.wikipedia" and edit hyperlink
  -notice the dialog pops up - close it. Cursor is before the hyperlink now.
-right click over "org/wiki/LibreOffice"
  -no dialog. Cursor has moved behind the hyperlink


In all the other apps/instances, all of these would be editing the same hyperlink.


----------------------------------------
As an aside: similarly, Insert - Hyperlink does not modify the existing link if the cursor is after the hyperlink. (Not linux specific in this case.) (It does edit if the cursor is before the link, or if the link is selected.)

I can reproduce the cursor-after-hyperlink problem in a Draw Textbox.
Comment 1 Justin L 2023-11-02 13:37:20 UTC
The reason the "Edit Hyperlink" is available is because there was a hyperlink underneath the mouse cursor.
(editeng/source/misc/urlfieldhelper.cxx URLFieldHelper::IsCursorAtURLField)

The right-click MOVES the cursor - either before the hyperlink (the first half) or after the hyperlink (the second half).

Caolan indicated that =gen tracks the mouse position at the point of the menu OPENING, while =gtk3 tracks the current mouse position as the menu is DISMISSED.

The problem is with the mouse moving away from the "target area" and pressing "Edit Hyperlink" in the menu. Now when it checks to verify that the command is allowed to run, the hyperlink is no longer underneath the mouse of course, because the mouse has moved into the menu!! Over the right half, the cursor position doesn't have field in it's "non-selection" position either, so GetState marked the slot as invalid and the command was simply not permitted to run.

Possibly the solution is just to make it a fastcall, so that it does not verify whether it is allowed to execute the slot. The fact that the slot was available in a menu should be enough...

SfxVoidItem EditHyperlink SID_EDIT_HYPERLINK
    FastCall = TRUE,

This works because all of the SID_EDIT_HYPERLINKs do a pOLV->SelectFieldAtCursor() which explicitly selects backwards if necessary.

SD doesn't have the mouse-moved-to-menu-position problem because of tdf#137445's https://gerrit.libreoffice.org/c/core/+/117653 which seems over-elaborate.

Alternatively, we could change the GetFieldAt...() to look for a field before the "non-selection" position.

-----
Relating to side note - that was a wild goose chase. If the cursor is AFTER the hyperlink, Insert - Hyperlink ALWAYS starts a new one - true for native URLs in all apps as well.
Comment 2 Justin L 2023-11-02 16:33:30 UTC
Interestingly "Open Hyperlink" doesn't have the mouse movement issue in GTK. Apparently it launches before GetState can disable it.
Comment 3 Commit Notification 2023-11-03 02:19:21 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

NFC related tdf#158031 editeng: flatten and simplify the code

It will be available in 24.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 4 Buovjaga 2023-11-13 17:29:04 UTC
(In reply to Justin L from comment #0)
> Steps to reproduce:
> -open 108318_copyHyperlink.odt and double click in the textbox to edit
> contents.
> -notice where the cursor is. (ENSURE the hyperlink is NOT selected.)
> -right click on over "https://de.wikipedia" and edit hyperlink
>   -notice the dialog pops up - close it. Cursor is before the hyperlink now.
> -right click over "org/wiki/LibreOffice"
>   -no dialog. Cursor has moved behind the hyperlink

Could not reproduce with gtk3 or kf5.

Arch Linux 64-bit, X11
Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: c8dfb25a77f53668e407a60a6f4ae9a826aa015c
CPU threads: 8; OS: Linux 6.6; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 13 November 2023
Comment 5 Justin L 2023-11-15 15:59:49 UTC
(In reply to Buovjaga from comment #4)
> (In reply to Justin L from comment #0)
> > Steps to reproduce:
> > -open 108318_copyHyperlink.odt and double click in the textbox to edit
> > contents.
> > -notice where the cursor is. (ENSURE the hyperlink is NOT selected.)
> > -right click on over "https://de.wikipedia" and edit hyperlink
> >   -notice the dialog pops up - close it.
> > -right click over "org/wiki/LibreOffice"
> >   -no dialog. Cursor has moved behind the hyperlink
> 
> Could not reproduce with gtk3 or kf5.
Note that there are two identical links in the document. The bug report is referring to the bottom one in the textbox.

Problems with the reproduction steps
- don't "Close" the dialog (because it leaves the field selected). "OK" the dialog instead.

The same problem applies to Open, Copy, and Remove, even in Windows/gen, if you:
-right-click on the second half of the hyperlink
-move the mouse away from the field and the menu (ex. over the footer area)
-use the keyboard to select one of the hyperlink options.
   -nothing happens.
Comment 6 Buovjaga 2023-11-15 16:52:37 UTC
(In reply to Justin L from comment #5)
> (In reply to Buovjaga from comment #4)
> > (In reply to Justin L from comment #0)
> > > Steps to reproduce:
> > > -open 108318_copyHyperlink.odt and double click in the textbox to edit
> > > contents.
> > > -notice where the cursor is. (ENSURE the hyperlink is NOT selected.)
> > > -right click on over "https://de.wikipedia" and edit hyperlink
> > >   -notice the dialog pops up - close it.
> > > -right click over "org/wiki/LibreOffice"
> > >   -no dialog. Cursor has moved behind the hyperlink
> > 
> > Could not reproduce with gtk3 or kf5.
> Note that there are two identical links in the document. The bug report is
> referring to the bottom one in the textbox.
> 
> Problems with the reproduction steps
> - don't "Close" the dialog (because it leaves the field selected). "OK" the
> dialog instead.
> 
> The same problem applies to Open, Copy, and Remove, even in Windows/gen, if
> you:
> -right-click on the second half of the hyperlink
> -move the mouse away from the field and the menu (ex. over the footer area)
> -use the keyboard to select one of the hyperlink options.
>    -nothing happens.

After clicking OK, Edit Hyperlink does not open the dialog with gtk3. Kf5 works, though.
Comment 7 Commit Notification 2023-11-15 19:04:16 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/213c6a9999e84f084978391c16276017078bf9ed

related tdf#158031 editeng: GetFieldAtSel...(+look before cursor)

It will be available in 24.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 Commit Notification 2023-11-15 19:04:19 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#158031 editeng SID_*_HYPERLINK: use AlsoCheckBeforeCursor

It will be available in 24.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 9 Commit Notification 2023-11-15 19:04:21 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/61d2d34b882b2b89c6702b04764058931ba70d60

tdf#158031 Revert "tdf#140361 use the DisableEditHyperlink state

It will be available in 24.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 10 Commit Notification 2023-11-15 19:05:25 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/023a2de2a8ef4bdcd9877e60f8739366de3a763c

tdf#158031 Revert "Resolves: tdf#137445 use the DisableEditHyperlink state

It will be available in 24.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 11 Commit Notification 2023-11-15 19:05:29 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#158031 editeng SID_COPY_HYPERLINK: use AlsoCheckBeforeCursor

It will be available in 24.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 12 Commit Notification 2023-11-15 19:05:32 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/0fc96d9b54e5a64c528bbf7fcdf9b71d74be8920

tdf#158031 editeng SID_OPEN_HYPERLINK: use AlsoCheckBeforeCursor

It will be available in 24.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 13 Commit Notification 2023-11-15 19:05:34 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#158031 editeng SID_REMOVE_HYPERLINK: use AlsoCheckBeforeCursor

It will be available in 24.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 14 Commit Notification 2023-11-15 19:06:37 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/33ec38c5333e0c71aa995292fbddc1a237979e32

tdf#158031 editeng SID_HYPERLINK_GETLINK: use GetFieldAtSelection

It will be available in 24.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 15 Commit Notification 2023-11-15 19:06:39 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/32d0efa9d934ec45f2863a285d250dfc0ab137e8

tdf#158031 editeng: rename GetFieldAtCursor

It will be available in 24.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 16 Justin L 2023-11-15 19:09:19 UTC
(In reply to Buovjaga from comment #6) 
> > The same problem applies to Open, Copy, and Remove, even in Windows/gen, if
> > you:
> > -right-click on the second half of the hyperlink
> > -move the mouse away from the field and the menu (ex. over the footer area)
> > -use the keyboard to select one of the hyperlink options.
> >    -nothing happens.
> 
> After clicking OK, Edit Hyperlink does not open the dialog with gtk3. Kf5
> works, though.
But it wouldn't have worked in Kf5 if you followed the Windows/gen breaking steps. It should now that it is fixed.
Comment 17 Stéphane Guillou (stragu) 2023-12-27 11:32:10 UTC
Reproduced the dialog not opening in:

Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Fix verified in:

Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 40617d867346956588ac023511f31210107217f4
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Thanks!