[Libreoffice-commits] core.git: sc/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Sun Sep 13 13:16:25 UTC 2020
sc/source/core/inc/interpre.hxx | 2 +-
sc/source/core/tool/interpr1.cxx | 39 ++++++++++++++-------------------------
2 files changed, 15 insertions(+), 26 deletions(-)
New commits:
commit 0847f77a112271bf498859ce99bd65de4243098a
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sat Sep 12 16:27:06 2020 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Sun Sep 13 15:15:48 2020 +0200
establish DetectSearchType pDoc arg is never null
so the "TODO: rare case" doesn't exist
Change-Id: I802a16d1c5022ede1a95473a07160823b2856fdf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102525
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 7c024e6e9150..46b6f49da87e 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -167,7 +167,7 @@ public:
/** Detect if string should be used as regular expression or wildcard
expression or literal string.
*/
- static utl::SearchParam::SearchType DetectSearchType( const OUString& rStr, const ScDocument* pDoc );
+ static utl::SearchParam::SearchType DetectSearchType( const OUString& rStr, const ScDocument& rDoc );
/// Fail safe division, returning a FormulaError::DivisionByZero coded into a double
/// if denominator is 0.0
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 575ee9bd162c..4a3f1cbfb60b 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -4933,7 +4933,7 @@ void ScInterpreter::ScMatch()
if ( bIsVBAMode )
rParam.eSearchType = utl::SearchParam::SearchType::Wildcard;
else
- rParam.eSearchType = DetectSearchType(rEntry.GetQueryItem().maString.getString(), &mrDoc);
+ rParam.eSearchType = DetectSearchType(rEntry.GetQueryItem().maString.getString(), mrDoc);
}
if (pMatSrc) // The source data is matrix array.
@@ -5475,7 +5475,7 @@ void ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc )
{
rParam.FillInExcelSyntax(mrDoc.GetSharedStringPool(), aString.getString(), 0, pFormatter);
if (rItem.meType == ScQueryEntry::ByString)
- rParam.eSearchType = DetectSearchType(rItem.maString.getString(), &mrDoc);
+ rParam.eSearchType = DetectSearchType(rItem.maString.getString(), mrDoc);
}
ScAddress aAdr;
aAdr.SetTab( nTab3 );
@@ -5789,7 +5789,7 @@ void ScInterpreter::ScCountIf()
{
rParam.FillInExcelSyntax(mrDoc.GetSharedStringPool(), aString.getString(), 0, pFormatter);
if (rItem.meType == ScQueryEntry::ByString)
- rParam.eSearchType = DetectSearchType(rItem.maString.getString(), &mrDoc);
+ rParam.eSearchType = DetectSearchType(rItem.maString.getString(), mrDoc);
}
rParam.nCol1 = nCol1;
rParam.nCol2 = nCol2;
@@ -6134,7 +6134,7 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf
{
rParam.FillInExcelSyntax(mrDoc.GetSharedStringPool(), aString.getString(), 0, pFormatter);
if (rItem.meType == ScQueryEntry::ByString)
- rParam.eSearchType = DetectSearchType(rItem.maString.getString(), &mrDoc);
+ rParam.eSearchType = DetectSearchType(rItem.maString.getString(), mrDoc);
}
rParam.nCol1 = nCol1;
rParam.nCol2 = nCol2;
@@ -7079,7 +7079,7 @@ void ScInterpreter::ScLookup()
rEntry.nField = nCol1;
ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
if (rItem.meType == ScQueryEntry::ByString)
- aParam.eSearchType = DetectSearchType(rItem.maString.getString(), &mrDoc);
+ aParam.eSearchType = DetectSearchType(rItem.maString.getString(), mrDoc);
ScQueryCellIterator aCellIter(&mrDoc, mrContext, nTab1, aParam, false);
SCCOL nC;
@@ -7310,7 +7310,7 @@ void ScInterpreter::CalculateLookup(bool bHLookup)
ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
if (rItem.meType == ScQueryEntry::ByString)
- aParam.eSearchType = DetectSearchType(rItem.maString.getString(), &mrDoc);
+ aParam.eSearchType = DetectSearchType(rItem.maString.getString(), mrDoc);
if (pMat)
{
SCSIZE nMatCount = bHLookup ? nC : nR;
@@ -7798,7 +7798,7 @@ std::unique_ptr<ScDBQueryParamBase> ScInterpreter::GetDBParams( bool& rMissingFi
rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
if (!bNumber && pParam->eSearchType == utl::SearchParam::SearchType::Normal)
- pParam->eSearchType = DetectSearchType(aQueryStr, &mrDoc);
+ pParam->eSearchType = DetectSearchType(aQueryStr, mrDoc);
}
return pParam;
}
@@ -9237,7 +9237,7 @@ void ScInterpreter::ScSearchB()
// search aSubStr for asStr
sal_Int32 nPos = 0;
sal_Int32 nEndPos = aSubStr.getLength();
- utl::SearchParam::SearchType eSearchType = DetectSearchType( asStr, &mrDoc );
+ utl::SearchParam::SearchType eSearchType = DetectSearchType( asStr, mrDoc );
utl::SearchParam sPar( asStr, eSearchType, false, '~', false );
utl::TextSearch sT( sPar, *ScGlobal::getCharClassPtr() );
if ( !sT.SearchForward( aSubStr, &nPos, &nEndPos ) )
@@ -9313,7 +9313,7 @@ void ScInterpreter::ScSearch()
PushNoValue();
else
{
- utl::SearchParam::SearchType eSearchType = DetectSearchType( SearchStr, &mrDoc );
+ utl::SearchParam::SearchType eSearchType = DetectSearchType( SearchStr, mrDoc );
utl::SearchParam sPar(SearchStr, eSearchType, false, '~', false);
utl::TextSearch sT( sPar, *ScGlobal::getCharClassPtr() );
bool bBool = sT.SearchForward(sStr, &nPos, &nEndPos);
@@ -9917,23 +9917,12 @@ bool ScInterpreter::MayBeWildcard( const OUString& rStr )
return false;
}
-utl::SearchParam::SearchType ScInterpreter::DetectSearchType( const OUString& rStr, const ScDocument* pDoc )
+utl::SearchParam::SearchType ScInterpreter::DetectSearchType( const OUString& rStr, const ScDocument& rDoc )
{
- if (pDoc)
- {
- if (pDoc->GetDocOptions().IsFormulaWildcardsEnabled())
- return MayBeWildcard( rStr ) ? utl::SearchParam::SearchType::Wildcard : utl::SearchParam::SearchType::Normal;
- if (pDoc->GetDocOptions().IsFormulaRegexEnabled())
- return MayBeRegExp( rStr ) ? utl::SearchParam::SearchType::Regexp : utl::SearchParam::SearchType::Normal;
- }
- else
- {
- /* TODO: obtain the global config for this rare case? */
- if (MayBeRegExp( rStr, true))
- return utl::SearchParam::SearchType::Regexp;
- if (MayBeWildcard( rStr ))
- return utl::SearchParam::SearchType::Wildcard;
- }
+ if (rDoc.GetDocOptions().IsFormulaWildcardsEnabled())
+ return MayBeWildcard( rStr ) ? utl::SearchParam::SearchType::Wildcard : utl::SearchParam::SearchType::Normal;
+ if (rDoc.GetDocOptions().IsFormulaRegexEnabled())
+ return MayBeRegExp( rStr ) ? utl::SearchParam::SearchType::Regexp : utl::SearchParam::SearchType::Normal;
return utl::SearchParam::SearchType::Normal;
}
More information about the Libreoffice-commits
mailing list