Kaydet (Commit) 013abfd2 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Pass cells to CompareFunc, rather than the whole Compare struct.

Change-Id: I4d5554fc5783b123aa0f90b7c078e1fc0f0cd866
üst 1882a2b1
...@@ -53,7 +53,6 @@ struct CompareOptions ...@@ -53,7 +53,6 @@ struct CompareOptions
ScQueryEntry aQueryEntry; ScQueryEntry aQueryEntry;
bool bRegEx; bool bRegEx;
bool bMatchWholeCell; bool bMatchWholeCell;
bool bIgnoreCase;
CompareOptions( ScDocument* pDoc, const ScQueryEntry& rEntry, bool bReg ); CompareOptions( ScDocument* pDoc, const ScQueryEntry& rEntry, bool bReg );
private: private:
...@@ -66,7 +65,7 @@ private: ...@@ -66,7 +65,7 @@ private:
/** @param pOptions /** @param pOptions
NULL means case sensitivity document option is to be used! NULL means case sensitivity document option is to be used!
*/ */
double CompareFunc( const Compare& rComp, CompareOptions* pOptions = NULL ); double CompareFunc( const Compare::Cell& rCell1, const Compare::Cell& rCell2, bool bIgnoreCase, CompareOptions* pOptions = NULL );
} }
......
...@@ -35,8 +35,7 @@ Compare::Compare() : ...@@ -35,8 +35,7 @@ Compare::Compare() :
CompareOptions::CompareOptions( ScDocument* pDoc, const ScQueryEntry& rEntry, bool bReg ) : CompareOptions::CompareOptions( ScDocument* pDoc, const ScQueryEntry& rEntry, bool bReg ) :
aQueryEntry(rEntry), aQueryEntry(rEntry),
bRegEx(bReg), bRegEx(bReg),
bMatchWholeCell(pDoc->GetDocOptions().IsMatchWholeCell()), bMatchWholeCell(pDoc->GetDocOptions().IsMatchWholeCell())
bIgnoreCase(true)
{ {
bRegEx = (bRegEx && (aQueryEntry.eOp == SC_EQUAL || aQueryEntry.eOp == SC_NOT_EQUAL)); bRegEx = (bRegEx && (aQueryEntry.eOp == SC_EQUAL || aQueryEntry.eOp == SC_NOT_EQUAL));
// Interpreter functions usually are case insensitive, except the simple // Interpreter functions usually are case insensitive, except the simple
...@@ -44,11 +43,8 @@ CompareOptions::CompareOptions( ScDocument* pDoc, const ScQueryEntry& rEntry, bo ...@@ -44,11 +43,8 @@ CompareOptions::CompareOptions( ScDocument* pDoc, const ScQueryEntry& rEntry, bo
// struct if needed. // struct if needed.
} }
double CompareFunc( const Compare& rComp, CompareOptions* pOptions ) double CompareFunc( const Compare::Cell& rCell1, const Compare::Cell& rCell2, bool bIgnoreCase, CompareOptions* pOptions )
{ {
const Compare::Cell& rCell1 = rComp.maCells[0];
const Compare::Cell& rCell2 = rComp.maCells[1];
// Keep DoubleError if encountered // Keep DoubleError if encountered
// #i40539# if bEmpty is set, bVal/nVal are uninitialized // #i40539# if bEmpty is set, bVal/nVal are uninitialized
if (!rCell1.mbEmpty && rCell1.mbValue && !rtl::math::isFinite(rCell1.mfValue)) if (!rCell1.mbEmpty && rCell1.mbValue && !rtl::math::isFinite(rCell1.mfValue))
...@@ -138,7 +134,7 @@ double CompareFunc( const Compare& rComp, CompareOptions* pOptions ) ...@@ -138,7 +134,7 @@ double CompareFunc( const Compare& rComp, CompareOptions* pOptions )
sal_Int32 nStart = 0; sal_Int32 nStart = 0;
sal_Int32 nStop = rCell1.maStr.getLength(); sal_Int32 nStop = rCell1.maStr.getLength();
bool bMatch = rEntry.GetSearchTextPtr( bool bMatch = rEntry.GetSearchTextPtr(
!pOptions->bIgnoreCase)->SearchForward( !bIgnoreCase)->SearchForward(
rCell1.maStr.getString(), &nStart, &nStop); rCell1.maStr.getString(), &nStart, &nStop);
if (bMatch && pOptions->bMatchWholeCell && (nStart != 0 || nStop != rCell1.maStr.getLength())) if (bMatch && pOptions->bMatchWholeCell && (nStart != 0 || nStop != rCell1.maStr.getLength()))
bMatch = false; // RegEx must match entire string. bMatch = false; // RegEx must match entire string.
...@@ -147,12 +143,12 @@ double CompareFunc( const Compare& rComp, CompareOptions* pOptions ) ...@@ -147,12 +143,12 @@ double CompareFunc( const Compare& rComp, CompareOptions* pOptions )
else if (rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL) else if (rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL)
{ {
::utl::TransliterationWrapper* pTransliteration = ::utl::TransliterationWrapper* pTransliteration =
(pOptions->bIgnoreCase ? ScGlobal::GetpTransliteration() : (bIgnoreCase ? ScGlobal::GetpTransliteration() :
ScGlobal::GetCaseTransliteration()); ScGlobal::GetCaseTransliteration());
bool bMatch = false; bool bMatch = false;
if (pOptions->bMatchWholeCell) if (pOptions->bMatchWholeCell)
{ {
if (pOptions->bIgnoreCase) if (bIgnoreCase)
bMatch = rCell1.maStr.getDataIgnoreCase() == rCell2.maStr.getDataIgnoreCase(); bMatch = rCell1.maStr.getDataIgnoreCase() == rCell2.maStr.getDataIgnoreCase();
else else
bMatch = rCell1.maStr.getData() == rCell2.maStr.getData(); bMatch = rCell1.maStr.getData() == rCell2.maStr.getData();
...@@ -169,14 +165,14 @@ double CompareFunc( const Compare& rComp, CompareOptions* pOptions ) ...@@ -169,14 +165,14 @@ double CompareFunc( const Compare& rComp, CompareOptions* pOptions )
} }
fRes = (bMatch ? 0 : 1); fRes = (bMatch ? 0 : 1);
} }
else if (pOptions->bIgnoreCase) else if (bIgnoreCase)
fRes = (double) ScGlobal::GetCollator()->compareString( fRes = (double) ScGlobal::GetCollator()->compareString(
rCell1.maStr.getString(), rCell2.maStr.getString()); rCell1.maStr.getString(), rCell2.maStr.getString());
else else
fRes = (double) ScGlobal::GetCaseCollator()->compareString( fRes = (double) ScGlobal::GetCaseCollator()->compareString(
rCell1.maStr.getString(), rCell2.maStr.getString()); rCell1.maStr.getString(), rCell2.maStr.getString());
} }
else if (rComp.mbIgnoreCase) else if (bIgnoreCase)
fRes = (double) ScGlobal::GetCollator()->compareString( fRes = (double) ScGlobal::GetCollator()->compareString(
rCell1.maStr.getString(), rCell2.maStr.getString()); rCell1.maStr.getString(), rCell2.maStr.getString());
else else
......
...@@ -876,7 +876,7 @@ double ScInterpreter::Compare() ...@@ -876,7 +876,7 @@ double ScInterpreter::Compare()
if( nGlobalError ) if( nGlobalError )
return 0; return 0;
nCurFmtType = nFuncFmtType = NUMBERFORMAT_LOGICAL; nCurFmtType = nFuncFmtType = NUMBERFORMAT_LOGICAL;
return sc::CompareFunc(aComp); return sc::CompareFunc(aComp.maCells[0], aComp.maCells[1], aComp.mbIgnoreCase);
} }
...@@ -986,7 +986,8 @@ sc::RangeMatrix ScInterpreter::CompareMat( ScQueryOp eOp, sc::CompareOptions* pO ...@@ -986,7 +986,8 @@ sc::RangeMatrix ScInterpreter::CompareMat( ScQueryOp eOp, sc::CompareOptions* pO
rCell.mbEmpty = false; rCell.mbEmpty = false;
} }
} }
aRes.mpMat->PutDouble(sc::CompareFunc(aComp, pOptions), j, k); aRes.mpMat->PutDouble(
sc::CompareFunc(aComp.maCells[0], aComp.maCells[1], aComp.mbIgnoreCase, pOptions), j, k);
} }
else else
aRes.mpMat->PutString(mrStrPool.intern(ScGlobal::GetRscString(STR_NO_VALUE)), j, k); aRes.mpMat->PutString(mrStrPool.intern(ScGlobal::GetRscString(STR_NO_VALUE)), j, k);
......
...@@ -1227,7 +1227,7 @@ class CompareMatrixFunc : std::unary_function<MatrixImplType::element_block_type ...@@ -1227,7 +1227,7 @@ class CompareMatrixFunc : std::unary_function<MatrixImplType::element_block_type
void compare() void compare()
{ {
double fVal = sc::CompareFunc(mrComp, mpOptions); double fVal = sc::CompareFunc(mrComp.maCells[0], mrComp.maCells[1], mrComp.mbIgnoreCase, mpOptions);
bool bRes = false; bool bRes = false;
switch (mrComp.meOp) switch (mrComp.meOp)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment