Kaydet (Commit) 0415cb33 authored tarafından Noel Grandin's avatar Noel Grandin

new loplugin: useuniqueptr: sot..tools

Change-Id: Ided435d016ae28e7c3f2726e41eedd981572ae10
Reviewed-on: https://gerrit.libreoffice.org/33263Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst c3e6d123
......@@ -42,7 +42,8 @@ private:
::osl::Mutex maMutex;
css::uno::Reference< css::awt::XDevice> mxDevice;
vcl::Font maFont;
FontMetric* mpFontMetric;
std::unique_ptr<FontMetric>
mpFontMetric;
protected:
bool ImplAssertValidFontMetric();
......
......@@ -27,13 +27,15 @@
#include <tools/resid.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <tools/toolsdllapi.h>
#include <memory>
class InternalResMgr;
class TOOLS_DLLPUBLIC SimpleResMgr final
{
osl::Mutex m_aAccessSafety;
InternalResMgr* m_pResImpl;
std::unique_ptr<InternalResMgr>
m_pResImpl;
public:
/** creates a new SimpleResManager
......
......@@ -44,12 +44,11 @@ StgPage::StgPage( short nSize, sal_Int32 nPage )
OSL_ENSURE( mnSize >= 512, "Unexpected page size is provided!" );
// We will write this data to a permanent file later
// best to clear if first.
memset( mpData, 0, mnSize );
memset( mpData.get(), 0, mnSize );
}
StgPage::~StgPage()
{
delete [] mpData;
}
rtl::Reference< StgPage > StgPage::Create( short nData, sal_Int32 nPage )
......
......@@ -96,7 +96,8 @@ public:
class StgPage : public salhelper::SimpleReferenceObject
{
const sal_Int32 mnPage; // page index
sal_uInt8* mpData; // nSize bytes
std::unique_ptr<sal_uInt8>
mpData; // nSize bytes
short mnSize; // size of this page
StgPage( short nData, sal_Int32 nPage );
virtual ~StgPage() override;
......@@ -106,7 +107,7 @@ public:
static rtl::Reference< StgPage > Create( short nData, sal_Int32 nPage );
sal_Int32 GetPage() { return mnPage; }
void* GetData() { return mpData; }
void* GetData() { return mpData.get(); }
short GetSize() { return mnSize; }
public:
......
......@@ -36,7 +36,7 @@ StgInternalStream::StgInternalStream( BaseStorage& rStg, const OUString& rName,
StreamMode nMode = bWr
? StreamMode::WRITE | StreamMode::SHARE_DENYALL
: StreamMode::READ | StreamMode::SHARE_DENYWRITE | StreamMode::NOCREATE;
m_pStrm = rStg.OpenStream( rName, nMode );
m_pStrm.reset( rStg.OpenStream( rName, nMode ) );
// set the error code right here in the stream
SetError( rStg.GetError() );
......@@ -45,7 +45,6 @@ StgInternalStream::StgInternalStream( BaseStorage& rStg, const OUString& rName,
StgInternalStream::~StgInternalStream()
{
delete m_pStrm;
}
std::size_t StgInternalStream::GetData(void* pData, std::size_t nSize)
......
......@@ -27,7 +27,7 @@
class StgInternalStream : public SvStream
{
BaseStorageStream* m_pStrm;
std::unique_ptr<BaseStorageStream> m_pStrm;
virtual std::size_t GetData(void* pData, std::size_t nSize) override;
virtual std::size_t PutData(const void* pData, std::size_t nSize) override;
virtual sal_uInt64 SeekPos( sal_uInt64 nPos ) override;
......
......@@ -330,7 +330,6 @@ StgStrm::StgStrm( StgIo& r ) : m_rIo( r )
StgStrm::~StgStrm()
{
delete m_pFat;
}
// Attach the stream to the given entry.
......@@ -558,7 +557,7 @@ bool StgStrm::SetSize( sal_Int32 nBytes )
StgFATStrm::StgFATStrm( StgIo& r ) : StgStrm( r )
{
m_pFat = new StgFAT( *this, true );
m_pFat.reset( new StgFAT( *this, true ) );
m_nSize = m_rIo.m_aHdr.GetFATSize() * m_nPageSize;
}
......@@ -821,7 +820,7 @@ StgDataStrm::StgDataStrm( StgIo& r, StgDirEntry& p ) : StgStrm( r )
void StgDataStrm::Init( sal_Int32 nBgn, sal_Int32 nLen )
{
if ( m_rIo.m_pFAT )
m_pFat = new StgFAT( *m_rIo.m_pFAT, true );
m_pFat.reset( new StgFAT( *m_rIo.m_pFAT, true ) );
OSL_ENSURE( m_pFat, "The pointer should not be empty!" );
......@@ -1027,7 +1026,7 @@ StgSmallStrm::StgSmallStrm( StgIo& r, StgDirEntry& p ) : StgStrm( r )
void StgSmallStrm::Init( sal_Int32 nBgn, sal_Int32 nLen )
{
if ( m_rIo.m_pDataFAT )
m_pFat = new StgFAT( *m_rIo.m_pDataFAT, false );
m_pFat.reset( new StgFAT( *m_rIo.m_pDataFAT, false ) );
m_pData = m_rIo.m_pDataStrm;
OSL_ENSURE( m_pFat && m_pData, "The pointers should not be empty!" );
......
......@@ -62,7 +62,7 @@ public:
class StgStrm { // base class for all streams
protected:
StgIo& m_rIo; // I/O system
StgFAT* m_pFat; // FAT stream for allocations
std::unique_ptr<StgFAT> m_pFat; // FAT stream for allocations
StgDirEntry* m_pEntry; // dir entry (for ownership)
sal_Int32 m_nStart; // 1st data page
sal_Int32 m_nSize; // stream size in bytes
......
......@@ -42,6 +42,7 @@
#include <algorithm>
#endif
#include <unordered_map>
#include <memory>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
......@@ -229,9 +230,10 @@ public:
class CompoundIdlClassImpl
: public IdlClassImpl
{
css::uno::Reference< css::reflection::XIdlClass > _xSuperClass;
css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > * _pFields;
css::uno::Reference< css::reflection::XIdlClass >
_xSuperClass;
std::unique_ptr< css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > >
_pFields;
OUString2Field _aName2Field;
public:
......@@ -294,7 +296,7 @@ public:
class EnumIdlClassImpl
: public IdlClassImpl
{
css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > * _pFields;
std::unique_ptr< css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > > _pFields;
OUString2Field _aName2Field;
public:
......
......@@ -277,7 +277,6 @@ void IdlCompFieldImpl::set( Any & rObj, const Any & rValue )
CompoundIdlClassImpl::~CompoundIdlClassImpl()
{
delete _pFields;
}
......@@ -374,7 +373,7 @@ Sequence< Reference< XIdlField > > CompoundIdlClassImpl::getFields()
}
}
_pFields = pFields;
_pFields.reset( pFields );
}
return *_pFields;
}
......
......@@ -165,7 +165,6 @@ void IdlEnumFieldImpl::set( Any &, const Any & )
EnumIdlClassImpl::~EnumIdlClassImpl()
{
delete _pFields;
}
// IdlClassImpl modifications
......@@ -203,7 +202,7 @@ Sequence< Reference< XIdlField > > EnumIdlClassImpl::getFields()
getReflection(), aName, IdlClassImpl::getTypeDescr(), getTypeDescr()->pEnumValues[nFields] );
}
_pFields = pFields;
_pFields.reset( pFields );
}
}
return *_pFields;
......
......@@ -23,6 +23,7 @@
#include <cstddef>
#include <limits>
#include <map>
#include <memory>
#include <set>
#include <o3tl/any.hxx>
......@@ -209,7 +210,7 @@ class IntrospectionAccessStatic_Impl: public salhelper::SimpleReferenceObject
bool mbUnoTunnel;
// Original handles of FastPropertySets
sal_Int32* mpOrgPropertyHandleArray;
std::unique_ptr<sal_Int32[]> mpOrgPropertyHandleArray;
// MethodSequence, that accepts all methods
std::vector< Reference<XIdlMethod> > maAllMethodSeq;
......@@ -230,10 +231,6 @@ class IntrospectionAccessStatic_Impl: public salhelper::SimpleReferenceObject
public:
explicit IntrospectionAccessStatic_Impl( Reference< XIdlReflection > const & xCoreReflection_ );
virtual ~IntrospectionAccessStatic_Impl() override
{
delete[] mpOrgPropertyHandleArray;
}
sal_Int32 getPropertyIndex( const OUString& aPropertyName ) const;
sal_Int32 getMethodIndex( const OUString& aMethodName ) const;
......@@ -1779,7 +1776,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect(
// For a FastPropertySet we must remember the original handles
if( bFast )
pAccess->mpOrgPropertyHandleArray = new sal_Int32[ nLen ];
pAccess->mpOrgPropertyHandleArray.reset( new sal_Int32[ nLen ] );
for( i = 0 ; i < nLen ; i++ )
{
......
......@@ -40,15 +40,13 @@ VCLXFont::VCLXFont()
VCLXFont::~VCLXFont()
{
delete mpFontMetric;
}
void VCLXFont::Init( css::awt::XDevice& rxDev, const vcl::Font& rFont )
{
mxDevice = &rxDev;
delete mpFontMetric;
mpFontMetric = nullptr;
mpFontMetric.reset();
maFont = rFont;
}
......@@ -62,7 +60,7 @@ bool VCLXFont::ImplAssertValidFontMetric()
{
vcl::Font aOldFont = pOutDev->GetFont();
pOutDev->SetFont( maFont );
mpFontMetric = new FontMetric( pOutDev->GetFontMetric() );
mpFontMetric.reset( new FontMetric( pOutDev->GetFontMetric() ) );
pOutDev->SetFont( aOldFont );
}
}
......
......@@ -118,11 +118,12 @@ public:
bool mbSynthesizingVCLEvent : 1;
bool mbWithDefaultProps : 1;
sal_uLong mnListenerLockLevel;
sal_uLong mnListenerLockLevel;
sal_Int16 mnWritingMode;
sal_Int16 mnContextWritingMode;
UnoPropertyArrayHelper* mpPropHelper;
std::unique_ptr<UnoPropertyArrayHelper>
mpPropHelper;
css::uno::Reference< css::awt::XPointer >
mxPointer;
......@@ -224,7 +225,6 @@ VCLXWindowImpl::VCLXWindowImpl( VCLXWindow& _rAntiImpl, bool _bWithDefaultProps
VCLXWindowImpl::~VCLXWindowImpl()
{
delete mpPropHelper;
}
......@@ -2551,9 +2551,9 @@ VCLXWindow::GetPropHelper()
{
std::vector< sal_uInt16 > aIDs;
GetPropertyIds( aIDs );
mpImpl->mpPropHelper = new UnoPropertyArrayHelper( aIDs );
mpImpl->mpPropHelper.reset( new UnoPropertyArrayHelper( aIDs ) );
}
return mpImpl->mpPropHelper;
return mpImpl->mpPropHelper.get();
}
css::uno::Sequence< css::beans::Property > SAL_CALL
......
......@@ -94,7 +94,6 @@ class InternalResMgr
const OUString& aPrefix,
const OUString& aResName,
const LanguageTag& rLocale );
~InternalResMgr();
bool Create();
bool IsGlobalAvailable( RESOURCE_TYPE nRT, sal_uInt32 nId ) const;
......@@ -102,6 +101,7 @@ class InternalResMgr
void **pResHandle );
public:
static void FreeGlobalRes( void const *, void * );
~InternalResMgr();
};
class ResMgrContainer
......@@ -1414,13 +1414,12 @@ SimpleResMgr::SimpleResMgr( const sal_Char* pPrefixName,
if( aLocale.isSystemLocale() )
aLocale = ResMgrContainer::get().getDefLocale();
m_pResImpl = ResMgrContainer::get().getResMgr( aPrefix, aLocale, true );
m_pResImpl.reset(ResMgrContainer::get().getResMgr( aPrefix, aLocale, true ));
DBG_ASSERT( m_pResImpl, "SimpleResMgr::SimpleResMgr : have no impl class !" );
}
SimpleResMgr::~SimpleResMgr()
{
delete m_pResImpl;
}
SimpleResMgr* SimpleResMgr::Create(const sal_Char* pPrefixName, const LanguageTag& rLocale)
......@@ -1451,7 +1450,7 @@ OUString SimpleResMgr::ReadString( sal_uInt32 nId )
return sReturn;
void* pResHandle = nullptr;
InternalResMgr* pFallback = m_pResImpl;
InternalResMgr* pFallback = m_pResImpl.get();
RSHEADER_TYPE* pResHeader = static_cast<RSHEADER_TYPE*>(m_pResImpl->LoadGlobalRes( RSC_STRING, nId, &pResHandle ));
if ( !pResHeader )
{
......@@ -1462,7 +1461,7 @@ OUString SimpleResMgr::ReadString( sal_uInt32 nId )
{
InternalResMgr* pOldFallback = pFallback;
pFallback = ResMgrContainer::get().getNextFallback( pFallback );
if( pOldFallback != m_pResImpl )
if( pOldFallback != m_pResImpl.get() )
ResMgrContainer::get().freeResMgr( pOldFallback );
if( pFallback )
{
......@@ -1489,7 +1488,7 @@ OUString SimpleResMgr::ReadString( sal_uInt32 nId )
// not necessary with the current implementation which holds the string table permanently, but to be sure ....
// note: pFallback cannot be NULL here and is either the fallback or m_pResImpl
InternalResMgr::FreeGlobalRes( pResHeader, pResHandle );
if( m_pResImpl != pFallback )
if( m_pResImpl.get() != pFallback )
{
osl::Guard<osl::Mutex> aGuard2( getResMgrMutex() );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment