diff options
-rw-r--r-- | i18npool/inc/breakiterator_cjk.hxx | 5 | ||||
-rw-r--r-- | i18npool/source/breakiterator/breakiterator_cjk.cxx | 45 |
2 files changed, 16 insertions, 34 deletions
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 <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 c9268b3e3439..167b942e040e 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: */ |