tdf#158031 editeng SID_REMOVE_HYPERLINK: use AlsoCheckBeforeCursor
This patch depends on prior patches for this bug report.
This is mostly just a clean-up patch to make it function like the others.
It was a lot like EDIT_HYPERLINK - because it selects the hyperlink first,
so it didn't need any fixing up.
However, there was one instance where KEYBOARD selection of
Remove Hyperlink in Draw could have been cancelled/slot-invalidated
if the mouse had been moved away from the field.
Change-Id: Id1b911f2548b8e2751ae34a2158ee4984dfc9a59
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159018
Reviewed-by: Justin Luth <jluth@mail.com>
Tested-by: Jenkins
diff --git a/editeng/source/misc/urlfieldhelper.cxx b/editeng/source/misc/urlfieldhelper.cxx
index 1ed8647..d60d7be 100644
--- a/editeng/source/misc/urlfieldhelper.cxx
+++ b/editeng/source/misc/urlfieldhelper.cxx
@@ -16,7 +16,8 @@
void URLFieldHelper::RemoveURLField(EditView& pEditView)
{
pEditView.SelectFieldAtCursor();
const SvxFieldData* pField = pEditView.GetFieldAtCursor();
const SvxFieldItem* pFieldItem = pEditView.GetFieldAtSelection();
const SvxFieldData* pField = pFieldItem ? pFieldItem->GetField() : nullptr;
if (auto pUrlField = dynamic_cast<const SvxURLField*>(pField))
{
ESelection aSel = pEditView.GetSelection();
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx
index 1339e27..863e97e 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -327,7 +327,6 @@ void ScDrawTextObjectBar::Execute( SfxRequest &rReq )
case SID_REMOVE_HYPERLINK:
{
// Ensure the field is selected first
URLFieldHelper::RemoveURLField(pOutView->GetEditView());
}
break;
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index ae77f55..90cde7c 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -1204,13 +1204,9 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
{
if (mpDrawView->IsTextEdit())
{
// First make sure the field is selected
OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView();
if (pOutView)
{
pOutView->SelectFieldAtCursor();
URLFieldHelper::RemoveURLField(pOutView->GetEditView());
}
}
}
Cancel();
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 9246c2c..7a9d40b 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -539,7 +539,8 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
case SID_REMOVE_HYPERLINK:
{
if (!URLFieldHelper::IsCursorAtURLField(mpDrawView->GetTextEditOutlinerView()))
if (!URLFieldHelper::IsCursorAtURLField(mpDrawView->GetTextEditOutlinerView(),
/*AlsoCheckBeforeCursor=*/true))
rSet.DisableItem(nWhich);
}
break;