diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-10 12:30:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-11 12:47:37 +0100 |
commit | e57a036939e27ecd173ace691689e26a6a33df8e (patch) | |
tree | a36d589da272c4732cddb4ca0548cdb5dcb2b2bd /unotools | |
parent | cb5d79b504aa8575ea15c777707c7465ea43cb07 (diff) |
loplugin:useuniqueptr in tools,stoc,unotools
Change-Id: Ia72b65577143623cedc7a40bc34f7fb897add097
Reviewed-on: https://gerrit.libreoffice.org/47726
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/source/i18n/intlwrapper.cxx | 9 | ||||
-rw-r--r-- | unotools/source/misc/syslocale.cxx | 17 | ||||
-rw-r--r-- | unotools/source/ucbhelper/tempfile.cxx | 17 |
3 files changed, 17 insertions, 26 deletions
diff --git a/unotools/source/i18n/intlwrapper.cxx b/unotools/source/i18n/intlwrapper.cxx index 63e47c71aed4..901f74394334 100644 --- a/unotools/source/i18n/intlwrapper.cxx +++ b/unotools/source/i18n/intlwrapper.cxx @@ -35,14 +35,11 @@ IntlWrapper::IntlWrapper( IntlWrapper::~IntlWrapper() { - delete pLocaleData; - delete pCollator; - delete pCaseCollator; } void IntlWrapper::ImplNewLocaleData() const { - const_cast<IntlWrapper*>(this)->pLocaleData = new LocaleDataWrapper( m_xContext, maLanguageTag ); + const_cast<IntlWrapper*>(this)->pLocaleData.reset( new LocaleDataWrapper( m_xContext, maLanguageTag ) ); } void IntlWrapper::ImplNewCollator( bool bCaseSensitive ) const @@ -51,13 +48,13 @@ void IntlWrapper::ImplNewCollator( bool bCaseSensitive ) const if ( bCaseSensitive ) { p->loadDefaultCollator( maLanguageTag.getLocale(), 0 ); - const_cast<IntlWrapper*>(this)->pCaseCollator = p; + const_cast<IntlWrapper*>(this)->pCaseCollator.reset(p); } else { p->loadDefaultCollator( maLanguageTag.getLocale(), css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE ); - const_cast<IntlWrapper*>(this)->pCollator = p; + const_cast<IntlWrapper*>(this)->pCollator.reset(p); } } diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx index 951ac9e3b4aa..017ec3b9c52c 100644 --- a/unotools/source/misc/syslocale.cxx +++ b/unotools/source/misc/syslocale.cxx @@ -32,6 +32,7 @@ #include <osl/nlsupport.h> #include <vector> +#include <memory> using namespace osl; using namespace com::sun::star; @@ -45,9 +46,9 @@ std::weak_ptr<SvtSysLocale_Impl> g_pSysLocale; class SvtSysLocale_Impl : public utl::ConfigurationListener { public: - SvtSysLocaleOptions aSysLocaleOptions; - LocaleDataWrapper* pLocaleData; - CharClass* pCharClass; + SvtSysLocaleOptions aSysLocaleOptions; + std::unique_ptr<LocaleDataWrapper> pLocaleData; + std::unique_ptr<CharClass> pCharClass; SvtSysLocale_Impl(); virtual ~SvtSysLocale_Impl() override; @@ -61,7 +62,7 @@ private: SvtSysLocale_Impl::SvtSysLocale_Impl() : pCharClass(nullptr) { - pLocaleData = new LocaleDataWrapper( aSysLocaleOptions.GetRealLanguageTag() ); + pLocaleData.reset(new LocaleDataWrapper( aSysLocaleOptions.GetRealLanguageTag() )); setDateAcceptancePatternsConfig(); // listen for further changes @@ -71,15 +72,13 @@ SvtSysLocale_Impl::SvtSysLocale_Impl() : pCharClass(nullptr) SvtSysLocale_Impl::~SvtSysLocale_Impl() { aSysLocaleOptions.RemoveListener( this ); - delete pCharClass; - delete pLocaleData; } CharClass* SvtSysLocale_Impl::GetCharClass() { if ( !pCharClass ) - pCharClass = new CharClass( aSysLocaleOptions.GetRealLanguageTag() ); - return pCharClass; + pCharClass.reset(new CharClass( aSysLocaleOptions.GetRealLanguageTag() )); + return pCharClass.get(); } void SvtSysLocale_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints nHint ) @@ -151,7 +150,7 @@ const LocaleDataWrapper& SvtSysLocale::GetLocaleData() const const LocaleDataWrapper* SvtSysLocale::GetLocaleDataPtr() const { - return pImpl->pLocaleData; + return pImpl->pLocaleData.get(); } const CharClass& SvtSysLocale::GetCharClass() const diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx index 47afc2ed82ce..9d4c717ed3ae 100644 --- a/unotools/source/ucbhelper/tempfile.cxx +++ b/unotools/source/ucbhelper/tempfile.cxx @@ -373,16 +373,15 @@ TempFile::TempFile( const OUString& rLeadingChars, bool _bStartWithZero, } TempFile::TempFile(TempFile && other): - aName(std::move(other.aName)), pStream(other.pStream), bIsDirectory(other.bIsDirectory), + aName(std::move(other.aName)), pStream(std::move(other.pStream)), bIsDirectory(other.bIsDirectory), bKillingFileEnabled(other.bKillingFileEnabled) { - other.pStream = nullptr; other.bKillingFileEnabled = false; } TempFile::~TempFile() { - delete pStream; + pStream.reset(); if ( bKillingFileEnabled ) { if ( bIsDirectory ) @@ -420,21 +419,17 @@ SvStream* TempFile::GetStream( StreamMode eMode ) if (!pStream) { if (!aName.isEmpty()) - pStream = new SvFileStream(aName, eMode); + pStream.reset(new SvFileStream(aName, eMode)); else - pStream = new SvMemoryStream(nullptr, 0, eMode); + pStream.reset(new SvMemoryStream(nullptr, 0, eMode)); } - return pStream; + return pStream.get(); } void TempFile::CloseStream() { - if ( pStream ) - { - delete pStream; - pStream = nullptr; - } + pStream.reset(); } OUString TempFile::SetTempNameBaseDirectory( const OUString &rBaseName ) |