diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-02-21 13:32:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-02-21 16:11:48 +0100 |
commit | 897970cd0b9709258b6b5b5fc05dba2e74a72b7c (patch) | |
tree | 45bd0da067e508cd233ca959b4d8bb7317260416 /framework/source/services | |
parent | 6b6f9fb71fa1bfcb438b89596e6f19529cfe1eba (diff) |
loplugin:refcounting in framework
Change-Id: I2d7d14fe0335689e4a338c70587bf33137ed1ddd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111279
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework/source/services')
-rw-r--r-- | framework/source/services/desktop.cxx | 17 | ||||
-rw-r--r-- | framework/source/services/frame.cxx | 27 | ||||
-rw-r--r-- | framework/source/services/modulemanager.cxx | 5 | ||||
-rw-r--r-- | framework/source/services/taskcreatorsrv.cxx | 15 |
4 files changed, 23 insertions, 41 deletions
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx index c9b5ed8d5b2b..73b29953873b 100644 --- a/framework/source/services/desktop.cxx +++ b/framework/source/services/desktop.cxx @@ -90,26 +90,23 @@ void Desktop::constructorInit() // We hold member as reference ... not as pointer too! // Attention: We share our frame container with this helper. Container is threadsafe himself ... So I think we can do that. // But look on dispose() for right order of deinitialization. - OFrames* pFramesHelper = new OFrames( this, &m_aChildTaskContainer ); - m_xFramesHelper.set( static_cast< ::cppu::OWeakObject* >(pFramesHelper), css::uno::UNO_QUERY ); + m_xFramesHelper = new OFrames( this, &m_aChildTaskContainer ); // Initialize a new dispatchhelper-object to handle dispatches. // We use these helper as slave for our interceptor helper ... not directly! // But he is event listener on THIS instance! - DispatchProvider* pDispatchHelper = new DispatchProvider( m_xContext, this ); - css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( static_cast< ::cppu::OWeakObject* >(pDispatchHelper), css::uno::UNO_QUERY ); + rtl::Reference<DispatchProvider> xDispatchProvider = new DispatchProvider( m_xContext, this ); // Initialize a new interception helper object to handle dispatches and implement an interceptor mechanism. // Set created dispatch provider as slowest slave of it. // Hold interception helper by reference only - not by pointer! // So it's easier to destroy it. - InterceptionHelper* pInterceptionHelper = new InterceptionHelper( this, xDispatchProvider ); - m_xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pInterceptionHelper), css::uno::UNO_QUERY ); + m_xDispatchHelper = new InterceptionHelper( this, xDispatchProvider ); OUString sUntitledPrefix = FwkResId(STR_UNTITLED_DOCUMENT) + " "; - ::comphelper::NumberedCollection* pNumbers = new ::comphelper::NumberedCollection (); - m_xTitleNumberGenerator.set(static_cast< ::cppu::OWeakObject* >(pNumbers), css::uno::UNO_QUERY_THROW); + rtl::Reference<::comphelper::NumberedCollection> pNumbers = new ::comphelper::NumberedCollection (); + m_xTitleNumberGenerator = pNumbers; pNumbers->setOwner ( static_cast< ::cppu::OWeakObject* >(this) ); pNumbers->setUntitledPrefix ( sUntitledPrefix ); @@ -488,9 +485,7 @@ css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL Desktop::getC // We use a helper class OComponentAccess to have access on all child components. // Create it on demand and return it as a reference. - OComponentAccess* pAccess = new OComponentAccess( this ); - css::uno::Reference< css::container::XEnumerationAccess > xAccess( static_cast< ::cppu::OWeakObject* >(pAccess), css::uno::UNO_QUERY ); - return xAccess; + return new OComponentAccess( this ); } /*-************************************************************************************************************ diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx index c6930eeed96b..9733b87a1041 100644 --- a/framework/source/services/frame.cxx +++ b/framework/source/services/frame.cxx @@ -481,30 +481,25 @@ void XFrameImpl::initListeners() // Initialize a new dispatchhelper-object to handle dispatches. // We use these helper as slave for our interceptor helper ... not directly! // But he is event listener on THIS instance! - DispatchProvider* pDispatchHelper = new DispatchProvider( m_xContext, this ); - css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( static_cast< ::cppu::OWeakObject* >(pDispatchHelper), css::uno::UNO_QUERY ); + rtl::Reference<DispatchProvider> xDispatchProvider = new DispatchProvider( m_xContext, this ); - DispatchInformationProvider* pInfoHelper = new DispatchInformationProvider(m_xContext, this); - m_xDispatchInfoHelper.set( static_cast< ::cppu::OWeakObject* >(pInfoHelper), css::uno::UNO_QUERY ); + m_xDispatchInfoHelper = new DispatchInformationProvider(m_xContext, this); // Initialize a new interception helper object to handle dispatches and implement an interceptor mechanism. // Set created dispatch provider as slowest slave of it. // Hold interception helper by reference only - not by pointer! // So it's easier to destroy it. - InterceptionHelper* pInterceptionHelper = new InterceptionHelper( this, xDispatchProvider ); - m_xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pInterceptionHelper), css::uno::UNO_QUERY ); + m_xDispatchHelper = new InterceptionHelper( this, xDispatchProvider ); // Initialize a new XFrames-helper-object to handle XIndexAccess and XElementAccess. // We hold member as reference ... not as pointer too! // Attention: We share our frame container with this helper. Container is threadsafe himself ... So I think we can do that. // But look on dispose() for right order of deinitialization. - OFrames* pFramesHelper = new OFrames( this, &m_aChildFrameContainer ); - m_xFramesHelper.set( static_cast< ::cppu::OWeakObject* >(pFramesHelper), css::uno::UNO_QUERY ); + m_xFramesHelper = new OFrames( this, &m_aChildFrameContainer ); // Initialize the drop target listener. // We hold member as reference ... not as pointer too! - OpenFileDropTargetListener* pDropListener = new OpenFileDropTargetListener( m_xContext, this ); - m_xDropTargetListener.set( static_cast< ::cppu::OWeakObject* >(pDropListener), css::uno::UNO_QUERY ); + m_xDropTargetListener = new OpenFileDropTargetListener( m_xContext, this ); // Safe impossible cases // We can't work without these helpers! @@ -736,9 +731,7 @@ void lcl_enableLayoutManager(const css::uno::Reference< css::frame::XLayoutManag xFrame->addFrameActionListener(xLayoutManager); - DockingAreaDefaultAcceptor* pAcceptor = new DockingAreaDefaultAcceptor(xFrame); - css::uno::Reference< css::ui::XDockingAreaAcceptor > xDockingAreaAcceptor( - static_cast< ::cppu::OWeakObject* >(pAcceptor), css::uno::UNO_QUERY_THROW); + rtl::Reference<DockingAreaDefaultAcceptor> xDockingAreaAcceptor = new DockingAreaDefaultAcceptor(xFrame); xLayoutManager->setDockingAreaAcceptor(xDockingAreaAcceptor); } @@ -831,8 +824,8 @@ void SAL_CALL XFrameImpl::initialize( const css::uno::Reference< css::awt::XWind m_pWindowCommandDispatch.reset(new WindowCommandDispatch(m_xContext, this)); // Initialize title functionality - TitleHelper* pTitleHelper = new TitleHelper( m_xContext ); - m_xTitleHelper.set(static_cast< ::cppu::OWeakObject* >(pTitleHelper), css::uno::UNO_QUERY_THROW); + rtl::Reference<TitleHelper> pTitleHelper = new TitleHelper( m_xContext ); + m_xTitleHelper = pTitleHelper; pTitleHelper->setOwner(xThis); } @@ -3347,8 +3340,8 @@ com_sun_star_comp_framework_Frame_get_implementation( css::uno::XComponentContext *context, css::uno::Sequence<css::uno::Any> const &) { - XFrameImpl *inst = new XFrameImpl(context); - css::uno::XInterface *acquired_inst = cppu::acquire(inst); + rtl::Reference<XFrameImpl> inst = new XFrameImpl(context); + css::uno::XInterface *acquired_inst = cppu::acquire(inst.get()); inst->initListeners(); diff --git a/framework/source/services/modulemanager.cxx b/framework/source/services/modulemanager.cxx index 5c066d034d74..ad98644bb0b7 100644 --- a/framework/source/services/modulemanager.cxx +++ b/framework/source/services/modulemanager.cxx @@ -308,10 +308,7 @@ css::uno::Reference< css::container::XEnumeration > SAL_CALL ModuleManager::crea } } - ::comphelper::OAnyEnumeration* pEnum = - new ::comphelper::OAnyEnumeration(comphelper::containerToSequence(lResult)); - css::uno::Reference< css::container::XEnumeration > xEnum(static_cast< css::container::XEnumeration* >(pEnum), css::uno::UNO_QUERY_THROW); - return xEnum; + return new ::comphelper::OAnyEnumeration(comphelper::containerToSequence(lResult)); } OUString ModuleManager::implts_identify(const css::uno::Reference< css::uno::XInterface >& xComponent) diff --git a/framework/source/services/taskcreatorsrv.cxx b/framework/source/services/taskcreatorsrv.cxx index 43dd64c7d573..b66a9dc3ac2d 100644 --- a/framework/source/services/taskcreatorsrv.cxx +++ b/framework/source/services/taskcreatorsrv.cxx @@ -313,12 +313,11 @@ void TaskCreatorService::implts_establishWindowStateListener( const css::uno::Re // We must create a special listener service and couple it with the new created task frame. // He will restore or save the window state of it ... // See used classes for further information too. - PersistentWindowState* pPersistentStateHandler = new PersistentWindowState( m_xContext ); - css::uno::Reference< css::lang::XInitialization > xInit(static_cast< ::cppu::OWeakObject* >(pPersistentStateHandler), css::uno::UNO_QUERY_THROW); + rtl::Reference<PersistentWindowState> pPersistentStateHandler = new PersistentWindowState( m_xContext ); css::uno::Sequence< css::uno::Any > lInitData(1); lInitData[0] <<= xFrame; - xInit->initialize(lInitData); + pPersistentStateHandler->initialize(lInitData); } void TaskCreatorService::implts_establishDocModifyListener( const css::uno::Reference< css::frame::XFrame2 >& xFrame ) @@ -326,22 +325,20 @@ void TaskCreatorService::implts_establishDocModifyListener( const css::uno::Refe // Special feature: It's allowed for frames using a top level window only! // We must create a special listener service and couple it with the new created task frame. // It will tag the window as modified if the underlying model was modified ... - TagWindowAsModified* pTag = new TagWindowAsModified(); - css::uno::Reference< css::lang::XInitialization > xInit(static_cast< ::cppu::OWeakObject* >(pTag), css::uno::UNO_QUERY_THROW); + rtl::Reference<TagWindowAsModified> pTag = new TagWindowAsModified(); css::uno::Sequence< css::uno::Any > lInitData(1); lInitData[0] <<= xFrame; - xInit->initialize(lInitData); + pTag->initialize(lInitData); } void TaskCreatorService::implts_establishTitleBarUpdate( const css::uno::Reference< css::frame::XFrame2 >& xFrame ) { - TitleBarUpdate* pHelper = new TitleBarUpdate (m_xContext); - css::uno::Reference< css::lang::XInitialization > xInit(static_cast< ::cppu::OWeakObject* >(pHelper), css::uno::UNO_QUERY_THROW); + rtl::Reference<TitleBarUpdate> pHelper = new TitleBarUpdate (m_xContext); css::uno::Sequence< css::uno::Any > lInitData(1); lInitData[0] <<= xFrame; - xInit->initialize(lInitData); + pHelper->initialize(lInitData); } OUString TaskCreatorService::impl_filterNames( const OUString& sName ) |