diff options
author | Eike Rathke <erack@redhat.com> | 2016-02-18 23:48:17 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-02-19 00:10:14 +0100 |
commit | 06fa2a521b49afe44a387dbfcb65198382f6c57a (patch) | |
tree | a56f669b5dd23c16666e461f3b35a34083800b30 | |
parent | 92173313eae76d721580120b0de2c98fd83c5384 (diff) |
change all bool bRegExp to utl::SearchParam::SearchType enum, tdf#72196
Later inspect all places that use utl::SearchParam::SRCH_REGEXP if and
how to use utl::SearchParam::SRCH_WILDCARD as well.
Change-Id: I6ad4e5dea3cd656fd670f2281aaceec817953211
22 files changed, 114 insertions, 95 deletions
diff --git a/sc/inc/compare.hxx b/sc/inc/compare.hxx index adfdfbc67597..cd4f9e7e7ac2 100644 --- a/sc/inc/compare.hxx +++ b/sc/inc/compare.hxx @@ -22,6 +22,7 @@ #include "queryentry.hxx" +#include <unotools/textsearch.hxx> #include <svl/sharedstring.hxx> class ScDocument; @@ -50,11 +51,11 @@ struct Compare struct CompareOptions { - ScQueryEntry aQueryEntry; - bool bRegEx; - bool bMatchWholeCell; + ScQueryEntry aQueryEntry; + utl::SearchParam::SearchType eSearchType; + bool bMatchWholeCell; - CompareOptions( ScDocument* pDoc, const ScQueryEntry& rEntry, bool bReg ); + CompareOptions( ScDocument* pDoc, const ScQueryEntry& rEntry, utl::SearchParam::SearchType eSrchTyp ); private: CompareOptions( const CompareOptions & ) = delete; CompareOptions& operator=( const CompareOptions & ) = delete; diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx index c1748637c30b..dba6c530d62c 100644 --- a/sc/inc/queryparam.hxx +++ b/sc/inc/queryparam.hxx @@ -20,6 +20,7 @@ #ifndef INCLUDED_SC_INC_QUERYPARAM_HXX #define INCLUDED_SC_INC_QUERYPARAM_HXX +#include <unotools/textsearch.hxx> #include "global.hxx" #include "types.hxx" @@ -39,11 +40,11 @@ class SharedStringPool; struct ScQueryParamBase { + utl::SearchParam::SearchType eSearchType; bool bHasHeader; bool bByRow; bool bInplace; bool bCaseSens; - bool bRegExp; bool bDuplicate; bool mbRangeLookup; ///< for spreadsheet functions like MATCH, LOOKUP, HLOOKUP, VLOOKUP diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index 4ea2d54f0e18..7ff9ee9c8670 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -1296,7 +1296,8 @@ bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol, SetStopOnMismatch( true ); // assume sorted keys SetTestEqualCondition( true ); bIgnoreMismatchOnLeadingStrings = bIgnoreMismatchOnLeadingStringsP; - bool bRegExp = mpParam->bRegExp && mpParam->GetEntry(0).GetQueryItem().meType == ScQueryEntry::ByString; + bool bRegExp = mpParam->eSearchType == utl::SearchParam::SRCH_REGEXP && + mpParam->GetEntry(0).GetQueryItem().meType == ScQueryEntry::ByString; bool bBinary = !bRegExp && mpParam->bByRow && (mpParam->GetEntry(0).eOp == SC_LESS_EQUAL || mpParam->GetEntry(0).eOp == SC_GREATER_EQUAL); bool bFound = false; @@ -1412,7 +1413,7 @@ bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol, maCurPos = aPosSave; return true; } - if ( (bSearchForEqualAfterMismatch || mpParam->bRegExp) && + if ( (bSearchForEqualAfterMismatch || mpParam->eSearchType == utl::SearchParam::SRCH_REGEXP) && 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 be366b90635b..1e77d25ddd9f 100644 --- a/sc/source/core/data/dpcache.cxx +++ b/sc/source/core/data/dpcache.cxx @@ -529,8 +529,8 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const { // by String OUString aCellStr = pCellData->GetString(); - bool bRealRegExp = (rParam.bRegExp && ((rEntry.eOp == SC_EQUAL) - || (rEntry.eOp == SC_NOT_EQUAL))); + bool bRealRegExp = (rParam.eSearchType == utl::SearchParam::SRCH_REGEXP && + ((rEntry.eOp == SC_EQUAL) || (rEntry.eOp == SC_NOT_EQUAL))); bool bTestRegExp = false; if (bRealRegExp || bTestRegExp) { diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 828f0a84a1fa..2820b9acbe59 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -2213,7 +2213,7 @@ class QueryEvaluator bool isRealRegExp(const ScQueryEntry& rEntry) const { - if (!mrParam.bRegExp) + if (mrParam.eSearchType != utl::SearchParam::SRCH_REGEXP) return false; return isTextMatchOp(rEntry); @@ -2224,7 +2224,7 @@ class QueryEvaluator if (!mpTestEqualCondition) return false; - if (!mrParam.bRegExp) + if (mrParam.eSearchType != utl::SearchParam::SRCH_REGEXP) return false; return (rEntry.eOp == SC_LESS_EQUAL || rEntry.eOp == SC_GREATER_EQUAL); diff --git a/sc/source/core/tool/compare.cxx b/sc/source/core/tool/compare.cxx index 8ec9e0076f60..d2d032293a6a 100644 --- a/sc/source/core/tool/compare.cxx +++ b/sc/source/core/tool/compare.cxx @@ -32,12 +32,16 @@ Compare::Cell::Cell() : Compare::Compare() : meOp(SC_EQUAL), mbIgnoreCase(true) {} -CompareOptions::CompareOptions( ScDocument* pDoc, const ScQueryEntry& rEntry, bool bReg ) : +CompareOptions::CompareOptions( ScDocument* pDoc, const ScQueryEntry& rEntry, utl::SearchParam::SearchType eSrchTyp ) : aQueryEntry(rEntry), - bRegEx(bReg), + eSearchType(eSrchTyp), bMatchWholeCell(pDoc->GetDocOptions().IsMatchWholeCell()) { - bRegEx = (bRegEx && (aQueryEntry.eOp == SC_EQUAL || aQueryEntry.eOp == SC_NOT_EQUAL)); + // Wildcard and Regex search work only with equal or not equal. + if (eSearchType != utl::SearchParam::SRCH_NORMAL && + !(aQueryEntry.eOp == SC_EQUAL || aQueryEntry.eOp == SC_NOT_EQUAL)) + eSearchType = utl::SearchParam::SRCH_NORMAL; + // Interpreter functions usually are case insensitive, except the simple // comparison operators, for which these options aren't used. Override in // struct if needed. @@ -132,7 +136,7 @@ double CompareFunc( const Compare& rComp, CompareOptions* pOptions ) // regex to work through GetSearchTextPtr(). ScQueryEntry& rEntry = pOptions->aQueryEntry; OSL_ENSURE(rEntry.GetQueryItem().maString == rCell2.maStr, "ScInterpreter::CompareFunc: broken options"); - if (pOptions->bRegEx) + if (pOptions->eSearchType == utl::SearchParam::SRCH_REGEXP) { sal_Int32 nStart = 0; sal_Int32 nStop = rCell1.maStr.getLength(); diff --git a/sc/source/core/tool/doubleref.cxx b/sc/source/core/tool/doubleref.cxx index 5089caaec7e1..c2b251c442f1 100644 --- a/sc/source/core/tool/doubleref.cxx +++ b/sc/source/core/tool/doubleref.cxx @@ -264,7 +264,7 @@ void ScDBRangeBase::fillQueryOptions(ScQueryParamBase* pParam) pParam->bByRow = true; pParam->bInplace = true; pParam->bCaseSens = false; - pParam->bRegExp = false; + pParam->eSearchType = utl::SearchParam::SRCH_NORMAL; pParam->bDuplicate = true; } diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 45a00c7c10e9..a444491d7c72 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -4384,11 +4384,10 @@ void ScInterpreter::ScMatch() { bool bIsVBAMode = pDok->IsInVBAMode(); - // #TODO handle MSO wildcards if ( bIsVBAMode ) - rParam.bRegExp = false; + rParam.eSearchType = utl::SearchParam::SRCH_WILDCARD; else - rParam.bRegExp = MayBeRegExp(rEntry.GetQueryItem().maString.getString(), pDok); + rParam.eSearchType = DetectSearchType(rEntry.GetQueryItem().maString.getString(), pDok); } if (pMatSrc) // The source data is matrix array. @@ -4885,7 +4884,7 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) { rParam.FillInExcelSyntax(pDok->GetSharedStringPool(), aString.getString(), 0, pFormatter); if (rItem.meType == ScQueryEntry::ByString) - rParam.bRegExp = MayBeRegExp(rItem.maString.getString(), pDok); + rParam.eSearchType = DetectSearchType(rItem.maString.getString(), pDok); } ScAddress aAdr; aAdr.SetTab( nTab3 ); @@ -4897,7 +4896,7 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) if (pQueryMatrix) { // Never case-sensitive. - sc::CompareOptions aOptions( pDok, rEntry, rParam.bRegExp); + sc::CompareOptions aOptions( pDok, rEntry, rParam.eSearchType); ScMatrixRef pResultMatrix = QueryMat( pQueryMatrix, aOptions); if (nGlobalError || !pResultMatrix) { @@ -5177,7 +5176,7 @@ void ScInterpreter::ScCountIf() { rParam.FillInExcelSyntax(pDok->GetSharedStringPool(), aString.getString(), 0, pFormatter); if (rItem.meType == ScQueryEntry::ByString) - rParam.bRegExp = MayBeRegExp(rItem.maString.getString(), pDok); + rParam.eSearchType = DetectSearchType(rItem.maString.getString(), pDok); } rParam.nCol1 = nCol1; rParam.nCol2 = nCol2; @@ -5185,7 +5184,7 @@ void ScInterpreter::ScCountIf() if (pQueryMatrix) { // Never case-sensitive. - sc::CompareOptions aOptions( pDok, rEntry, rParam.bRegExp); + sc::CompareOptions aOptions( pDok, rEntry, rParam.eSearchType); ScMatrixRef pResultMatrix = QueryMat( pQueryMatrix, aOptions); if (nGlobalError || !pResultMatrix) { @@ -5430,7 +5429,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) { rParam.FillInExcelSyntax(pDok->GetSharedStringPool(), aString.getString(), 0, pFormatter); if (rItem.meType == ScQueryEntry::ByString) - rParam.bRegExp = MayBeRegExp(rItem.maString.getString(), pDok); + rParam.eSearchType = DetectSearchType(rItem.maString.getString(), pDok); } ScAddress aAdr; aAdr.SetTab( nTab1 ); @@ -5442,7 +5441,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) if (pQueryMatrix) { // Never case-sensitive. - sc::CompareOptions aOptions( pDok, rEntry, rParam.bRegExp); + sc::CompareOptions aOptions( pDok, rEntry, rParam.eSearchType); ScMatrixRef pResultMatrix = QueryMat( pQueryMatrix, aOptions); if (nGlobalError || !pResultMatrix) { @@ -6085,7 +6084,7 @@ void ScInterpreter::ScLookup() rEntry.nField = nCol1; ScQueryEntry::Item& rItem = rEntry.GetQueryItem(); if (rItem.meType == ScQueryEntry::ByString) - aParam.bRegExp = MayBeRegExp(rItem.maString.getString(), pDok); + aParam.eSearchType = DetectSearchType(rItem.maString.getString(), pDok); ScQueryCellIterator aCellIter(pDok, nTab1, aParam, false); SCCOL nC; @@ -6316,7 +6315,7 @@ void ScInterpreter::CalculateLookup(bool bHLookup) ScQueryEntry::Item& rItem = rEntry.GetQueryItem(); if (rItem.meType == ScQueryEntry::ByString) - aParam.bRegExp = MayBeRegExp(rItem.maString.getString(), pDok); + aParam.eSearchType = DetectSearchType(rItem.maString.getString(), pDok); if (pMat) { SCSIZE nMatCount = bHLookup ? nC : nR; @@ -6786,8 +6785,8 @@ std::unique_ptr<ScDBQueryParamBase> ScInterpreter::GetDBParams( bool& rMissingFi aQueryStr, nIndex, rItem.mfVal); rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString; - if (!bNumber && !pParam->bRegExp) - pParam->bRegExp = MayBeRegExp(aQueryStr, pDok); + if (!bNumber && pParam->eSearchType == utl::SearchParam::SRCH_NORMAL) + pParam->eSearchType = DetectSearchType(aQueryStr, pDok); } return pParam; } diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx index 6a90ba2b6cac..ebc4b550762a 100644 --- a/sc/source/core/tool/queryparam.cxx +++ b/sc/source/core/tool/queryparam.cxx @@ -64,11 +64,11 @@ ScQueryParamBase::const_iterator ScQueryParamBase::end() const } ScQueryParamBase::ScQueryParamBase() : + eSearchType(utl::SearchParam::SRCH_NORMAL), bHasHeader(true), bByRow(true), bInplace(true), bCaseSens(false), - bRegExp(false), bDuplicate(false), mbRangeLookup(false) { @@ -76,9 +76,9 @@ ScQueryParamBase::ScQueryParamBase() : m_Entries.push_back(o3tl::make_unique<ScQueryEntry>()); } -ScQueryParamBase::ScQueryParamBase(const ScQueryParamBase& r) - : bHasHeader(r.bHasHeader), bByRow(r.bByRow), bInplace(r.bInplace), bCaseSens(r.bCaseSens) - , bRegExp(r.bRegExp), bDuplicate(r.bDuplicate), mbRangeLookup(r.mbRangeLookup) +ScQueryParamBase::ScQueryParamBase(const ScQueryParamBase& r) : + eSearchType(r.eSearchType), bHasHeader(r.bHasHeader), bByRow(r.bByRow), bInplace(r.bInplace), + bCaseSens(r.bCaseSens), bDuplicate(r.bDuplicate), mbRangeLookup(r.mbRangeLookup) { for (auto const& it : r.m_Entries) { @@ -300,7 +300,8 @@ void ScQueryParam::Clear() nCol1=nCol2 = 0; nRow1=nRow2 = 0; nTab = SCTAB_MAX; - bHasHeader = bCaseSens = bRegExp = false; + eSearchType = utl::SearchParam::SRCH_NORMAL; + bHasHeader = bCaseSens = false; bInplace = bByRow = bDuplicate = true; for (auto & itr : m_Entries) @@ -332,7 +333,7 @@ ScQueryParam& ScQueryParam::operator=( const ScQueryParam& r ) bHasHeader = r.bHasHeader; bInplace = r.bInplace; bCaseSens = r.bCaseSens; - bRegExp = r.bRegExp; + eSearchType = r.eSearchType; bDuplicate = r.bDuplicate; bByRow = r.bByRow; bDestPers = r.bDestPers; @@ -370,7 +371,7 @@ bool ScQueryParam::operator==( const ScQueryParam& rOther ) const && (bByRow == rOther.bByRow) && (bInplace == rOther.bInplace) && (bCaseSens == rOther.bCaseSens) - && (bRegExp == rOther.bRegExp) + && (eSearchType == rOther.eSearchType) && (bDuplicate == rOther.bDuplicate) && (bDestPers == rOther.bDestPers) && (nDestTab == rOther.nDestTab) diff --git a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx index 46745b740c1e..836d5308a0e0 100644 --- a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx +++ b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx @@ -40,12 +40,12 @@ ScXMLCalculationSettingsContext::ScXMLCalculationSettingsContext( ScXMLImport& r fIterationEpsilon(0.001), nIterationCount(100), nYear2000(1930), + eSearchType(utl::SearchParam::SRCH_REGEXP), bIsIterationEnabled(false), bCalcAsShown(false), bIgnoreCase(false), bLookUpLabels(true), - bMatchWholeCell(true), - bUseRegularExpressions(true) + bMatchWholeCell(true) { aNullDate.Day = 30; aNullDate.Month = 12; @@ -90,7 +90,7 @@ ScXMLCalculationSettingsContext::ScXMLCalculationSettingsContext( ScXMLImport& r else if (IsXMLToken(aLocalName, XML_USE_REGULAR_EXPRESSIONS)) { if (IsXMLToken(sValue, XML_FALSE)) - bUseRegularExpressions = false; + eSearchType = utl::SearchParam::SRCH_NORMAL; } } } @@ -131,7 +131,8 @@ void ScXMLCalculationSettingsContext::EndElement() xPropertySet->setPropertyValue( SC_UNO_IGNORECASE, uno::makeAny(bIgnoreCase) ); xPropertySet->setPropertyValue( SC_UNO_LOOKUPLABELS, uno::makeAny(bLookUpLabels) ); xPropertySet->setPropertyValue( SC_UNO_MATCHWHOLE, uno::makeAny(bMatchWholeCell) ); - xPropertySet->setPropertyValue( SC_UNO_REGEXENABLED, uno::makeAny(bUseRegularExpressions) ); + xPropertySet->setPropertyValue( SC_UNO_REGEXENABLED, + uno::makeAny(eSearchType == utl::SearchParam::SRCH_REGEXP) ); xPropertySet->setPropertyValue( SC_UNO_ITERENABLED, uno::makeAny(bIsIterationEnabled) ); xPropertySet->setPropertyValue( SC_UNO_ITERCOUNT, uno::makeAny(nIterationCount) ); xPropertySet->setPropertyValue( SC_UNO_ITEREPSILON, uno::makeAny(fIterationEpsilon) ); diff --git a/sc/source/filter/xml/XMLCalculationSettingsContext.hxx b/sc/source/filter/xml/XMLCalculationSettingsContext.hxx index 0d18153c7c8d..0c213576fb46 100644 --- a/sc/source/filter/xml/XMLCalculationSettingsContext.hxx +++ b/sc/source/filter/xml/XMLCalculationSettingsContext.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SC_SOURCE_FILTER_XML_XMLCALCULATIONSETTINGSCONTEXT_HXX #include <xmloff/xmlictxt.hxx> +#include <unotools/textsearch.hxx> #include <com/sun/star/util/Date.hpp> #include "xmlimprt.hxx" @@ -31,12 +32,12 @@ class ScXMLCalculationSettingsContext : public SvXMLImportContext double fIterationEpsilon; sal_Int32 nIterationCount; sal_uInt16 nYear2000; + utl::SearchParam::SearchType eSearchType; bool bIsIterationEnabled; bool bCalcAsShown; bool bIgnoreCase; bool bLookUpLabels; bool bMatchWholeCell; - bool bUseRegularExpressions; const ScXMLImport& GetScImport() const { return static_cast<const ScXMLImport&>(GetImport()); } ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); } diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx index 160cbf5e73c9..aa461163755a 100644 --- a/sc/source/filter/xml/XMLExportDataPilot.cxx +++ b/sc/source/filter/xml/XMLExportDataPilot.cxx @@ -66,20 +66,20 @@ ScXMLExportDataPilot::~ScXMLExportDataPilot() } OUString ScXMLExportDataPilot::getDPOperatorXML( - const ScQueryOp aFilterOperator, const bool bUseRegularExpressions) + const ScQueryOp aFilterOperator, const utl::SearchParam::SearchType eSearchType) { switch (aFilterOperator) { case SC_EQUAL : { - if (bUseRegularExpressions) + if (eSearchType == utl::SearchParam::SRCH_REGEXP) return GetXMLToken(XML_MATCH); else return OUString("="); } case SC_NOT_EQUAL : { - if (bUseRegularExpressions) + if (eSearchType == utl::SearchParam::SRCH_REGEXP) return GetXMLToken(XML_NOMATCH); else return OUString("!="); @@ -106,7 +106,8 @@ OUString ScXMLExportDataPilot::getDPOperatorXML( return OUString("="); } -void ScXMLExportDataPilot::WriteDPCondition(const ScQueryEntry& aQueryEntry, bool bIsCaseSensitive, bool bUseRegularExpressions) +void ScXMLExportDataPilot::WriteDPCondition(const ScQueryEntry& aQueryEntry, bool bIsCaseSensitive, + utl::SearchParam::SearchType eSearchType) { rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, OUString::number(aQueryEntry.nField)); if (bIsCaseSensitive) @@ -134,7 +135,7 @@ void ScXMLExportDataPilot::WriteDPCondition(const ScQueryEntry& aQueryEntry, boo else rExport.AddAttribute( XML_NAMESPACE_TABLE, XML_OPERATOR, - getDPOperatorXML(aQueryEntry.eOp, bUseRegularExpressions)); + getDPOperatorXML(aQueryEntry.eOp, eSearchType)); SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_FILTER_CONDITION, true, true); } @@ -187,14 +188,14 @@ void ScXMLExportDataPilot::WriteDPFilter(const ScQueryParam& aQueryParam) rExport.CheckAttrList(); if (nQueryEntryCount == 1) { - WriteDPCondition(aQueryParam.GetEntry(0), aQueryParam.bCaseSens, aQueryParam.bRegExp); + WriteDPCondition(aQueryParam.GetEntry(0), aQueryParam.bCaseSens, aQueryParam.eSearchType); } else if (bOr && !bAnd) { SvXMLElementExport aElemOr(rExport, XML_NAMESPACE_TABLE, XML_FILTER_OR, true, true); for (j = 0; j < nQueryEntryCount; ++j) { - WriteDPCondition(aQueryParam.GetEntry(j), aQueryParam.bCaseSens, aQueryParam.bRegExp); + WriteDPCondition(aQueryParam.GetEntry(j), aQueryParam.bCaseSens, aQueryParam.eSearchType); } } else if (bAnd && !bOr) @@ -202,7 +203,7 @@ void ScXMLExportDataPilot::WriteDPFilter(const ScQueryParam& aQueryParam) SvXMLElementExport aElemAnd(rExport, XML_NAMESPACE_TABLE, XML_FILTER_AND, true, true); for (j = 0; j < nQueryEntryCount; ++j) { - WriteDPCondition(aQueryParam.GetEntry(j), aQueryParam.bCaseSens, aQueryParam.bRegExp); + WriteDPCondition(aQueryParam.GetEntry(j), aQueryParam.bCaseSens, aQueryParam.eSearchType); } } else @@ -228,18 +229,18 @@ void ScXMLExportDataPilot::WriteDPFilter(const ScQueryParam& aQueryParam) { rExport.StartElement( aName, true ); bOpenAndElement = true; - WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.bRegExp); + WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.eSearchType); aPrevFilterField = aQueryParam.GetEntry(j); if (j == nQueryEntryCount - 1) { - WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.bRegExp); + WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.eSearchType); rExport.EndElement(aName, true); bOpenAndElement = false; } } else { - WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.bRegExp); + WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.eSearchType); aPrevFilterField = aQueryParam.GetEntry(j); if (bOpenAndElement) { @@ -248,16 +249,16 @@ void ScXMLExportDataPilot::WriteDPFilter(const ScQueryParam& aQueryParam) } if (j == nQueryEntryCount - 1) { - WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.bRegExp); + WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.eSearchType); } } } else { - WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.bRegExp); + WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.eSearchType); aPrevFilterField = aQueryParam.GetEntry(j); if (j == nQueryEntryCount - 1) - WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.bRegExp); + WriteDPCondition(aPrevFilterField, aQueryParam.bCaseSens, aQueryParam.eSearchType); } } } diff --git a/sc/source/filter/xml/XMLExportDataPilot.hxx b/sc/source/filter/xml/XMLExportDataPilot.hxx index bf3bf3adca21..835924c8d0a7 100644 --- a/sc/source/filter/xml/XMLExportDataPilot.hxx +++ b/sc/source/filter/xml/XMLExportDataPilot.hxx @@ -24,6 +24,7 @@ #include <rtl/ustring.hxx> #include "global.hxx" #include <xmloff/xmltoken.hxx> +#include <unotools/textsearch.hxx> class ScXMLExport; class ScDocument; @@ -41,8 +42,9 @@ class ScXMLExportDataPilot ScXMLExport& rExport; ScDocument* pDoc; - static OUString getDPOperatorXML(const ScQueryOp aFilterOperator, const bool bUseRegularExpressions); - void WriteDPCondition(const ScQueryEntry& aQueryEntry, bool bIsCaseSensitive, bool bUseRegularExpressions); + static OUString getDPOperatorXML(const ScQueryOp aFilterOperator, const utl::SearchParam::SearchType eSearchType); + void WriteDPCondition(const ScQueryEntry& aQueryEntry, bool bIsCaseSensitive, + utl::SearchParam::SearchType eSearchType); void WriteDPFilter(const ScQueryParam& aQueryParam); void WriteFieldReference(ScDPSaveDimension* pDim); diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx index 72e220761ce2..f8cef27a78d8 100644 --- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx +++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx @@ -368,7 +368,7 @@ private: } } - static OUString getOperatorXML(const ScQueryEntry& rEntry, bool bRegExp) + static OUString getOperatorXML(const ScQueryEntry& rEntry, utl::SearchParam::SearchType eSearchType) { switch (rEntry.eOp) { @@ -395,7 +395,7 @@ private: else if (rEntry.IsQueryByNonEmpty()) return GetXMLToken(XML_NOEMPTY); - if (bRegExp) + if (eSearchType == utl::SearchParam::SRCH_REGEXP) return GetXMLToken(XML_MATCH); else return OUString("="); @@ -409,7 +409,7 @@ private: case SC_LESS_EQUAL: return OUString("<="); case SC_NOT_EQUAL: - if (bRegExp) + if (eSearchType == utl::SearchParam::SRCH_REGEXP) return GetXMLToken(XML_NOMATCH); else return OUString("!="); @@ -435,7 +435,8 @@ private: } }; - void writeCondition(const ScQueryEntry& rEntry, SCCOLROW nFieldStart, bool bCaseSens, bool bRegExp) + void writeCondition(const ScQueryEntry& rEntry, SCCOLROW nFieldStart, bool bCaseSens, + utl::SearchParam::SearchType eSearchType) { const ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems(); if (rItems.empty()) @@ -462,7 +463,7 @@ private: mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, aBuf.makeStringAndClear()); } - mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_OPERATOR, getOperatorXML(rEntry, bRegExp)); + mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_OPERATOR, getOperatorXML(rEntry, eSearchType)); SvXMLElementExport aElemC(mrExport, XML_NAMESPACE_TABLE, XML_FILTER_CONDITION, true, true); } else @@ -539,17 +540,17 @@ private: { SvXMLElementExport aElemOr(mrExport, XML_NAMESPACE_TABLE, XML_FILTER_OR, true, true); for (size_t i = 0; i < nCount; ++i) - writeCondition(aParam.GetEntry(i), nFieldStart, aParam.bCaseSens, aParam.bRegExp); + writeCondition(aParam.GetEntry(i), nFieldStart, aParam.bCaseSens, aParam.eSearchType); } else if (bAnd && !bOr) { SvXMLElementExport aElemAnd(mrExport, XML_NAMESPACE_TABLE, XML_FILTER_AND, true, true); for (size_t i = 0; i < nCount; ++i) - writeCondition(aParam.GetEntry(i), nFieldStart, aParam.bCaseSens, aParam.bRegExp); + writeCondition(aParam.GetEntry(i), nFieldStart, aParam.bCaseSens, aParam.eSearchType); } else if (nCount == 1) { - writeCondition(aParam.GetEntry(0), nFieldStart, aParam.bCaseSens, aParam.bRegExp); + writeCondition(aParam.GetEntry(0), nFieldStart, aParam.bCaseSens, aParam.eSearchType); } else { @@ -577,18 +578,18 @@ private: { mrExport.StartElement(aName, true ); bOpenAndElement = true; - writeCondition(aPrevEntry, nFieldStart, aParam.bCaseSens, aParam.bRegExp); + writeCondition(aPrevEntry, nFieldStart, aParam.bCaseSens, aParam.eSearchType); aPrevEntry = rEntry; if (i == nCount - 1) { - writeCondition(aPrevEntry, nFieldStart, aParam.bCaseSens, aParam.bRegExp); + writeCondition(aPrevEntry, nFieldStart, aParam.bCaseSens, aParam.eSearchType); mrExport.EndElement(aName, true); bOpenAndElement = false; } } else { - writeCondition(aPrevEntry, nFieldStart, aParam.bCaseSens, aParam.bRegExp); + writeCondition(aPrevEntry, nFieldStart, aParam.bCaseSens, aParam.eSearchType); aPrevEntry = rEntry; if (bOpenAndElement) { @@ -596,15 +597,15 @@ private: bOpenAndElement = false; } if (i == nCount - 1) - writeCondition(aPrevEntry, nFieldStart, aParam.bCaseSens, aParam.bRegExp); + writeCondition(aPrevEntry, nFieldStart, aParam.bCaseSens, aParam.eSearchType); } } else { - writeCondition(aPrevEntry, nFieldStart, aParam.bCaseSens, aParam.bRegExp); + writeCondition(aPrevEntry, nFieldStart, aParam.bCaseSens, aParam.eSearchType); aPrevEntry = rEntry; if (i == nCount - 1) - writeCondition(aPrevEntry, nFieldStart, aParam.bCaseSens, aParam.bRegExp); + writeCondition(aPrevEntry, nFieldStart, aParam.bCaseSens, aParam.eSearchType); } } if(bOpenAndElement) diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx index ab70483ee29e..e4eb33cc391c 100644 --- a/sc/source/filter/xml/xmlfilti.cxx +++ b/sc/source/filter/xml/xmlfilti.cxx @@ -380,15 +380,15 @@ SvXMLImportContext *ScXMLConditionContext::CreateChildContext( sal_uInt16 nPrefi void ScXMLConditionContext::GetOperator( const OUString& aOpStr, ScQueryParam& rParam, ScQueryEntry& rEntry) { - rParam.bRegExp = false; + rParam.eSearchType = utl::SearchParam::SRCH_NORMAL; if (IsXMLToken(aOpStr, XML_MATCH)) { - rParam.bRegExp = true; + rParam.eSearchType = utl::SearchParam::SRCH_REGEXP; rEntry.eOp = SC_EQUAL; } else if (IsXMLToken(aOpStr, XML_NOMATCH)) { - rParam.bRegExp = true; + rParam.eSearchType = utl::SearchParam::SRCH_REGEXP; rEntry.eOp = SC_NOT_EQUAL; } else if (aOpStr == "=") @@ -532,10 +532,10 @@ ScXMLDPFilterContext::ScXMLDPFilterContext( ScXMLImport& rImport, SvXMLImportContext( rImport, nPrfx, rLName ), pDataPilotTable(pTempDataPilotTableContext), aFilterFields(), + eSearchType(utl::SearchParam::SRCH_NORMAL), nFilterFieldCount(0), bSkipDuplicates(false), bCopyOutputData(false), - bUseRegularExpressions(false), bIsCaseSensitive(false), bConnectionOr(true), bNextConnectionOr(true), @@ -628,7 +628,7 @@ SvXMLImportContext *ScXMLDPFilterContext::CreateChildContext( sal_uInt16 nPrefix void ScXMLDPFilterContext::EndElement() { - aFilterFields.bRegExp = bUseRegularExpressions; + aFilterFields.eSearchType = eSearchType; aFilterFields.bCaseSens = bIsCaseSensitive; aFilterFields.bDuplicate = !bSkipDuplicates; if (bCopyOutputData) @@ -810,17 +810,17 @@ SvXMLImportContext *ScXMLDPConditionContext::CreateChildContext( sal_uInt16 nPre } void ScXMLDPConditionContext::getOperatorXML( - const OUString& sTempOperator, ScQueryOp& aFilterOperator, bool& bUseRegularExpressions) + const OUString& sTempOperator, ScQueryOp& aFilterOperator, utl::SearchParam::SearchType& rSearchType) { - bUseRegularExpressions = false; + rSearchType = utl::SearchParam::SRCH_NORMAL; if (IsXMLToken(sTempOperator, XML_MATCH)) { - bUseRegularExpressions = true; + rSearchType = utl::SearchParam::SRCH_REGEXP; aFilterOperator = SC_EQUAL; } else if (IsXMLToken(sTempOperator, XML_NOMATCH)) { - bUseRegularExpressions = true; + rSearchType = utl::SearchParam::SRCH_REGEXP; aFilterOperator = SC_NOT_EQUAL; } else if (sTempOperator == "=") @@ -859,9 +859,9 @@ void ScXMLDPConditionContext::EndElement() aFilterField.SetQueryByNonEmpty(); else { - bool bUseRegularExpressions = false; - getOperatorXML(sOperator, aFilterField.eOp, bUseRegularExpressions); - pFilterContext->SetUseRegularExpressions(bUseRegularExpressions); + utl::SearchParam::SearchType eSearchType = utl::SearchParam::SRCH_NORMAL; + getOperatorXML(sOperator, aFilterField.eOp, eSearchType); + pFilterContext->SetSearchType(eSearchType); aFilterField.nField = nField; ScQueryEntry::Item& rItem = aFilterField.GetQueryItem(); svl::SharedStringPool& rPool = GetScImport().GetDocument()->GetSharedStringPool(); diff --git a/sc/source/filter/xml/xmlfilti.hxx b/sc/source/filter/xml/xmlfilti.hxx index e4db602a096b..487b1c68739d 100644 --- a/sc/source/filter/xml/xmlfilti.hxx +++ b/sc/source/filter/xml/xmlfilti.hxx @@ -194,10 +194,10 @@ class ScXMLDPFilterContext : public SvXMLImportContext ScQueryParam aFilterFields; ScAddress aOutputPosition; ScRange aConditionSourceRangeAddress; + utl::SearchParam::SearchType eSearchType; sal_uInt8 nFilterFieldCount; bool bSkipDuplicates:1; bool bCopyOutputData:1; - bool bUseRegularExpressions:1; bool bIsCaseSensitive:1; bool bConnectionOr:1; bool bNextConnectionOr:1; @@ -223,7 +223,11 @@ public: virtual void EndElement() override; void SetIsCaseSensitive(const bool bTemp) { bIsCaseSensitive = bTemp; } - void SetUseRegularExpressions(const bool bTemp) { if (!bUseRegularExpressions) bUseRegularExpressions = bTemp;} + void SetSearchType(const utl::SearchParam::SearchType eTemp) + { + if (eSearchType == utl::SearchParam::SRCH_NORMAL) + eSearchType = eTemp; + } void OpenConnection(const bool bVal) { @@ -324,7 +328,7 @@ public: const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override; static void getOperatorXML( - const OUString& sTempOperator, ScQueryOp& aFilterOperator, bool& bUseRegularExpressions); + const OUString& sTempOperator, ScQueryOp& aFilterOperator, utl::SearchParam::SearchType& rSearchType); virtual void EndElement() override; }; diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx index eda750709393..79fe8ab38db0 100644 --- a/sc/source/ui/dbgui/filtdlg.cxx +++ b/sc/source/ui/dbgui/filtdlg.cxx @@ -688,7 +688,7 @@ ScQueryItem* ScFilterDlg::GetOutputItem() theParam.bByRow = true; theParam.bDuplicate = !pBtnUnique->IsChecked(); theParam.bCaseSens = pBtnCase->IsChecked(); - theParam.bRegExp = pBtnRegExp->IsChecked(); + theParam.eSearchType = pBtnRegExp->IsChecked() ? utl::SearchParam::SRCH_REGEXP : utl::SearchParam::SRCH_NORMAL; theParam.bDestPers = pBtnDestPers->IsChecked(); // only set the three - reset everything else diff --git a/sc/source/ui/dbgui/foptmgr.cxx b/sc/source/ui/dbgui/foptmgr.cxx index e5ae0ec42c9a..db56b77a200c 100644 --- a/sc/source/ui/dbgui/foptmgr.cxx +++ b/sc/source/ui/dbgui/foptmgr.cxx @@ -85,7 +85,7 @@ void ScFilterOptionsMgr::Init() pBtnCase ->Check( rQueryData.bCaseSens ); pBtnHeader ->Check( rQueryData.bHasHeader ); - pBtnRegExp ->Check( rQueryData.bRegExp ); + pBtnRegExp ->Check( rQueryData.eSearchType == utl::SearchParam::SRCH_REGEXP ); pBtnUnique ->Check( !rQueryData.bDuplicate ); if ( pViewData && pDoc ) diff --git a/sc/source/ui/dbgui/pfiltdlg.cxx b/sc/source/ui/dbgui/pfiltdlg.cxx index d7ce3490cad5..0ad42d05c965 100644 --- a/sc/source/ui/dbgui/pfiltdlg.cxx +++ b/sc/source/ui/dbgui/pfiltdlg.cxx @@ -127,7 +127,7 @@ void ScPivotFilterDlg::Init( const SfxItemSet& rArgSet ) m_pLbConnect2->SetSelectHdl( LINK( this, ScPivotFilterDlg, LbSelectHdl ) ); m_pBtnCase->Check( theQueryData.bCaseSens ); - m_pBtnRegExp->Check( theQueryData.bRegExp ); + m_pBtnRegExp->Check( theQueryData.eSearchType == utl::SearchParam::SRCH_REGEXP ); m_pBtnUnique->Check( !theQueryData.bDuplicate ); pViewData = rQueryItem.GetViewData(); @@ -419,7 +419,7 @@ const ScQueryItem& ScPivotFilterDlg::GetOutputItem() theParam.bDuplicate = !m_pBtnUnique->IsChecked(); theParam.bCaseSens = m_pBtnCase->IsChecked(); - theParam.bRegExp = m_pBtnRegExp->IsChecked(); + theParam.eSearchType = m_pBtnRegExp->IsChecked() ? utl::SearchParam::SRCH_REGEXP : utl::SearchParam::SRCH_NORMAL; if ( pOutItem ) DELETEZ( pOutItem ); pOutItem = new ScQueryItem( nWhichQuery, &theParam ); diff --git a/sc/source/ui/dbgui/sfiltdlg.cxx b/sc/source/ui/dbgui/sfiltdlg.cxx index a631c537b92b..990939dca7ff 100644 --- a/sc/source/ui/dbgui/sfiltdlg.cxx +++ b/sc/source/ui/dbgui/sfiltdlg.cxx @@ -363,7 +363,8 @@ IMPL_LINK_TYPED( ScSpecialFilterDlg, EndDlgHdl, Button*, pBtn, void ) theOutParam.bHasHeader = pBtnHeader->IsChecked(); theOutParam.bByRow = true; theOutParam.bCaseSens = pBtnCase->IsChecked(); - theOutParam.bRegExp = pBtnRegExp->IsChecked(); + theOutParam.eSearchType = pBtnRegExp->IsChecked() ? utl::SearchParam::SRCH_REGEXP : + utl::SearchParam::SRCH_NORMAL; theOutParam.bDuplicate = !pBtnUnique->IsChecked(); theOutParam.bDestPers = pBtnDestPers->IsChecked(); diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx index 70921f106245..ba4858f10903 100644 --- a/sc/source/ui/unoobj/datauno.cxx +++ b/sc/source/ui/unoobj/datauno.cxx @@ -1471,7 +1471,8 @@ void SAL_CALL ScFilterDescriptorBase::setPropertyValue( else if (aString == SC_UNONAME_SKIPDUP) aParam.bDuplicate = !(ScUnoHelpFunctions::GetBoolFromAny( aValue )); else if (aString == SC_UNONAME_USEREGEX) - aParam.bRegExp = ScUnoHelpFunctions::GetBoolFromAny( aValue ); + aParam.eSearchType = ScUnoHelpFunctions::GetBoolFromAny( aValue ) ? utl::SearchParam::SRCH_REGEXP : + utl::SearchParam::SRCH_NORMAL; PutData(aParam); } @@ -1514,7 +1515,7 @@ uno::Any SAL_CALL ScFilterDescriptorBase::getPropertyValue( const OUString& aPro else if (aString == SC_UNONAME_SKIPDUP ) ScUnoHelpFunctions::SetBoolInAny( aRet, !(aParam.bDuplicate) ); else if (aString == SC_UNONAME_USEREGEX ) - ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bRegExp ); + ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.eSearchType == utl::SearchParam::SRCH_REGEXP ); return aRet; } diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 303391516aee..1191c664d8c4 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -1434,7 +1434,7 @@ void ScGridWindow::ExecFilter( sal_uLong nSel, bool bFound = false; if (!aParam.bInplace) bDeleteOld = true; - if (aParam.bRegExp) + if (aParam.eSearchType != utl::SearchParam::SRCH_NORMAL) bDeleteOld = true; SCSIZE nCount = aParam.GetEntryCount(); for (SCSIZE i = 0; i < nCount && !bDeleteOld; ++i) // current filter settings @@ -1465,7 +1465,7 @@ void ScGridWindow::ExecFilter( sal_uLong nSel, aParam.GetEntry(i).Clear(); nQueryPos = 0; aParam.bInplace = true; - aParam.bRegExp = false; + aParam.eSearchType = utl::SearchParam::SRCH_NORMAL; } if ( nQueryPos < nCount || SC_AUTOFILTER_ALL == nSel ) // delete is always possible |