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 @@
#include <osl/mutex.hxx>
#include <rtl/ustring.hxx>
#include <vcl/dllapi.h>
#include <memory>
namespace com {
namespace sun {
......@@ -51,8 +52,8 @@ class VCL_DLLPUBLIC I18nHelper
LanguageTag maLanguageTag;
css::uno::Reference< css::uno::XComponentContext > m_xContext;
LocaleDataWrapper* mpLocaleDataWrapper;
utl::TransliterationWrapper* mpTransliterationWrapper;
std::unique_ptr<LocaleDataWrapper> mpLocaleDataWrapper;
std::unique_ptr<utl::TransliterationWrapper> mpTransliterationWrapper;
bool mbTransliterateIgnoreCase;
......
......@@ -48,11 +48,8 @@ vcl::I18nHelper::~I18nHelper()
void vcl::I18nHelper::ImplDestroyWrappers()
{
delete mpLocaleDataWrapper;
mpLocaleDataWrapper = nullptr;
delete mpTransliterationWrapper;
mpTransliterationWrapper= nullptr;
mpLocaleDataWrapper.reset();
mpTransliterationWrapper.reset();
}
utl::TransliterationWrapper& vcl::I18nHelper::ImplGetTransliterationWrapper() const
......@@ -63,7 +60,7 @@ utl::TransliterationWrapper& vcl::I18nHelper::ImplGetTransliterationWrapper() co
if ( mbTransliterateIgnoreCase )
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() );
}
return *mpTransliterationWrapper;
......@@ -73,7 +70,7 @@ LocaleDataWrapper& vcl::I18nHelper::ImplGetLocaleDataWrapper() const
{
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;
}
......@@ -118,8 +115,7 @@ sal_Int32 vcl::I18nHelper::CompareString( const OUString& rStr1, const OUString&
// Change mbTransliterateIgnoreCase and destroy the wrapper, next call to
// ImplGetTransliterationWrapper() will create a wrapper with the correct bIgnoreCase
const_cast<vcl::I18nHelper*>(this)->mbTransliterateIgnoreCase = false;
delete const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper;
const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper = nullptr;
const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper.reset();
}
OUString aStr1( filterFormattingChars(rStr1) );
......@@ -136,8 +132,7 @@ bool vcl::I18nHelper::MatchString( const OUString& rStr1, const OUString& rStr2
// Change mbTransliterateIgnoreCase and destroy the wrapper, next call to
// ImplGetTransliterationWrapper() will create a wrapper with the correct bIgnoreCase
const_cast<vcl::I18nHelper*>(this)->mbTransliterateIgnoreCase = true;
delete const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper;
const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper = nullptr;
const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper.reset();
}
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