From dd286c3874c3afe6bd37b7cd63c9163c172834f8 Mon Sep 17 00:00:00 2001 From: Jochen Nitschke Date: Wed, 28 Dec 2016 14:51:34 +0100 Subject: use unique_ptr for xdictionary default destructors are good enough now Change-Id: I6d4ab68d2ee527f5f4e5696c3f093dc66cdc5b4c Reviewed-on: https://gerrit.libreoffice.org/32492 Tested-by: Jenkins Reviewed-by: Noel Grandin --- i18npool/inc/breakiterator_cjk.hxx | 5 ++- .../source/breakiterator/breakiterator_cjk.cxx | 45 +++++++--------------- 2 files changed, 16 insertions(+), 34 deletions(-) (limited to 'i18npool') diff --git a/i18npool/inc/breakiterator_cjk.hxx b/i18npool/inc/breakiterator_cjk.hxx index 8731745385c6..9429176cd72e 100644 --- a/i18npool/inc/breakiterator_cjk.hxx +++ b/i18npool/inc/breakiterator_cjk.hxx @@ -22,6 +22,8 @@ #include #include +#include + namespace com { namespace sun { namespace star { namespace i18n { // class BreakIterator_CJK @@ -46,7 +48,7 @@ public: throw(css::uno::RuntimeException, std::exception) override; protected: - xdictionary *dict; + std::unique_ptr m_xDict; OUString hangingCharacters; }; @@ -54,7 +56,6 @@ protected: class BreakIterator_##lang : public BreakIterator_CJK {\ public:\ BreakIterator_##lang (); \ - virtual ~BreakIterator_##lang () override; \ }; BREAKITERATOR_CJK( zh ) diff --git a/i18npool/source/breakiterator/breakiterator_cjk.cxx b/i18npool/source/breakiterator/breakiterator_cjk.cxx index c9268b3e3439..167b942e040e 100644 --- a/i18npool/source/breakiterator/breakiterator_cjk.cxx +++ b/i18npool/source/breakiterator/breakiterator_cjk.cxx @@ -21,6 +21,8 @@ #include #include +#include + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -30,9 +32,7 @@ namespace com { namespace sun { namespace star { namespace i18n { // class BreakIterator_CJK // ----------------------------------------------------; -BreakIterator_CJK::BreakIterator_CJK() : - dict( nullptr ), - hangingCharacters() +BreakIterator_CJK::BreakIterator_CJK() { cBreakIterator = "com.sun.star.i18n.BreakIterator_CJK"; } @@ -41,8 +41,8 @@ Boundary SAL_CALL BreakIterator_CJK::previousWord(const OUString& text, sal_Int32 anyPos, const lang::Locale& nLocale, sal_Int16 wordType) throw(RuntimeException, std::exception) { - if (dict) { - result = dict->previousWord(text, anyPos, wordType); + if (m_xDict) { + result = m_xDict->previousWord(text, anyPos, wordType); // #109813# for non-CJK, single character word, fallback to ICU breakiterator. if (result.endPos - result.startPos != 1 || getScriptType(text, result.startPos) == ScriptType::ASIAN) @@ -58,8 +58,8 @@ Boundary SAL_CALL BreakIterator_CJK::nextWord(const OUString& text, sal_Int32 anyPos, const lang::Locale& nLocale, sal_Int16 wordType) throw(RuntimeException, std::exception) { - if (dict) { - result = dict->nextWord(text, anyPos, wordType); + if (m_xDict) { + result = m_xDict->nextWord(text, anyPos, wordType); // #109813# for non-CJK, single character word, fallback to ICU breakiterator. if (result.endPos - result.startPos != 1 || getScriptType(text, result.startPos) == ScriptType::ASIAN) @@ -76,8 +76,8 @@ BreakIterator_CJK::getWordBoundary( const OUString& text, sal_Int32 anyPos, const lang::Locale& nLocale, sal_Int16 wordType, sal_Bool bDirection ) throw(RuntimeException, std::exception) { - if (dict) { - result = dict->getWordBoundary(text, anyPos, wordType, bDirection); + if (m_xDict) { + result = m_xDict->getWordBoundary(text, anyPos, wordType, bDirection); // #109813# for non-CJK, single character word, fallback to ICU breakiterator. if (result.endPos - result.startPos != 1 || getScriptType(text, result.startPos) == ScriptType::ASIAN) @@ -116,47 +116,32 @@ LineBreakResults SAL_CALL BreakIterator_CJK::getLineBreak( // ----------------------------------------------------; BreakIterator_zh::BreakIterator_zh() { - dict = new xdictionary("zh"); + m_xDict = o3tl::make_unique("zh"); hangingCharacters = LocaleDataImpl::get()->getHangingCharacters(LOCALE("zh", "CN")); cBreakIterator = "com.sun.star.i18n.BreakIterator_zh"; } -BreakIterator_zh::~BreakIterator_zh() -{ - delete dict; -} - // ---------------------------------------------------- // class BreakIterator_zh_TW // ----------------------------------------------------; BreakIterator_zh_TW::BreakIterator_zh_TW() { - dict = new xdictionary("zh"); + m_xDict = o3tl::make_unique("zh"); hangingCharacters = LocaleDataImpl::get()->getHangingCharacters(LOCALE("zh", "TW")); cBreakIterator = "com.sun.star.i18n.BreakIterator_zh_TW"; } -BreakIterator_zh_TW::~BreakIterator_zh_TW() -{ - delete dict; -} - // ---------------------------------------------------- // class BreakIterator_ja // ----------------------------------------------------; BreakIterator_ja::BreakIterator_ja() { - dict = new xdictionary("ja"); - dict->setJapaneseWordBreak(); + m_xDict = o3tl::make_unique("ja"); + m_xDict->setJapaneseWordBreak(); hangingCharacters = LocaleDataImpl::get()->getHangingCharacters(LOCALE("ja", "JP")); cBreakIterator = "com.sun.star.i18n.BreakIterator_ja"; } -BreakIterator_ja::~BreakIterator_ja() -{ - delete dict; -} - // ---------------------------------------------------- // class BreakIterator_ko // ----------------------------------------------------; @@ -166,10 +151,6 @@ BreakIterator_ko::BreakIterator_ko() cBreakIterator = "com.sun.star.i18n.BreakIterator_ko"; } -BreakIterator_ko::~BreakIterator_ko() -{ -} - } } } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit