tdf#158031 editeng SID_HYPERLINK_GETLINK: use GetFieldAtSelection
This is just a clean-up commit to eliminate the pointless
check of a field under the mouse pointer.
It is up to the caller to make sure that the field is selected
before calling the GETLINK function.
GETLINK is primarily used to get the link from a field
for the insert/edit hyperlink dialog.
This function SHOULD NOT check before the cursor for the link,
or else it will mess up the insert hyperlink if the user
is inserting one field directly after another one.
So, my changes here are just following what already existed in sw.
Change-Id: Iaa7699d2e5f2fdf26996aede8b35bd4e18b21b98
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159021
Reviewed-by: Justin Luth <jluth@mail.com>
Tested-by: Jenkins
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx
index 863e97e..78bafa2 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -384,7 +384,8 @@ void ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
if ( pOutView )
{
bool bField = false;
const SvxFieldData* pField = pOutView->GetFieldAtCursor();
const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
const SvxFieldData* pField = pFieldItem ? pFieldItem->GetField() : nullptr;
if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
{
aHLinkItem.SetName( pURLField->GetRepresentation() );
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 7a9d40b..1844d79 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -88,7 +88,8 @@ void DrawViewShell::GetCtrlState(SfxItemSet &rSet)
if (pOLV)
{
const SvxFieldData* pField = pOLV->GetFieldAtCursor();
const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
const SvxFieldData* pField = pFieldItem ? pFieldItem->GetField() : nullptr;
if( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
{
aHLinkItem.SetName(pUrlField->GetRepresentation());