summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2021-02-23 09:41:33 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-02-23 09:25:07 +0100
commita079e9010398ba2c33cf2509ff511e711b5e5b37 (patch)
tree70c7513515f3e827694c2084318237131f6ae7c9 /toolkit
parent0bbb687d37f6493956259fe8486820618a28af0b (diff)
loplugin:refcounting in toolkit
Change-Id: I4a65ee848eed7c48340c73d3144b4a1e29ab867c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111370 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/inc/controls/accessiblecontrolcontext.hxx4
-rw-r--r--toolkit/inc/controls/geometrycontrolmodel.hxx2
-rw-r--r--toolkit/inc/controls/roadmapentry.hxx2
-rw-r--r--toolkit/source/awt/vclxaccessiblecomponent.cxx12
-rw-r--r--toolkit/source/awt/vclxdevice.cxx11
-rw-r--r--toolkit/source/awt/vclxgraphics.cxx2
-rw-r--r--toolkit/source/awt/vclxprinter.cxx2
-rw-r--r--toolkit/source/awt/vclxtoolkit.cxx12
-rw-r--r--toolkit/source/awt/vclxwindow.cxx2
-rw-r--r--toolkit/source/awt/vclxwindows.cxx2
-rw-r--r--toolkit/source/controls/accessiblecontrolcontext.cxx6
-rw-r--r--toolkit/source/controls/controlmodelcontainerbase.cxx6
-rw-r--r--toolkit/source/controls/dialogcontrol.cxx8
-rw-r--r--toolkit/source/controls/roadmapcontrol.cxx8
-rw-r--r--toolkit/source/helper/unowrapper.cxx6
-rw-r--r--toolkit/source/helper/vclunohelper.cxx9
16 files changed, 44 insertions, 50 deletions
diff --git a/toolkit/inc/controls/accessiblecontrolcontext.hxx b/toolkit/inc/controls/accessiblecontrolcontext.hxx
index 6a07e3e89865..ea4f959b853e 100644
--- a/toolkit/inc/controls/accessiblecontrolcontext.hxx
+++ b/toolkit/inc/controls/accessiblecontrolcontext.hxx
@@ -58,14 +58,14 @@ namespace toolkit
the uno control's XAccessible interface. This must be an XControl, from which an XControlModel
can be retrieved.
*/
- static OAccessibleControlContext* create(
+ static rtl::Reference<OAccessibleControlContext> create(
const css::uno::Reference< css::accessibility::XAccessible >& _rxCreator
);
- private:
// XInterface
DECLARE_XINTERFACE( )
DECLARE_XTYPEPROVIDER( )
+ private:
// XAccessibleContext
virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override;
diff --git a/toolkit/inc/controls/geometrycontrolmodel.hxx b/toolkit/inc/controls/geometrycontrolmodel.hxx
index 8c1109c30396..2d87f7cca2af 100644
--- a/toolkit/inc/controls/geometrycontrolmodel.hxx
+++ b/toolkit/inc/controls/geometrycontrolmodel.hxx
@@ -103,11 +103,13 @@ namespace com::sun::star {
// XAggregation
css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _aType ) override;
+ public:
// XInterface
virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
virtual void SAL_CALL acquire( ) throw() override;
virtual void SAL_CALL release( ) throw() override;
+ protected:
// XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
diff --git a/toolkit/inc/controls/roadmapentry.hxx b/toolkit/inc/controls/roadmapentry.hxx
index 81aa9b74dff0..b8490439c99c 100644
--- a/toolkit/inc/controls/roadmapentry.hxx
+++ b/toolkit/inc/controls/roadmapentry.hxx
@@ -42,10 +42,10 @@ class ORoadmapEntry final : public ORoadmapEntry_Base
public:
ORoadmapEntry();
-private:
DECLARE_XINTERFACE() // merge XInterface implementations
DECLARE_XTYPEPROVIDER() // merge XTypeProvider implementations
+private:
/// @see css::beans::XPropertySet
virtual css::uno::Reference< css::beans::XPropertySetInfo >
SAL_CALL getPropertySetInfo() override;
diff --git a/toolkit/source/awt/vclxaccessiblecomponent.cxx b/toolkit/source/awt/vclxaccessiblecomponent.cxx
index 9ce8f6a61d7c..101307bf1d96 100644
--- a/toolkit/source/awt/vclxaccessiblecomponent.cxx
+++ b/toolkit/source/awt/vclxaccessiblecomponent.cxx
@@ -631,20 +631,18 @@ uno::Reference< accessibility::XAccessibleRelationSet > VCLXAccessibleComponent:
{
OExternalLockGuard aGuard( this );
- utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
- uno::Reference< accessibility::XAccessibleRelationSet > xSet = pRelationSetHelper;
+ rtl::Reference<utl::AccessibleRelationSetHelper> pRelationSetHelper = new utl::AccessibleRelationSetHelper;
FillAccessibleRelationSet( *pRelationSetHelper );
- return xSet;
+ return pRelationSetHelper;
}
uno::Reference< accessibility::XAccessibleStateSet > VCLXAccessibleComponent::getAccessibleStateSet( )
{
OExternalLockGuard aGuard( this );
- utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
- uno::Reference< accessibility::XAccessibleStateSet > xSet = pStateSetHelper;
+ rtl::Reference<utl::AccessibleStateSetHelper> pStateSetHelper = new utl::AccessibleStateSetHelper;
FillAccessibleStateSet( *pStateSetHelper );
- return xSet;
+ return pStateSetHelper;
}
lang::Locale VCLXAccessibleComponent::getLocale()
@@ -790,7 +788,7 @@ uno::Reference< awt::XFont > SAL_CALL VCLXAccessibleComponent::getFont( )
aFont = pWindow->GetControlFont();
else
aFont = pWindow->GetFont();
- VCLXFont* pVCLXFont = new VCLXFont;
+ rtl::Reference<VCLXFont> pVCLXFont = new VCLXFont;
pVCLXFont->Init( *xDev, aFont );
xFont = pVCLXFont;
}
diff --git a/toolkit/source/awt/vclxdevice.cxx b/toolkit/source/awt/vclxdevice.cxx
index ba382248c0fd..d82e1a6ec905 100644
--- a/toolkit/source/awt/vclxdevice.cxx
+++ b/toolkit/source/awt/vclxdevice.cxx
@@ -70,7 +70,7 @@ css::uno::Reference< css::awt::XDevice > VCLXDevice::createDevice( sal_Int32 nWi
css::uno::Reference< css::awt::XDevice > xRef;
if ( GetOutputDevice() )
{
- VCLXVirtualDevice* pVDev = new VCLXVirtualDevice;
+ rtl::Reference<VCLXVirtualDevice> pVDev = new VCLXVirtualDevice;
VclPtrInstance<VirtualDevice> pVclVDev( *GetOutputDevice() );
pVclVDev->SetOutputSizePixel( Size( nWidth, nHeight ) );
pVDev->SetVirtualDevice( pVclVDev );
@@ -117,7 +117,7 @@ css::uno::Reference< css::awt::XFont > VCLXDevice::getFont( const css::awt::Font
css::uno::Reference< css::awt::XFont > xRef;
if( mpOutputDevice )
{
- VCLXFont* pMetric = new VCLXFont;
+ rtl::Reference<VCLXFont> pMetric = new VCLXFont;
pMetric->Init( *this, VCLUnoHelper::CreateFont( rDescriptor, mpOutputDevice->GetFont() ) );
xRef = pMetric;
}
@@ -133,7 +133,7 @@ css::uno::Reference< css::awt::XBitmap > VCLXDevice::createBitmap( sal_Int32 nX,
{
BitmapEx aBmp = mpOutputDevice->GetBitmapEx( Point( nX, nY ), Size( nWidth, nHeight ) );
- VCLXBitmap* pBmp = new VCLXBitmap;
+ rtl::Reference<VCLXBitmap> pBmp = new VCLXBitmap;
pBmp->SetBitmap( aBmp );
xBmp = pBmp;
}
@@ -145,10 +145,9 @@ css::uno::Reference< css::awt::XDisplayBitmap > VCLXDevice::createDisplayBitmap(
SolarMutexGuard aGuard;
BitmapEx aBmp = VCLUnoHelper::GetBitmap( rxBitmap );
- VCLXBitmap* pBmp = new VCLXBitmap;
+ rtl::Reference<VCLXBitmap> pBmp = new VCLXBitmap;
pBmp->SetBitmap( aBmp );
- css::uno::Reference< css::awt::XDisplayBitmap > xDBmp = pBmp;
- return xDBmp;
+ return pBmp;
}
VCLXVirtualDevice::~VCLXVirtualDevice()
diff --git a/toolkit/source/awt/vclxgraphics.cxx b/toolkit/source/awt/vclxgraphics.cxx
index 3125a0341030..5e9fc634bf39 100644
--- a/toolkit/source/awt/vclxgraphics.cxx
+++ b/toolkit/source/awt/vclxgraphics.cxx
@@ -130,7 +130,7 @@ uno::Reference< awt::XDevice > VCLXGraphics::getDevice()
if( !mxDevice.is() && mpOutputDevice )
{
- VCLXDevice* pDev = new VCLXDevice;
+ rtl::Reference<VCLXDevice> pDev = new VCLXDevice;
pDev->SetOutputDevice( mpOutputDevice );
mxDevice = pDev;
}
diff --git a/toolkit/source/awt/vclxprinter.cxx b/toolkit/source/awt/vclxprinter.cxx
index 51ced99ea3cc..be107498c1d8 100644
--- a/toolkit/source/awt/vclxprinter.cxx
+++ b/toolkit/source/awt/vclxprinter.cxx
@@ -67,7 +67,7 @@ css::uno::Reference< css::awt::XDevice > const & VCLXPrinterPropertySet::GetDev
{
if ( !mxPrnDevice.is() )
{
- VCLXDevice* pDev = new VCLXDevice;
+ rtl::Reference<VCLXDevice> pDev = new VCLXDevice;
pDev->SetOutputDevice( GetPrinter() );
mxPrnDevice = pDev;
}
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index 11f04d9dc0cd..efc0a27876bd 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -1021,8 +1021,7 @@ css::uno::Reference< css::awt::XDevice > VCLXToolkit::createScreenCompatibleDevi
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
- css::uno::Reference< css::awt::XDevice > xRef;
- VCLXVirtualDevice* pVDev = new VCLXVirtualDevice;
+ rtl::Reference<VCLXVirtualDevice> pVDev = new VCLXVirtualDevice;
SolarMutexGuard aSolarGuard;
@@ -1030,8 +1029,7 @@ css::uno::Reference< css::awt::XDevice > VCLXToolkit::createScreenCompatibleDevi
pV->SetOutputSizePixel( Size( Width, Height ) );
pVDev->SetVirtualDevice( pV );
- xRef = pVDev;
- return xRef;
+ return pVDev;
}
css::uno::Reference< css::awt::XRegion > VCLXToolkit::createRegion( )
@@ -1804,7 +1802,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( rtl::Reference<VCLXWindow>* ppNewCom
}
else if (aServiceName == "tree")
{
- TreeControlPeer* pPeer = new TreeControlPeer;
+ rtl::Reference<TreeControlPeer> pPeer = new TreeControlPeer;
*ppNewComp = pPeer;
pNewWindow = pPeer->createVclControl( pParent, nWinBits );
}
@@ -1829,7 +1827,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( rtl::Reference<VCLXWindow>* ppNewCom
static_cast<CalendarField*>(pNewWindow.get())->EnableToday();
static_cast<CalendarField*>(pNewWindow.get())->EnableNone();
static_cast<CalendarField*>(pNewWindow.get())->EnableEmptyFieldValue( true );
- SVTXDateField * newComp = new SVTXDateField;
+ rtl::Reference<SVTXDateField> newComp = new SVTXDateField;
*ppNewComp = newComp;
newComp->SetFormatter( static_cast<FormatterBase*>(static_cast<DateField*>(pNewWindow.get())) );
}
@@ -2045,7 +2043,7 @@ css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::createSystemChild( con
css::uno::Reference< css::awt::XWindowPeer > xPeer;
if ( pChildWindow )
{
- VCLXTopWindow* pPeer = new VCLXTopWindow;
+ rtl::Reference<VCLXTopWindow> pPeer = new VCLXTopWindow;
SolarMutexGuard aGuard;
pPeer->SetWindow( pChildWindow );
xPeer = pPeer;
diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx
index 1e7c15918ab4..1799022f553f 100644
--- a/toolkit/source/awt/vclxwindow.cxx
+++ b/toolkit/source/awt/vclxwindow.cxx
@@ -1888,7 +1888,7 @@ css::uno::Any VCLXWindow::getProperty( const OUString& PropertyName )
if ( !pControl )
break;
- VCLXDevice* pDevice = new VCLXDevice;
+ rtl::Reference<VCLXDevice> pDevice = new VCLXDevice;
pDevice->SetOutputDevice( pControl->GetReferenceDevice() );
aProp <<= Reference< XDevice >( pDevice );
}
diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx
index 56792659f9b4..15ac50d88ef9 100644
--- a/toolkit/source/awt/vclxwindows.cxx
+++ b/toolkit/source/awt/vclxwindows.cxx
@@ -7275,7 +7275,7 @@ void SVTXFormattedField::setFormatsSupplier(const css::uno::Reference< css::util
{
VclPtr<FormattedField> pField = GetAs< FormattedField >();
- SvNumberFormatsSupplierObj* pNew = nullptr;
+ rtl::Reference<SvNumberFormatsSupplierObj> pNew;
if (!xSupplier.is())
{
if (pField)
diff --git a/toolkit/source/controls/accessiblecontrolcontext.cxx b/toolkit/source/controls/accessiblecontrolcontext.cxx
index cf4cf7207749..5b4be7ed0d84 100644
--- a/toolkit/source/controls/accessiblecontrolcontext.cxx
+++ b/toolkit/source/controls/accessiblecontrolcontext.cxx
@@ -85,9 +85,9 @@ namespace toolkit
}
- OAccessibleControlContext* OAccessibleControlContext::create( const Reference< XAccessible >& _rxCreator )
+ rtl::Reference<OAccessibleControlContext> OAccessibleControlContext::create( const Reference< XAccessible >& _rxCreator )
{
- OAccessibleControlContext* pNew = nullptr;
+ rtl::Reference<OAccessibleControlContext> pNew;
try
{
pNew = new OAccessibleControlContext;
@@ -170,7 +170,7 @@ namespace toolkit
::osl::MutexGuard aGuard( GetMutex() );
// no OContextEntryGuard here, as we do not want to throw an exception in case we're not alive anymore
- ::utl::AccessibleStateSetHelper* pStateSet = nullptr;
+ rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet;
if ( isAlive() )
{
// no own states, only the ones which are foreign controlled
diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx b/toolkit/source/controls/controlmodelcontainerbase.cxx
index 6c5aedde4776..42ccde3b6592 100644
--- a/toolkit/source/controls/controlmodelcontainerbase.cxx
+++ b/toolkit/source/controls/controlmodelcontainerbase.cxx
@@ -265,7 +265,7 @@ void ControlModelContainerBase::Clone_Impl(ControlModelContainerBase& _rClone) c
rtl::Reference<UnoControlModel> ControlModelContainerBase::Clone() const
{
// clone the container itself
- ControlModelContainerBase* pClone = new ControlModelContainerBase( *this );
+ rtl::Reference<ControlModelContainerBase> pClone = new ControlModelContainerBase( *this );
Clone_Impl(*pClone);
return pClone;
@@ -281,7 +281,7 @@ Reference< XInterface > ControlModelContainerBase::createInstance( const OUStrin
{
SolarMutexGuard aGuard;
- OGeometryControlModel_Base* pNewModel = nullptr;
+ rtl::Reference<OGeometryControlModel_Base> pNewModel;
if ( aServiceSpecifier == "com.sun.star.awt.UnoControlEditModel" )
pNewModel = new OGeometryControlModel< UnoControlEditModel >( m_xContext );
@@ -360,7 +360,7 @@ Reference< XInterface > ControlModelContainerBase::createInstance( const OUStrin
}
}
- Reference< XInterface > xNewModel = static_cast<cppu::OWeakObject*>(pNewModel);
+ Reference< XInterface > xNewModel = static_cast<cppu::OWeakObject*>(pNewModel.get());
return xNewModel;
}
diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx
index bf035e3bcfa6..b2563f4e8261 100644
--- a/toolkit/source/controls/dialogcontrol.cxx
+++ b/toolkit/source/controls/dialogcontrol.cxx
@@ -211,7 +211,7 @@ UnoControlDialogModel::UnoControlDialogModel( const UnoControlDialogModel& rMode
rtl::Reference<UnoControlModel> UnoControlDialogModel::Clone() const
{
// clone the container itself
- UnoControlDialogModel* pClone = new UnoControlDialogModel( *this );
+ rtl::Reference<UnoControlDialogModel> pClone = new UnoControlDialogModel( *this );
Clone_Impl(*pClone);
@@ -870,7 +870,7 @@ UnoMultiPageModel::~UnoMultiPageModel()
rtl::Reference<UnoControlModel> UnoMultiPageModel::Clone() const
{
// clone the container itself
- UnoMultiPageModel* pClone = new UnoMultiPageModel( *this );
+ rtl::Reference<UnoMultiPageModel> pClone = new UnoMultiPageModel( *this );
Clone_Impl( *pClone );
return pClone;
}
@@ -976,7 +976,7 @@ UnoPageModel::~UnoPageModel()
rtl::Reference<UnoControlModel> UnoPageModel::Clone() const
{
// clone the container itself
- UnoPageModel* pClone = new UnoPageModel( *this );
+ rtl::Reference<UnoPageModel> pClone = new UnoPageModel( *this );
Clone_Impl( *pClone );
return pClone;
}
@@ -1122,7 +1122,7 @@ UnoFrameModel::~UnoFrameModel()
rtl::Reference<UnoControlModel> UnoFrameModel::Clone() const
{
// clone the container itself
- UnoFrameModel* pClone = new UnoFrameModel( *this );
+ rtl::Reference<UnoFrameModel> pClone = new UnoFrameModel( *this );
Clone_Impl( *pClone );
return pClone;
}
diff --git a/toolkit/source/controls/roadmapcontrol.cxx b/toolkit/source/controls/roadmapcontrol.cxx
index 0a0006014981..4bf888811ee2 100644
--- a/toolkit/source/controls/roadmapcontrol.cxx
+++ b/toolkit/source/controls/roadmapcontrol.cxx
@@ -128,8 +128,8 @@ static void lcl_throwIndexOutOfBoundsException( )
Reference< XInterface > SAL_CALL UnoControlRoadmapModel::createInstance( )
{
- ORoadmapEntry* pRoadmapItem = new ORoadmapEntry();
- Reference< XInterface > xNewRoadmapItem = static_cast<cppu::OWeakObject*>(pRoadmapItem);
+ rtl::Reference<ORoadmapEntry> pRoadmapItem = new ORoadmapEntry();
+ Reference< XInterface > xNewRoadmapItem = static_cast<cppu::OWeakObject*>(pRoadmapItem.get());
return xNewRoadmapItem;
}
@@ -137,8 +137,8 @@ static void lcl_throwIndexOutOfBoundsException( )
Reference< XInterface > SAL_CALL UnoControlRoadmapModel::createInstanceWithArguments( const Sequence< Any >& /*aArguments*/ )
{
// Todo: implementation of the arguments handling
- ORoadmapEntry* pRoadmapItem = new ORoadmapEntry();
- Reference< XInterface > xNewRoadmapItem = static_cast<cppu::OWeakObject*>(pRoadmapItem);
+ rtl::Reference<ORoadmapEntry> pRoadmapItem = new ORoadmapEntry();
+ Reference< XInterface > xNewRoadmapItem = static_cast<cppu::OWeakObject*>(pRoadmapItem.get());
return xNewRoadmapItem;
}
diff --git a/toolkit/source/helper/unowrapper.cxx b/toolkit/source/helper/unowrapper.cxx
index c3240eee2c4b..df689f8bc02e 100644
--- a/toolkit/source/helper/unowrapper.cxx
+++ b/toolkit/source/helper/unowrapper.cxx
@@ -187,11 +187,9 @@ css::uno::Reference<css::awt::XPopupMenu> UnoWrapper::CreateMenuInterface( Popup
css::uno::Reference< css::awt::XGraphics> UnoWrapper::CreateGraphics( OutputDevice* pOutDev )
{
- css::uno::Reference< css::awt::XGraphics> xGrf;
- VCLXGraphics* pGrf = new VCLXGraphics;
- xGrf = pGrf;
+ rtl::Reference<VCLXGraphics> pGrf = new VCLXGraphics;
pGrf->Init( pOutDev );
- return xGrf;
+ return pGrf;
}
void UnoWrapper::ReleaseAllGraphics( OutputDevice* pOutDev )
diff --git a/toolkit/source/helper/vclunohelper.cxx b/toolkit/source/helper/vclunohelper.cxx
index 62ad182d38af..3ef71e8aab07 100644
--- a/toolkit/source/helper/vclunohelper.cxx
+++ b/toolkit/source/helper/vclunohelper.cxx
@@ -187,13 +187,12 @@ tools::Polygon VCLUnoHelper::CreatePolygon( const css::uno::Sequence< sal_Int32
css::uno::Reference< css::awt::XControlContainer> VCLUnoHelper::CreateControlContainer( vcl::Window* pWindow )
{
- UnoControlContainer* pContainer = new UnoControlContainer( pWindow->GetComponentInterface() );
- css::uno::Reference< css::awt::XControlContainer > x = pContainer;
+ rtl::Reference<UnoControlContainer> pContainer = new UnoControlContainer( pWindow->GetComponentInterface() );
- UnoControlModel* pContainerModel = new UnoControlContainerModel( ::comphelper::getProcessComponentContext() );
- pContainer->setModel( static_cast<css::awt::XControlModel*>(pContainerModel) );
+ rtl::Reference<UnoControlModel> pContainerModel = new UnoControlContainerModel( ::comphelper::getProcessComponentContext() );
+ pContainer->setModel( pContainerModel );
- return x;
+ return pContainer;
}
css::awt::FontDescriptor VCLUnoHelper::CreateFontDescriptor( const vcl::Font& rFont )