framework/source/fwe/classes/sfxhelperfunctions.cxx | 6 ++++-- framework/source/uielement/toolbarmanager.cxx | 4 ++-- include/framework/sfxhelperfunctions.hxx | 9 +++++---- include/sfx2/stbitem.hxx | 10 +++++----- include/sfx2/tbxctrl.hxx | 13 +++++++------ include/sfx2/thumbnailviewitem.hxx | 3 ++- sfx2/source/control/thumbnailviewitem.cxx | 2 +- sfx2/source/doc/SfxDocumentMetaData.cxx | 6 +++--- sfx2/source/sidebar/ControllerFactory.cxx | 6 ++---- sfx2/source/statbar/stbitem.cxx | 4 ++-- sfx2/source/toolbox/tbxitem.cxx | 6 +++--- 11 files changed, 36 insertions(+), 33 deletions(-)
New commits: commit 05d6dae5ebd172c6738dc8cd7c94b57f671f698e Author: Noel <noel.gran...@collabora.co.uk> AuthorDate: Sat Feb 27 18:22:18 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Mar 1 19:34:08 2021 +0100 loplugin:refcounting in sfx2 Change-Id: Iba7b1be688f1a7c1b0947c2423cc1965362386b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111682 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/framework/source/fwe/classes/sfxhelperfunctions.cxx b/framework/source/fwe/classes/sfxhelperfunctions.cxx index c6fe0bf030f1..c96791c2f422 100644 --- a/framework/source/fwe/classes/sfxhelperfunctions.cxx +++ b/framework/source/fwe/classes/sfxhelperfunctions.cxx @@ -20,6 +20,8 @@ #include <framework/sfxhelperfunctions.hxx> #include <framework/ContextChangeEventMultiplexerTunnel.hxx> #include <helper/mischelper.hxx> +#include <svtools/toolboxcontroller.hxx> +#include <svtools/statusbarcontroller.hxx> static pfunc_setToolBoxControllerCreator pToolBoxControllerCreator = nullptr; static pfunc_setStatusBarControllerCreator pStatusBarControllerCreator = nullptr; @@ -41,7 +43,7 @@ pfunc_setToolBoxControllerCreator SetToolBoxControllerCreator( pfunc_setToolBoxC return pOldSetToolBoxControllerCreator; } -svt::ToolboxController* CreateToolBoxController( const Reference< XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const OUString& aCommandURL ) +rtl::Reference<svt::ToolboxController> CreateToolBoxController( const Reference< XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const OUString& aCommandURL ) { pfunc_setToolBoxControllerCreator pFactory = nullptr; { @@ -63,7 +65,7 @@ pfunc_setStatusBarControllerCreator SetStatusBarControllerCreator( pfunc_setStat return pOldSetStatusBarControllerCreator; } -svt::StatusbarController* CreateStatusBarController( const Reference< XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, const OUString& aCommandURL ) +rtl::Reference<svt::StatusbarController> CreateStatusBarController( const Reference< XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, const OUString& aCommandURL ) { pfunc_setStatusBarControllerCreator pFactory = nullptr; { diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 6902bcf49e00..d88ba1384f39 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -669,7 +669,7 @@ void ToolBarManager::CreateControllers() bool bCreate( true ); Reference< XStatusListener > xController; - svt::ToolboxController* pController( nullptr ); + rtl::Reference<svt::ToolboxController> pController; OUString aCommandURL( m_pToolBar->GetItemCommand( nId ) ); // Command can be just an alias to another command. @@ -768,7 +768,7 @@ void ToolBarManager::CreateControllers() } else if ( pController ) { - xController.set( static_cast< ::cppu::OWeakObject *>( pController ), UNO_QUERY ); + xController = pController; } } diff --git a/include/framework/sfxhelperfunctions.hxx b/include/framework/sfxhelperfunctions.hxx index 0fedd75d11f5..7a30899d97de 100644 --- a/include/framework/sfxhelperfunctions.hxx +++ b/include/framework/sfxhelperfunctions.hxx @@ -22,6 +22,7 @@ #include <framework/fwkdllapi.h> #include <rtl/ustring.hxx> +#include <rtl/ref.hxx> namespace com::sun::star::frame { class XFrame; } namespace com::sun::star::uno { template <typename > class Reference; } @@ -31,13 +32,13 @@ namespace svt { class ToolboxController; } class StatusBar; class ToolBox; -typedef svt::ToolboxController* ( *pfunc_setToolBoxControllerCreator)( +typedef rtl::Reference<svt::ToolboxController> ( *pfunc_setToolBoxControllerCreator)( const css::uno::Reference< css::frame::XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const OUString& aCommandURL ); -typedef svt::StatusbarController* ( *pfunc_setStatusBarControllerCreator)( +typedef rtl::Reference<svt::StatusbarController> ( *pfunc_setStatusBarControllerCreator)( const css::uno::Reference< css::frame::XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, @@ -58,14 +59,14 @@ typedef bool ( *pfunc_isDockingWindowVisible)( namespace framework { FWK_DLLPUBLIC pfunc_setToolBoxControllerCreator SetToolBoxControllerCreator( pfunc_setToolBoxControllerCreator pSetToolBoxControllerCreator ); -FWK_DLLPUBLIC svt::ToolboxController* CreateToolBoxController( +FWK_DLLPUBLIC rtl::Reference<svt::ToolboxController> CreateToolBoxController( const css::uno::Reference< css::frame::XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const OUString& aCommandURL ); FWK_DLLPUBLIC pfunc_setStatusBarControllerCreator SetStatusBarControllerCreator( pfunc_setStatusBarControllerCreator pSetStatusBarControllerCreator ); -FWK_DLLPUBLIC svt::StatusbarController* CreateStatusBarController( +FWK_DLLPUBLIC rtl::Reference<svt::StatusbarController> CreateStatusBarController( const css::uno::Reference< css::frame::XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, diff --git a/include/sfx2/stbitem.hxx b/include/sfx2/stbitem.hxx index 060866e4c3eb..a77dc04333b7 100644 --- a/include/sfx2/stbitem.hxx +++ b/include/sfx2/stbitem.hxx @@ -29,12 +29,12 @@ class SfxModule; class SfxStatusBarControl; class StatusBar; -svt::StatusbarController* SfxStatusBarControllerFactory( +rtl::Reference<svt::StatusbarController> SfxStatusBarControllerFactory( const css::uno::Reference< css::frame::XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, const OUString& aCommandURL ); -typedef SfxStatusBarControl* (*SfxStatusBarControlCtor)( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ); +typedef rtl::Reference<SfxStatusBarControl> (*SfxStatusBarControlCtor)( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ); struct SfxStbCtrlFactory { @@ -111,18 +111,18 @@ public: sal_uInt16 GetId() const { return nId; } StatusBar& GetStatusBar() const { return *pBar; } - static SfxStatusBarControl* CreateControl( sal_uInt16 nSlotID, sal_uInt16 nId, StatusBar *pBar, SfxModule const * ); + static rtl::Reference<SfxStatusBarControl> CreateControl( sal_uInt16 nSlotID, sal_uInt16 nId, StatusBar *pBar, SfxModule const * ); static void RegisterStatusBarControl(SfxModule*, const SfxStbCtrlFactory&); }; #define SFX_DECL_STATUSBAR_CONTROL() \ - static SfxStatusBarControl* CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ); \ + static rtl::Reference<SfxStatusBarControl> CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ); \ static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=nullptr) #define SFX_IMPL_STATUSBAR_CONTROL(Class, nItemClass) \ - SfxStatusBarControl* Class::CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ) \ + rtl::Reference<SfxStatusBarControl> Class::CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ) \ { return new Class( nSlotId, nId, rStb ); } \ void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \ { SfxStatusBarControl::RegisterStatusBarControl( pMod, SfxStbCtrlFactory( \ diff --git a/include/sfx2/tbxctrl.hxx b/include/sfx2/tbxctrl.hxx index 9ce86c659143..daa9d77b84ac 100644 --- a/include/sfx2/tbxctrl.hxx +++ b/include/sfx2/tbxctrl.hxx @@ -26,6 +26,7 @@ #include <svl/poolitem.hxx> #include <svtools/toolboxcontroller.hxx> #include <vcl/window.hxx> +#include <rtl/ref.hxx> namespace com::sun::star::frame { class XDispatchProvider; } namespace com::sun::star::frame { class XFrame; } @@ -34,9 +35,9 @@ class InterimItemWindow; class SfxToolBoxControl; class SfxModule; -svt::ToolboxController* SfxToolBoxControllerFactory( const css::uno::Reference< css::frame::XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const OUString& aCommandURL ); +rtl::Reference<svt::ToolboxController> SfxToolBoxControllerFactory( const css::uno::Reference< css::frame::XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const OUString& aCommandURL ); -typedef SfxToolBoxControl* (*SfxToolBoxControlCtor)( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rBox ); +typedef rtl::Reference<SfxToolBoxControl> (*SfxToolBoxControlCtor)( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rBox ); struct SfxTbxCtrlFactory { @@ -54,7 +55,7 @@ struct SfxTbxCtrlFactory #define SFX_DECL_TOOLBOX_CONTROL() \ - static SfxToolBoxControl* CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx ); \ + static rtl::Reference<SfxToolBoxControl> CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx ); \ static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=nullptr) /* For special ToolBox controls, such as a font selection box or toolbox @@ -115,19 +116,19 @@ public: css::uno::Sequence< css::beans::PropertyValue > const & aArgs ); static SfxItemState GetItemState( const SfxPoolItem* pState ); - static SfxToolBoxControl* CreateControl( sal_uInt16 nSlotId, sal_uInt16 nTbxId, ToolBox *pBox, SfxModule const *pMod ); + static rtl::Reference<SfxToolBoxControl> CreateControl( sal_uInt16 nSlotId, sal_uInt16 nTbxId, ToolBox *pBox, SfxModule const *pMod ); static void RegisterToolBoxControl( SfxModule*, const SfxTbxCtrlFactory&); }; #define SFX_IMPL_TOOLBOX_CONTROL(Class, nItemClass) \ - SfxToolBoxControl* Class::CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx ) \ + rtl::Reference<SfxToolBoxControl> Class::CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx ) \ { return new Class( nSlotId, nId, rTbx ); } \ void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \ { SfxToolBoxControl::RegisterToolBoxControl( pMod, SfxTbxCtrlFactory( \ Class::CreateImpl, typeid(nItemClass), nSlotId ) ); } #define SFX_IMPL_TOOLBOX_CONTROL_ARG(Class, nItemClass, Arg) \ - SfxToolBoxControl* Class::CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx ) \ + rtl::Reference<SfxToolBoxControl> Class::CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx ) \ { return new Class( nSlotId, nId, rTbx, Arg); } \ void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \ { SfxToolBoxControl::RegisterToolBoxControl( pMod, SfxTbxCtrlFactory( \ diff --git a/include/sfx2/thumbnailviewitem.hxx b/include/sfx2/thumbnailviewitem.hxx index 0b80df682dbf..82c98e2c482d 100644 --- a/include/sfx2/thumbnailviewitem.hxx +++ b/include/sfx2/thumbnailviewitem.hxx @@ -23,6 +23,7 @@ #include <drawinglayer/attribute/fontattribute.hxx> #include <vcl/bitmapex.hxx> #include <sfx2/dllapi.h> +#include <rtl/ref.hxx> namespace com::sun::star::accessibility { class XAccessible; } namespace drawinglayer::primitive2d { class Primitive2DContainer; } @@ -122,7 +123,7 @@ public: const ThumbnailItemAttributes *pAttrs); void addTextPrimitives (const OUString& rText, const ThumbnailItemAttributes *pAttrs, Point aPos, drawinglayer::primitive2d::Primitive2DContainer& rSeq); - static drawinglayer::primitive2d::PolygonHairlinePrimitive2D* + static rtl::Reference<drawinglayer::primitive2d::PolygonHairlinePrimitive2D> createBorderLine (const basegfx::B2DPolygon &rPolygon); virtual void MouseButtonUp(const MouseEvent&) {} diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx index 79a71c361c9b..e5ed6e3cb7f4 100644 --- a/sfx2/source/control/thumbnailviewitem.cxx +++ b/sfx2/source/control/thumbnailviewitem.cxx @@ -308,7 +308,7 @@ void ThumbnailViewItem::addTextPrimitives (const OUString& rText, const Thumbnai } } -drawinglayer::primitive2d::PolygonHairlinePrimitive2D* +rtl::Reference<drawinglayer::primitive2d::PolygonHairlinePrimitive2D> ThumbnailViewItem::createBorderLine (const basegfx::B2DPolygon& rPolygon) { return new PolygonHairlinePrimitive2D(rPolygon, Color(128, 128, 128).getBColor()); diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index 4312c241e32d..476b8c6ae41e 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -234,7 +234,7 @@ public: protected: virtual ~SfxDocumentMetaData() override {} - virtual SfxDocumentMetaData* createMe( css::uno::Reference< css::uno::XComponentContext > const & context ) { return new SfxDocumentMetaData( context ); }; + virtual rtl::Reference<SfxDocumentMetaData> createMe( css::uno::Reference< css::uno::XComponentContext > const & context ) { return new SfxDocumentMetaData( context ); }; const css::uno::Reference< css::uno::XComponentContext > m_xContext; /// for notification @@ -307,7 +307,7 @@ class CompatWriterDocPropsImpl : public CompatWriterDocPropsImpl_BASE OUString msCategory; OUString msCompany; protected: - virtual SfxDocumentMetaData* createMe( css::uno::Reference< css::uno::XComponentContext > const & context ) override { return new CompatWriterDocPropsImpl( context ); }; + virtual rtl::Reference<SfxDocumentMetaData> createMe( css::uno::Reference< css::uno::XComponentContext > const & context ) override { return new CompatWriterDocPropsImpl( context ); }; public: explicit CompatWriterDocPropsImpl( css::uno::Reference< css::uno::XComponentContext > const & context) : CompatWriterDocPropsImpl_BASE( context ) {} @@ -1987,7 +1987,7 @@ SfxDocumentMetaData::createClone() ::osl::MutexGuard g(m_aMutex); checkInit(); - SfxDocumentMetaData *pNew = createMe(m_xContext); + rtl::Reference<SfxDocumentMetaData> pNew = createMe(m_xContext); // NB: do not copy the modification listeners, only DOM css::uno::Reference<css::xml::dom::XDocument> xDoc = createDOM(); diff --git a/sfx2/source/sidebar/ControllerFactory.cxx b/sfx2/source/sidebar/ControllerFactory.cxx index 24bb15c3ec98..d42a9ff807ce 100644 --- a/sfx2/source/sidebar/ControllerFactory.cxx +++ b/sfx2/source/sidebar/ControllerFactory.cxx @@ -59,13 +59,11 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController( // Create a controller for the new item. if ( !bFactoryHasController ) { - xController.set( - static_cast<XWeak*>(::framework::CreateToolBoxController( + xController = ::framework::CreateToolBoxController( rxFrame, pToolBox, nItemId, - rsCommandName)), - UNO_QUERY); + rsCommandName); } if ( ! xController.is()) { diff --git a/sfx2/source/statbar/stbitem.cxx b/sfx2/source/statbar/stbitem.cxx index 58dea92b8026..d8a360a54a62 100644 --- a/sfx2/source/statbar/stbitem.cxx +++ b/sfx2/source/statbar/stbitem.cxx @@ -66,7 +66,7 @@ sal_uInt16 SfxStatusBarControl::convertAwtToVCLMouseButtons( sal_Int16 nAwtMouse } -svt::StatusbarController* SfxStatusBarControllerFactory( +rtl::Reference<svt::StatusbarController> SfxStatusBarControllerFactory( const uno::Reference< frame::XFrame >& rFrame, StatusBar* pStatusBar, unsigned short nID, @@ -516,7 +516,7 @@ void SfxStatusBarControl::Paint } -SfxStatusBarControl* SfxStatusBarControl::CreateControl +rtl::Reference<SfxStatusBarControl> SfxStatusBarControl::CreateControl ( sal_uInt16 nSlotID, sal_uInt16 nStbId, diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx index 038b65d55914..efdd50a2ecd7 100644 --- a/sfx2/source/toolbox/tbxitem.cxx +++ b/sfx2/source/toolbox/tbxitem.cxx @@ -69,7 +69,7 @@ using namespace ::com::sun::star::ui; SFX_IMPL_TOOLBOX_CONTROL_ARG(SfxToolBoxControl, SfxStringItem, true); -svt::ToolboxController* SfxToolBoxControllerFactory( const Reference< XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const OUString& aCommandURL ) +rtl::Reference<svt::ToolboxController> SfxToolBoxControllerFactory( const Reference< XFrame >& rFrame, ToolBox* pToolbox, unsigned short nID, const OUString& aCommandURL ) { SolarMutexGuard aGuard; @@ -170,7 +170,7 @@ void SfxToolBoxControl::RegisterToolBoxControl( SfxModule* pMod, const SfxTbxCtr SfxGetpApp()->RegisterToolBoxControl_Impl( pMod, rFact ); } -SfxToolBoxControl* SfxToolBoxControl::CreateControl( sal_uInt16 nSlotId, sal_uInt16 nTbxId, ToolBox *pBox, SfxModule const * pMod ) +rtl::Reference<SfxToolBoxControl> SfxToolBoxControl::CreateControl( sal_uInt16 nSlotId, sal_uInt16 nTbxId, ToolBox *pBox, SfxModule const * pMod ) { SolarMutexGuard aGuard; @@ -184,7 +184,7 @@ SfxToolBoxControl* SfxToolBoxControl::CreateControl( sal_uInt16 nSlotId, sal_uIn const std::type_info* aSlotType = pSlotPool->GetSlotType( nSlotId ); if ( aSlotType ) { - SfxToolBoxControl *pCtrl; + rtl::Reference<SfxToolBoxControl> pCtrl; if ( pMod ) { SfxTbxCtrlFactArr_Impl *pFactories = pMod->GetTbxCtrlFactories_Impl(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits