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 | |
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')
37 files changed, 128 insertions, 201 deletions
diff --git a/framework/inc/uielement/toolbarmerger.hxx b/framework/inc/uielement/toolbarmerger.hxx index b62e3be6972c..bd07bb17e7e4 100644 --- a/framework/inc/uielement/toolbarmerger.hxx +++ b/framework/inc/uielement/toolbarmerger.hxx @@ -115,7 +115,7 @@ class ToolBarMerger ToolBox::ImplToolItems::size_type nPos, const OUString& rMergeCommandParameter ); - static ::cppu::OWeakObject* CreateController( + static rtl::Reference<::cppu::OWeakObject> CreateController( const css::uno::Reference< css::uno::XComponentContext > & rxContext, const css::uno::Reference< css::frame::XFrame > & xFrame, ToolBox* pToolbar, diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx index 96c0056d35c0..821b1137259c 100644 --- a/framework/source/accelerators/acceleratorconfiguration.cxx +++ b/framework/source/accelerators/acceleratorconfiguration.cxx @@ -384,14 +384,12 @@ void XMLBasedAcceleratorConfiguration::impl_ts_load(const css::uno::Reference< c // Note: Use special filter object between parser and reader // to get filtered xml with right namespaces ... // Use further a temp cache for reading! - AcceleratorConfigurationReader* pReader = new AcceleratorConfigurationReader(m_aReadCache); - css::uno::Reference< css::xml::sax::XDocumentHandler > xReader (static_cast< ::cppu::OWeakObject* >(pReader), css::uno::UNO_QUERY_THROW); - SaxNamespaceFilter* pFilter = new SaxNamespaceFilter(xReader); - css::uno::Reference< css::xml::sax::XDocumentHandler > xFilter (static_cast< ::cppu::OWeakObject* >(pFilter), css::uno::UNO_QUERY_THROW); + rtl::Reference<AcceleratorConfigurationReader> pReader = new AcceleratorConfigurationReader(m_aReadCache); + rtl::Reference<SaxNamespaceFilter> pFilter = new SaxNamespaceFilter(pReader); // connect parser, filter and stream css::uno::Reference< css::xml::sax::XParser > xParser = css::xml::sax::Parser::create(xContext); - xParser->setDocumentHandler(xFilter); + xParser->setDocumentHandler(pFilter); css::xml::sax::InputSource aSource; aSource.aInputStream = xStream; diff --git a/framework/source/accelerators/documentacceleratorconfiguration.cxx b/framework/source/accelerators/documentacceleratorconfiguration.cxx index df638d2b2ab3..31f76fc92bf2 100644 --- a/framework/source/accelerators/documentacceleratorconfiguration.cxx +++ b/framework/source/accelerators/documentacceleratorconfiguration.cxx @@ -185,8 +185,8 @@ com_sun_star_comp_framework_DocumentAcceleratorConfiguration_get_implementation( css::uno::XComponentContext *context, css::uno::Sequence<css::uno::Any> const &arguments) { - DocumentAcceleratorConfiguration *inst = new DocumentAcceleratorConfiguration(context, arguments); - css::uno::XInterface *acquired_inst = cppu::acquire(inst); + rtl::Reference<DocumentAcceleratorConfiguration> inst = new DocumentAcceleratorConfiguration(context, arguments); + css::uno::XInterface *acquired_inst = cppu::acquire(inst.get()); inst->fillCache(); diff --git a/framework/source/accelerators/moduleacceleratorconfiguration.cxx b/framework/source/accelerators/moduleacceleratorconfiguration.cxx index 71f33bc5b0ab..c8ce39fec495 100644 --- a/framework/source/accelerators/moduleacceleratorconfiguration.cxx +++ b/framework/source/accelerators/moduleacceleratorconfiguration.cxx @@ -146,8 +146,8 @@ com_sun_star_comp_framework_ModuleAcceleratorConfiguration_get_implementation( css::uno::XComponentContext *context, css::uno::Sequence<css::uno::Any> const &arguments) { - ModuleAcceleratorConfiguration *inst = new ModuleAcceleratorConfiguration(context, arguments); - css::uno::XInterface *acquired_inst = cppu::acquire(inst); + rtl::Reference<ModuleAcceleratorConfiguration> inst = new ModuleAcceleratorConfiguration(context, arguments); + css::uno::XInterface *acquired_inst = cppu::acquire(inst.get()); inst->fillCache(); diff --git a/framework/source/dispatch/dispatchinformationprovider.cxx b/framework/source/dispatch/dispatchinformationprovider.cxx index 47234f4d6a02..3ad13062fd62 100644 --- a/framework/source/dispatch/dispatchinformationprovider.cxx +++ b/framework/source/dispatch/dispatchinformationprovider.cxx @@ -113,15 +113,13 @@ css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvide if (!xFrame.is()) return css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > >(); - CloseDispatcher* pCloser = new CloseDispatcher(m_xContext, xFrame, "_self"); // explicit "_self" ... not "" ... see implementation of close dispatcher itself! - css::uno::Reference< css::uno::XInterface > xCloser(static_cast< css::frame::XDispatch* >(pCloser), css::uno::UNO_QUERY); + rtl::Reference<CloseDispatcher> xCloser = new CloseDispatcher(m_xContext, xFrame, "_self"); // explicit "_self" ... not "" ... see implementation of close dispatcher itself! - css::uno::Reference< css::frame::XDispatchInformationProvider > xCloseDispatch(xCloser , css::uno::UNO_QUERY); css::uno::Reference< css::frame::XDispatchInformationProvider > xController (xFrame->getController() , css::uno::UNO_QUERY); css::uno::Reference< css::frame::XDispatchInformationProvider > xAppDispatcher = css::frame::AppDispatchProvider::create(m_xContext); css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > > lProvider(3); lProvider[0] = xController; - lProvider[1] = xCloseDispatch; + lProvider[1] = css::uno::Reference< css::frame::XDispatchInformationProvider >(xCloser); lProvider[2] = xAppDispatcher; return lProvider; diff --git a/framework/source/dispatch/dispatchprovider.cxx b/framework/source/dispatch/dispatchprovider.cxx index 9d86254061a7..e7c7fdfbe1a1 100644 --- a/framework/source/dispatch/dispatchprovider.cxx +++ b/framework/source/dispatch/dispatchprovider.cxx @@ -509,51 +509,33 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_getOrCreat switch (eHelper) { case E_CREATEDISPATCHER : - { - LoadDispatcher* pDispatcher = new LoadDispatcher(m_xContext, xOwner, sTarget, nSearchFlags); - xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); - } + xDispatchHelper = new LoadDispatcher(m_xContext, xOwner, sTarget, nSearchFlags); break; case E_BLANKDISPATCHER : { if (xOwner.is()) - { - LoadDispatcher* pDispatcher = new LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_BLANK, 0); - xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); - } + xDispatchHelper = new LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_BLANK, 0); } break; case E_DEFAULTDISPATCHER : { if (xOwner.is()) - { - LoadDispatcher* pDispatcher = new LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_DEFAULT, 0); - xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); - } + xDispatchHelper = new LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_DEFAULT, 0); } break; case E_SELFDISPATCHER : - { - LoadDispatcher* pDispatcher = new LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_SELF, 0); - xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); - } + xDispatchHelper = new LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_SELF, 0); break; case E_CLOSEDISPATCHER : - { - CloseDispatcher* pDispatcher = new CloseDispatcher( m_xContext, xOwner, sTarget ); - xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); - } + xDispatchHelper = new CloseDispatcher( m_xContext, xOwner, sTarget ); break; case E_STARTMODULEDISPATCHER : - { - StartModuleDispatcher* pDispatcher = new StartModuleDispatcher( m_xContext ); - xDispatchHelper.set( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); - } + xDispatchHelper = new StartModuleDispatcher( m_xContext ); break; } diff --git a/framework/source/fwe/xml/menudocumenthandler.cxx b/framework/source/fwe/xml/menudocumenthandler.cxx index d1fd63bc2b3b..7e697a667dd1 100644 --- a/framework/source/fwe/xml/menudocumenthandler.cxx +++ b/framework/source/fwe/xml/menudocumenthandler.cxx @@ -717,8 +717,7 @@ OWriteMenuDocumentHandler::OWriteMenuDocumentHandler( m_xWriteDocumentHandler( rDocumentHandler ), m_bIsMenuBar( bIsMenuBar ) { - ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; - m_xEmptyList.set( static_cast<XAttributeList *>(pList), UNO_QUERY ); + m_xEmptyList = new ::comphelper::AttributeList; m_aAttributeType = ATTRIBUTE_TYPE_CDATA; } @@ -789,8 +788,7 @@ void OWriteMenuDocumentHandler::WriteMenu( const Reference< XIndexAccess >& rMen { if ( !aCommandURL.isEmpty() ) { - ::comphelper::AttributeList* pListMenu = new ::comphelper::AttributeList; - Reference< XAttributeList > xListMenu( static_cast<XAttributeList *>(pListMenu) , UNO_QUERY ); + rtl::Reference<::comphelper::AttributeList> pListMenu = new ::comphelper::AttributeList; pListMenu->AddAttribute( ATTRIBUTE_NS_ID, m_aAttributeType, @@ -802,7 +800,7 @@ void OWriteMenuDocumentHandler::WriteMenu( const Reference< XIndexAccess >& rMen aLabel ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); - m_xWriteDocumentHandler->startElement( ELEMENT_NS_MENU, xListMenu ); + m_xWriteDocumentHandler->startElement( ELEMENT_NS_MENU, pListMenu ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); m_xWriteDocumentHandler->startElement( ELEMENT_NS_MENUPOPUP, m_xEmptyList ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); @@ -840,8 +838,7 @@ void OWriteMenuDocumentHandler::WriteMenu( const Reference< XIndexAccess >& rMen void OWriteMenuDocumentHandler::WriteMenuItem( const OUString& aCommandURL, const OUString& aLabel, const OUString& aHelpURL, sal_Int16 nStyle ) { - ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; - Reference< XAttributeList > xList( static_cast<XAttributeList *>(pList) , UNO_QUERY ); + rtl::Reference<::comphelper::AttributeList> pList = new ::comphelper::AttributeList; pList->AddAttribute( ATTRIBUTE_NS_ID, m_aAttributeType, @@ -880,7 +877,7 @@ void OWriteMenuDocumentHandler::WriteMenuItem( const OUString& aCommandURL, cons } m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); - m_xWriteDocumentHandler->startElement( ELEMENT_NS_MENUITEM, xList ); + m_xWriteDocumentHandler->startElement( ELEMENT_NS_MENUITEM, pList ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); m_xWriteDocumentHandler->endElement( ELEMENT_NS_MENUITEM ); } diff --git a/framework/source/fwe/xml/saxnamespacefilter.cxx b/framework/source/fwe/xml/saxnamespacefilter.cxx index 5a05dfb54e43..18baa687422b 100644 --- a/framework/source/fwe/xml/saxnamespacefilter.cxx +++ b/framework/source/fwe/xml/saxnamespacefilter.cxx @@ -27,6 +27,7 @@ #include <xml/saxnamespacefilter.hxx> #include <comphelper/attributelist.hxx> +#include <rtl/ref.hxx> using namespace ::com::sun::star::xml::sax; using namespace ::com::sun::star::uno; @@ -58,7 +59,7 @@ void SAL_CALL SaxNamespaceFilter::startElement( if ( !m_aNamespaceStack.empty() ) aXMLNamespaces = m_aNamespaceStack.top(); - ::comphelper::AttributeList* pNewList = new ::comphelper::AttributeList(); + rtl::Reference<::comphelper::AttributeList> pNewList = new ::comphelper::AttributeList(); // examine all namespaces for this level ::std::vector< sal_Int16 > aAttributeIndexes; diff --git a/framework/source/fwe/xml/statusbardocumenthandler.cxx b/framework/source/fwe/xml/statusbardocumenthandler.cxx index 36cf5da27a48..a6f157ba21b9 100644 --- a/framework/source/fwe/xml/statusbardocumenthandler.cxx +++ b/framework/source/fwe/xml/statusbardocumenthandler.cxx @@ -476,8 +476,7 @@ OWriteStatusBarDocumentHandler::OWriteStatusBarDocumentHandler( m_aStatusBarItems( aStatusBarItems ), m_xWriteDocumentHandler( rWriteDocumentHandler ) { - ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; - m_xEmptyList.set( static_cast<XAttributeList *>(pList), UNO_QUERY ); + m_xEmptyList = new ::comphelper::AttributeList; m_aAttributeType = ATTRIBUTE_TYPE_CDATA; m_aXMLXlinkNS = XMLNS_XLINK_PREFIX; m_aXMLStatusBarNS = XMLNS_STATUSBAR_PREFIX; @@ -556,8 +555,7 @@ void OWriteStatusBarDocumentHandler::WriteStatusBarItem( sal_Int16 nStyle, sal_Int16 nWidth ) { - ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; - Reference< XAttributeList > xList( static_cast<XAttributeList *>(pList) , UNO_QUERY ); + rtl::Reference<::comphelper::AttributeList> pList = new ::comphelper::AttributeList; if (m_aAttributeURL.isEmpty() ) { @@ -642,7 +640,7 @@ void OWriteStatusBarDocumentHandler::WriteStatusBarItem( } m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); - m_xWriteDocumentHandler->startElement( ELEMENT_NS_STATUSBARITEM, xList ); + m_xWriteDocumentHandler->startElement( ELEMENT_NS_STATUSBARITEM, pList ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); m_xWriteDocumentHandler->endElement( ELEMENT_NS_STATUSBARITEM ); } diff --git a/framework/source/fwe/xml/toolboxdocumenthandler.cxx b/framework/source/fwe/xml/toolboxdocumenthandler.cxx index 386da1bc7f53..401a08fbeca1 100644 --- a/framework/source/fwe/xml/toolboxdocumenthandler.cxx +++ b/framework/source/fwe/xml/toolboxdocumenthandler.cxx @@ -577,8 +577,7 @@ OWriteToolBoxDocumentHandler::OWriteToolBoxDocumentHandler( m_xWriteDocumentHandler( rWriteDocumentHandler ), m_rItemAccess( rItemAccess ) { - ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; - m_xEmptyList.set( static_cast<XAttributeList *>(pList), UNO_QUERY ); + m_xEmptyList = new ::comphelper::AttributeList; m_aAttributeType = ATTRIBUTE_TYPE_CDATA; m_aXMLXlinkNS = XMLNS_XLINK_PREFIX; m_aXMLToolbarNS = XMLNS_TOOLBAR_PREFIX; @@ -674,8 +673,7 @@ void OWriteToolBoxDocumentHandler::WriteToolBoxItem( sal_Int16 nStyle, bool bVisible ) { - ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; - Reference< XAttributeList > xList( static_cast<XAttributeList *>(pList) , UNO_QUERY ); + rtl::Reference<::comphelper::AttributeList> pList = new ::comphelper::AttributeList; if ( m_aAttributeURL.isEmpty() ) { @@ -719,7 +717,7 @@ void OWriteToolBoxDocumentHandler::WriteToolBoxItem( } m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); - m_xWriteDocumentHandler->startElement( ELEMENT_NS_TOOLBARITEM, xList ); + m_xWriteDocumentHandler->startElement( ELEMENT_NS_TOOLBARITEM, pList ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); m_xWriteDocumentHandler->endElement( ELEMENT_NS_TOOLBARITEM ); } diff --git a/framework/source/fwi/uielement/constitemcontainer.cxx b/framework/source/fwi/uielement/constitemcontainer.cxx index e02fb7aa3d9a..77952563d4f2 100644 --- a/framework/source/fwi/uielement/constitemcontainer.cxx +++ b/framework/source/fwi/uielement/constitemcontainer.cxx @@ -25,6 +25,7 @@ #include <comphelper/propertysetinfo.hxx> #include <comphelper/servicehelper.hxx> +#include <rtl/ref.hxx> using namespace cppu; using namespace com::sun::star::uno; @@ -147,12 +148,12 @@ Reference< XIndexAccess > ConstItemContainer::deepCopyContainer( const Reference if ( rSubContainer.is() ) { ItemContainer* pSource = comphelper::getUnoTunnelImplementation<ItemContainer>( rSubContainer ); - ConstItemContainer* pSubContainer( nullptr ); + rtl::Reference<ConstItemContainer> pSubContainer; if ( pSource ) pSubContainer = new ConstItemContainer( *pSource ); else pSubContainer = new ConstItemContainer( rSubContainer ); - xReturn.set( static_cast< OWeakObject* >( pSubContainer ), UNO_QUERY ); + xReturn = pSubContainer; } return xReturn; diff --git a/framework/source/fwi/uielement/itemcontainer.cxx b/framework/source/fwi/uielement/itemcontainer.cxx index de2b047653ab..f9945deb9050 100644 --- a/framework/source/fwi/uielement/itemcontainer.cxx +++ b/framework/source/fwi/uielement/itemcontainer.cxx @@ -23,6 +23,7 @@ #include <uielement/itemcontainer.hxx> #include <uielement/constitemcontainer.hxx> #include <comphelper/servicehelper.hxx> +#include <rtl/ref.hxx> using namespace cppu; using namespace com::sun::star::uno; @@ -122,12 +123,12 @@ Reference< XIndexAccess > ItemContainer::deepCopyContainer( const Reference< XIn if ( rSubContainer.is() ) { ConstItemContainer* pSource = comphelper::getUnoTunnelImplementation<ConstItemContainer>( rSubContainer ); - ItemContainer* pSubContainer( nullptr ); + rtl::Reference<ItemContainer> pSubContainer; if ( pSource ) pSubContainer = new ItemContainer( *pSource, rMutex ); else pSubContainer = new ItemContainer( rSubContainer, rMutex ); - xReturn.set( static_cast< OWeakObject* >( pSubContainer ), UNO_QUERY ); + xReturn = pSubContainer; } return xReturn; diff --git a/framework/source/fwi/uielement/rootitemcontainer.cxx b/framework/source/fwi/uielement/rootitemcontainer.cxx index b570154f2eb0..8c573f12dbff 100644 --- a/framework/source/fwi/uielement/rootitemcontainer.cxx +++ b/framework/source/fwi/uielement/rootitemcontainer.cxx @@ -26,6 +26,7 @@ #include <properties.h> #include <com/sun/star/beans/PropertyAttribute.hpp> +#include <rtl/ref.hxx> using namespace cppu; using namespace com::sun::star::uno; @@ -126,12 +127,12 @@ Reference< XIndexAccess > RootItemContainer::deepCopyContainer( const Reference< if ( rSubContainer.is() ) { ConstItemContainer* pSource = comphelper::getUnoTunnelImplementation<ConstItemContainer>( rSubContainer ); - ItemContainer* pSubContainer( nullptr ); + rtl::Reference<ItemContainer> pSubContainer; if ( pSource ) pSubContainer = new ItemContainer( *pSource, m_aShareMutex ); else pSubContainer = new ItemContainer( rSubContainer, m_aShareMutex ); - xReturn.set( static_cast< OWeakObject* >( pSubContainer ), UNO_QUERY ); + xReturn = pSubContainer; } return xReturn; diff --git a/framework/source/helper/ocomponentaccess.cxx b/framework/source/helper/ocomponentaccess.cxx index b814fc49b83a..bfb4113eab4d 100644 --- a/framework/source/helper/ocomponentaccess.cxx +++ b/framework/source/helper/ocomponentaccess.cxx @@ -68,8 +68,7 @@ css::uno::Reference< XEnumeration > SAL_CALL OComponentAccess::createEnumeration std::vector< css::uno::Reference< XComponent > > seqComponents; impl_collectAllChildComponents( css::uno::Reference< XFramesSupplier >( xLock, UNO_QUERY ), seqComponents ); - OComponentEnumeration* pEnumeration = new OComponentEnumeration( seqComponents ); - xReturn.set( static_cast<OWeakObject*>(pEnumeration), UNO_QUERY ); + xReturn = new OComponentEnumeration( seqComponents ); } // Return result of this operation. diff --git a/framework/source/helper/statusindicatorfactory.cxx b/framework/source/helper/statusindicatorfactory.cxx index 62efba05933f..addda602667f 100644 --- a/framework/source/helper/statusindicatorfactory.cxx +++ b/framework/source/helper/statusindicatorfactory.cxx @@ -98,10 +98,7 @@ void SAL_CALL StatusIndicatorFactory::initialize(const css::uno::Sequence< css:: css::uno::Reference< css::task::XStatusIndicator > SAL_CALL StatusIndicatorFactory::createStatusIndicator() { - StatusIndicator* pIndicator = new StatusIndicator(this); - css::uno::Reference< css::task::XStatusIndicator > xIndicator(static_cast< ::cppu::OWeakObject* >(pIndicator), css::uno::UNO_QUERY_THROW); - - return xIndicator; + return new StatusIndicator(this); } void SAL_CALL StatusIndicatorFactory::update() @@ -391,8 +388,7 @@ void StatusIndicatorFactory::impl_createProgress() if (xWindow.is()) { // use vcl based progress implementation in plugged mode - VCLStatusIndicator* pVCLProgress = new VCLStatusIndicator(xWindow); - xProgress.set(static_cast< css::task::XStatusIndicator* >(pVCLProgress), css::uno::UNO_QUERY); + xProgress = new VCLStatusIndicator(xWindow); } else if (xFrame.is()) { diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index d484ca108a95..917e4182e1e2 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -893,7 +893,7 @@ void LayoutManager::implts_createProgressBar() aWriteLock.clear(); bool bRecycled = xProgressBarBackup.is(); - ProgressBarWrapper* pWrapper = nullptr; + rtl::Reference<ProgressBarWrapper> pWrapper; if ( bRecycled ) pWrapper = static_cast<ProgressBarWrapper*>(xProgressBarBackup.get()); else if ( xProgressBar.is() ) @@ -926,7 +926,7 @@ void LayoutManager::implts_createProgressBar() /* SAFE AREA ----------------------------------------------------------------------------------------------- */ aWriteLock.reset(); - m_aProgressBarElement.m_xUIElement.set( static_cast< cppu::OWeakObject* >( pWrapper ), UNO_QUERY ); + m_aProgressBarElement.m_xUIElement = pWrapper; aWriteLock.clear(); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index 159247cb2d29..b6b4c7c34860 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -892,11 +892,10 @@ bool LoadEnv::impl_handleContent() // SAFE -> ----------------------------------- osl::ClearableMutexGuard aWriteLock(m_mutex); m_xAsynchronousJob = xHandler; - LoadEnvListener* pListener = new LoadEnvListener(this); + rtl::Reference<LoadEnvListener> xListener = new LoadEnvListener(this); aWriteLock.clear(); // <- SAFE ----------------------------------- - css::uno::Reference< css::frame::XDispatchResultListener > xListener(static_cast< css::frame::XDispatchResultListener* >(pListener), css::uno::UNO_QUERY); xHandler->dispatchWithNotification(aURL, lDescriptor, xListener); return true; @@ -959,13 +958,11 @@ bool LoadEnv::impl_furtherDocsAllowed() css::uno::Any aInteraction; css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations(2); - comphelper::OInteractionAbort* pAbort = new comphelper::OInteractionAbort(); - comphelper::OInteractionApprove* pApprove = new comphelper::OInteractionApprove(); + rtl::Reference<comphelper::OInteractionAbort> pAbort = new comphelper::OInteractionAbort(); + rtl::Reference<comphelper::OInteractionApprove> pApprove = new comphelper::OInteractionApprove(); - lContinuations[0].set( static_cast< css::task::XInteractionContinuation* >(pAbort), - css::uno::UNO_QUERY_THROW); - lContinuations[1].set( static_cast< css::task::XInteractionContinuation* >(pApprove), - css::uno::UNO_QUERY_THROW); + lContinuations[0] = pAbort; + lContinuations[1] = pApprove; css::task::ErrorCodeRequest aErrorCode; aErrorCode.ErrCode = sal_uInt32(ERRCODE_SFX_NOMOREDOCUMENTSALLOWED); @@ -1142,11 +1139,10 @@ bool LoadEnv::impl_loadContent() if (xAsyncLoader.is()) { m_xAsynchronousJob = xAsyncLoader; - LoadEnvListener* pListener = new LoadEnvListener(this); + rtl::Reference<LoadEnvListener> xListener = new LoadEnvListener(this); aWriteLock.clear(); // <- SAFE ----------------------------------- - css::uno::Reference< css::frame::XLoadEventListener > xListener(static_cast< css::frame::XLoadEventListener* >(pListener), css::uno::UNO_QUERY); xAsyncLoader->load(xTargetFrame, sURL, lDescriptor, xListener); return true; 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 ) diff --git a/framework/source/uiconfiguration/globalsettings.cxx b/framework/source/uiconfiguration/globalsettings.cxx index f8a492299b95..2727c2bb24cb 100644 --- a/framework/source/uiconfiguration/globalsettings.cxx +++ b/framework/source/uiconfiguration/globalsettings.cxx @@ -26,6 +26,7 @@ #include <com/sun/star/lang/XEventListener.hpp> #include <rtl/instance.hxx> +#include <rtl/ref.hxx> #include <comphelper/propertysequence.hxx> #include <cppuhelper/implbase.hxx> @@ -227,14 +228,14 @@ struct mutexGlobalSettings : public rtl::Static< osl::Mutex, mutexGlobalSettings } -static GlobalSettings_Access* pStaticSettings = nullptr; +static rtl::Reference<GlobalSettings_Access> pStaticSettings; static GlobalSettings_Access* GetGlobalSettings( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) { osl::MutexGuard aGuard(mutexGlobalSettings::get()); if ( !pStaticSettings ) pStaticSettings = new GlobalSettings_Access( rxContext ); - return pStaticSettings; + return pStaticSettings.get(); } GlobalSettings::GlobalSettings( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) : diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx index cfccf014f11c..64cf3a53342c 100644 --- a/framework/source/uiconfiguration/imagemanagerimpl.cxx +++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx @@ -743,8 +743,8 @@ void ImageManagerImpl::replaceImages( const Sequence< OUString >& aCommandURLSequence, const Sequence< uno::Reference< XGraphic > >& aGraphicsSequence ) { - GraphicNameAccess* pInsertedImages( nullptr ); - GraphicNameAccess* pReplacedImages( nullptr ); + rtl::Reference<GraphicNameAccess> pInsertedImages; + rtl::Reference<GraphicNameAccess> pReplacedImages; { SolarMutexGuard g; @@ -803,8 +803,7 @@ void ImageManagerImpl::replaceImages( aInsertEvent.Accessor <<= xOwner; aInsertEvent.Source = xOwner; aInsertEvent.ResourceURL = m_aResourceString; - aInsertEvent.Element <<= uno::Reference< XNameAccess >( - static_cast< OWeakObject *>( pInsertedImages ), UNO_QUERY ); + aInsertEvent.Element <<= uno::Reference< XNameAccess >(pInsertedImages); implts_notifyContainerListener( aInsertEvent, NotifyOp_Insert ); } if ( pReplacedImages != nullptr ) @@ -815,16 +814,15 @@ void ImageManagerImpl::replaceImages( aReplaceEvent.Source = xOwner; aReplaceEvent.ResourceURL = m_aResourceString; aReplaceEvent.ReplacedElement = Any(); - aReplaceEvent.Element <<= uno::Reference< XNameAccess >( - static_cast< OWeakObject *>( pReplacedImages ), UNO_QUERY ); + aReplaceEvent.Element <<= uno::Reference< XNameAccess >(pReplacedImages); implts_notifyContainerListener( aReplaceEvent, NotifyOp_Replace ); } } void ImageManagerImpl::removeImages( ::sal_Int16 nImageType, const Sequence< OUString >& aCommandURLSequence ) { - GraphicNameAccess* pRemovedImages( nullptr ); - GraphicNameAccess* pReplacedImages( nullptr ); + rtl::Reference<GraphicNameAccess> pRemovedImages; + rtl::Reference<GraphicNameAccess> pReplacedImages; { SolarMutexGuard g; @@ -903,8 +901,7 @@ void ImageManagerImpl::removeImages( ::sal_Int16 nImageType, const Sequence< OUS aRemoveEvent.Accessor <<= xOwner; aRemoveEvent.Source = xOwner; aRemoveEvent.ResourceURL = m_aResourceString; - aRemoveEvent.Element <<= uno::Reference< XNameAccess >( - static_cast< OWeakObject *>( pRemovedImages ), UNO_QUERY ); + aRemoveEvent.Element <<= uno::Reference< XNameAccess >(pRemovedImages); implts_notifyContainerListener( aRemoveEvent, NotifyOp_Remove ); } if ( pReplacedImages != nullptr ) @@ -915,8 +912,7 @@ void ImageManagerImpl::removeImages( ::sal_Int16 nImageType, const Sequence< OUS aReplaceEvent.Source = xOwner; aReplaceEvent.ResourceURL = m_aResourceString; aReplaceEvent.ReplacedElement = Any(); - aReplaceEvent.Element <<= uno::Reference< XNameAccess >( - static_cast< OWeakObject *>( pReplacedImages ), UNO_QUERY ); + aReplaceEvent.Element <<= uno::Reference< XNameAccess >(pReplacedImages); implts_notifyContainerListener( aReplaceEvent, NotifyOp_Replace ); } } @@ -959,9 +955,9 @@ void ImageManagerImpl::reload() pImageList = implts_getUserImageList(i); pImageList->GetImageNames( aNewUserCmdImageSet ); - GraphicNameAccess* pInsertedImages( nullptr ); - GraphicNameAccess* pReplacedImages( nullptr ); - GraphicNameAccess* pRemovedImages( nullptr ); + rtl::Reference<GraphicNameAccess> pInsertedImages; + rtl::Reference<GraphicNameAccess> pReplacedImages; + rtl::Reference<GraphicNameAccess> pRemovedImages; for (auto const& newUserCmdImage : aNewUserCmdImageSet) { @@ -1040,8 +1036,7 @@ void ImageManagerImpl::reload() aInsertEvent.Accessor <<= xOwner; aInsertEvent.Source = xOwner; aInsertEvent.ResourceURL = m_aResourceString; - aInsertEvent.Element <<= uno::Reference< XNameAccess >( - static_cast< OWeakObject *>( pInsertedImages ), UNO_QUERY ); + aInsertEvent.Element <<= uno::Reference< XNameAccess >( pInsertedImages ); implts_notifyContainerListener( aInsertEvent, NotifyOp_Insert ); } if ( pReplacedImages != nullptr ) @@ -1052,8 +1047,7 @@ void ImageManagerImpl::reload() aReplaceEvent.Source = xOwner; aReplaceEvent.ResourceURL = m_aResourceString; aReplaceEvent.ReplacedElement = Any(); - aReplaceEvent.Element <<= uno::Reference< XNameAccess >( - static_cast< OWeakObject *>( pReplacedImages ), UNO_QUERY ); + aReplaceEvent.Element <<= uno::Reference< XNameAccess >( pReplacedImages ); implts_notifyContainerListener( aReplaceEvent, NotifyOp_Replace ); } if ( pRemovedImages != nullptr ) @@ -1063,8 +1057,7 @@ void ImageManagerImpl::reload() aRemoveEvent.Accessor <<= xOwner; aRemoveEvent.Source = xOwner; aRemoveEvent.ResourceURL = m_aResourceString; - aRemoveEvent.Element <<= uno::Reference< XNameAccess >( - static_cast< OWeakObject *>( pRemovedImages ), UNO_QUERY ); + aRemoveEvent.Element <<= uno::Reference< XNameAccess >( pRemovedImages ); implts_notifyContainerListener( aRemoveEvent, NotifyOp_Remove ); } diff --git a/framework/source/uiconfiguration/windowstateconfiguration.cxx b/framework/source/uiconfiguration/windowstateconfiguration.cxx index 2d6d2b95e102..ba8d0c15a43e 100644 --- a/framework/source/uiconfiguration/windowstateconfiguration.cxx +++ b/framework/source/uiconfiguration/windowstateconfiguration.cxx @@ -1344,9 +1344,7 @@ Any SAL_CALL WindowStateConfiguration::getByName( const OUString& aModuleIdentif a <<= pModuleIter->second; else { - Reference< XNameAccess > xResourceURLWindowState; - ConfigurationAccess_WindowState* pModuleWindowState = new ConfigurationAccess_WindowState( aWindowStateConfigFile, m_xContext ); - xResourceURLWindowState.set( static_cast< cppu::OWeakObject* >( pModuleWindowState ),UNO_QUERY ); + Reference< XNameAccess > xResourceURLWindowState = new ConfigurationAccess_WindowState( aWindowStateConfigFile, m_xContext ); pModuleIter->second = xResourceURLWindowState; a <<= xResourceURLWindowState; } diff --git a/framework/source/uielement/addonstoolbarwrapper.cxx b/framework/source/uielement/addonstoolbarwrapper.cxx index fb7ac0f0f5e8..bc9b5937d3b0 100644 --- a/framework/source/uielement/addonstoolbarwrapper.cxx +++ b/framework/source/uielement/addonstoolbarwrapper.cxx @@ -96,7 +96,7 @@ void SAL_CALL AddonsToolBarWrapper::initialize( const Sequence< Any >& aArgument // Create VCL based toolbar which will be filled with settings data VclPtr<ToolBox> pToolBar; - ToolBarManager* pToolBarManager = nullptr; + rtl::Reference<ToolBarManager> pToolBarManager; { SolarMutexGuard aSolarMutexGuard; VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); @@ -107,7 +107,7 @@ void SAL_CALL AddonsToolBarWrapper::initialize( const Sequence< Any >& aArgument pToolBar = VclPtr<ToolBox>::Create( pWindow, nStyles ); pToolBar->SetLineSpacing(true); pToolBarManager = new ToolBarManager( m_xContext, xFrame, m_aResourceURL, pToolBar ); - m_xToolBarManager.set( static_cast< OWeakObject *>( pToolBarManager ), UNO_QUERY ); + m_xToolBarManager = pToolBarManager; } } diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index b2d1f7cbd372..5cf5e9b77cd5 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -1009,7 +1009,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF // We have to set an empty popup menu into our menu structure so the controller also // works with inplace OLE. MenuItemHandler* pItemHandler = new MenuItemHandler( nItemId, xStatusListener, xDispatch ); - VCLXPopupMenu* pVCLXPopupMenu = new VCLXPopupMenu(pPopup); + rtl::Reference<VCLXPopupMenu> pVCLXPopupMenu = new VCLXPopupMenu(pPopup); pItemHandler->xPopupMenu = pVCLXPopupMenu; pItemHandler->aMenuItemURL = aItemCommand; m_aMenuItemHandlerVector.push_back( std::unique_ptr<MenuItemHandler>(pItemHandler) ); @@ -1041,10 +1041,10 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF pSubMenu.disposeAndClear(); } - MenuBarManager* pSubMenuManager = new MenuBarManager( m_xContext, rFrame, m_xURLTransformer, + rtl::Reference<MenuBarManager> pSubMenuManager = new MenuBarManager( m_xContext, rFrame, m_xURLTransformer, xPopupMenuDispatchProvider, aModuleIdentifier, pPopup, false, m_bHasMenuBar ); - AddMenu(pSubMenuManager, aItemCommand, nItemId); + AddMenu(pSubMenuManager.get(), aItemCommand, nItemId); } } else if ( pMenu->GetItemType( i ) != MenuItemType::SEPARATOR ) @@ -1065,7 +1065,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF // Check if we have to create a popup menu for a uno based popup menu controller. // We have to set an empty popup menu into our menu structure so the controller also // works with inplace OLE. - VCLXPopupMenu* pVCLXPopupMenu = new VCLXPopupMenu; + rtl::Reference<VCLXPopupMenu> pVCLXPopupMenu = new VCLXPopupMenu; PopupMenu* pPopupMenu = static_cast<PopupMenu *>(pVCLXPopupMenu->GetMenu()); pMenu->SetPopupMenu( pItemHandler->nItemId, pPopupMenu ); pItemHandler->xPopupMenu = pVCLXPopupMenu; diff --git a/framework/source/uielement/menubarwrapper.cxx b/framework/source/uielement/menubarwrapper.cxx index 6342f63cf637..9d39e2623dce 100644 --- a/framework/source/uielement/menubarwrapper.cxx +++ b/framework/source/uielement/menubarwrapper.cxx @@ -157,7 +157,6 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) // Create VCL menubar which will be filled with settings data VclPtr<MenuBar> pVCLMenuBar; - VCLXMenuBar* pAwtMenuBar = nullptr; { SolarMutexGuard aSolarMutexGuard; pVCLMenuBar = VclPtr<MenuBar>::Create(); @@ -208,21 +207,18 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) // support. This feature is currently used for "Inplace editing"! Reference< XDispatchProvider > xDispatchProvider; - MenuBarManager* pMenuBarManager = new MenuBarManager( m_xContext, + m_xMenuBarManager = new MenuBarManager( m_xContext, xFrame, xTrans, xDispatchProvider, aModuleIdentifier, pVCLMenuBar, false ); - - m_xMenuBarManager.set( static_cast< OWeakObject *>( pMenuBarManager ), UNO_QUERY ); } // Initialize toolkit menu bar implementation to have awt::XMenuBar for data exchange. // Don't use this toolkit menu bar or one of its functions. It is only used as a data container! - pAwtMenuBar = new VCLXMenuBar( pVCLMenuBar ); - m_xMenuBar = pAwtMenuBar; + m_xMenuBar = new VCLXMenuBar( pVCLMenuBar ); } // XUIElementSettings diff --git a/framework/source/uielement/progressbarwrapper.cxx b/framework/source/uielement/progressbarwrapper.cxx index 68e0220fb1bb..d0a2068c2649 100644 --- a/framework/source/uielement/progressbarwrapper.cxx +++ b/framework/source/uielement/progressbarwrapper.cxx @@ -296,12 +296,12 @@ uno::Reference< uno::XInterface > SAL_CALL ProgressBarWrapper::getRealInterface( uno::Reference< uno::XInterface > xComp( m_xProgressBarIfacWrapper ); if ( !xComp.is() ) { - StatusIndicatorInterfaceWrapper* pWrapper = + rtl::Reference<StatusIndicatorInterfaceWrapper> pWrapper = new StatusIndicatorInterfaceWrapper( uno::Reference< lang::XComponent >( static_cast< cppu::OWeakObject* >( this ), uno::UNO_QUERY )); - xComp.set(static_cast< cppu::OWeakObject* >( pWrapper ), + xComp.set(static_cast< cppu::OWeakObject* >( pWrapper.get() ), uno::UNO_QUERY ); m_xProgressBarIfacWrapper = xComp; } diff --git a/framework/source/uielement/statusbarmanager.cxx b/framework/source/uielement/statusbarmanager.cxx index 6c417903b807..6754cb85a002 100644 --- a/framework/source/uielement/statusbarmanager.cxx +++ b/framework/source/uielement/statusbarmanager.cxx @@ -348,13 +348,13 @@ void StatusBarManager::CreateControllers() if ( !xController.is() ) { // 2) Old SFX2 Statusbar controllers - svt::StatusbarController* pController = CreateStatusBarController( m_xFrame, m_pStatusBar, nId, aCommandURL ); - if ( !pController ) + xController = CreateStatusBarController( m_xFrame, m_pStatusBar, nId, aCommandURL ); + if ( !xController ) { // 3) Is Add-on? Generic statusbar controller if ( pItemData ) { - pController = new GenericStatusbarController( m_xContext, + xController = new GenericStatusbarController( m_xContext, m_xFrame, xStatusbarItem, pItemData ); @@ -362,11 +362,9 @@ void StatusBarManager::CreateControllers() else { // 4) Default Statusbar controller - pController = new svt::StatusbarController( m_xContext, m_xFrame, aCommandURL, nId ); + xController = new svt::StatusbarController( m_xContext, m_xFrame, aCommandURL, nId ); } } - - xController = pController; } m_aControllerMap[nId] = xController; diff --git a/framework/source/uielement/statusbarwrapper.cxx b/framework/source/uielement/statusbarwrapper.cxx index f22736f796a4..bf5f08a6384c 100644 --- a/framework/source/uielement/statusbarwrapper.cxx +++ b/framework/source/uielement/statusbarwrapper.cxx @@ -92,7 +92,7 @@ void SAL_CALL StatusBarWrapper::initialize( const Sequence< Any >& aArguments ) // Create VCL based toolbar which will be filled with settings data StatusBar* pStatusBar( nullptr ); - StatusBarManager* pStatusBarManager( nullptr ); + rtl::Reference<StatusBarManager> pStatusBarManager; { SolarMutexGuard aSolarMutexGuard; VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); @@ -102,8 +102,8 @@ void SAL_CALL StatusBarWrapper::initialize( const Sequence< Any >& aArguments ) pStatusBar = VclPtr<FrameworkStatusBar>::Create( pWindow, nStyles ); pStatusBarManager = new StatusBarManager( m_xContext, xFrame, pStatusBar ); - static_cast<FrameworkStatusBar*>(pStatusBar)->SetStatusBarManager( pStatusBarManager ); - m_xStatusBarManager.set( static_cast< OWeakObject *>( pStatusBarManager ), UNO_QUERY ); + static_cast<FrameworkStatusBar*>(pStatusBar)->SetStatusBarManager( pStatusBarManager.get() ); + m_xStatusBarManager = pStatusBarManager; } } diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 82b7e82607c8..6902bcf49e00 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -751,7 +751,7 @@ void ToolBarManager::CreateControllers() aCommandURL, nId, nWidth, - aControlType ), UNO_QUERY ); + aControlType ).get(), UNO_QUERY ); xController = xStatusListener; } diff --git a/framework/source/uielement/toolbarmerger.cxx b/framework/source/uielement/toolbarmerger.cxx index 294e34cbc30f..297f38cba9ad 100644 --- a/framework/source/uielement/toolbarmerger.cxx +++ b/framework/source/uielement/toolbarmerger.cxx @@ -582,7 +582,7 @@ void ToolBarMerger::RemoveItems( Returns true for a successful operation otherwise false. */ -::cppu::OWeakObject* ToolBarMerger::CreateController( +rtl::Reference<::cppu::OWeakObject> ToolBarMerger::CreateController( const uno::Reference< uno::XComponentContext >& rxContext, const uno::Reference< frame::XFrame > & xFrame, ToolBox* pToolbar, @@ -591,7 +591,7 @@ void ToolBarMerger::RemoveItems( sal_uInt16 nWidth, std::u16string_view rControlType ) { - ::cppu::OWeakObject* pResult( nullptr ); + rtl::Reference<::cppu::OWeakObject> pResult; if ( rControlType == TOOLBARCONTROLLER_BUTTON ) pResult = new ButtonToolbarController( rxContext, pToolbar, rCommandURL ); diff --git a/framework/source/uielement/toolbarwrapper.cxx b/framework/source/uielement/toolbarwrapper.cxx index b74aa19136f3..1a701e286186 100644 --- a/framework/source/uielement/toolbarwrapper.cxx +++ b/framework/source/uielement/toolbarwrapper.cxx @@ -132,7 +132,7 @@ void SAL_CALL ToolBarWrapper::initialize( const Sequence< Any >& aArguments ) // Create VCL based toolbar which will be filled with settings data VclPtr<ToolBox> pToolBar; - ToolBarManager* pToolBarManager = nullptr; + rtl::Reference<ToolBarManager> pToolBarManager; { SolarMutexGuard aSolarMutexGuard; if ( !xParentWindow.is() ) @@ -145,7 +145,7 @@ void SAL_CALL ToolBarWrapper::initialize( const Sequence< Any >& aArguments ) pToolBar = VclPtr<ToolBox>::Create( pWindow, nStyles ); pToolBar->SetLineSpacing(true); pToolBarManager = new ToolBarManager( m_xContext, xFrame, m_aResourceURL, pToolBar ); - m_xToolBarManager.set( static_cast< OWeakObject *>( pToolBarManager ), UNO_QUERY ); + m_xToolBarManager = pToolBarManager; pToolBar->WillUsePopupMode( bPopupMode ); } } diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx index 7fdef0eaf06d..d791ddfd89ab 100644 --- a/framework/source/uielement/uicommanddescription.cxx +++ b/framework/source/uielement/uicommanddescription.cxx @@ -658,11 +658,9 @@ Any SAL_CALL UICommandDescription::getByName( const OUString& aName ) { ensureGenericUICommandsForLanguage(aCurrentLanguage); - Reference< XNameAccess > xUICommands; - ConfigurationAccess_UICommand* pUICommands = new ConfigurationAccess_UICommand( aCommandFile, - m_xGenericUICommands[aCurrentLanguage], - m_xContext ); - xUICommands.set( static_cast< cppu::OWeakObject* >( pUICommands ),UNO_QUERY ); + Reference< XNameAccess > xUICommands = new ConfigurationAccess_UICommand( aCommandFile, + m_xGenericUICommands[aCurrentLanguage], + m_xContext ); pIter->second = xUICommands; a <<= xUICommands; } diff --git a/framework/source/uifactory/addonstoolbarfactory.cxx b/framework/source/uifactory/addonstoolbarfactory.cxx index 63742c89249c..1c48d6c5844b 100644 --- a/framework/source/uifactory/addonstoolbarfactory.cxx +++ b/framework/source/uifactory/addonstoolbarfactory.cxx @@ -193,10 +193,9 @@ Reference< XUIElement > SAL_CALL AddonsToolBarFactory::createUIElement( aPropSeq[2] <<= aPropValue; SolarMutexGuard aGuard; - AddonsToolBarWrapper* pToolBarWrapper = new AddonsToolBarWrapper( m_xContext ); - xToolBar.set( static_cast<OWeakObject *>(pToolBarWrapper), UNO_QUERY ); - Reference< XInitialization > xInit( xToolBar, UNO_QUERY ); - xInit->initialize( aPropSeq ); + rtl::Reference<AddonsToolBarWrapper> pToolBarWrapper = new AddonsToolBarWrapper( m_xContext ); + xToolBar = pToolBarWrapper; + pToolBarWrapper->initialize( aPropSeq ); } return xToolBar; diff --git a/framework/source/xml/acceleratorconfigurationwriter.cxx b/framework/source/xml/acceleratorconfigurationwriter.cxx index c94501ad12dc..6092d40d5b54 100644 --- a/framework/source/xml/acceleratorconfigurationwriter.cxx +++ b/framework/source/xml/acceleratorconfigurationwriter.cxx @@ -29,6 +29,7 @@ #include <com/sun/star/awt/KeyModifier.hpp> #include <comphelper/attributelist.hxx> +#include <rtl/ref.hxx> namespace framework{ @@ -48,8 +49,7 @@ void AcceleratorConfigurationWriter::flush() css::uno::Reference< css::xml::sax::XExtendedDocumentHandler > xExtendedCFG(m_xConfig, css::uno::UNO_QUERY_THROW); // prepare attribute list - ::comphelper::AttributeList* pAttribs = new ::comphelper::AttributeList; - css::uno::Reference< css::xml::sax::XAttributeList > xAttribs(static_cast< css::xml::sax::XAttributeList* >(pAttribs), css::uno::UNO_QUERY); + rtl::Reference<::comphelper::AttributeList> pAttribs = new ::comphelper::AttributeList; pAttribs->AddAttribute( "xmlns:accel", ATTRIBUTE_TYPE_CDATA, @@ -65,7 +65,7 @@ void AcceleratorConfigurationWriter::flush() " OfficeDocument 1.0//EN\" \"accelerator.dtd\">"); xExtendedCFG->ignorableWhitespace(OUString()); - xExtendedCFG->startElement(AL_ELEMENT_ACCELERATORLIST, xAttribs); + xExtendedCFG->startElement(AL_ELEMENT_ACCELERATORLIST, pAttribs); xExtendedCFG->ignorableWhitespace(OUString()); // TODO think about threadsafe using of cache @@ -91,8 +91,7 @@ void AcceleratorConfigurationWriter::impl_ts_writeKeyCommandPair(const css::awt: const OUString& sCommand, const css::uno::Reference< css::xml::sax::XDocumentHandler >& xConfig ) { - ::comphelper::AttributeList* pAttribs = new ::comphelper::AttributeList; - css::uno::Reference< css::xml::sax::XAttributeList > xAttribs (static_cast< css::xml::sax::XAttributeList* >(pAttribs) , css::uno::UNO_QUERY_THROW); + rtl::Reference<::comphelper::AttributeList> pAttribs = new ::comphelper::AttributeList; OUString sKey = KeyMapping::get().mapCodeToIdentifier(aKey.KeyCode); // TODO check if key is empty! @@ -113,7 +112,7 @@ void AcceleratorConfigurationWriter::impl_ts_writeKeyCommandPair(const css::awt: pAttribs->AddAttribute("accel:mod3", ATTRIBUTE_TYPE_CDATA, "true"); xConfig->ignorableWhitespace(OUString()); - xConfig->startElement(AL_ELEMENT_ITEM, xAttribs); + xConfig->startElement(AL_ELEMENT_ITEM, pAttribs); xConfig->ignorableWhitespace(OUString()); xConfig->endElement(AL_ELEMENT_ITEM); xConfig->ignorableWhitespace(OUString()); diff --git a/framework/source/xml/imagesdocumenthandler.cxx b/framework/source/xml/imagesdocumenthandler.cxx index 79e95eb87886..0cb245cfcc3a 100644 --- a/framework/source/xml/imagesdocumenthandler.cxx +++ b/framework/source/xml/imagesdocumenthandler.cxx @@ -296,8 +296,7 @@ OWriteImagesDocumentHandler::OWriteImagesDocumentHandler( m_rImageItemList( rItems ), m_xWriteDocumentHandler( rWriteDocumentHandler ) { - ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; - m_xEmptyList.set( static_cast<XAttributeList *>(pList), UNO_QUERY ); + m_xEmptyList = new ::comphelper::AttributeList; m_aAttributeType = ATTRIBUTE_TYPE_CDATA; m_aXMLImageNS = XMLNS_IMAGE_PREFIX; m_aAttributeXlinkType = ATTRIBUTE_XLINK_TYPE; @@ -347,15 +346,14 @@ void OWriteImagesDocumentHandler::WriteImagesDocument() void OWriteImagesDocumentHandler::WriteImageList( const ImageItemDescriptorList* pImageList ) { - ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; - Reference< XAttributeList > xList( static_cast<XAttributeList *>(pList) , UNO_QUERY ); + rtl::Reference<::comphelper::AttributeList> pList = new ::comphelper::AttributeList; // save required attributes pList->AddAttribute( m_aAttributeXlinkType, m_aAttributeType, m_aAttributeValueSimple ); - m_xWriteDocumentHandler->startElement( ELEMENT_NS_IMAGES, xList ); + m_xWriteDocumentHandler->startElement( ELEMENT_NS_IMAGES, pList ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); for (const ImageItemDescriptor & i : *pImageList) @@ -367,14 +365,13 @@ void OWriteImagesDocumentHandler::WriteImageList( const ImageItemDescriptorList* void OWriteImagesDocumentHandler::WriteImage( const ImageItemDescriptor* pImage ) { - ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; - Reference< XAttributeList > xList( static_cast<XAttributeList *>(pList) , UNO_QUERY ); + rtl::Reference<::comphelper::AttributeList> pList = new ::comphelper::AttributeList; pList->AddAttribute( m_aXMLImageNS + ATTRIBUTE_COMMAND, m_aAttributeType, pImage->aCommandURL ); - m_xWriteDocumentHandler->startElement( ELEMENT_NS_ENTRY, xList ); + m_xWriteDocumentHandler->startElement( ELEMENT_NS_ENTRY, pList ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); m_xWriteDocumentHandler->endElement( ELEMENT_NS_ENTRY ); |