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] Fri Jan 11 10:03:45 +0000
2008 -------
lvyue:
Apart from the missing ODF code I have only one consolidation issue.
================================================================================
sc/source/core/data/table3.cxx
================================================================================
@@ -1045,14 +1055,51 @@ BOOL ScTable::ValidQuery(SCROW nRow, con
{
xub_StrLen nStart = 0;
xub_StrLen nEnd = aCellStr.Len();
- BOOL bMatch = (BOOL) rEntry.GetSearchTextPtr( rParam.bCaseSens
)
- ->SearchFrwrd( aCellStr, &nStart, &nEnd );
// from 614 on, nEnd is behind the found text
+ BOOL bMatch = FALSE;
+ if ( rEntry.eOp == SC_ENDS_WITH || rEntry.eOp ==
SC_DOES_NOT_END_WITH )
+ {
+ nEnd = 0;
+ nStart = aCellStr.Len();
+ bMatch = (BOOL) rEntry.GetSearchTextPtr( rParam.bCaseSens )
+ ->SearchBkwrd( aCellStr, &nStart, &nEnd );
+ }
+ else
+ {
+ bMatch = (BOOL) rEntry.GetSearchTextPtr( rParam.bCaseSens )
+ ->SearchFrwrd( aCellStr, &nStart, &nEnd );
+ }
if ( bMatch && bMatchWholeCell
&& (nStart != 0 || nEnd != aCellStr.Len()) )
bMatch = FALSE; // RegExp must match entire cell string
if ( bRealRegExp )
- bOk = ((rEntry.eOp == SC_NOT_EQUAL) ? !bMatch : bMatch);
+ switch (rEntry.eOp)
+ {
+ case SC_EQUAL:
+ case SC_CONTAINS:
+ bOk = bMatch;
+ break;
+ case SC_NOT_EQUAL:
+ case SC_DOES_NOT_CONTAIN:
+ bOk = !bMatch;
+ break;
+ case SC_BEGINS_WITH:
+ bOk = ( bMatch && (nStart == 0) );
+ break;
+ case SC_DOES_NOT_BEGIN_WITH:
+ bOk = !( bMatch && (nStart == 0) );
+ break;
+ case SC_ENDS_WITH:
+ bOk = ( bMatch && (nEnd == aCellStr.Len()) );
+ break;
+ case SC_DOES_NOT_END_WITH:
+ bOk = !( bMatch && (nEnd == aCellStr.Len()) );
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
This is really nice code, that's exactly what I meant.
@@ -1083,6 +1130,46 @@ BOOL ScTable::ValidQuery(SCROW nRow, con
if ( rEntry.eOp == SC_NOT_EQUAL )
bOk = !bOk;
}
+ 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_DOES_NOT_BEGIN_WITH || rEntry.eOp ==
SC_DOES_NOT_END_WITH )
+ {
+ ::com::sun::star::uno::Sequence< sal_Int32 > xOff;
+ String aCell( pTransliteration->transliterate(
+ aCellStr, ScGlobal::eLnge, 0, aCellStr.Len(),
+ &xOff ) );
+ String aQuer( pTransliteration->transliterate(
+ *rEntry.pStr, ScGlobal::eLnge, 0, rEntry.pStr->Len(),
+ &xOff ) );
+ 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_CONTAINS:
+ bOk = ( nStrPos != STRING_NOTFOUND );
+ break;
+ case SC_DOES_NOT_CONTAIN:
+ bOk = ( nStrPos == STRING_NOTFOUND );
+ break;
+ case SC_BEGINS_WITH:
+ bOk = ( nStrPos == 0 );
+ break;
+ case SC_DOES_NOT_BEGIN_WITH:
+ bOk = ( nStrPos != 0 );
+ break;
+ case SC_ENDS_WITH:
+ bOk = ( nStrPos + aQuer.Len() == aCell.Len() );
+ break;
+ case SC_DOES_NOT_END_WITH:
+ bOk = ( nStrPos + aQuer.Len() != aCell.Len() );
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
Also that's what I meant, but I think you can further consolidate code by
combining the SC_EQUAL ... code branch and the SC_CONTAINS ... code branch.
---------------------------------------------------------------------
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]