sw/source/uibase/docvw/edtdd.cxx |   18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

New commits:
commit 8da7c8f01beb71e233622b748867b725b7e8caee
Author:     Justin Luth <[email protected]>
AuthorDate: Mon Oct 27 21:59:05 2025 -0400
Commit:     Justin Luth <[email protected]>
CommitDate: Fri Nov 14 17:32:16 2025 +0100

    tdf#39015 sw: use the start/end of hyperlink to select, not move
    
    Instead of switching into drag-and-drop mode
    as soon as the mouse touches the outer edge of the hyperlink,
    allow a selection-drag to start
    as long as the mouse is over the first half-char/last half-char
    of the hyperlink.
    
    SAL_USE_VCLPLUGIN=gen gdb ./instdir/program/soffice.bin
    
    Change-Id: I6e021f327a0f54fcc543fbb7033ff3535953629d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193064
    Reviewed-by: Justin Luth <[email protected]>
    Tested-by: Jenkins

diff --git a/sw/source/uibase/docvw/edtdd.cxx b/sw/source/uibase/docvw/edtdd.cxx
index c400c7e15a80..2974f230fbc5 100644
--- a/sw/source/uibase/docvw/edtdd.cxx
+++ b/sw/source/uibase/docvw/edtdd.cxx
@@ -112,11 +112,23 @@ void SwEditWin::StartDrag( sal_Int8 /*nAction*/, const 
Point& rPosPixel )
         else
             rSh.UnlockPaint();
     }
-    else if (!bInSelect)// tdf#116384 only drag hyperlink if user's not 
currently setting the selection
+    else if (!bInSelect)// tdf#116384 only drag hyperlink if not currently 
setting the selection
     {
+        // Prefer starting a selection (rather than a drag) when at the 
start/end of a hyperlink.
+
+        // Use the cursor point, not the mouse point, to determine whether 
this is at the start/end.
+        Point aCursorPoint = rSh.GetCharRect().Center();
+
         SwContentAtPos aSwContentAtPos( IsAttrAtPos::InetAttr );
-        bStart = rSh.GetContentAtPos( aDocPos,
-                    aSwContentAtPos );
+        bStart = rSh.GetContentAtPos(aCursorPoint, aSwContentAtPos);
+
+        // If true (cursor is in hyperlink), perhaps the cursor is at the 
start of the hyperlink?
+        if (bStart)
+        {
+            aCursorPoint.AdjustX(-1);
+            aSwContentAtPos = SwContentAtPos(IsAttrAtPos::InetAttr);
+            bStart = rSh.GetContentAtPos(aCursorPoint, aSwContentAtPos);
+        }
     }
 
     if ( !bStart || m_bIsInDrag )

Reply via email to