summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-02-23 23:18:47 +0100
committerEike Rathke <erack@redhat.com>2016-02-23 23:25:15 +0100
commit1f3357013ba1f319a3bcddf4c9a658c46e8c0390 (patch)
treef170f7bbe5759119e80ae09eafb0f9e8409dd58e /unotools
parent8af13dd19d589c9996848fab7f4967f9018751d6 (diff)
SearchFlags::WILD_MATCH_SELECTION, SearchOptions2::WildcardEscapeCharacter
At least '\' (search in Word) and '~' (search in Excel) should be supported as escape character. Being able to restrict a match to entire selection instead of substring speeds up the Calc match whole cell scenario. Change-Id: Ice242b9cd59009f172b724e03c2cc08feda4cd3c
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/i18n/textsearch.cxx18
1 files changed, 15 insertions, 3 deletions
diff --git a/unotools/source/i18n/textsearch.cxx b/unotools/source/i18n/textsearch.cxx
index ed6a58fa26a1..7e0d5a4ae3a8 100644
--- a/unotools/source/i18n/textsearch.cxx
+++ b/unotools/source/i18n/textsearch.cxx
@@ -41,14 +41,19 @@ SearchParam::SearchParam( const OUString &rText,
SearchType eType,
bool bCaseSensitive,
bool bWrdOnly,
- bool bSearchInSel )
+ bool bSearchInSel,
+ sal_uInt32 cWildEscChar,
+ bool bWildMatchSel )
{
sSrchStr = rText;
m_eSrchType = eType;
+ m_cWildEscChar = cWildEscChar;
+
m_bWordOnly = bWrdOnly;
m_bSrchInSel = bSearchInSel;
m_bCaseSense = bCaseSensitive;
+ m_bWildMatchSel = bWildMatchSel;
nTransliterationFlags = 0;
@@ -65,9 +70,12 @@ SearchParam::SearchParam( const SearchParam& rParam )
sReplaceStr = rParam.sReplaceStr;
m_eSrchType = rParam.m_eSrchType;
+ m_cWildEscChar = rParam.m_cWildEscChar;
+
m_bWordOnly = rParam.m_bWordOnly;
m_bSrchInSel = rParam.m_bSrchInSel;
m_bCaseSense = rParam.m_bCaseSense;
+ m_bWildMatchSel = rParam.m_bWildMatchSel;
bLEV_Relaxed = rParam.bLEV_Relaxed;
nLEV_OtherX = rParam.nLEV_OtherX;
@@ -83,6 +91,7 @@ static bool lcl_Equals( const SearchOptions2& rSO1, const SearchOptions2& rSO2 )
{
return
rSO1.AlgorithmType2 == rSO2.AlgorithmType2 &&
+ rSO1.WildcardEscapeCharacter == rSO2.WildcardEscapeCharacter &&
rSO1.algorithmType == rSO2.algorithmType &&
rSO1.searchFlag == rSO2.searchFlag &&
rSO1.searchString.equals(rSO2.searchString) &&
@@ -175,7 +184,8 @@ css::util::SearchOptions2 TextSearch::UpgradeToSearchOptions2( const css::util::
rOptions.deletedChars,
rOptions.insertedChars,
rOptions.transliterateFlags,
- nAlgorithmType2
+ nAlgorithmType2,
+ 0 // no wildcard search, no escape character..
);
return aOptions2;
}
@@ -190,6 +200,9 @@ void TextSearch::Init( const SearchParam & rParam,
{
case SearchParam::SRCH_WILDCARD:
aSOpt.AlgorithmType2 = SearchAlgorithms2::WILDCARD;
+ aSOpt.WildcardEscapeCharacter = rParam.GetWildEscChar();
+ if (rParam.IsWildMatchSel())
+ aSOpt.searchFlag |= SearchFlags::WILD_MATCH_SELECTION;
aSOpt.algorithmType = static_cast<SearchAlgorithms>(-1); // no old enum for that
break;
@@ -237,7 +250,6 @@ void TextSearch::Init( const SearchParam & rParam,
void TextSearch::SetLocale( const css::util::SearchOptions2& rOptions,
const css::lang::Locale& rLocale )
{
- // convert SearchParam to the UNO SearchOptions2
SearchOptions2 aSOpt( rOptions );
aSOpt.Locale = rLocale;