20#include <com/sun/star/embed/VerbDescriptor.hpp>
21#include <com/sun/star/embed/VerbAttributes.hpp>
22#include <officecfg/Office/Common.hxx>
23#include <rtl/ustring.hxx>
25#include <osl/diagnose.h>
41#include <sfx2/sfxsids.hrc>
44#include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
59 std::map<sal_uInt16, std::unique_ptr<SfxPoolItem>>
68 std::unique_ptr<svtools::AsynchronLink>
pUpdater;
69 std::vector<std::unique_ptr<SfxSlot> >
aSlotArr;
71 css::uno::Sequence < css::embed::VerbDescriptor >
aVerbList;
107 pImpl->pViewSh = pViewSh;
116 pImpl->aObjectName = rName;
121 return pImpl->aObjectName;
126 return pImpl->pFrame ?
pImpl->pFrame->GetDispatcher() :
nullptr;
131 return pImpl->pViewSh;
137 return pImpl->pFrame;
138 if (
pImpl->pViewSh )
139 return &
pImpl->pViewSh->GetViewFrame();
148 auto const it =
pImpl->m_Items.find( nSlotId );
149 if (it !=
pImpl->m_Items.end())
150 return it->second.get();
160 DBG_ASSERT(
dynamic_cast< const SfxSetItem*
>( &rItem) ==
nullptr,
"SetItems aren't allowed here" );
162 "items with Which-Ids aren't allowed here" );
167 sal_uInt16 nWhich = rItem.
Which();
169 auto const it =
pImpl->m_Items.find(nWhich);
170 if (it !=
pImpl->m_Items.end())
173 it->second = std::unique_ptr<SfxPoolItem>(pItem);
181 sal_uInt16 nSlotId = nWhich;
185 pCache->
SetState( SfxItemState::DEFAULT, pItem,
true );
194 pImpl->m_Items.insert(std::make_pair(nWhich, std::unique_ptr<SfxPoolItem>(pItem)));
210 OSL_ENSURE( (
pUndoMgr ==
nullptr ) || ( pNewUndoMgr ==
nullptr ) || (
pUndoMgr == pNewUndoMgr ),
211 "SfxShell::SetUndoManager: exchanging one non-NULL manager with another non-NULL manager? Suspicious!" );
220 officecfg::Office::Common::Undo::Steps::get());
226 return pImpl->pRepeatTarget;
231 pImpl->pRepeatTarget = pTarget;
244 OSL_FAIL(
"wrong Invalidate method called!" );
275 SAL_INFO(
"sfx.control",
"W3: invalidating slot-id unknown in shell" );
283 uno::Reference < ui::dialogs::XExecutableDialog > xDialog = ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() );
286 catch (
const uno::Exception&)
297 const OUString sActiveDocName = pObjectShell->
GetTitle();
298 if( !
pImpl->aObjectName.startsWith(sActiveDocName) )
315 "SfxShell::DoActivate() " <<
this <<
" " <<
GetInterface()->GetClassName()
316 <<
" bMDI " << (bMDI ?
"MDI" :
""));
321 pImpl->pFrame = pFrame;
322 pImpl->bActive =
true;
338 "SfxShell::DoDeactivate()" <<
this <<
" " <<
GetInterface()->GetClassName()
339 <<
" bMDI " << (bMDI ?
"MDI" :
""));
343 if ( bMDI &&
pImpl->pFrame == pFrame )
346 pImpl->pFrame =
nullptr;
347 pImpl->bActive =
false;
356 return pImpl->bActive;
400 (*pFunc)(
this, aSet );
409 if (
nId == SID_UNDO ||
nId == SID_REDO)
412 if (pArgs && pArgs->
HasItem(SID_REPAIRPACKAGE))
430 if( !
pImpl->pExecuter )
431 pImpl->pExecuter.reset(
new svtools::AsynchronLink(
446 sal_uInt16 nSlot = rReq.
GetSlot();
447 const SfxSlot* pSlot =
nullptr;
448 if ( nSlot >= SID_VERB_START && nSlot <= SID_VERB_END )
456 (*pFunc)(
this, rReq );
472 bool bItemStateSet(
false);
475 const SfxSlot* pSlot =
nullptr;
476 if ( nSlotId >= SID_VERB_START && nSlotId <= SID_VERB_END )
487 if (
nullptr != pSlot )
492 (*pFunc)(
this, aSet );
494 bItemStateSet =
true;
497 if ( eState == SfxItemState::DEFAULT )
502 eState = SfxItemState::DONTCARE;
507 std::unique_ptr<SfxPoolItem> pRetItem;
508 if ( !bItemStateSet || eState <= SfxItemState::DISABLED )
514 else if ( bItemStateSet && eState == SfxItemState::DONTCARE )
522 if ( pStateSet && pStateSet->
Put( *pItem ) )
523 return &pStateSet->
Get( pItem->
Which() );
524 pRetItem.reset(pItem->
Clone());
526 auto pTemp = pRetItem.get();
542 DBG_ASSERT(pViewSh,
"Only call SetVerbs at the ViewShell!");
554 sal_uInt16
nId = SID_VERB_START +
n1;
560 for (sal_Int32
n=0;
n<aVerbs.getLength();
n++)
562 sal_uInt16 nSlotId = SID_VERB_START + nr++;
563 DBG_ASSERT(nSlotId <= SID_VERB_END,
"Too many Verbs!");
564 if (nSlotId > SID_VERB_END)
577 if (!
pImpl->aSlotArr.empty())
586 pImpl->aSlotArr.insert(
pImpl->aSlotArr.begin() +
static_cast<sal_uInt16
>(
n), std::unique_ptr<SfxSlot>(pNewSlot));
589 pImpl->aVerbList = aVerbs;
594 pBindings->
Invalidate(SID_OBJECT,
true,
true);
599 return pImpl->aVerbList;
610 const css::uno::Sequence < css::embed::VerbDescriptor > aList = pViewShell->
GetVerbs();
612 for (
const auto& rVerb : aList)
615 if (
bReadOnly && !(rVerb.VerbAttributes & embed::VerbAttributes::MS_VERBATTR_NEVERDIRTIES) )
619 if ( !(rVerb.VerbAttributes & embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU) )
622 if (
nId == SID_VERB_START + nVerb++)
624 pViewShell->
DoVerb(rVerb.VerbID);
637 css::uno::Sequence < css::embed::VerbDescriptor > rList =
pImpl->aVerbList;
640 sal_uInt16
nIndex =
nId - SID_VERB_START;
643 if (
nIndex < rList.getLength())
676 if ( !
pImpl->pUpdater )
686 pImpl->nDisableFlags = nFlags;
691 return pImpl->nDisableFlags;
705 pImpl->maContextChangeBroadcaster.Initialize(rsContextName);
710 pImpl->pViewSh = pView;
722 if (pViewFrame !=
nullptr)
733 return pImpl->maContextChangeBroadcaster.SetBroadcasterEnabled(
bIsEnabled);
static void setActiveSfxObjectName(SAL_UNUSED_PARAMETER const OUString &)
SAL_DLLPRIVATE SfxStateCache * GetStateCache(sal_uInt16 nId, std::size_t *pPos)
void InvalidateShell(const SfxShell &rSh, bool bDeep=false)
void Invalidate(sal_uInt16 nId)
void InvalidateAll(bool bWithMsg)
void Broadcast(const SfxHint &rHint)
SfxBindings * GetBindings() const
This method returns a pointer to the <SfxBinding> Instance on which the SfxDispatcher is currently bo...
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
const SfxSlot * GetSlot(sal_uInt16 nSlotId) const
const SfxInterface * GetGenoType() const
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
static bool IsWhich(sal_uInt16 nId)
static bool IsSlot(sal_uInt16 nId)
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void DisableItem(sal_uInt16 nWhich)
OUString GetTitle(sal_uInt16 nMaxLen=0) const
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
sal_uInt16 GetSlot() const
const SfxPoolItem * GetReturnValue() const
const SfxItemSet * GetArgs() const
void Done(bool bRemove=false)
The class SfxShell is the base class for all classes, which provide the functionality of the form <Sl...
void PutItem(const SfxPoolItem &rItem)
With this method, any objects of subclasses of <SfxPoolItem> can be made available.
virtual void ApplyItemSet(sal_uInt16 nId, const SfxItemSet &rSet)
const SfxPoolItem * GetSlotState(sal_uInt16 nSlotId, const SfxInterface *pIF=nullptr, SfxItemSet *pStateSet=nullptr)
This method returns the status of the slot with the specified slot ID on the specified interface.
SfxShell()
The constructor of the SfxShell class initializes only simple types, the corresponding SbxObject is o...
void SetUndoManager(SfxUndoManager *pNewUndoMgr)
Sets a <SfxUndoManager> for this <SfxShell> Instance.
SAL_DLLPRIVATE bool CanExecuteSlot_Impl(const SfxSlot &rSlot)
This method determines by calling the status function whether 'rSlot' can be executed currently.
SfxItemPool & GetPool() const
Each Subclass of SfxShell must reference a pool.
void SetRepeatTarget(SfxRepeatTarget *pTarget)
Sets the <SfxRepeatTarget> instance that is used in SID_REPEAT as RepeatTarget, when the current supp...
virtual void Activate(bool bMDI)
Virtual method that is called when enabling the SfxShell instance, in order to give the Subclasses th...
const OUString & GetName() const
Returns the name of the Shell object.
void BroadcastContextForActivation(const bool bIsActivated)
Broadcast a sidebar context change.
bool SetContextBroadcasterEnabled(const bool bIsEnabled)
Enabled or disable the context broadcaster.
virtual bool IsConditionalFastCall(const SfxRequest &rReq)
This method determines whether we need to execute without checking the disabled state of the slot.
virtual ~SfxShell() override
The connection to a possible corresponding SbxObject is dissolved.
void SetVerbs(const css::uno::Sequence< css::embed::VerbDescriptor > &aVerbs)
void SetContextName(const OUString &rsContextName)
Set the name of the sidebar context that is broadcast on calls to Activation().
virtual bool HasUIFeature(SfxShellFeature nFeature) const
SAL_DLLPRIVATE void DoActivate_Impl(SfxViewFrame *pFrame, bool bMDI)
This method controls the activation of SfxShell instance.
SfxUndoManager * pUndoMgr
static void HandleOpenXmlFilterSettings(SfxRequest &)
SfxViewFrame * GetFrame() const
This method returns a pointer to the <SfxViewFrame> to which this SfxShell instance is associated or ...
void SetDisableFlags(SfxDisableFlags nFlags)
virtual std::optional< SfxItemSet > CreateItemSet(sal_uInt16 nId)
SAL_DLLPRIVATE void Invalidate_Impl(SfxBindings &rBindings, sal_uInt16 nId)
void VerbExec(SfxRequest &)
const css::uno::Sequence< css::embed::VerbDescriptor > & GetVerbs() const
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
With this method any objects of <SfxPoolItemu> subclasses can be accessed.
SAL_DLLPRIVATE void DoDeactivate_Impl(SfxViewFrame const *pFrame, bool bMDI)
This method controls the deactivation of the SfxShell instance.
SAL_DLLPRIVATE const SfxSlot * GetVerbSlot_Impl(sal_uInt16 nId) const
virtual SfxInterface * GetInterface() const
With this virtual method, which is automatically overridden by each subclass with its own slots throu...
virtual void Invalidate(sal_uInt16 nId=0)
With this method can the slots of the subclasses be invalidated through the slot Id or alternatively ...
virtual void Deactivate(bool bMDI)
Virtual method that is called when disabling the SfxShell instance, to give the Subclasses the opport...
void SetViewShell_Impl(SfxViewShell *pView)
SfxDisableFlags GetDisableFlags() const
virtual SfxObjectShell * GetObjectShell()
std::unique_ptr< SfxShell_Impl > pImpl
static SfxInterface * GetStaticInterface()
SfxRepeatTarget * GetRepeatTarget() const
Returns a pointer to the <SfxRepeatTarget> instance that is used in SID_REPEAT as repeat target when ...
const SfxPoolItem * ExecuteSlot(SfxRequest &rReq, const SfxInterface *pIF=nullptr)
This method allows you to forward a <SfxRequest> to the specified base <SfxShell>.
virtual SfxUndoManager * GetUndoManager()
Each Subclass of SfxShell can have a <SfxUndoManager>.
static void EmptyExecStub(SfxShell *pShell, SfxRequest &)
SfxViewShell * GetViewShell() const
Returns the SfxViewShell in which they are located in the subshells.
static void VerbState(SfxItemSet &)
static void EmptyStateStub(SfxShell *pShell, SfxItemSet &)
SfxDispatcher * GetDispatcher() const
This method returns a pointer to the <SfxDispatcher>, when the SfxShell is currently <UI-active> or a...
void SetName(const OUString &rName)
Sets the name of the Shell object.
sal_uInt16 GetSlotId() const
const SfxSlot * pNextSlot
SfxStateFunc GetStateFnc() const
SfxExecFunc GetExecFnc() const
sal_uInt16 GetWhich(const SfxItemPool &rPool) const
void SetState(SfxItemState, const SfxPoolItem *, bool bMaybeDirty=false)
void SetCachedState(bool bAlways)
void SetMaxUndoActionCount(size_t nMaxUndoActionCount)
SfxDispatcher * GetDispatcher()
SfxFrame & GetFrame() const
virtual SfxObjectShell * GetObjectShell() override
One SfxViewShell more or less represents one edit window for a document, there can be multiple ones f...
SfxViewFrame & GetViewFrame() const
virtual ErrCode DoVerb(sal_Int32 nVerb)
virtual SfxObjectShell * GetObjectShell() override
#define DBG_ASSERT(sCon, aError)
virtual SfxBindings & GetBindings() override
void DeleteItemOnIdle(std::unique_ptr< SfxPoolItem > pItem)
#define SAL_INFO(area, stream)
#define SFX_STUB_PTR(aShellClass, aMethod)
static SFX_EXEC_STUB(SfxShell, VerbExec) static void SfxStubSfxShellVerbState(SfxShell *
static void DispatcherUpdate_Impl(void *, void *pArg)
static void ShellCall_Impl(void *pObj, void *pArg)
void(* SfxExecFunc)(SfxShell *, SfxRequest &rReq)
void(* SfxStateFunc)(SfxShell *, SfxItemSet &rSet)
::sfx2::sidebar::ContextChangeBroadcaster maContextChangeBroadcaster
std::vector< std::unique_ptr< SfxSlot > > aSlotArr
SfxDisableFlags nDisableFlags
css::uno::Sequence< css::embed::VerbDescriptor > aVerbList
std::map< sal_uInt16, std::unique_ptr< SfxPoolItem > > m_Items
virtual ~SfxShell_Impl() override
SfxRepeatTarget * pRepeatTarget
std::unique_ptr< svtools::AsynchronLink > pExecuter
std::unique_ptr< svtools::AsynchronLink > pUpdater