Index: sc/inc/global.hxx =================================================================== RCS file: /cvs/sc/sc/inc/global.hxx,v --- sc/inc/global.hxx 16 Nov 2005 10:12:10 -0000 1.44 +++ sc/inc/global.hxx 12 Feb 2006 09:39:45 -0000 @@ -804,7 +804,11 @@ SC_TOPVAL, SC_BOTVAL, SC_TOPPERC, - SC_BOTPERC + SC_BOTPERC, + SC_CONTAINS, + SC_DOES_NOT_CONTAIN, + SC_BEGINS_WITH, + SC_ENDS_WITH }; // ----------------------------------------------------------------------- Index: sc/source/core/data/table3.cxx =================================================================== RCS file: /cvs/sc/sc/source/core/data/table3.cxx,v --- sc/source/core/data/table3.cxx 8 Sep 2005 18:30:49 -0000 1.21 +++ sc/source/core/data/table3.cxx 12 Feb 2006 09:39:45 -0000 @@ -1011,13 +1011,22 @@ break; } } - else if ( (rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL) || + else if ( (rEntry.eOp == SC_CONTAINS || rEntry.eOp == SC_DOES_NOT_CONTAIN || + rEntry.eOp == SC_BEGINS_WITH || rEntry.eOp == SC_ENDS_WITH || + rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL) || (rEntry.bQueryByString && (pCell ? pCell->HasStringData() : HasStringData( static_cast(rEntry.nField), nRow)))) { // by String String aCellStr; + + // Contains and Does not contain is similar to EQUAL and NOT EQUAL + // but with bMatchWholeCell set to false + if( rEntry.eOp == SC_CONTAINS || rEntry.eOp == SC_DOES_NOT_CONTAIN || + rEntry.eOp == SC_BEGINS_WITH || rEntry.eOp == SC_ENDS_WITH ) + bMatchWholeCell = FALSE; + if ( pCell ) { if (pCell->GetCellType() != CELLTYPE_NOTE) @@ -1030,7 +1039,9 @@ GetInputString( static_cast(rEntry.nField), nRow, aCellStr ); BOOL bRealRegExp = (rParam.bRegExp && ((rEntry.eOp == SC_EQUAL) - || (rEntry.eOp == SC_NOT_EQUAL))); + || (rEntry.eOp == SC_NOT_EQUAL) || (rEntry.eOp == SC_CONTAINS) + || (rEntry.eOp == SC_DOES_NOT_CONTAIN) || (rEntry.eOp == SC_BEGINS_WITH) + || (rEntry.eOp == SC_ENDS_WITH))); BOOL bTestRegExp = (pbTestEqualCondition && rParam.bRegExp && ((rEntry.eOp == SC_LESS_EQUAL) || (rEntry.eOp == SC_GREATER_EQUAL))); @@ -1041,17 +1052,25 @@ BOOL bMatch = (BOOL) rEntry.GetSearchTextPtr( rParam.bCaseSens ) ->SearchFrwrd( aCellStr, &nStart, &nEnd ); // from 614 on, nEnd is behind the found text - if ( bMatch && bMatchWholeCell - && (nStart != 0 || nEnd != aCellStr.Len()) ) - bMatch = FALSE; // RegExp must match entire cell string + if ( bMatch ) + { + if ( bMatchWholeCell && (nStart != 0 || nEnd != aCellStr.Len()) ) + bMatch = FALSE; // RegExp must match entire cell string + else if ( ( rEntry.eOp == SC_BEGINS_WITH && nStart != 0 ) || + ( rEntry.eOp == SC_ENDS_WITH && nEnd != aCellStr.Len()-1 ) ) + bMatch = FALSE; + } if ( bRealRegExp ) - bOk = ((rEntry.eOp == SC_NOT_EQUAL) ? !bMatch : bMatch); + bOk = ( ( rEntry.eOp == SC_NOT_EQUAL || + rEntry.eOp == SC_DOES_NOT_CONTAIN ) ? !bMatch : bMatch ); else bTestEqual = bMatch; } if ( !bRealRegExp ) { - if ( rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL ) + if ( rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL || + rEntry.eOp == SC_CONTAINS || rEntry.eOp == SC_DOES_NOT_CONTAIN || + rEntry.eOp == SC_BEGINS_WITH || rEntry.eOp == SC_ENDS_WITH ) { if ( !rEntry.bQueryByString && rEntry.pStr->Len() == 0 ) { @@ -1071,9 +1090,15 @@ String aQuer( pTransliteration->transliterate( *rEntry.pStr, ScGlobal::eLnge, 0, rEntry.pStr->Len(), &xOff ) ); - bOk = (aCell.Search( aQuer ) != STRING_NOTFOUND); + xub_StrLen nPos = aCell.Search( aQuer ); + bOk = ( nPos != STRING_NOTFOUND ); + if ( bOk ) + if ( rEntry.eOp == SC_BEGINS_WITH && nPos != 0 || + rEntry.eOp == SC_ENDS_WITH && nPos != aCell.Len()-aQuer.Len()-1 ) + bOk = FALSE; } - if ( rEntry.eOp == SC_NOT_EQUAL ) + if ( rEntry.eOp == SC_NOT_EQUAL || + rEntry.eOp == SC_DOES_NOT_CONTAIN ) bOk = !bOk; } else Index: sc/source/ui/src/filter.src =================================================================== RCS file: /cvs/sc/sc/source/ui/src/filter.src,v --- sc/source/ui/src/filter.src 23 Sep 2005 15:06:19 -0000 1.56 +++ sc/source/ui/src/filter.src 12 Feb 2006 09:39:45 -0000 @@ -154,16 +154,20 @@ }; stringlist [ en-US ] = { - < "=" ; Default ; > ; + < "Equals" ; Default ; > ; < "<" ; Default ; > ; < ">" ; Default ; > ; < "<=" ; Default ; > ; < ">=" ; Default ; > ; - < "<>" ; Default ; > ; + < "Not equals" ; Default ; > ; < "Largest" ; Default ; > ; < "Smallest" ; Default ; > ; < "Largest %" ; Default ; > ; < "Smallest %" ; Default ; > ; + < "Contains" ; Default ; > ; + < "Does not Contain" ; Default ; > ; + < "Begins with" ; Default ; > ; + < "Ends with" ; Default ; > ; }; }; ListBox LB_COND2 @@ -188,16 +192,20 @@ }; stringlist [ en-US ] = { - < "=" ; Default ; > ; + < "Equals" ; Default ; > ; < "<" ; Default ; > ; < ">" ; Default ; > ; < "<=" ; Default ; > ; < ">=" ; Default ; > ; - < "<>" ; Default ; > ; + < "Not equals" ; Default ; > ; < "Largest" ; Default ; > ; < "Smallest" ; Default ; > ; < "Largest %" ; Default ; > ; < "Smallest %" ; Default ; > ; + < "Contains" ; Default ; > ; + < "Does not Contain" ; Default ; > ; + < "Begins with" ; Default ; > ; + < "Ends with" ; Default ; > ; }; }; ListBox LB_COND3 @@ -222,16 +230,20 @@ }; stringlist [ en-US ] = { - < "=" ; Default ; > ; + < "Equals" ; Default ; > ; < "<" ; Default ; > ; < ">" ; Default ; > ; < "<=" ; Default ; > ; < ">=" ; Default ; > ; - < "<>" ; Default ; > ; + < "Not equals" ; Default ; > ; < "Largest" ; Default ; > ; < "Smallest" ; Default ; > ; < "Largest %" ; Default ; > ; < "Smallest %" ; Default ; > ; + < "Contains" ; Default ; > ; + < "Does not Contain" ; Default ; > ; + < "Begins with" ; Default ; > ; + < "Ends with" ; Default ; > ; }; }; ComboBox ED_VAL1