editeng/source/outliner/outlvw.cxx   |    4 ++--
 include/editeng/outliner.hxx         |    2 +-
 sc/source/ui/drawfunc/drtxtob.cxx    |    4 +++-
 sc/source/ui/view/editsh.cxx         |    4 +++-
 sd/source/ui/view/drviews2.cxx       |    4 +++-
 sw/source/uibase/shells/drwtxtex.cxx |    4 +++-
 6 files changed, 15 insertions(+), 7 deletions(-)

New commits:
commit aaca48eb12357fa5cf23054fe77554bcfff74e95
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Mon Nov 6 13:41:05 2023 -0500
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Wed Nov 15 20:04:37 2023 +0100

    tdf#158031 editeng SID_COPY_HYPERLINK: use AlsoCheckBeforeCursor
    
    This patch depends on prior patches for this bug report.
    
    This fixes nothing being copied if the mouse was right-clicked
    over that second half of the hyperlink (since a "smart" positioning
    set the cursor after the field instead of before it).
    
    Change-Id: I6c933224cd8d36f48f4e1f0aafaa1f45555e46d3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159015
    Reviewed-by: Justin Luth <jl...@mail.com>
    Tested-by: Jenkins

diff --git a/editeng/source/outliner/outlvw.cxx 
b/editeng/source/outliner/outlvw.cxx
index adf75cc54afa..2649e865d6d7 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -1340,9 +1340,9 @@ const SvxFieldItem* 
OutlinerView::GetFieldUnderMousePointer() const
     return pEditView->GetFieldUnderMousePointer();
 }
 
-const SvxFieldItem* OutlinerView::GetFieldAtSelection() const
+const SvxFieldItem* OutlinerView::GetFieldAtSelection(bool 
bAlsoCheckBeforeCursor) const
 {
-    return pEditView->GetFieldAtSelection();
+    return pEditView->GetFieldAtSelection(bAlsoCheckBeforeCursor);
 }
 
 const SvxFieldData* OutlinerView::GetFieldAtCursor() const
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index cc921f4cd0af..4f8d41e21b9b 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -306,7 +306,7 @@ public:
 
     void                InsertField( const SvxFieldItem& rFld );
     const SvxFieldItem* GetFieldUnderMousePointer() const;
-    const SvxFieldItem* GetFieldAtSelection() const;
+    const SvxFieldItem* GetFieldAtSelection(bool bAlsoCheckBeforeCursor = 
false) const;
     /// Return the field at the current cursor position or nullptr if no field 
found
     const SvxFieldData* GetFieldAtCursor() const;
     /// Select the field at the current cursor position
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx 
b/sc/source/ui/drawfunc/drtxtob.cxx
index ec527db045ac..65da5aac262c 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -311,7 +311,9 @@ void ScDrawTextObjectBar::Execute( SfxRequest &rReq )
 
         case SID_COPY_HYPERLINK_LOCATION:
             {
-                const SvxFieldData* pField = pOutView->GetFieldAtCursor();
+                const SvxFieldItem* pFieldItem
+                    = 
pOutView->GetFieldAtSelection(/*AlsoCheckBeforeCursor=*/true);
+                const SvxFieldData* pField = pFieldItem ? 
pFieldItem->GetField() : nullptr;
                 if (const SvxURLField* pURLField = dynamic_cast<const 
SvxURLField*>(pField))
                 {
                     uno::Reference<datatransfer::clipboard::XClipboard> 
xClipboard
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 3393ca3ad090..ba76f89c4651 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -655,7 +655,9 @@ void ScEditShell::Execute( SfxRequest& rReq )
         break;
         case SID_COPY_HYPERLINK_LOCATION:
             {
-                const SvxFieldData* pField = pEditView->GetFieldAtCursor();
+                const SvxFieldItem* pFieldItem
+                    = 
pEditView->GetFieldAtSelection(/*AlsoCheckBeforeCursor=*/true);
+                const SvxFieldData* pField = pFieldItem ? 
pFieldItem->GetField() : nullptr;
                 if (const SvxURLField* pURLField = dynamic_cast<const 
SvxURLField*>(pField))
                 {
                     uno::Reference<datatransfer::clipboard::XClipboard> 
xClipboard
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index b49e7bfc497a..fab59b59f00a 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -2280,7 +2280,9 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
             OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView();
             if ( pOutView )
             {
-                const SvxFieldData* pField = pOutView->GetFieldAtCursor();
+                const SvxFieldItem* pFieldItem
+                    = 
pOutView->GetFieldAtSelection(/*AlsoCheckBeforeCursor=*/true);
+                const SvxFieldData* pField = pFieldItem ? 
pFieldItem->GetField() : nullptr;
                 if (const SvxURLField* pURLField = dynamic_cast<const 
SvxURLField*>(pField))
                 {
                     uno::Reference<datatransfer::clipboard::XClipboard> 
xClipboard
diff --git a/sw/source/uibase/shells/drwtxtex.cxx 
b/sw/source/uibase/shells/drwtxtex.cxx
index db76755474e4..dc10ba46f143 100644
--- a/sw/source/uibase/shells/drwtxtex.cxx
+++ b/sw/source/uibase/shells/drwtxtex.cxx
@@ -509,7 +509,9 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
 
         case SID_COPY_HYPERLINK_LOCATION:
         {
-            const SvxFieldData* pField = pOLV->GetFieldAtCursor();
+            const SvxFieldItem* pFieldItem
+                = pOLV->GetFieldAtSelection(/*AlsoCheckBeforeCursor=*/true);
+            const SvxFieldData* pField = pFieldItem ? pFieldItem->GetField() : 
nullptr;
             if (const SvxURLField* pURLField = dynamic_cast<const 
SvxURLField*>(pField))
             {
                 uno::Reference<datatransfer::clipboard::XClipboard> xClipboard

Reply via email to