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 <jluth@mail.com>
Tested-by: Jenkins
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index adf75cc..2649e86 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 cc921f4..4f8d41e 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 ec527db..65da5aa 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 3393ca3..ba76f89 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 b49e7bf..fab59b5 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 db76755..dc10ba4 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