Lines 1036-1117
Link Here
|
1036 |
else |
1036 |
else |
1037 |
GetInputString( static_cast<SCCOL>(rEntry.nField), nRow, aCellStr ); |
1037 |
GetInputString( static_cast<SCCOL>(rEntry.nField), nRow, aCellStr ); |
1038 |
|
1038 |
|
1039 |
BOOL bRealRegExp = (rParam.bRegExp && ((rEntry.eOp == SC_EQUAL) |
1039 |
if (rEntry.bMatchMultiStrValues) |
1040 |
|| (rEntry.eOp == SC_NOT_EQUAL))); |
|
|
1041 |
BOOL bTestRegExp = (pbTestEqualCondition && rParam.bRegExp |
1042 |
&& ((rEntry.eOp == SC_LESS_EQUAL) |
1043 |
|| (rEntry.eOp == SC_GREATER_EQUAL))); |
1044 |
if ( bRealRegExp || bTestRegExp ) |
1045 |
{ |
1040 |
{ |
1046 |
xub_StrLen nStart = 0; |
1041 |
// Filter by individual string values. |
1047 |
xub_StrLen nEnd = aCellStr.Len(); |
1042 |
|
1048 |
BOOL bMatch = (BOOL) rEntry.GetSearchTextPtr( rParam.bCaseSens ) |
1043 |
rtl::OUString aCellStr2(aCellStr); |
1049 |
->SearchFrwrd( aCellStr, &nStart, &nEnd ); |
1044 |
ScHashOUStringSet::const_iterator pos = rEntry.aStrValues.find(aCellStr2); |
1050 |
// from 614 on, nEnd is behind the found text |
1045 |
if (pos == rEntry.aStrValues.end()) |
1051 |
if ( bMatch && bMatchWholeCell |
1046 |
bOk = FALSE; |
1052 |
&& (nStart != 0 || nEnd != aCellStr.Len()) ) |
|
|
1053 |
bMatch = FALSE; // RegExp must match entire cell string |
1054 |
if ( bRealRegExp ) |
1055 |
bOk = ((rEntry.eOp == SC_NOT_EQUAL) ? !bMatch : bMatch); |
1056 |
else |
1047 |
else |
1057 |
bTestEqual = bMatch; |
1048 |
bOk = TRUE; |
1058 |
} |
1049 |
} |
1059 |
if ( !bRealRegExp ) |
1050 |
else |
1060 |
{ |
1051 |
{ |
1061 |
if ( rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL ) |
1052 |
BOOL bRealRegExp = (rParam.bRegExp && ((rEntry.eOp == SC_EQUAL) |
1062 |
{ |
1053 |
|| (rEntry.eOp == SC_NOT_EQUAL))); |
1063 |
if ( !rEntry.bQueryByString && rEntry.pStr->Len() == 0 ) |
1054 |
BOOL bTestRegExp = (pbTestEqualCondition && rParam.bRegExp |
|
|
1055 |
&& ((rEntry.eOp == SC_LESS_EQUAL) |
1056 |
|| (rEntry.eOp == SC_GREATER_EQUAL))); |
1057 |
if ( bRealRegExp || bTestRegExp ) |
1058 |
{ |
1059 |
xub_StrLen nStart = 0; |
1060 |
xub_StrLen nEnd = aCellStr.Len(); |
1061 |
BOOL bMatch = (BOOL) rEntry.GetSearchTextPtr( rParam.bCaseSens ) |
1062 |
->SearchFrwrd( aCellStr, &nStart, &nEnd ); |
1063 |
// from 614 on, nEnd is behind the found text |
1064 |
if ( bMatch && bMatchWholeCell |
1065 |
&& (nStart != 0 || nEnd != aCellStr.Len()) ) |
1066 |
bMatch = FALSE; // RegExp must match entire cell string |
1067 |
if ( bRealRegExp ) |
1068 |
bOk = ((rEntry.eOp == SC_NOT_EQUAL) ? !bMatch : bMatch); |
1069 |
else |
1070 |
bTestEqual = bMatch; |
1071 |
} |
1072 |
if ( !bRealRegExp ) |
1073 |
{ |
1074 |
if ( rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL ) |
1064 |
{ |
1075 |
{ |
1065 |
// #i18374# When used from functions (match, countif, sumif, vlookup, hlookup, lookup), |
1076 |
if ( !rEntry.bQueryByString && rEntry.pStr->Len() == 0 ) |
1066 |
// the query value is assigned directly, and the string is empty. In that case, |
1077 |
{ |
1067 |
// don't find any string (isEqual would find empty string results in formula cells). |
1078 |
// #i18374# When used from functions (match, countif, sumif, vlookup, hlookup, lookup), |
1068 |
bOk = FALSE; |
1079 |
// the query value is assigned directly, and the string is empty. In that case, |
|
|
1080 |
// don't find any string (isEqual would find empty string results in formula cells). |
1081 |
bOk = FALSE; |
1082 |
} |
1083 |
else if ( bMatchWholeCell ) |
1084 |
bOk = pTransliteration->isEqual( aCellStr, *rEntry.pStr ); |
1085 |
else |
1086 |
{ |
1087 |
::com::sun::star::uno::Sequence< sal_Int32 > xOff; |
1088 |
String aCell( pTransliteration->transliterate( |
1089 |
aCellStr, ScGlobal::eLnge, 0, aCellStr.Len(), |
1090 |
&xOff ) ); |
1091 |
String aQuer( pTransliteration->transliterate( |
1092 |
*rEntry.pStr, ScGlobal::eLnge, 0, rEntry.pStr->Len(), |
1093 |
&xOff ) ); |
1094 |
bOk = (aCell.Search( aQuer ) != STRING_NOTFOUND); |
1095 |
} |
1096 |
if ( rEntry.eOp == SC_NOT_EQUAL ) |
1097 |
bOk = !bOk; |
1069 |
} |
1098 |
} |
1070 |
else if ( bMatchWholeCell ) |
1099 |
else |
1071 |
bOk = pTransliteration->isEqual( aCellStr, *rEntry.pStr ); |
1100 |
{ // use collator here because data was probably sorted |
1072 |
else |
1101 |
sal_Int32 nCompare = pCollator->compareString( |
1073 |
{ |
1102 |
aCellStr, *rEntry.pStr ); |
1074 |
::com::sun::star::uno::Sequence< sal_Int32 > xOff; |
1103 |
switch (rEntry.eOp) |
1075 |
String aCell( pTransliteration->transliterate( |
|
|
1076 |
aCellStr, ScGlobal::eLnge, 0, aCellStr.Len(), |
1077 |
&xOff ) ); |
1078 |
String aQuer( pTransliteration->transliterate( |
1079 |
*rEntry.pStr, ScGlobal::eLnge, 0, rEntry.pStr->Len(), |
1080 |
&xOff ) ); |
1081 |
bOk = (aCell.Search( aQuer ) != STRING_NOTFOUND); |
1082 |
} |
1083 |
if ( rEntry.eOp == SC_NOT_EQUAL ) |
1084 |
bOk = !bOk; |
1085 |
} |
1086 |
else |
1087 |
{ // use collator here because data was probably sorted |
1088 |
sal_Int32 nCompare = pCollator->compareString( |
1089 |
aCellStr, *rEntry.pStr ); |
1090 |
switch (rEntry.eOp) |
1091 |
{ |
1092 |
case SC_LESS : |
1093 |
bOk = (nCompare < 0); |
1094 |
break; |
1095 |
case SC_GREATER : |
1096 |
bOk = (nCompare > 0); |
1097 |
break; |
1098 |
case SC_LESS_EQUAL : |
1099 |
bOk = (nCompare <= 0); |
1100 |
if ( bOk && pbTestEqualCondition && !bTestEqual ) |
1101 |
bTestEqual = (nCompare == 0); |
1102 |
break; |
1103 |
case SC_GREATER_EQUAL : |
1104 |
bOk = (nCompare >= 0); |
1105 |
if ( bOk && pbTestEqualCondition && !bTestEqual ) |
1106 |
bTestEqual = (nCompare == 0); |
1107 |
break; |
1108 |
default: |
1109 |
{ |
1104 |
{ |
1110 |
// added to avoid warnings |
1105 |
case SC_LESS : |
|
|
1106 |
bOk = (nCompare < 0); |
1107 |
break; |
1108 |
case SC_GREATER : |
1109 |
bOk = (nCompare > 0); |
1110 |
break; |
1111 |
case SC_LESS_EQUAL : |
1112 |
bOk = (nCompare <= 0); |
1113 |
if ( bOk && pbTestEqualCondition && !bTestEqual ) |
1114 |
bTestEqual = (nCompare == 0); |
1115 |
break; |
1116 |
case SC_GREATER_EQUAL : |
1117 |
bOk = (nCompare >= 0); |
1118 |
if ( bOk && pbTestEqualCondition && !bTestEqual ) |
1119 |
bTestEqual = (nCompare == 0); |
1120 |
break; |
1121 |
default: |
1122 |
{ |
1123 |
// added to avoid warnings |
1124 |
} |
1111 |
} |
1125 |
} |
1112 |
} |
1126 |
} |
1113 |
} |
1127 |
} // if ( !bRealRegExp ) |
1114 |
} |
1128 |
} |
1115 |
} |
1129 |
} |
1116 |
else if (rParam.bMixedComparison) |
1130 |
else if (rParam.bMixedComparison) |
1117 |
{ |
1131 |
{ |