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

loplugin:useuniqueptr in I18nHelper

Change-Id: I46ba0150bc4ca39fd781b8b979e960df0cffc7d4
Reviewed-on: https://gerrit.libreoffice.org/53355Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 4acc2daa
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <vcl/dllapi.h> #include <vcl/dllapi.h>
#include <memory>
namespace com { namespace com {
namespace sun { namespace sun {
...@@ -51,8 +52,8 @@ class VCL_DLLPUBLIC I18nHelper ...@@ -51,8 +52,8 @@ class VCL_DLLPUBLIC I18nHelper
LanguageTag maLanguageTag; LanguageTag maLanguageTag;
css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::uno::XComponentContext > m_xContext;
LocaleDataWrapper* mpLocaleDataWrapper; std::unique_ptr<LocaleDataWrapper> mpLocaleDataWrapper;
utl::TransliterationWrapper* mpTransliterationWrapper; std::unique_ptr<utl::TransliterationWrapper> mpTransliterationWrapper;
bool mbTransliterateIgnoreCase; bool mbTransliterateIgnoreCase;
......
...@@ -48,11 +48,8 @@ vcl::I18nHelper::~I18nHelper() ...@@ -48,11 +48,8 @@ vcl::I18nHelper::~I18nHelper()
void vcl::I18nHelper::ImplDestroyWrappers() void vcl::I18nHelper::ImplDestroyWrappers()
{ {
delete mpLocaleDataWrapper; mpLocaleDataWrapper.reset();
mpLocaleDataWrapper = nullptr; mpTransliterationWrapper.reset();
delete mpTransliterationWrapper;
mpTransliterationWrapper= nullptr;
} }
utl::TransliterationWrapper& vcl::I18nHelper::ImplGetTransliterationWrapper() const utl::TransliterationWrapper& vcl::I18nHelper::ImplGetTransliterationWrapper() const
...@@ -63,7 +60,7 @@ utl::TransliterationWrapper& vcl::I18nHelper::ImplGetTransliterationWrapper() co ...@@ -63,7 +60,7 @@ utl::TransliterationWrapper& vcl::I18nHelper::ImplGetTransliterationWrapper() co
if ( mbTransliterateIgnoreCase ) if ( mbTransliterateIgnoreCase )
nModules |= TransliterationFlags::IGNORE_CASE; nModules |= TransliterationFlags::IGNORE_CASE;
const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper = new utl::TransliterationWrapper( m_xContext, nModules ); const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper.reset(new utl::TransliterationWrapper( m_xContext, nModules ));
const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper->loadModuleIfNeeded( maLanguageTag.getLanguageType() ); const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper->loadModuleIfNeeded( maLanguageTag.getLanguageType() );
} }
return *mpTransliterationWrapper; return *mpTransliterationWrapper;
...@@ -73,7 +70,7 @@ LocaleDataWrapper& vcl::I18nHelper::ImplGetLocaleDataWrapper() const ...@@ -73,7 +70,7 @@ LocaleDataWrapper& vcl::I18nHelper::ImplGetLocaleDataWrapper() const
{ {
if ( !mpLocaleDataWrapper ) if ( !mpLocaleDataWrapper )
{ {
const_cast<vcl::I18nHelper*>(this)->mpLocaleDataWrapper = new LocaleDataWrapper( m_xContext, maLanguageTag ); const_cast<vcl::I18nHelper*>(this)->mpLocaleDataWrapper.reset(new LocaleDataWrapper( m_xContext, maLanguageTag ));
} }
return *mpLocaleDataWrapper; return *mpLocaleDataWrapper;
} }
...@@ -118,8 +115,7 @@ sal_Int32 vcl::I18nHelper::CompareString( const OUString& rStr1, const OUString& ...@@ -118,8 +115,7 @@ sal_Int32 vcl::I18nHelper::CompareString( const OUString& rStr1, const OUString&
// Change mbTransliterateIgnoreCase and destroy the wrapper, next call to // Change mbTransliterateIgnoreCase and destroy the wrapper, next call to
// ImplGetTransliterationWrapper() will create a wrapper with the correct bIgnoreCase // ImplGetTransliterationWrapper() will create a wrapper with the correct bIgnoreCase
const_cast<vcl::I18nHelper*>(this)->mbTransliterateIgnoreCase = false; const_cast<vcl::I18nHelper*>(this)->mbTransliterateIgnoreCase = false;
delete const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper; const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper.reset();
const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper = nullptr;
} }
OUString aStr1( filterFormattingChars(rStr1) ); OUString aStr1( filterFormattingChars(rStr1) );
...@@ -136,8 +132,7 @@ bool vcl::I18nHelper::MatchString( const OUString& rStr1, const OUString& rStr2 ...@@ -136,8 +132,7 @@ bool vcl::I18nHelper::MatchString( const OUString& rStr1, const OUString& rStr2
// Change mbTransliterateIgnoreCase and destroy the wrapper, next call to // Change mbTransliterateIgnoreCase and destroy the wrapper, next call to
// ImplGetTransliterationWrapper() will create a wrapper with the correct bIgnoreCase // ImplGetTransliterationWrapper() will create a wrapper with the correct bIgnoreCase
const_cast<vcl::I18nHelper*>(this)->mbTransliterateIgnoreCase = true; const_cast<vcl::I18nHelper*>(this)->mbTransliterateIgnoreCase = true;
delete const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper; const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper.reset();
const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper = nullptr;
} }
OUString aStr1( filterFormattingChars(rStr1) ); OUString aStr1( filterFormattingChars(rStr1) );
......
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