summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-02-22 19:20:08 +0100
committerEike Rathke <erack@redhat.com>2016-02-22 21:30:28 +0100
commitbad266fa06294f1dacec11ec02dfc6ae4ec8cdc4 (patch)
tree9ec77a0436a1768fbd88d41a76fe2b950f3b59ee
parentb3a66ccdd3f4098670b593883602093c4a9e712c (diff)
ScQueryEntry::GetSearchTextPtr() with SearchType, tdf#72196
Change-Id: I1c9c5c6271927bb2d2ac9309e9a6ca36016237f4
-rw-r--r--sc/inc/queryentry.hxx14
-rw-r--r--sc/source/core/data/dociter.cxx6
-rw-r--r--sc/source/core/data/dpcache.cxx2
-rw-r--r--sc/source/core/data/table3.cxx4
-rw-r--r--sc/source/core/tool/compare.cxx2
-rw-r--r--sc/source/core/tool/queryentry.cxx4
6 files changed, 14 insertions, 18 deletions
diff --git a/sc/inc/queryentry.hxx b/sc/inc/queryentry.hxx
index cac117061fe8..1669f6cc3e75 100644
--- a/sc/inc/queryentry.hxx
+++ b/sc/inc/queryentry.hxx
@@ -23,14 +23,10 @@
#include "address.hxx"
#include "global.hxx"
#include <svl/sharedstring.hxx>
+#include <unotools/textsearch.hxx>
#include <vector>
-namespace utl {
- class SearchParam;
- class TextSearch;
-}
-
/**
* Each instance of this struct represents a single filtering criteria.
*/
@@ -55,15 +51,15 @@ struct SC_DLLPUBLIC ScQueryEntry
SCCOLROW nField;
ScQueryOp eOp;
ScQueryConnect eConnect;
- mutable utl::SearchParam* pSearchParam; ///< if RegExp, not saved
- mutable utl::TextSearch* pSearchText; ///< if RegExp, not saved
+ mutable utl::SearchParam* pSearchParam; ///< if Wildcard or RegExp, not saved
+ mutable utl::TextSearch* pSearchText; ///< if Wildcard or RegExp, not saved
ScQueryEntry();
ScQueryEntry(const ScQueryEntry& r);
~ScQueryEntry();
- /// creates pSearchParam and pSearchText if necessary, always RegExp!
- utl::TextSearch* GetSearchTextPtr( bool bCaseSens ) const;
+ /// creates pSearchParam and pSearchText if necessary
+ utl::TextSearch* GetSearchTextPtr( utl::SearchParam::SearchType eSearchType, bool bCaseSens ) const;
QueryItemsType& GetQueryItems() { return maQueryItems;}
const QueryItemsType& GetQueryItems() const { return maQueryItems;}
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 7ff9ee9c8670..1b86461c1098 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1296,9 +1296,9 @@ bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol,
SetStopOnMismatch( true ); // assume sorted keys
SetTestEqualCondition( true );
bIgnoreMismatchOnLeadingStrings = bIgnoreMismatchOnLeadingStringsP;
- bool bRegExp = mpParam->eSearchType == utl::SearchParam::SRCH_REGEXP &&
+ bool bLiteral = mpParam->eSearchType == utl::SearchParam::SRCH_NORMAL &&
mpParam->GetEntry(0).GetQueryItem().meType == ScQueryEntry::ByString;
- bool bBinary = !bRegExp && mpParam->bByRow && (mpParam->GetEntry(0).eOp ==
+ bool bBinary = bLiteral && mpParam->bByRow && (mpParam->GetEntry(0).eOp ==
SC_LESS_EQUAL || mpParam->GetEntry(0).eOp == SC_GREATER_EQUAL);
bool bFound = false;
if (bBinary)
@@ -1413,7 +1413,7 @@ bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol,
maCurPos = aPosSave;
return true;
}
- if ( (bSearchForEqualAfterMismatch || mpParam->eSearchType == utl::SearchParam::SRCH_REGEXP) &&
+ if ( (bSearchForEqualAfterMismatch || mpParam->eSearchType != utl::SearchParam::SRCH_NORMAL) &&
StoppedOnMismatch() )
{
// Assume found entry to be the last value less than respectively
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index 1e77d25ddd9f..d6e104dcde2d 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -537,7 +537,7 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
sal_Int32 nStart = 0;
sal_Int32 nEnd = aCellStr.getLength();
- bool bMatch = (bool) rEntry.GetSearchTextPtr( rParam.bCaseSens )
+ bool bMatch = (bool) rEntry.GetSearchTextPtr( rParam.eSearchType, rParam.bCaseSens )
->SearchForward( aCellStr, &nStart, &nEnd );
// from 614 on, nEnd is behind the found text
if (bMatch && bMatchWholeCell
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 67d9e3e23e71..cfefd5730ecd 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2423,12 +2423,12 @@ public:
{
nEnd = 0;
nStart = aCellStr.getLength();
- bMatch = rEntry.GetSearchTextPtr( mrParam.bCaseSens )
+ bMatch = rEntry.GetSearchTextPtr( mrParam.eSearchType, mrParam.bCaseSens )
->SearchBackward(aCellStr.getString(), &nStart, &nEnd);
}
else
{
- bMatch = rEntry.GetSearchTextPtr( mrParam.bCaseSens )
+ bMatch = rEntry.GetSearchTextPtr( mrParam.eSearchType, mrParam.bCaseSens )
->SearchForward(aCellStr.getString(), &nStart, &nEnd);
}
if ( bMatch && bMatchWholeCell
diff --git a/sc/source/core/tool/compare.cxx b/sc/source/core/tool/compare.cxx
index d2d032293a6a..8433202dd11d 100644
--- a/sc/source/core/tool/compare.cxx
+++ b/sc/source/core/tool/compare.cxx
@@ -140,7 +140,7 @@ double CompareFunc( const Compare& rComp, CompareOptions* pOptions )
{
sal_Int32 nStart = 0;
sal_Int32 nStop = rCell1.maStr.getLength();
- bool bMatch = rEntry.GetSearchTextPtr(
+ bool bMatch = rEntry.GetSearchTextPtr( pOptions->eSearchType,
!rComp.mbIgnoreCase)->SearchForward(
rCell1.maStr.getString(), &nStart, &nStop);
if (bMatch && pOptions->bMatchWholeCell && (nStart != 0 || nStop != rCell1.maStr.getLength()))
diff --git a/sc/source/core/tool/queryentry.cxx b/sc/source/core/tool/queryentry.cxx
index 1a5c47145dcf..17529c52a4b8 100644
--- a/sc/source/core/tool/queryentry.cxx
+++ b/sc/source/core/tool/queryentry.cxx
@@ -164,13 +164,13 @@ bool ScQueryEntry::operator==( const ScQueryEntry& r ) const
// do not compare pSearchParam and pSearchText!
}
-utl::TextSearch* ScQueryEntry::GetSearchTextPtr( bool bCaseSens ) const
+utl::TextSearch* ScQueryEntry::GetSearchTextPtr( utl::SearchParam::SearchType eSearchType, bool bCaseSens ) const
{
if ( !pSearchParam )
{
OUString aStr = maQueryItems[0].maString.getString();
pSearchParam = new utl::SearchParam(
- aStr, utl::SearchParam::SRCH_REGEXP, bCaseSens, false, false);
+ aStr, eSearchType, bCaseSens, false, false);
pSearchText = new utl::TextSearch( *pSearchParam, *ScGlobal::pCharClass );
}
return pSearchText;