To comment on the following update, log in, then open the issue: http://www.openoffice.org/issues/show_bug.cgi?id=35579
------- Additional comments from [EMAIL PROTECTED] Mon Jan 7 16:28:47 +0000 2008 ------- This iteration of the patch is much better. Please see my comments below. Thomas ================================================================================ The code for exporting/importing the new filter conditions to/from ODF is missing!!! ================================================================================ I got the news from Eike, that the missing '!begins' and '!ends' attribute values were proposed to the OASIS ODF TC today. Probably next week they will decide about them. ================================================================================ sc/source/core/data/table3.cxx ================================================================================ @@ -1036,29 +1043,45 @@ BOOL ScTable::ValidQuery(SCROW nRow, con else GetInputString( static_cast<SCCOL>(rEntry.nField), nRow, aCellStr ); - BOOL bRealRegExp = (rParam.bRegExp && ((rEntry.eOp == SC_EQUAL) - || (rEntry.eOp == SC_NOT_EQUAL))); + BOOL bRealRegExp = (rParam.bRegExp && ((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) || (rEntry.eOp == SC_DOES_NOT_BEGIN_WITH) + || (rEntry.eOp == SC_DOES_NOT_END_WITH))); BOOL bTestRegExp = (pbTestEqualCondition && rParam.bRegExp && ((rEntry.eOp == SC_LESS_EQUAL) || (rEntry.eOp == SC_GREATER_EQUAL))); if ( bRealRegExp || bTestRegExp ) { - xub_StrLen nStart = 0; + xub_StrLen nStart = (rEntry.eOp == SC_ENDS_WITH + || rEntry.eOp == SC_DOES_NOT_END_WITH)? ( aCellStr.Len() - rEntry.pStr->Len() ):0; xub_StrLen nEnd = aCellStr.Len(); BOOL bMatch = (BOOL) rEntry.GetSearchTextPtr( rParam.bCaseSens ) ->SearchFrwrd( aCellStr, &nStart, &nEnd ); The code branch for searching with regular expressions needs some rework. Thanks to Eike for all the hints. For the SC_ENDS_WITH and SC_DOES_NOT_END_WITH part, setting nStart to aCellStr.Len() - rEntry.pStr->Len() is not correct, as your regular expression can match the whole cell string, although the length of the regular expression is much shorter. Therefore you have to search starting with nStart=0, that means the whole cell string. You'll get some problems, if the cell string contains the regular expression more than one time, therefore you have to guarantee, that you find the last occurance. Probably TextSearch::SearchBkwrd() is your friend in this case. Finally you can check, if nEnd equals aCellStr.Len(). - 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; + else if ( ((rEntry.eOp == SC_BEGINS_WITH || rEntry.eOp == SC_DOES_NOT_BEGIN_WITH) + && (nStart != 0)) + || ((rEntry.eOp == SC_ENDS_WITH || rEntry.eOp == SC_DOES_NOT_END_WITH) + && (nEnd != aCellStr.Len())) ) + bMatch = FALSE; + } if ( bRealRegExp ) - bOk = ((rEntry.eOp == SC_NOT_EQUAL) ? !bMatch : bMatch); + bOk = ((rEntry.eOp == SC_NOT_EQUAL || rEntry.eOp == SC_DOES_NOT_CONTAIN + || rEntry.eOp == SC_DOES_NOT_BEGIN_WITH + || rEntry.eOp == SC_DOES_NOT_END_WITH) ? !bMatch : bMatch); This part of the code is hard to read and hard to understand, especially bOK = !bMatch a few lines later. I would recommend to have a switch statement and handle there the different cases for SC_BEGINS_WITH, SC_DOES_NOT_BEGIN_WITH, etc. @@ -1078,10 +1101,35 @@ BOOL ScTable::ValidQuery(SCROW nRow, con String aQuer( pTransliteration->transliterate( *rEntry.pStr, ScGlobal::eLnge, 0, rEntry.pStr->Len(), &xOff ) ); - bOk = (aCell.Search( aQuer ) != STRING_NOTFOUND); + xub_StrLen nIndex = (rEntry.eOp == SC_ENDS_WITH + || rEntry.eOp == SC_DOES_NOT_END_WITH)? (aCell.Len()-aQuer.Len()):0; + xub_StrLen nStrPos = aCell.Search( aQuer, nIndex ); + switch (rEntry.eOp) + { + case SC_EQUAL: + case SC_CONTAINS: + case SC_NOT_EQUAL: + case SC_DOES_NOT_CONTAIN: + bOk = ( nStrPos != STRING_NOTFOUND ); + break; + case SC_BEGINS_WITH : + case SC_DOES_NOT_BEGIN_WITH : + bOk = ( nStrPos == 0 ); + break; + case SC_ENDS_WITH : + case SC_DOES_NOT_END_WITH : + bOk = ( nStrPos + aQuer.Len() == aCell.Len() ); + break; + default: + { + // added to avoid warnings + } + } } - if ( rEntry.eOp == SC_NOT_EQUAL ) - bOk = !bOk; + if ( rEntry.eOp == SC_NOT_EQUAL || rEntry.eOp == SC_DOES_NOT_CONTAIN + || rEntry.eOp == SC_DOES_NOT_BEGIN_WITH + || rEntry.eOp == SC_DOES_NOT_END_WITH ) + bOk = !bOk; The code branch for searching without regular expressions is in general fine. Nevertheless I would also recommend to move the bOk = !bOk part to the case statements, e.g. case SC_BEGINS_WITH : bOk = ( nStrPos == 0 ); break; case SC_DOES_NOT_BEGIN_WITH : bOk = ( nStrPos != 0 ); break; ================================================================================ sc/source/ui/inc/filtdlg.hxx ================================================================================ @@ -103,6 +103,7 @@ ScFilterDlg::ScFilterDlg( SfxBindings* p aFtField ( this, ScResId( FT_FIELD ) ), aFtCond ( this, ScResId( FT_COND ) ), aFtVal ( this, ScResId( FT_VAL ) ), + aFlSeparator ( this, ScResId( FL_SEPARATOR ) ), Please indent with 8 spaces. ================================================================================ sc/source/ui/inc/filtdlg.hxx ================================================================================ @@ -154,6 +154,7 @@ private: FixedText aFtField; FixedText aFtCond; FixedText aFtVal; + FixedLine aFlSeparator; Please indent with 4 spaces. ================================================================================ sc/source/ui/src/filter.src ================================================================================ Please align the 'Copy results to ...' list boxes and the Shrink button (Options section) on the right edge with the Help button. See Franks mockup (http://wiki.services.openoffice.org/wiki/Image:Standard_Filter_Dialog.png) for more details. @@ -58,13 +58,13 @@ ModelessDialog RID_SCDLG_FILTER FixedText FT_COND { Pos = MAP_APPFONT ( 122 , 14 ) ; - Size = MAP_APPFONT ( 47 , 8 ) ; + Size = MAP_APPFONT ( 75 , 8 ) ; Text [ en-US ] = "Condition" ; }; FixedText FT_VAL { - Pos = MAP_APPFONT ( 173 , 14 ) ; - Size = MAP_APPFONT ( 60 , 8 ) ; + Pos = MAP_APPFONT ( 201 , 14 ) ; + Size = MAP_APPFONT ( 60 , 8 ) ; Please indent with 8 spaces. @@ -178,25 +190,31 @@ ModelessDialog RID_SCDLG_FILTER < "Smallest" ; Default ; > ; < "Largest %" ; Default ; > ; < "Smallest %" ; Default ; > ; + < "Contains" ; Default ; > ; + < "Does not contain" ; Default ; > ; + < "Begins with" ; Default ; > ; + < "Does not begin with" ; Default ; > ; + < "Ends with" ; Default ; > ; + < "Does not end with" ; Default ; > ; }; }; ComboBox ED_VAL1 { - Pos = MAP_APPFONT ( 173 , 25 ) ; + Pos = MAP_APPFONT ( 201 , 25 ) ; Size = MAP_APPFONT ( 60 , 90 ) ; TabStop = TRUE ; DropDown = TRUE ; }; ComboBox ED_VAL2 { - Pos = MAP_APPFONT ( 173 , 41 ) ; + Pos = MAP_APPFONT ( 201 , 41 ) ; Please indent with 8 spaces. ComboBox ED_VAL3 { - Pos = MAP_APPFONT ( 173 , 57 ) ; + Pos = MAP_APPFONT ( 201 , 57 ) ; Please indent with 8 spaces. @@ -204,13 +222,13 @@ ModelessDialog RID_SCDLG_FILTER FixedLine FL_CRITERIA { Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 230 , 8 ) ; + Size = MAP_APPFONT ( 258 , 8 ) ; Please indent with 8 spaces. --------------------------------------------------------------------- Please do not reply to this automatically generated notification from Issue Tracker. Please log onto the website and enter your comments. http://qa.openoffice.org/issue_handling/project_issues.html#notification --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]