Kaydet (Commit) faf9d81f authored tarafından Tamás Zolnai's avatar Tamás Zolnai Kaydeden (comit) Jan Holesovsky

sw lok: Accept / reject change is always enabled in the context menu

Use conditional fastcall for allow executing these two uno commands
even if there is no tracked changes at the cursor position instead of
enable the menu slots unconditionally.

See also:
b6011f07

Reviewed-on: https://gerrit.libreoffice.org/53148Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit 67919621)

Change-Id: Iaf8a8082961cd174c038fc021d2c41fb7cb97bff
Reviewed-on: https://gerrit.libreoffice.org/53181Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
Tested-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst 547dfbaa
......@@ -486,6 +486,14 @@ public:
*/
SAL_DLLPRIVATE bool CanExecuteSlot_Impl( const SfxSlot &rSlot );
/**
This method determines whether we need to execute without checking
the disabled state of the slot. This is used for dynamic conditions
while you can use SfxSlotMode::FASTCALL for a specific slotid in general.
*/
virtual bool IsConditionalFastCall( const SfxRequest &rReq );
/**
This method controls the activation of SfxShell instance. First, by calling
......
......@@ -312,22 +312,6 @@ bool SfxDispatcher::IsAppDispatcher() const
return !xImp->pFrame;
}
/// Decides if the request is FASTCALL or not, depending on arguments.
bool lcl_IsConditionalFastCall(SfxRequest &rReq)
{
sal_uInt16 nId = rReq.GetSlot();
bool bRet = false;
if (nId == SID_UNDO || nId == SID_REDO)
{
const SfxItemSet* pArgs = rReq.GetArgs();
if (pArgs && pArgs->HasItem(SID_REPAIRPACKAGE))
bRet = true;
}
return bRet;
}
/** Helper function to check whether a slot can be executed and
check the execution itself
*/
......@@ -336,7 +320,7 @@ void SfxDispatcher::Call_Impl(SfxShell& rShell, const SfxSlot &rSlot, SfxRequest
SFX_STACK(SfxDispatcher::Call_Impl);
// The slot may be called (meaning enabled)
if ( rSlot.IsMode(SfxSlotMode::FASTCALL) || rShell.CanExecuteSlot_Impl(rSlot) || lcl_IsConditionalFastCall(rReq))
if ( rSlot.IsMode(SfxSlotMode::FASTCALL) || rShell.CanExecuteSlot_Impl(rSlot) || rShell.IsConditionalFastCall(rReq))
{
if ( GetFrame() )
{
......
......@@ -400,6 +400,21 @@ bool SfxShell::CanExecuteSlot_Impl( const SfxSlot &rSlot )
return aSet.GetItemState(nId) != SfxItemState::DISABLED;
}
bool SfxShell::IsConditionalFastCall( const SfxRequest &rReq )
{
sal_uInt16 nId = rReq.GetSlot();
bool bRet = false;
if (nId == SID_UNDO || nId == SID_REDO)
{
const SfxItemSet* pArgs = rReq.GetArgs();
if (pArgs && pArgs->HasItem(SID_REPAIRPACKAGE))
bRet = true;
}
return bRet;
}
void ShellCall_Impl( void* pObj, void* pArg )
{
static_cast<SfxShell*>(pObj)->ExecuteSlot( *static_cast<SfxRequest*>(pArg) );
......
......@@ -503,6 +503,8 @@ public:
void ExecSearch(SfxRequest&);
void ExecViewOptions(SfxRequest &);
virtual bool IsConditionalFastCall( const SfxRequest &rReq ) override;
void StateViewOptions(SfxItemSet &);
void StateSearch(SfxItemSet &);
void GetState(SfxItemSet&);
......
......@@ -123,6 +123,7 @@
#include <dbconfig.hxx>
#include <dbmgr.hxx>
#include <reffld.hxx>
#include <comphelper/lok.hxx>
#include <PostItMgr.hxx>
......@@ -1249,6 +1250,20 @@ void SwView::Execute(SfxRequest &rReq)
rReq.Done();
}
bool SwView::IsConditionalFastCall( const SfxRequest &rReq )
{
sal_uInt16 nId = rReq.GetSlot();
bool bRet = false;
if (nId == FN_REDLINE_ACCEPT_DIRECT || nId == FN_REDLINE_REJECT_DIRECT)
{
if (comphelper::LibreOfficeKit::isActive())
bRet = true;
}
return bRet || SfxShell::IsConditionalFastCall(rReq);
}
/// invalidate page numbering field
void SwView::UpdatePageNums(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUString& rPgStr)
{
......
......@@ -322,7 +322,7 @@ void SwView::GetState(SfxItemSet &rSet)
}
// LibreOfficeKit wants to handle changes by index, so always allow here.
if (bDisable && !comphelper::LibreOfficeKit::isActive())
if (bDisable)
rSet.DisableItem(nWhich);
if (comphelper::LibreOfficeKit::isActive())
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment