i18npool/inc/breakiterator_cjk.hxx | 5 +- i18npool/source/breakiterator/breakiterator_cjk.cxx | 45 +++++--------------- 2 files changed, 16 insertions(+), 34 deletions(-)
New commits: commit dd286c3874c3afe6bd37b7cd63c9163c172834f8 Author: Jochen Nitschke <j.nitschke+loger...@ok.de> Date: Wed Dec 28 14:51:34 2016 +0100 use unique_ptr for xdictionary default destructors are good enough now Change-Id: I6d4ab68d2ee527f5f4e5696c3f093dc66cdc5b4c Reviewed-on: https://gerrit.libreoffice.org/32492 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/i18npool/inc/breakiterator_cjk.hxx b/i18npool/inc/breakiterator_cjk.hxx index 8731745..9429176 100644 --- a/i18npool/inc/breakiterator_cjk.hxx +++ b/i18npool/inc/breakiterator_cjk.hxx @@ -22,6 +22,8 @@ #include <breakiterator_unicode.hxx> #include <xdictionary.hxx> +#include <memory> + 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<xdictionary> 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 c9268b3..167b942 100644 --- a/i18npool/source/breakiterator/breakiterator_cjk.cxx +++ b/i18npool/source/breakiterator/breakiterator_cjk.cxx @@ -21,6 +21,8 @@ #include <localedata.hxx> #include <i18nutil/unicode.hxx> +#include <o3tl/make_unique.hxx> + 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<xdictionary>("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<xdictionary>("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<xdictionary>("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: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits