editeng/source/misc/urlfieldhelper.cxx | 3 ++- sc/source/ui/drawfunc/drtxtob.cxx | 5 +++-- sc/source/ui/view/editsh.cxx | 7 ++++--- sd/source/ui/view/drviews2.cxx | 8 +++----- sd/source/ui/view/drviewsf.cxx | 3 ++- sw/source/uibase/shells/drwtxtex.cxx | 4 +++- 6 files changed, 17 insertions(+), 13 deletions(-)
New commits: commit ac0b3ff84522a388e0d44b09bf681af13a8288b2 Author: Justin Luth <jl...@mail.com> AuthorDate: Mon Nov 6 16:22:26 2023 -0500 Commit: Justin Luth <jl...@mail.com> CommitDate: Wed Nov 15 20:05:07 2023 +0100 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 <jl...@mail.com> Tested-by: Jenkins diff --git a/editeng/source/misc/urlfieldhelper.cxx b/editeng/source/misc/urlfieldhelper.cxx index 1ed8647a15ae..d60d7be92934 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 1339e27bc4c1..863e97edc46b 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 ae77f5593045..90cde7c792f5 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 9246c2cd55ba..7a9d40bfc914 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; commit 0fc96d9b54e5a64c528bbf7fcdf9b71d74be8920 Author: Justin Luth <jl...@mail.com> AuthorDate: Mon Nov 6 14:23:16 2023 -0500 Commit: Justin Luth <jl...@mail.com> CommitDate: Wed Nov 15 20:04:52 2023 +0100 tdf#158031 editeng SID_OPEN_HYPERLINK: use AlsoCheckBeforeCursor This patch depends on prior patches for this bug report. This fixes nothing being opened 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). Note that for some reason, OPEN always seemed to work with the mouse, even though other hyperlink menu options using the same code failed to find the field! So this code change is mainly for consistency. However, I WAS able to make it always fail, by moving the mouse away once the popup menu arrived, and then using the KEYBOARD to "Open Hyperlink". In that case, it always failed (because the field was not selected, and not under the mouse). Change-Id: I8fcd0386de6cea8c6a937afb6f63061ed62d4cb1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159016 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx index 65da5aac262c..1339e27bc4c1 100644 --- a/sc/source/ui/drawfunc/drtxtob.cxx +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -292,8 +292,10 @@ void ScDrawTextObjectBar::Execute( SfxRequest &rReq ) break; case SID_OPEN_HYPERLINK: - if (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)) { ScGlobal::OpenURL(pURLField->GetURL(), pURLField->GetTargetFrame(), true); diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx index ba76f89c4651..c48b7772f7e3 100644 --- a/sc/source/ui/view/editsh.cxx +++ b/sc/source/ui/view/editsh.cxx @@ -639,9 +639,10 @@ void ScEditShell::Execute( SfxRequest& rReq ) break; case SID_OPEN_HYPERLINK: { - std::unique_ptr<const SvxFieldData> aSvxFieldDataPtr(GetURLField()); - const SvxURLField* pURLField(static_cast<const SvxURLField*>(aSvxFieldDataPtr.get())); - if ( pURLField ) + const SvxFieldItem* pFieldItem + = pEditView->GetFieldAtSelection(/*AlsoCheckBeforeCursor=*/true); + const SvxFieldData* pField = pFieldItem ? pFieldItem->GetField() : nullptr; + if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField)) ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame(), true ); return; } diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index fab59b59f00a..ae77f5593045 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -2243,7 +2243,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( auto pURLField = dynamic_cast< const SvxURLField *>( pField ) ) { SfxStringItem aUrl( SID_FILE_NAME, pURLField->GetURL() ); diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx index dc10ba46f143..9c4218567e22 100644 --- a/sw/source/uibase/shells/drwtxtex.cxx +++ b/sw/source/uibase/shells/drwtxtex.cxx @@ -494,7 +494,9 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) case SID_OPEN_HYPERLINK: { - 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)) { SfxStringItem aUrl(SID_FILE_NAME, pURLField->GetURL());