tdf#158031 Revert "Resolves: tdf#137445 use the DisableEditHyperlink state

... as of menu launch time"

This code is now obsolete from generic changes for bug 158031,
so revert 7.1 commit eb395e21a7b1f15de664c4b207dc9e130aa635cf.

It was a fine idea, but overly complex, dependent on invalidations,
and hard to re-implement everywhere it would be needed.

Instead, just also check before cursor for a field.

Change-Id: I08354e32fefb66ff051458097d3bd07946198a4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159014
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
index d1e9b74..3043ba0 100644
--- a/sd/source/ui/inc/DrawViewShell.hxx
+++ b/sd/source/ui/inc/DrawViewShell.hxx
@@ -456,11 +456,6 @@ private:
    VclPtr<TabControl>  maTabControl;
    EditMode            meEditMode;
    PageKind            mePageKind;
    // tdf#137445 at context menu popup time set if the EditHyperlink entry
    // should be disabled and use that state if queried about it if
    // EditHyperlink is dispatched from the menu. So ignoring where the mouse
    // currently happens to be when the menu was dismissed.
    std::optional<bool> moAtContextMenu_DisableEditHyperlink;
    bool                mbZoomOnPage;
    bool                mbIsRulerDrag;
    sal_uLong           mnLockCount;
diff --git a/sd/source/ui/view/drviews4.cxx b/sd/source/ui/view/drviews4.cxx
index 986aec2..4226f0e 100644
--- a/sd/source/ui/view/drviews4.cxx
+++ b/sd/source/ui/view/drviews4.cxx
@@ -804,10 +804,6 @@ void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin)
        {
            GetActiveWindow()->ReleaseMouse();

            // tdf#137445 at this context menu popup time get what the
            // DisableEditHyperlink would be for this position
            bool bShouldDisableEditHyperlink = ShouldDisableEditHyperlink();

            if(rCEvt.IsMouseEvent())
                GetViewFrame()->GetDispatcher()->ExecutePopup( aPopupId );
            else
@@ -839,16 +835,6 @@ void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin)
                //open context menu at that point
                GetViewFrame()->GetDispatcher()->ExecutePopup( aPopupId, GetActiveWindow(), &aMenuPos );
            }

            if (!bShouldDisableEditHyperlink)
            {
                SfxBindings& rBindings = GetViewFrame()->GetBindings();
                // tdf#137445 set what the menu popup state for this was
                moAtContextMenu_DisableEditHyperlink = bShouldDisableEditHyperlink;
                // ensure moAtContextMenu_DisableEditHyperlink will be cleared
                // in the case that EditHyperlink is not dispatched by the menu
                rBindings.Invalidate(SID_EDIT_HYPERLINK);
            }
        }
    }
    else
diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
index 3bace95..223493f 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -293,7 +293,8 @@ bool DrawViewShell::ShouldDisableEditHyperlink() const
    bool bDisableEditHyperlink = true;
    if( mpDrawView->IsTextEdit() )
    {
        if (URLFieldHelper::IsCursorAtURLField(mpDrawView->GetTextEditOutlinerView()))
        if (URLFieldHelper::IsCursorAtURLField(mpDrawView->GetTextEditOutlinerView(),
                                               /*AlsoCheckBeforeCursor=*/true))
            bDisableEditHyperlink = false;
    }
    else
@@ -1479,16 +1480,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )

    // Menuoption: Edit->Hyperlink
    // Disable, if there is no hyperlink
    bool bDisableEditHyperlink;
    if (!moAtContextMenu_DisableEditHyperlink.has_value())
        bDisableEditHyperlink = ShouldDisableEditHyperlink();
    else
    {
        // tdf#137445 if a popup menu was active, use the state as of when the popup was launched and then drop
        // moAtContextMenu_DisableEditHyperlink
        bDisableEditHyperlink = *moAtContextMenu_DisableEditHyperlink;
        moAtContextMenu_DisableEditHyperlink.reset();
    }
    bool bDisableEditHyperlink = ShouldDisableEditHyperlink();

    //highlight selected custom shape
    {