struct SfxShell_Impl: public SfxBroadcaster
{
OUString aObjectName; // Name of Sbx-Objects // Maps the Which() field to a pointer to a SfxPoolItem
std::map<sal_uInt16, std::unique_ptr<SfxPoolItem>>
m_Items; // Data exchange on Item level
SfxViewShell* pViewSh; // SfxViewShell if Shell is // ViewFrame/ViewShell/SubShell list
SfxViewFrame* pFrame; // Frame, if <UI-active>
SfxRepeatTarget* pRepeatTarget; // SbxObjectRef xParent; bool bActive;
SfxDisableFlags nDisableFlags;
std::unique_ptr<svtools::AsynchronLink> pExecuter;
std::unique_ptr<svtools::AsynchronLink> pUpdater;
std::vector<std::unique_ptr<SfxSlot> > aSlotArr;
SfxViewFrame* SfxShell::GetFrame() const
{ if ( pImpl->pFrame ) return pImpl->pFrame; if ( pImpl->pViewSh ) return &pImpl->pViewSh->GetViewFrame(); return nullptr;
}
const SfxPoolItem* SfxShell::GetItem
(
sal_uInt16 nSlotId // Slot-Id of the querying <SfxPoolItem>s
) const
{ autoconst it = pImpl->m_Items.find( nSlotId ); if (it != pImpl->m_Items.end()) return it->second.get(); return nullptr;
}
void SfxShell::PutItem
( const SfxPoolItem& rItem /* Instance, of which a copy is created,
which is stored in the SfxShell in a list. */
)
{
DBG_ASSERT( !rItem.isSetItem(), "SetItems aren't allowed here" );
DBG_ASSERT( SfxItemPool::IsSlot( rItem.Which() ), "items with Which-Ids aren't allowed here" );
// MSC made a mess here of WNT/W95, beware of changes
SfxPoolItem *pItem = rItem.Clone();
SfxPoolItemHint aItemHint( pItem );
sal_uInt16 nWhich = rItem.Which();
autoconst it = pImpl->m_Items.find(nWhich); if (it != pImpl->m_Items.end())
{ // Replace Item
it->second = std::unique_ptr<SfxPoolItem>(pItem);
void SfxShell::SetUndoManager( SfxUndoManager *pNewUndoMgr )
{
OSL_ENSURE( ( pUndoMgr == nullptr ) || ( pNewUndoMgr == nullptr ) || ( pUndoMgr == pNewUndoMgr ), "SfxShell::SetUndoManager: exchanging one non-NULL manager with another non-NULL manager? Suspicious!" ); // there's at least one client of our UndoManager - the DocumentUndoManager at the SfxBaseModel - which // caches the UndoManager, and registers itself as listener. If exchanging non-NULL UndoManagers is really // a supported scenario (/me thinks it is not), then we would need to notify all such clients instances.
// Only when it comes from a Frame // (not when for instance by popping BASIC-IDE from AppDisp) if ( bMDI && pImpl->pFrame == pFrame )
{ // deliver
pImpl->pFrame = nullptr;
pImpl->bActive = false;
}
void SfxShell::Activate
( bool/*bMDI*/ /* TRUE
the <SfxDispatcher>, on which the SfxShell is
located, is activated or the SfxShell instance
was pushed on an active SfxDispatcher.
(compare with SystemWindow::IsMDIActivate())
FALSE
the <SfxViewFrame>, on which SfxDispatcher
the SfxShell instance is located, was
activated. (for example by a closing dialog) */
)
{
BroadcastContextForActivation(true);
}
void SfxShell::Deactivate
( bool/*bMDI*/ /* TRUE
the <SfxDispatcher>, on which the SfxShell is
located, is inactivated or the SfxShell instance
was popped on an active SfxDispatcher.
(compare with SystemWindow::IsMDIActivate())
FALSE
the <SfxViewFrame>, on which SfxDispatcher
the SfxShell instance is located, was
deactivated. (for example by a dialog) */
)
{
BroadcastContextForActivation(false);
}
bool SfxShell::CanExecuteSlot_Impl( const SfxSlot &rSlot )
{ // Get Slot status
SfxItemPool &rPool = GetPool(); const sal_uInt16 nId = rSlot.GetWhich( rPool );
SfxItemSet aSet(rPool, nId, nId);
SfxStateFunc pFunc = rSlot.GetStateFnc();
(*pFunc)( this, aSet ); return aSet.GetItemState(nId) != SfxItemState::DISABLED;
}
SfxPoolItemHolder SfxShell::GetSlotState
(
sal_uInt16 nSlotId, // Slot-Id to the Slots in question const SfxInterface* pIF, // default = 0 means get virtually
SfxItemSet* pStateSet // SfxItemSet of the Slot-State method
)
{ // Get Slot on the given Interface if ( !pIF )
pIF = GetInterface();
SfxItemState eState(SfxItemState::DEFAULT); bool bItemStateSet(false);
SfxItemPool &rPool = GetPool();
const SfxSlot* pSlot = nullptr; if ( nSlotId >= SID_VERB_START && nSlotId <= SID_VERB_END )
pSlot = GetVerbSlot_Impl(nSlotId); if ( !pSlot )
pSlot = pIF->GetSlot(nSlotId); if ( pSlot ) // Map on Which-Id if possible
nSlotId = pSlot->GetWhich( rPool );
// Get Item and Item status const SfxPoolItem *pItem = nullptr;
SfxItemSet aSet( rPool, nSlotId, nSlotId ); // else pItem dies too soon if ( nullptr != pSlot )
{ // Call Status method
SfxStateFunc pFunc = pSlot->GetStateFnc(); if ( pFunc )
(*pFunc)( this, aSet );
eState = aSet.GetItemState( nSlotId, true, &pItem );
bItemStateSet = true;
// get default Item if possible if ( eState == SfxItemState::DEFAULT )
{ if ( SfxItemPool::IsWhich(nSlotId) )
pItem = &rPool.GetUserOrPoolDefaultItem(nSlotId); else
eState = SfxItemState::INVALID;
}
}
// Evaluate Item and item status and possibly maintain them in pStateSet if ( !bItemStateSet || eState <= SfxItemState::DISABLED )
{ if ( pStateSet )
pStateSet->DisableItem(nSlotId); return SfxPoolItemHolder();
}
if ( bItemStateSet && eState == SfxItemState::INVALID )
{ if ( pStateSet )
pStateSet->ClearItem(nSlotId); return SfxPoolItemHolder(rPool, DISABLED_POOL_ITEM);
}
DBG_ASSERT(pViewSh, "Only call SetVerbs at the ViewShell!"); if ( !pViewSh ) return;
// First make all Statecaches dirty, so that no-one no longer tries to use // the Slots
{
SfxBindings *pBindings =
pViewSh->GetViewFrame().GetDispatcher()->GetBindings();
sal_uInt16 nCount = pImpl->aSlotArr.size(); for (sal_uInt16 n1=0; n1<nCount ; n1++)
{
sal_uInt16 nId = SID_VERB_START + n1;
pBindings->Invalidate(nId, false, true);
}
}
sal_uInt16 nr=0; for (sal_Int32 n=0; n<aVerbs.getLength(); n++)
{
sal_uInt16 nSlotId = SID_VERB_START + nr++;
DBG_ASSERT(nSlotId <= SID_VERB_END, "Too many Verbs!"); if (nSlotId > SID_VERB_END) break;
SfxSlot* pNewSlot = new SfxSlot{
nSlotId, SfxGroupId::NONE, // Verb slots must be executed asynchronously, so that they can be // destroyed while executing.
SfxSlotMode::ASYNCHRON | SfxSlotMode::CONTAINER, 0, 0,
SFX_STUB_PTR(SfxShell, VerbExec), SFX_STUB_PTR(SfxShell, VerbState),
nullptr, // HACK(SFX_TYPE(SfxVoidItem)) ???
nullptr, nullptr, 0, SfxDisableFlags::NONE, u""_ustr};
// The status of SID_OBJECT is collected in the controller directly on // the Shell, it is thus enough to encourage a new status update
SfxBindings* pBindings = pViewSh->GetViewFrame().GetDispatcher()->GetBindings();
pBindings->Invalidate(SID_OBJECT, true, true);
}
void SfxShell::UIFeatureChanged()
{
SfxViewFrame *pFrame = GetFrame(); if ( pFrame && pFrame->IsVisible() )
{ // Also force an update, if dispatcher is already updated otherwise // something may get stuck in the bunkered tools. Asynchronous call to // prevent recursion. if ( !pImpl->pUpdater )
pImpl->pUpdater.reset( new svtools::AsynchronLink( LINK_NONMEMBER( this, DispatcherUpdate_Impl ) ) );
void SfxShell::BroadcastContextForActivation (constbool bIsActivated)
{ // Avoids activation and de-activation (can be seen on switching view) from causing // the sidebar to re-build. Such switching can happen as we change view to render // using LOK for example, and is un-necessary for Online. if (comphelper::LibreOfficeKit::isDialogPainting()) return;
SfxViewFrame* pViewFrame = GetFrame(); if (pViewFrame != nullptr)
{ if (bIsActivated)
pImpl->maContextChangeBroadcaster.Activate(pViewFrame->GetFrame().GetFrameInterface()); else
pImpl->maContextChangeBroadcaster.Deactivate(pViewFrame->GetFrame().GetFrameInterface());
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.