diff options
Diffstat (limited to 'connectivity/source/drivers/mork/MResultSet.cxx')
-rw-r--r-- | connectivity/source/drivers/mork/MResultSet.cxx | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/connectivity/source/drivers/mork/MResultSet.cxx b/connectivity/source/drivers/mork/MResultSet.cxx index 524f9d02a2ac..d14a0468d7e3 100644 --- a/connectivity/source/drivers/mork/MResultSet.cxx +++ b/connectivity/source/drivers/mork/MResultSet.cxx @@ -761,6 +761,10 @@ void OResultSet::parseParameter( const OSQLParseNode* pNode, OUString& rMatchStr #endif } +#define WILDCARD "%" +#define ALT_WILDCARD "*" +static const sal_Unicode MATCHCHAR = '_'; + void OResultSet::analyseWhereClause( const OSQLParseNode* parseTree, MQueryExpression &queryExpression) { @@ -912,10 +916,6 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_LIKE_STRING, *this ); } - const sal_Unicode WILDCARD = '%'; - const sal_Unicode ALT_WILDCARD = '*'; - const sal_Unicode MATCHCHAR = '_'; - OUString sTableRange; if(SQL_ISRULE(pColumn,column_ref)) m_pSQLIterator->getColumnRange(pColumn,columnName,sTableRange); @@ -926,7 +926,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT parseParameter( pAtom, matchString ); // Replace all '*' with '%' : UI Usually does this but not with // Parameters for some reason. - matchString = matchString.replace( ALT_WILDCARD, WILDCARD ); + matchString = matchString.replaceAll( ALT_WILDCARD, WILDCARD ); } else { @@ -935,7 +935,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT // Determine where '%' character is... - if ( matchString.equals( OUString( WILDCARD ) ) ) + if ( matchString == WILDCARD ) { // String containing only a '%' and nothing else op = MQueryOp::Exists; @@ -951,8 +951,8 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT else op = MQueryOp::Contains; } - else if ( matchString.indexOf ( WILDCARD ) == 0 - && matchString.lastIndexOf ( WILDCARD ) == matchString.getLength() -1 + else if ( matchString.startsWith( WILDCARD ) + && matchString.endsWith( WILDCARD ) && matchString.indexOf ( WILDCARD, 1 ) == matchString.lastIndexOf ( WILDCARD ) && matchString.indexOf( MATCHCHAR ) == -1 ) @@ -980,7 +980,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT ) { // One occurrence of '%' - no '_' matches... - if ( matchString.indexOf ( WILDCARD ) == 0 ) + if ( matchString.startsWith( WILDCARD ) ) { op = MQueryOp::EndsWith; matchString = matchString.replaceAt( 0, 1, OUString()); @@ -993,7 +993,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT else { sal_Int32 pos = matchString.indexOf ( WILDCARD ); - matchString = matchString.replaceAt( pos, 1,OUString(".*") ); + matchString = matchString.replaceAt( pos, 1, ".*" ); op = MQueryOp::RegExp; } @@ -1001,13 +1001,12 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT else { // Most Complex, need to use an RE - sal_Int32 pos = matchString.indexOf ( WILDCARD ); + sal_Int32 pos; while ( (pos = matchString.indexOf ( WILDCARD )) != -1 ) { matchString = matchString.replaceAt( pos, 1, OUString(".*") ); } - pos = matchString.indexOf ( MATCHCHAR ); while ( (pos = matchString.indexOf( MATCHCHAR )) != -1 ) { matchString = matchString.replaceAt( pos, 1, OUString(".") ); |