tdf#158031 Revert "tdf#140361 use the DisableEditHyperlink state
... as of menu launch time"
This code is now obsolete,
so revert 7.3 commit d9a5302ca8bef90914539c12adb6c81496c28504.
(This cleanly reverted with the relevant portions of
the following code-refactor commits also reverted.
commit 29489b33b435683021b72cb2bce27aba8cb7a430
commit 68e797402692c5c8abf1b2c4374e12a8d2707d07
)
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: Id570fc4e33611b217eae8b2a2a85aa58e23d9d1a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159013
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
diff --git a/sc/source/ui/inc/editsh.hxx b/sc/source/ui/inc/editsh.hxx
index 3777d19..99df24e 100644
--- a/sc/source/ui/inc/editsh.hxx
+++ b/sc/source/ui/inc/editsh.hxx
@@ -42,12 +42,6 @@ private:
bool bPastePossible;
bool bIsInsertMode;
// tdf#140361 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;
// These methods did return 'const SvxURLField*' before, but
// at least for GetFirstURLFieldFromCell this is not safe: The
// SvxFieldItem accessed there and held in the local temporary
@@ -86,12 +80,6 @@ public:
void GetUndoState(SfxItemSet &rSet);
OUString GetSelectionText( bool bWholeWord );
/// return true if "Edit Hyperlink" in context menu should be disabled
bool ShouldDisableEditHyperlink() const;
/// force "Edit Hyperlink" to true, with the expectation that SID_EDIT_HYPERLINK is
/// later Invalidated to reset it back to its natural value
void EnableEditHyperlink();
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index cc52a84..b537af6 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -430,12 +430,6 @@ public:
void ClearFormEditData();
ScFormEditData* GetFormEditData() { return mpFormEditData.get(); }
/// return true if "Edit Hyperlink" in context menu should be disabled
bool ShouldDisableEditHyperlink() const;
/// force "Edit Hyperlink" to true, with the expectation that SID_EDIT_HYPERLINK is
/// later Invalidated to reset it back to its natural value
void EnableEditHyperlink();
virtual tools::Rectangle getLOKVisibleArea() const override;
const ScDragData& GetDragData() const { return *m_pDragData; }
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 737418d..3393ca3 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -733,16 +733,6 @@ static void lcl_DisableAll( SfxItemSet& rSet ) // disable all slots
}
}
bool ScEditShell::ShouldDisableEditHyperlink() const
{
return !rViewData.HasEditView(rViewData.GetActivePart()) || !URLFieldHelper::IsCursorAtURLField(*pEditView);
}
void ScEditShell::EnableEditHyperlink()
{
moAtContextMenu_DisableEditHyperlink = false;
}
void ScEditShell::GetState( SfxItemSet& rSet )
{
// When deactivating the view, edit mode is stopped, but the EditShell is left active
@@ -841,18 +831,8 @@ void ScEditShell::GetState( SfxItemSet& rSet )
case SID_COPY_HYPERLINK_LOCATION:
case SID_REMOVE_HYPERLINK:
{
bool bDisableEditHyperlink;
if (!moAtContextMenu_DisableEditHyperlink.has_value())
bDisableEditHyperlink = ShouldDisableEditHyperlink();
else
{
// tdf#140361 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();
}
if (bDisableEditHyperlink)
if (!URLFieldHelper::IsCursorAtURLField(*pEditView,
/*AlsoCheckBeforeCursor=*/true))
rSet.DisableItem (nWhich);
}
break;
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 6456ded..58a7d8f 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -3471,21 +3471,7 @@ void ScGridWindow::Command( const CommandEvent& rCEvt )
if (bDone)
return;
// tdf#140361 at this context menu popup time get what the
// DisableEditHyperlink would be for this position
bool bShouldDisableEditHyperlink = mrViewData.GetViewShell()->ShouldDisableEditHyperlink();
SfxDispatcher::ExecutePopup( this, &aMenuPos );
if (!bShouldDisableEditHyperlink)
{
SfxBindings& rBindings = mrViewData.GetBindings();
// tdf#140361 set what the menu popup state for this was
mrViewData.GetViewShell()->EnableEditHyperlink();
// ensure moAtContextMenu_DisableEditHyperlink will be cleared
// in the case that EditHyperlink is not dispatched by the menu
rBindings.Invalidate(SID_EDIT_HYPERLINK);
}
}
void ScGridWindow::SelectForContextMenu( const Point& rPosPixel, SCCOL nCellX, SCROW nCellY )
diff --git a/sc/source/ui/view/tabvwshe.cxx b/sc/source/ui/view/tabvwshe.cxx
index 7089c17..0c809b3 100644
--- a/sc/source/ui/view/tabvwshe.cxx
+++ b/sc/source/ui/view/tabvwshe.cxx
@@ -116,26 +116,6 @@ OUString ScTabViewShell::GetSelectionText( bool bWholeWord, bool bOnlyASample )
return aStrSelection;
}
bool ScTabViewShell::ShouldDisableEditHyperlink() const
{
bool bRet = false;
if (pEditShell && pEditShell.get() == GetMySubShell())
{
bRet = pEditShell->ShouldDisableEditHyperlink();
}
return bRet;
}
void ScTabViewShell::EnableEditHyperlink()
{
if (pEditShell && pEditShell.get() == GetMySubShell())
{
pEditShell->EnableEditHyperlink();
}
}
void ScTabViewShell::InsertURL( const OUString& rName, const OUString& rURL, const OUString& rTarget,
sal_uInt16 nMode )
{
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
index 319afe1..d1e9b74 100644
--- a/sd/source/ui/inc/DrawViewShell.hxx
+++ b/sd/source/ui/inc/DrawViewShell.hxx
@@ -447,9 +447,6 @@ private:
/// return true if "Edit Hyperlink" in context menu should be disabled
bool ShouldDisableEditHyperlink() const;
/// force "Edit Hyperlink" to true, with the expectation that SID_EDIT_HYPERLINK is
/// later Invalidated to reset it back to its natural value
void EnableEditHyperlink();
private:
std::unique_ptr<DrawView> mpDrawView;
diff --git a/sd/source/ui/view/drviews4.cxx b/sd/source/ui/view/drviews4.cxx
index 8919a52..986aec2 100644
--- a/sd/source/ui/view/drviews4.cxx
+++ b/sd/source/ui/view/drviews4.cxx
@@ -844,7 +844,7 @@ void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin)
{
SfxBindings& rBindings = GetViewFrame()->GetBindings();
// tdf#137445 set what the menu popup state for this was
EnableEditHyperlink();
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);
@@ -857,11 +857,6 @@ void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin)
}
}
void DrawViewShell::EnableEditHyperlink()
{
moAtContextMenu_DisableEditHyperlink = false;
}
void DrawViewShell::ShowMousePosInfo(const ::tools::Rectangle& rRect,
::sd::Window const * pWin)
{