diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-02-23 16:15:18 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-03-01 07:28:03 +0000 |
commit | 4c09fc48e9fa9114f32f2973090cbe75177cdd37 (patch) | |
tree | 09d4ee3c2d75d038f45ba13a086a344d35aeadb6 /svx/source/form | |
parent | d97380c66904328e9d706a0b03a6800dc048aa7d (diff) |
typesafe wrappers for css::i18nutil::TransliterationModules
and related css::util::SearchOptions2
The TransliterationModules enum has it's constants spread over multiple
UNO enum/constant-collections - TransliterationModules and
TransliterationModulesExtra, which means that most code simply uses
sal_Int32.
Wrap them up into a better bundle so that only the lowest layer needs to
deal directly with the UNO constants.
Change-Id: I1edeab79fcc7817a4a97c933ef84ab7015bb849b
Reviewed-on: https://gerrit.libreoffice.org/34582
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/form')
-rw-r--r-- | svx/source/form/fmsrccfg.cxx | 107 | ||||
-rw-r--r-- | svx/source/form/fmsrcimp.cxx | 21 |
2 files changed, 63 insertions, 65 deletions
diff --git a/svx/source/form/fmsrccfg.cxx b/svx/source/form/fmsrccfg.cxx index ee71be3a63de..6181fc2c3cc6 100644 --- a/svx/source/form/fmsrccfg.cxx +++ b/svx/source/form/fmsrccfg.cxx @@ -20,18 +20,17 @@ #include "svx/fmsrccfg.hxx" #include <osl/diagnose.h> -#include <com/sun/star/i18n/TransliterationModules.hpp> #include <comphelper/processfactory.hxx> +#include <i18nutil/transliteration.hxx> using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::i18n; namespace svxform { // search parameters FmSearchParams::FmSearchParams() - :nTransliterationFlags( 0 ) + :nTransliterationFlags( TransliterationFlags::NONE ) ,nSearchForType ( 0 ) ,nPosition ( MATCHING_ANYWHERE ) ,nLevOther ( 2 ) @@ -47,29 +46,29 @@ namespace svxform ,bSoundsLikeCJK ( false ) { nTransliterationFlags = - TransliterationModules_ignoreSpace_ja_JP - | TransliterationModules_ignoreMiddleDot_ja_JP - | TransliterationModules_ignoreProlongedSoundMark_ja_JP - | TransliterationModules_ignoreSeparator_ja_JP - | TransliterationModules_IGNORE_CASE; + TransliterationFlags::ignoreSpace_ja_JP + | TransliterationFlags::ignoreMiddleDot_ja_JP + | TransliterationFlags::ignoreProlongedSoundMark_ja_JP + | TransliterationFlags::ignoreSeparator_ja_JP + | TransliterationFlags::IGNORE_CASE; } bool FmSearchParams::isIgnoreWidthCJK( ) const { - return 0 != (nTransliterationFlags & TransliterationModules_IGNORE_WIDTH); + return bool(nTransliterationFlags & TransliterationFlags::IGNORE_WIDTH); } bool FmSearchParams::isCaseSensitive( ) const { - return 0 == (nTransliterationFlags & TransliterationModules_IGNORE_CASE); + return !(nTransliterationFlags & TransliterationFlags::IGNORE_CASE); } void FmSearchParams::setCaseSensitive( bool _bCase ) { if ( _bCase ) - nTransliterationFlags &= ~TransliterationModules_IGNORE_CASE; + nTransliterationFlags &= ~TransliterationFlags::IGNORE_CASE; else - nTransliterationFlags |= TransliterationModules_IGNORE_CASE; + nTransliterationFlags |= TransliterationFlags::IGNORE_CASE; } // maps from ascii values to int values @@ -206,28 +205,28 @@ namespace svxform nPosition = lcl_implMapAsciiValue( m_sSearchPosition, lcl_getSearchPositionValueMap() ); // the transliteration flags - nTransliterationFlags = 0; - - if ( !m_bIsMatchCase ) nTransliterationFlags |= TransliterationModules_IGNORE_CASE; - if ( m_bIsMatchFullHalfWidthForms ) nTransliterationFlags |= TransliterationModules_IGNORE_WIDTH; - if ( m_bIsMatchHiraganaKatakana ) nTransliterationFlags |= TransliterationModules_IGNORE_KANA; - if ( m_bIsMatchContractions ) nTransliterationFlags |= TransliterationModules_ignoreSize_ja_JP; - if ( m_bIsMatchMinusDashCho_on ) nTransliterationFlags |= TransliterationModules_ignoreMinusSign_ja_JP; - if ( m_bIsMatchRepeatCharMarks ) nTransliterationFlags |= TransliterationModules_ignoreIterationMark_ja_JP; - if ( m_bIsMatchVariantFormKanji ) nTransliterationFlags |= TransliterationModules_ignoreTraditionalKanji_ja_JP; - if ( m_bIsMatchOldKanaForms ) nTransliterationFlags |= TransliterationModules_ignoreTraditionalKana_ja_JP; - if ( m_bIsMatch_DiZi_DuZu ) nTransliterationFlags |= TransliterationModules_ignoreZiZu_ja_JP; - if ( m_bIsMatch_BaVa_HaFa ) nTransliterationFlags |= TransliterationModules_ignoreBaFa_ja_JP; - if ( m_bIsMatch_TsiThiChi_DhiZi ) nTransliterationFlags |= TransliterationModules_ignoreTiJi_ja_JP; - if ( m_bIsMatch_HyuIyu_ByuVyu ) nTransliterationFlags |= TransliterationModules_ignoreHyuByu_ja_JP; - if ( m_bIsMatch_SeShe_ZeJe ) nTransliterationFlags |= TransliterationModules_ignoreSeZe_ja_JP; - if ( m_bIsMatch_IaIya ) nTransliterationFlags |= TransliterationModules_ignoreIandEfollowedByYa_ja_JP; - if ( m_bIsMatch_KiKu ) nTransliterationFlags |= TransliterationModules_ignoreKiKuFollowedBySa_ja_JP; - - if ( m_bIsIgnorePunctuation ) nTransliterationFlags |= TransliterationModules_ignoreSeparator_ja_JP; - if ( m_bIsIgnoreWhitespace ) nTransliterationFlags |= TransliterationModules_ignoreSpace_ja_JP; - if ( m_bIsIgnoreProlongedSoundMark ) nTransliterationFlags |= TransliterationModules_ignoreProlongedSoundMark_ja_JP; - if ( m_bIsIgnoreMiddleDot ) nTransliterationFlags |= TransliterationModules_ignoreMiddleDot_ja_JP; + nTransliterationFlags = TransliterationFlags::NONE; + + if ( !m_bIsMatchCase ) nTransliterationFlags |= TransliterationFlags::IGNORE_CASE; + if ( m_bIsMatchFullHalfWidthForms ) nTransliterationFlags |= TransliterationFlags::IGNORE_WIDTH; + if ( m_bIsMatchHiraganaKatakana ) nTransliterationFlags |= TransliterationFlags::IGNORE_KANA; + if ( m_bIsMatchContractions ) nTransliterationFlags |= TransliterationFlags::ignoreSize_ja_JP; + if ( m_bIsMatchMinusDashCho_on ) nTransliterationFlags |= TransliterationFlags::ignoreMinusSign_ja_JP; + if ( m_bIsMatchRepeatCharMarks ) nTransliterationFlags |= TransliterationFlags::ignoreIterationMark_ja_JP; + if ( m_bIsMatchVariantFormKanji ) nTransliterationFlags |= TransliterationFlags::ignoreTraditionalKanji_ja_JP; + if ( m_bIsMatchOldKanaForms ) nTransliterationFlags |= TransliterationFlags::ignoreTraditionalKana_ja_JP; + if ( m_bIsMatch_DiZi_DuZu ) nTransliterationFlags |= TransliterationFlags::ignoreZiZu_ja_JP; + if ( m_bIsMatch_BaVa_HaFa ) nTransliterationFlags |= TransliterationFlags::ignoreBaFa_ja_JP; + if ( m_bIsMatch_TsiThiChi_DhiZi ) nTransliterationFlags |= TransliterationFlags::ignoreTiJi_ja_JP; + if ( m_bIsMatch_HyuIyu_ByuVyu ) nTransliterationFlags |= TransliterationFlags::ignoreHyuByu_ja_JP; + if ( m_bIsMatch_SeShe_ZeJe ) nTransliterationFlags |= TransliterationFlags::ignoreSeZe_ja_JP; + if ( m_bIsMatch_IaIya ) nTransliterationFlags |= TransliterationFlags::ignoreIandEfollowedByYa_ja_JP; + if ( m_bIsMatch_KiKu ) nTransliterationFlags |= TransliterationFlags::ignoreKiKuFollowedBySa_ja_JP; + + if ( m_bIsIgnorePunctuation ) nTransliterationFlags |= TransliterationFlags::ignoreSeparator_ja_JP; + if ( m_bIsIgnoreWhitespace ) nTransliterationFlags |= TransliterationFlags::ignoreSpace_ja_JP; + if ( m_bIsIgnoreProlongedSoundMark ) nTransliterationFlags |= TransliterationFlags::ignoreProlongedSoundMark_ja_JP; + if ( m_bIsIgnoreMiddleDot ) nTransliterationFlags |= TransliterationFlags::ignoreMiddleDot_ja_JP; } void FmSearchConfigItem::implTranslateToConfig( ) @@ -240,26 +239,26 @@ namespace svxform // the transliteration flags - m_bIsMatchCase = ( 0 == ( nTransliterationFlags & TransliterationModules_IGNORE_CASE ) ); - m_bIsMatchFullHalfWidthForms = ( 0 != ( nTransliterationFlags & TransliterationModules_IGNORE_WIDTH ) ); - m_bIsMatchHiraganaKatakana = ( 0 != ( nTransliterationFlags & TransliterationModules_IGNORE_KANA ) ); - m_bIsMatchContractions = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreSize_ja_JP ) ); - m_bIsMatchMinusDashCho_on = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreMinusSign_ja_JP ) ); - m_bIsMatchRepeatCharMarks = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreIterationMark_ja_JP ) ); - m_bIsMatchVariantFormKanji = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreTraditionalKanji_ja_JP ) ); - m_bIsMatchOldKanaForms = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreTraditionalKana_ja_JP ) ); - m_bIsMatch_DiZi_DuZu = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreZiZu_ja_JP ) ); - m_bIsMatch_BaVa_HaFa = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreBaFa_ja_JP ) ); - m_bIsMatch_TsiThiChi_DhiZi = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreTiJi_ja_JP ) ); - m_bIsMatch_HyuIyu_ByuVyu = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreHyuByu_ja_JP ) ); - m_bIsMatch_SeShe_ZeJe = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreSeZe_ja_JP ) ); - m_bIsMatch_IaIya = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreIandEfollowedByYa_ja_JP ) ); - m_bIsMatch_KiKu = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreKiKuFollowedBySa_ja_JP ) ); - - m_bIsIgnorePunctuation = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreSeparator_ja_JP ) ); - m_bIsIgnoreWhitespace = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreSpace_ja_JP ) ); - m_bIsIgnoreProlongedSoundMark = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreProlongedSoundMark_ja_JP ) ); - m_bIsIgnoreMiddleDot = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreMiddleDot_ja_JP ) ); + m_bIsMatchCase = !( nTransliterationFlags & TransliterationFlags::IGNORE_CASE ); + m_bIsMatchFullHalfWidthForms = bool( nTransliterationFlags & TransliterationFlags::IGNORE_WIDTH ); + m_bIsMatchHiraganaKatakana = bool( nTransliterationFlags & TransliterationFlags::IGNORE_KANA ); + m_bIsMatchContractions = bool( nTransliterationFlags & TransliterationFlags::ignoreSize_ja_JP ); + m_bIsMatchMinusDashCho_on = bool( nTransliterationFlags & TransliterationFlags::ignoreMinusSign_ja_JP ); + m_bIsMatchRepeatCharMarks = bool( nTransliterationFlags & TransliterationFlags::ignoreIterationMark_ja_JP ); + m_bIsMatchVariantFormKanji = bool( nTransliterationFlags & TransliterationFlags::ignoreTraditionalKanji_ja_JP ); + m_bIsMatchOldKanaForms = bool( nTransliterationFlags & TransliterationFlags::ignoreTraditionalKana_ja_JP ); + m_bIsMatch_DiZi_DuZu = bool( nTransliterationFlags & TransliterationFlags::ignoreZiZu_ja_JP ); + m_bIsMatch_BaVa_HaFa = bool( nTransliterationFlags & TransliterationFlags::ignoreBaFa_ja_JP ); + m_bIsMatch_TsiThiChi_DhiZi = bool( nTransliterationFlags & TransliterationFlags::ignoreTiJi_ja_JP ); + m_bIsMatch_HyuIyu_ByuVyu = bool( nTransliterationFlags & TransliterationFlags::ignoreHyuByu_ja_JP ); + m_bIsMatch_SeShe_ZeJe = bool( nTransliterationFlags & TransliterationFlags::ignoreSeZe_ja_JP ); + m_bIsMatch_IaIya = bool( nTransliterationFlags & TransliterationFlags::ignoreIandEfollowedByYa_ja_JP ); + m_bIsMatch_KiKu = bool( nTransliterationFlags & TransliterationFlags::ignoreKiKuFollowedBySa_ja_JP ); + + m_bIsIgnorePunctuation = bool( nTransliterationFlags & TransliterationFlags::ignoreSeparator_ja_JP ); + m_bIsIgnoreWhitespace = bool( nTransliterationFlags & TransliterationFlags::ignoreSpace_ja_JP ); + m_bIsIgnoreProlongedSoundMark = bool( nTransliterationFlags & TransliterationFlags::ignoreProlongedSoundMark_ja_JP ); + m_bIsIgnoreMiddleDot = bool( nTransliterationFlags & TransliterationFlags::ignoreMiddleDot_ja_JP ); } const FmSearchParams& FmSearchConfigItem::getParams() const diff --git a/svx/source/form/fmsrcimp.cxx b/svx/source/form/fmsrcimp.cxx index 1e1d3aa337c5..f84ceee8ab2b 100644 --- a/svx/source/form/fmsrcimp.cxx +++ b/svx/source/form/fmsrcimp.cxx @@ -29,12 +29,10 @@ #include <svx/dialmgr.hxx> #include <vcl/svapp.hxx> #include <unotools/textsearch.hxx> -#include <com/sun/star/util/SearchOptions2.hpp> #include <com/sun/star/util/SearchAlgorithms2.hpp> #include <com/sun/star/util/SearchResult.hpp> #include <com/sun/star/util/SearchFlags.hpp> #include <com/sun/star/lang/Locale.hpp> -#include <com/sun/star/i18n/TransliterationModules.hpp> #include <com/sun/star/i18n/CollatorOptions.hpp> #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> @@ -51,6 +49,7 @@ #include <comphelper/numbers.hxx> #include <unotools/syslocale.hxx> +#include <i18nutil/searchopt.hxx> #define EQUAL_BOOKMARKS(a, b) a == b @@ -474,13 +473,13 @@ FmSearchEngine::SearchResult FmSearchEngine::SearchRegularApprox(const OUString& FieldCollection::const_iterator iterInitialField = iterFieldLoop; // Parameter sammeln - SearchOptions2 aParam; + i18nutil::SearchOptions2 aParam; aParam.AlgorithmType2 = m_bRegular ? SearchAlgorithms2::REGEXP : SearchAlgorithms2::APPROXIMATE; aParam.searchFlag = 0; aParam.transliterateFlags = GetTransliterationFlags(); if ( !GetTransliteration() ) { // if transliteration is not enabled, the only flags which matter are IGNORE_CASE and IGNORE_WIDTH - aParam.transliterateFlags &= TransliterationModules_IGNORE_CASE | TransliterationModules_IGNORE_WIDTH; + aParam.transliterateFlags &= TransliterationFlags::IGNORE_CASE | TransliterationFlags::IGNORE_WIDTH; } if (m_bLevenshtein) { @@ -605,7 +604,7 @@ FmSearchEngine::FmSearchEngine(const Reference< XComponentContext >& _rxContext, ,m_nLevShorter(0) ,m_nLevLonger(0) ,m_nPosition(MATCHING_ANYWHERE) - ,m_nTransliterationFlags(0) + ,m_nTransliterationFlags(TransliterationFlags::NONE) { fillControlTexts(arrFields); @@ -623,30 +622,30 @@ FmSearchEngine::~FmSearchEngine() void FmSearchEngine::SetIgnoreWidthCJK(bool bSet) { if (bSet) - m_nTransliterationFlags |= TransliterationModules_IGNORE_WIDTH; + m_nTransliterationFlags |= TransliterationFlags::IGNORE_WIDTH; else - m_nTransliterationFlags &= ~TransliterationModules_IGNORE_WIDTH; + m_nTransliterationFlags &= ~TransliterationFlags::IGNORE_WIDTH; } bool FmSearchEngine::GetIgnoreWidthCJK() const { - return 0 != (m_nTransliterationFlags & TransliterationModules_IGNORE_WIDTH); + return bool(m_nTransliterationFlags & TransliterationFlags::IGNORE_WIDTH); } void FmSearchEngine::SetCaseSensitive(bool bSet) { if (bSet) - m_nTransliterationFlags &= ~TransliterationModules_IGNORE_CASE; + m_nTransliterationFlags &= ~TransliterationFlags::IGNORE_CASE; else - m_nTransliterationFlags |= TransliterationModules_IGNORE_CASE; + m_nTransliterationFlags |= TransliterationFlags::IGNORE_CASE; } bool FmSearchEngine::GetCaseSensitive() const { - return 0 == (m_nTransliterationFlags & TransliterationModules_IGNORE_CASE); + return !(m_nTransliterationFlags & TransliterationFlags::IGNORE_CASE); } |