diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2023-05-13 10:12:16 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-05-14 08:58:57 +0200 |
commit | 35dca0ad624586c490bad612de0010c3bb228565 (patch) | |
tree | dde4e104b52ffcd358e7e409b0dec0d01aa80fad /i18npool | |
parent | 975590e69edfa351ef20a0973a5005ca49d08edc (diff) |
use more optional in i18npool
Change-Id: If813a8bc339013c58f1b2d1f45f05b58d57f0abe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151724
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/inc/breakiterator_cjk.hxx | 4 | ||||
-rw-r--r-- | i18npool/source/breakiterator/breakiterator_cjk.cxx | 20 |
2 files changed, 12 insertions, 12 deletions
diff --git a/i18npool/inc/breakiterator_cjk.hxx b/i18npool/inc/breakiterator_cjk.hxx index fce0d295ca68..0f8b0c6c0a7d 100644 --- a/i18npool/inc/breakiterator_cjk.hxx +++ b/i18npool/inc/breakiterator_cjk.hxx @@ -20,7 +20,7 @@ #include "breakiterator_unicode.hxx" #include "xdictionary.hxx" - +#include <optional> #include <memory> namespace i18npool { @@ -43,7 +43,7 @@ public: const css::i18n::LineBreakUserOptions& bOptions ) override; protected: - std::unique_ptr<xdictionary> m_xDict; + std::optional<xdictionary> m_oDict; OUString hangingCharacters; }; diff --git a/i18npool/source/breakiterator/breakiterator_cjk.cxx b/i18npool/source/breakiterator/breakiterator_cjk.cxx index baf302e6ef0c..f657daab0e2f 100644 --- a/i18npool/source/breakiterator/breakiterator_cjk.cxx +++ b/i18npool/source/breakiterator/breakiterator_cjk.cxx @@ -42,8 +42,8 @@ Boundary SAL_CALL BreakIterator_CJK::previousWord(const OUString& text, sal_Int32 anyPos, const css::lang::Locale& nLocale, sal_Int16 wordType) { - if (m_xDict) { - result = m_xDict->previousWord(text, anyPos, wordType); + if (m_oDict) { + result = m_oDict->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) @@ -59,8 +59,8 @@ Boundary SAL_CALL BreakIterator_CJK::nextWord(const OUString& text, sal_Int32 anyPos, const css::lang::Locale& nLocale, sal_Int16 wordType) { - if (m_xDict) { - result = m_xDict->nextWord(text, anyPos, wordType); + if (m_oDict) { + result = m_oDict->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 @@ Boundary SAL_CALL BreakIterator_CJK::getWordBoundary( const OUString& text, sal_Int32 anyPos, const css::lang::Locale& nLocale, sal_Int16 wordType, sal_Bool bDirection ) { - if (m_xDict) { - result = m_xDict->getWordBoundary(text, anyPos, wordType, bDirection); + if (m_oDict) { + result = m_oDict->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) @@ -144,7 +144,7 @@ LineBreakResults SAL_CALL BreakIterator_CJK::getLineBreak( // ----------------------------------------------------; BreakIterator_zh::BreakIterator_zh() { - m_xDict = std::make_unique<xdictionary>("zh"); + m_oDict.emplace("zh"); assert(hangingCharacters.pData); hangingCharacters = LocaleDataImpl::get()->getHangingCharacters(LOCALE("zh", "CN")); cBreakIterator = "com.sun.star.i18n.BreakIterator_zh"; @@ -155,7 +155,7 @@ BreakIterator_zh::BreakIterator_zh() // ----------------------------------------------------; BreakIterator_zh_TW::BreakIterator_zh_TW() { - m_xDict = std::make_unique<xdictionary>("zh"); + m_oDict.emplace("zh"); assert(hangingCharacters.pData); hangingCharacters = LocaleDataImpl::get()->getHangingCharacters(LOCALE("zh", "TW")); cBreakIterator = "com.sun.star.i18n.BreakIterator_zh_TW"; @@ -166,8 +166,8 @@ BreakIterator_zh_TW::BreakIterator_zh_TW() // ----------------------------------------------------; BreakIterator_ja::BreakIterator_ja() { - m_xDict = std::make_unique<xdictionary>("ja"); - m_xDict->setJapaneseWordBreak(); + m_oDict.emplace("ja"); + m_oDict->setJapaneseWordBreak(); assert(hangingCharacters.pData); hangingCharacters = LocaleDataImpl::get()->getHangingCharacters(LOCALE("ja", "JP")); cBreakIterator = "com.sun.star.i18n.BreakIterator_ja"; |