Kaydet (Commit) 9129a4d6 authored tarafından Xisco Fauli's avatar Xisco Fauli Kaydeden (comit) Noel Grandin

tdf#89329: use unique_ptr for pImpl in shell

Change-Id: Ie925d6c47d718ef46349c11b7450b1f2c1a93c21
Reviewed-on: https://gerrit.libreoffice.org/25318Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst 3a077c0c
...@@ -134,7 +134,7 @@ class SFX2_DLLPUBLIC SfxShell: public SfxBroadcaster ...@@ -134,7 +134,7 @@ class SFX2_DLLPUBLIC SfxShell: public SfxBroadcaster
{ {
friend class SfxObjectItem; friend class SfxObjectItem;
SfxShell_Impl* pImp; std::unique_ptr< SfxShell_Impl > pImpl;
SfxItemPool* pPool; SfxItemPool* pPool;
::svl::IUndoManager* pUndoMgr; ::svl::IUndoManager* pUndoMgr;
......
...@@ -95,53 +95,50 @@ void SfxShell::EmptyStateStub(SfxShell *, SfxItemSet &) ...@@ -95,53 +95,50 @@ void SfxShell::EmptyStateStub(SfxShell *, SfxItemSet &)
} }
SfxShell::SfxShell() SfxShell::SfxShell()
: pImp(nullptr), : pImpl(new SfxShell_Impl),
pPool(nullptr), pPool(nullptr),
pUndoMgr(nullptr) pUndoMgr(nullptr)
{ {
pImp = new SfxShell_Impl;
} }
SfxShell::SfxShell( SfxViewShell *pViewSh ) SfxShell::SfxShell( SfxViewShell *pViewSh )
: pImp(nullptr), : pImpl(new SfxShell_Impl),
pPool(nullptr), pPool(nullptr),
pUndoMgr(nullptr) pUndoMgr(nullptr)
{ {
pImp = new SfxShell_Impl; pImpl->pViewSh = pViewSh;
pImp->pViewSh = pViewSh;
} }
SfxShell::~SfxShell() SfxShell::~SfxShell()
{ {
delete pImp;
} }
void SfxShell::SetName( const OUString &rName ) void SfxShell::SetName( const OUString &rName )
{ {
pImp->aObjectName = rName; pImpl->aObjectName = rName;
} }
const OUString& SfxShell::GetName() const const OUString& SfxShell::GetName() const
{ {
return pImp->aObjectName; return pImpl->aObjectName;
} }
SfxDispatcher* SfxShell::GetDispatcher() const SfxDispatcher* SfxShell::GetDispatcher() const
{ {
return pImp->pFrame ? pImp->pFrame->GetDispatcher() : nullptr; return pImpl->pFrame ? pImpl->pFrame->GetDispatcher() : nullptr;
} }
SfxViewShell* SfxShell::GetViewShell() const SfxViewShell* SfxShell::GetViewShell() const
{ {
return pImp->pViewSh; return pImpl->pViewSh;
} }
SfxViewFrame* SfxShell::GetFrame() const SfxViewFrame* SfxShell::GetFrame() const
{ {
if ( pImp->pFrame ) if ( pImpl->pFrame )
return pImp->pFrame; return pImpl->pFrame;
if ( pImp->pViewSh ) if ( pImpl->pViewSh )
return pImp->pViewSh->GetViewFrame(); return pImpl->pViewSh->GetViewFrame();
return nullptr; return nullptr;
} }
...@@ -150,8 +147,8 @@ const SfxPoolItem* SfxShell::GetItem ...@@ -150,8 +147,8 @@ const SfxPoolItem* SfxShell::GetItem
sal_uInt16 nSlotId // Slot-Id of the querying <SfxPoolItem>s sal_uInt16 nSlotId // Slot-Id of the querying <SfxPoolItem>s
) const ) const
{ {
auto const it = pImp->m_Items.find( nSlotId ); auto const it = pImpl->m_Items.find( nSlotId );
if (it != pImp->m_Items.end()) if (it != pImpl->m_Items.end())
return it->second.get(); return it->second.get();
return nullptr; return nullptr;
} }
...@@ -171,12 +168,12 @@ void SfxShell::PutItem ...@@ -171,12 +168,12 @@ void SfxShell::PutItem
SfxPoolItemHint aItemHint( pItem ); SfxPoolItemHint aItemHint( pItem );
sal_uInt16 nWhich = rItem.Which(); sal_uInt16 nWhich = rItem.Which();
auto const it = pImp->m_Items.find(nWhich); auto const it = pImpl->m_Items.find(nWhich);
if (it != pImp->m_Items.end()) if (it != pImpl->m_Items.end())
{ {
// Replace Item // Replace Item
pImp->m_Items.erase( it ); pImpl->m_Items.erase( it );
pImp->m_Items.insert(std::make_pair(nWhich, std::unique_ptr<SfxPoolItem>(pItem))); pImpl->m_Items.insert(std::make_pair(nWhich, std::unique_ptr<SfxPoolItem>(pItem)));
// if active, notify Bindings // if active, notify Bindings
SfxDispatcher *pDispat = GetDispatcher(); SfxDispatcher *pDispat = GetDispatcher();
...@@ -197,7 +194,7 @@ void SfxShell::PutItem ...@@ -197,7 +194,7 @@ void SfxShell::PutItem
else else
{ {
Broadcast( aItemHint ); Broadcast( aItemHint );
pImp->m_Items.insert(std::make_pair(nWhich, std::unique_ptr<SfxPoolItem>(pItem))); pImpl->m_Items.insert(std::make_pair(nWhich, std::unique_ptr<SfxPoolItem>(pItem)));
} }
} }
...@@ -229,12 +226,12 @@ void SfxShell::SetUndoManager( ::svl::IUndoManager *pNewUndoMgr ) ...@@ -229,12 +226,12 @@ void SfxShell::SetUndoManager( ::svl::IUndoManager *pNewUndoMgr )
SfxRepeatTarget* SfxShell::GetRepeatTarget() const SfxRepeatTarget* SfxShell::GetRepeatTarget() const
{ {
return pImp->pRepeatTarget; return pImpl->pRepeatTarget;
} }
void SfxShell::SetRepeatTarget( SfxRepeatTarget *pTarget ) void SfxShell::SetRepeatTarget( SfxRepeatTarget *pTarget )
{ {
pImp->pRepeatTarget = pTarget; pImpl->pRepeatTarget = pTarget;
} }
void SfxShell::Invalidate void SfxShell::Invalidate
...@@ -320,8 +317,8 @@ void SfxShell::DoActivate_Impl( SfxViewFrame *pFrame, bool bMDI ) ...@@ -320,8 +317,8 @@ void SfxShell::DoActivate_Impl( SfxViewFrame *pFrame, bool bMDI )
if ( bMDI ) if ( bMDI )
{ {
// Remember Frame, in which it was activated // Remember Frame, in which it was activated
pImp->pFrame = pFrame; pImpl->pFrame = pFrame;
pImp->bActive = true; pImpl->bActive = true;
} }
// Notify Subclass // Notify Subclass
...@@ -342,11 +339,11 @@ void SfxShell::DoDeactivate_Impl( SfxViewFrame *pFrame, bool bMDI ) ...@@ -342,11 +339,11 @@ void SfxShell::DoDeactivate_Impl( SfxViewFrame *pFrame, bool bMDI )
// Only when it comes from a Frame // Only when it comes from a Frame
// (not when for instance by poping BASIC-IDE from AppDisp) // (not when for instance by poping BASIC-IDE from AppDisp)
if ( bMDI && pImp->pFrame == pFrame ) if ( bMDI && pImpl->pFrame == pFrame )
{ {
// deliver // deliver
pImp->pFrame = nullptr; pImpl->pFrame = nullptr;
pImp->bActive = false; pImpl->bActive = false;
} }
// Notify Subclass // Notify Subclass
...@@ -355,7 +352,7 @@ void SfxShell::DoDeactivate_Impl( SfxViewFrame *pFrame, bool bMDI ) ...@@ -355,7 +352,7 @@ void SfxShell::DoDeactivate_Impl( SfxViewFrame *pFrame, bool bMDI )
bool SfxShell::IsActive() const bool SfxShell::IsActive() const
{ {
return pImp->bActive; return pImpl->bActive;
} }
void SfxShell::Activate void SfxShell::Activate
...@@ -414,10 +411,10 @@ void SfxShell::ExecuteSlot( SfxRequest& rReq, bool bAsync ) ...@@ -414,10 +411,10 @@ void SfxShell::ExecuteSlot( SfxRequest& rReq, bool bAsync )
ExecuteSlot( rReq ); ExecuteSlot( rReq );
else else
{ {
if( !pImp->pExecuter ) if( !pImpl->pExecuter )
pImp->pExecuter = new svtools::AsynchronLink( pImpl->pExecuter = new svtools::AsynchronLink(
Link<void*,void>( this, ShellCall_Impl ) ); Link<void*,void>( this, ShellCall_Impl ) );
pImp->pExecuter->Call( new SfxRequest( rReq ) ); pImpl->pExecuter->Call( new SfxRequest( rReq ) );
} }
} }
...@@ -534,7 +531,7 @@ void SfxShell::SetVerbs(const css::uno::Sequence < css::embed::VerbDescriptor >& ...@@ -534,7 +531,7 @@ void SfxShell::SetVerbs(const css::uno::Sequence < css::embed::VerbDescriptor >&
{ {
SfxBindings *pBindings = SfxBindings *pBindings =
pViewSh->GetViewFrame()->GetDispatcher()->GetBindings(); pViewSh->GetViewFrame()->GetDispatcher()->GetBindings();
sal_uInt16 nCount = pImp->aSlotArr.size(); sal_uInt16 nCount = pImpl->aSlotArr.size();
for (sal_uInt16 n1=0; n1<nCount ; n1++) for (sal_uInt16 n1=0; n1<nCount ; n1++)
{ {
sal_uInt16 nId = SID_VERB_START + n1; sal_uInt16 nId = SID_VERB_START + n1;
...@@ -567,19 +564,19 @@ void SfxShell::SetVerbs(const css::uno::Sequence < css::embed::VerbDescriptor >& ...@@ -567,19 +564,19 @@ void SfxShell::SetVerbs(const css::uno::Sequence < css::embed::VerbDescriptor >&
pNewSlot->pFirstArgDef = nullptr; pNewSlot->pFirstArgDef = nullptr;
pNewSlot->pUnoName = nullptr; pNewSlot->pUnoName = nullptr;
if (!pImp->aSlotArr.empty()) if (!pImpl->aSlotArr.empty())
{ {
SfxSlot& rSlot = *pImp->aSlotArr[0].get(); SfxSlot& rSlot = *pImpl->aSlotArr[0].get();
pNewSlot->pNextSlot = rSlot.pNextSlot; pNewSlot->pNextSlot = rSlot.pNextSlot;
rSlot.pNextSlot = pNewSlot; rSlot.pNextSlot = pNewSlot;
} }
else else
pNewSlot->pNextSlot = pNewSlot; pNewSlot->pNextSlot = pNewSlot;
pImp->aSlotArr.insert(pImp->aSlotArr.begin() + (sal_uInt16) n, std::unique_ptr<SfxSlot>(pNewSlot)); pImpl->aSlotArr.insert(pImpl->aSlotArr.begin() + (sal_uInt16) n, std::unique_ptr<SfxSlot>(pNewSlot));
} }
pImp->aVerbList = aVerbs; pImpl->aVerbList = aVerbs;
if (pViewSh) if (pViewSh)
{ {
...@@ -593,7 +590,7 @@ void SfxShell::SetVerbs(const css::uno::Sequence < css::embed::VerbDescriptor >& ...@@ -593,7 +590,7 @@ void SfxShell::SetVerbs(const css::uno::Sequence < css::embed::VerbDescriptor >&
const css::uno::Sequence < css::embed::VerbDescriptor >& SfxShell::GetVerbs() const const css::uno::Sequence < css::embed::VerbDescriptor >& SfxShell::GetVerbs() const
{ {
return pImp->aVerbList; return pImpl->aVerbList;
} }
void SfxShell::VerbExec(SfxRequest& rReq) void SfxShell::VerbExec(SfxRequest& rReq)
...@@ -630,26 +627,26 @@ void SfxShell::VerbState(SfxItemSet& ) ...@@ -630,26 +627,26 @@ void SfxShell::VerbState(SfxItemSet& )
const SfxSlot* SfxShell::GetVerbSlot_Impl(sal_uInt16 nId) const const SfxSlot* SfxShell::GetVerbSlot_Impl(sal_uInt16 nId) const
{ {
css::uno::Sequence < css::embed::VerbDescriptor > rList = pImp->aVerbList; css::uno::Sequence < css::embed::VerbDescriptor > rList = pImpl->aVerbList;
DBG_ASSERT(nId >= SID_VERB_START && nId <= SID_VERB_END,"Wrong VerbId!"); DBG_ASSERT(nId >= SID_VERB_START && nId <= SID_VERB_END,"Wrong VerbId!");
sal_uInt16 nIndex = nId - SID_VERB_START; sal_uInt16 nIndex = nId - SID_VERB_START;
DBG_ASSERT(nIndex < rList.getLength(),"Wrong VerbId!"); DBG_ASSERT(nIndex < rList.getLength(),"Wrong VerbId!");
if (nIndex < rList.getLength()) if (nIndex < rList.getLength())
return pImp->aSlotArr[nIndex].get(); return pImpl->aSlotArr[nIndex].get();
else else
return nullptr; return nullptr;
} }
void SfxShell::SetHelpId(sal_uIntPtr nId) void SfxShell::SetHelpId(sal_uIntPtr nId)
{ {
pImp->nHelpId = nId; pImpl->nHelpId = nId;
} }
sal_uIntPtr SfxShell::GetHelpId() const sal_uIntPtr SfxShell::GetHelpId() const
{ {
return pImp->nHelpId; return pImpl->nHelpId;
} }
SfxObjectShell* SfxShell::GetObjectShell() SfxObjectShell* SfxShell::GetObjectShell()
...@@ -679,22 +676,22 @@ void SfxShell::UIFeatureChanged() ...@@ -679,22 +676,22 @@ void SfxShell::UIFeatureChanged()
// Also force an update, if dispatcher is already updated otherwise // Also force an update, if dispatcher is already updated otherwise
// something my get stuck in the bunkered tools. Asynchronous call to // something my get stuck in the bunkered tools. Asynchronous call to
// prevent recursion. // prevent recursion.
if ( !pImp->pUpdater ) if ( !pImpl->pUpdater )
pImp->pUpdater = new svtools::AsynchronLink( Link<void*,void>( this, DispatcherUpdate_Impl ) ); pImpl->pUpdater = new svtools::AsynchronLink( Link<void*,void>( this, DispatcherUpdate_Impl ) );
// Multiple views allowed // Multiple views allowed
pImp->pUpdater->Call( pFrame->GetDispatcher(), true ); pImpl->pUpdater->Call( pFrame->GetDispatcher(), true );
} }
} }
void SfxShell::SetDisableFlags( sal_uIntPtr nFlags ) void SfxShell::SetDisableFlags( sal_uIntPtr nFlags )
{ {
pImp->nDisableFlags = nFlags; pImpl->nDisableFlags = nFlags;
} }
sal_uIntPtr SfxShell::GetDisableFlags() const sal_uIntPtr SfxShell::GetDisableFlags() const
{ {
return pImp->nDisableFlags; return pImpl->nDisableFlags;
} }
SfxItemSet* SfxShell::CreateItemSet( sal_uInt16 ) SfxItemSet* SfxShell::CreateItemSet( sal_uInt16 )
...@@ -708,12 +705,12 @@ void SfxShell::ApplyItemSet( sal_uInt16, const SfxItemSet& ) ...@@ -708,12 +705,12 @@ void SfxShell::ApplyItemSet( sal_uInt16, const SfxItemSet& )
void SfxShell::SetContextName (const ::rtl::OUString& rsContextName) void SfxShell::SetContextName (const ::rtl::OUString& rsContextName)
{ {
pImp->maContextChangeBroadcaster.Initialize(rsContextName); pImpl->maContextChangeBroadcaster.Initialize(rsContextName);
} }
void SfxShell::SetViewShell_Impl( SfxViewShell* pView ) void SfxShell::SetViewShell_Impl( SfxViewShell* pView )
{ {
pImp->pViewSh = pView; pImpl->pViewSh = pView;
} }
void SfxShell::BroadcastContextForActivation (const bool bIsActivated) void SfxShell::BroadcastContextForActivation (const bool bIsActivated)
...@@ -722,15 +719,15 @@ void SfxShell::BroadcastContextForActivation (const bool bIsActivated) ...@@ -722,15 +719,15 @@ void SfxShell::BroadcastContextForActivation (const bool bIsActivated)
if (pViewFrame != nullptr) if (pViewFrame != nullptr)
{ {
if (bIsActivated) if (bIsActivated)
pImp->maContextChangeBroadcaster.Activate(pViewFrame->GetFrame().GetFrameInterface()); pImpl->maContextChangeBroadcaster.Activate(pViewFrame->GetFrame().GetFrameInterface());
else else
pImp->maContextChangeBroadcaster.Deactivate(pViewFrame->GetFrame().GetFrameInterface()); pImpl->maContextChangeBroadcaster.Deactivate(pViewFrame->GetFrame().GetFrameInterface());
} }
} }
bool SfxShell::SetContextBroadcasterEnabled (const bool bIsEnabled) bool SfxShell::SetContextBroadcasterEnabled (const bool bIsEnabled)
{ {
return pImp->maContextChangeBroadcaster.SetBroadcasterEnabled(bIsEnabled); return pImpl->maContextChangeBroadcaster.SetBroadcasterEnabled(bIsEnabled);
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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