summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-05-30 10:24:31 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-05-30 16:56:41 +0200
commit33cacd2f3e06921e0d4d591b93febecc4afd4fbb (patch)
tree32e27df20e8bad587f2606f8a7f5c45ace8bd3e5 /sfx2
parenta7779c6dd428bb9997aaf3c43e6a4258223c751e (diff)
no need to allocate this separately
an empty vector is only 2 words Change-Id: Ie9b6b8e97a9781916250cdc1b6b29406fe27d6b8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116401 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/view/viewimp.hxx4
-rw-r--r--sfx2/source/view/viewsh.cxx54
2 files changed, 28 insertions, 30 deletions
diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx
index c36187fb554d..f4d3bb6b6f10 100644
--- a/sfx2/source/view/viewimp.hxx
+++ b/sfx2/source/view/viewimp.hxx
@@ -46,7 +46,7 @@ struct SfxViewShell_Impl
::rtl::Reference<SfxClipboardChangeListener> xClipboardListener;
std::shared_ptr<vcl::PrinterController> m_xPrinterController;
- mutable std::unique_ptr<std::vector<SfxInPlaceClient*>> mpIPClients;
+ mutable std::vector<SfxInPlaceClient*> maIPClients;
LibreOfficeKitCallback m_pLibreOfficeKitViewCallback;
void* m_pLibreOfficeKitViewData;
@@ -59,7 +59,7 @@ struct SfxViewShell_Impl
explicit SfxViewShell_Impl(SfxViewShellFlags const nFlags, ViewShellDocId nDocId);
~SfxViewShell_Impl();
- std::vector<SfxInPlaceClient*>* GetIPClients_Impl(bool bCreate = true) const;
+ std::vector<SfxInPlaceClient*>& GetIPClients_Impl();
};
#endif
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index ee5bcccec5be..177ed2c69e21 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -234,11 +234,9 @@ SfxViewShell_Impl::~SfxViewShell_Impl()
{
}
-std::vector< SfxInPlaceClient* > *SfxViewShell_Impl::GetIPClients_Impl( bool bCreate ) const
+std::vector< SfxInPlaceClient* >& SfxViewShell_Impl::GetIPClients_Impl()
{
- if (!mpIPClients && bCreate)
- mpIPClients.reset(new std::vector< SfxInPlaceClient* >);
- return mpIPClients.get();
+ return maIPClients;
}
SFX_IMPL_SUPERCLASS_INTERFACE(SfxViewShell,SfxShell)
@@ -358,16 +356,16 @@ static OUString impl_searchFormatTypeForApp(const css::uno::Reference< css::fram
void SfxViewShell::NewIPClient_Impl( SfxInPlaceClient *pIPClient )
{
- pImpl->GetIPClients_Impl()->push_back(pIPClient);
+ pImpl->GetIPClients_Impl().push_back(pIPClient);
}
void SfxViewShell::IPClientGone_Impl( SfxInPlaceClient const *pIPClient )
{
- std::vector< SfxInPlaceClient* > *pClients = pImpl->GetIPClients_Impl();
+ std::vector< SfxInPlaceClient* >& pClients = pImpl->GetIPClients_Impl();
- auto it = std::find(pClients->begin(), pClients->end(), pIPClient);
- if (it != pClients->end())
- pClients->erase( it );
+ auto it = std::find(pClients.begin(), pClients.end(), pIPClient);
+ if (it != pClients.end())
+ pClients.erase( it );
}
@@ -787,13 +785,13 @@ SfxInPlaceClient* SfxViewShell::FindIPClient
vcl::Window* pObjParentWin
) const
{
- std::vector< SfxInPlaceClient* > *pClients = pImpl->GetIPClients_Impl(false);
- if ( !pClients )
+ std::vector< SfxInPlaceClient* >& rClients = pImpl->GetIPClients_Impl();
+ if ( rClients.empty() )
return nullptr;
if( !pObjParentWin )
pObjParentWin = GetWindow();
- for (SfxInPlaceClient* pIPClient : *pClients)
+ for (SfxInPlaceClient* pIPClient : rClients)
{
if ( pIPClient->GetObject() == xObj && pIPClient->GetEditWin() == pObjParentWin )
return pIPClient;
@@ -812,11 +810,11 @@ SfxInPlaceClient* SfxViewShell::GetIPClient() const
SfxInPlaceClient* SfxViewShell::GetUIActiveIPClient_Impl() const
{
// this method is needed as long as SFX still manages the border space for ChildWindows (see SfxFrame::Resize)
- std::vector< SfxInPlaceClient* > *pClients = pImpl->GetIPClients_Impl(false);
- if ( !pClients )
+ std::vector< SfxInPlaceClient* >& rClients = pImpl->GetIPClients_Impl();
+ if ( rClients.empty() )
return nullptr;
- for (SfxInPlaceClient* pIPClient : *pClients)
+ for (SfxInPlaceClient* pIPClient : rClients)
{
if ( pIPClient->IsUIActive() )
return pIPClient;
@@ -827,13 +825,13 @@ SfxInPlaceClient* SfxViewShell::GetUIActiveIPClient_Impl() const
SfxInPlaceClient* SfxViewShell::GetUIActiveClient() const
{
- std::vector< SfxInPlaceClient* > *pClients = pImpl->GetIPClients_Impl(false);
- if ( !pClients )
+ std::vector< SfxInPlaceClient* >& rClients = pImpl->GetIPClients_Impl();
+ if ( rClients.empty() )
return nullptr;
const bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive();
- for (SfxInPlaceClient* pIPClient : *pClients)
+ for (SfxInPlaceClient* pIPClient : rClients)
{
if ( pIPClient->IsObjectUIActive() || ( bIsTiledRendering && pIPClient->IsObjectInPlaceActive() ) )
return pIPClient;
@@ -1627,11 +1625,11 @@ void SfxViewShell::ShowCursor( bool /*bOn*/ )
void SfxViewShell::ResetAllClients_Impl( SfxInPlaceClient const *pIP )
{
- std::vector< SfxInPlaceClient* > *pClients = pImpl->GetIPClients_Impl(false);
- if ( !pClients )
+ std::vector< SfxInPlaceClient* >& rClients = pImpl->GetIPClients_Impl();
+ if ( rClients.empty() )
return;
- for (SfxInPlaceClient* pIPClient : *pClients)
+ for (SfxInPlaceClient* pIPClient : rClients)
{
if( pIPClient != pIP )
pIPClient->ResetObject();
@@ -1641,13 +1639,13 @@ void SfxViewShell::ResetAllClients_Impl( SfxInPlaceClient const *pIP )
void SfxViewShell::DisconnectAllClients()
{
- std::vector< SfxInPlaceClient* > *pClients = pImpl->GetIPClients_Impl(false);
- if ( !pClients )
+ std::vector< SfxInPlaceClient* >& rClients = pImpl->GetIPClients_Impl();
+ if ( rClients.empty() )
return;
- for ( size_t n = 0; n < pClients->size(); )
+ for ( size_t n = 0; n < rClients.size(); )
// clients will remove themselves from the list
- delete pClients->at( n );
+ delete rClients.at( n );
}
@@ -1658,11 +1656,11 @@ void SfxViewShell::QueryObjAreaPixel( tools::Rectangle& ) const
void SfxViewShell::VisAreaChanged()
{
- std::vector< SfxInPlaceClient* > *pClients = pImpl->GetIPClients_Impl(false);
- if ( !pClients )
+ std::vector< SfxInPlaceClient* >& rClients = pImpl->GetIPClients_Impl();
+ if ( rClients.empty() )
return;
- for (SfxInPlaceClient* pIPClient : *pClients)
+ for (SfxInPlaceClient* pIPClient : rClients)
{
if ( pIPClient->IsObjectInPlaceActive() )
// client is active, notify client that the VisArea might have changed