diff options
103 files changed, 214 insertions, 246 deletions
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index b22db958658e..a7b0b20b147d 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -820,7 +820,7 @@ bool DialogWindow::SaveDialog() if( aExtension == "properties" || aExtension == "default" ) { - if( aPureName.indexOf( aDialogName_ ) == 0 ) + if( aPureName.startsWith( aDialogName_ ) ) { try { diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index a2c55a811aaf..6cd204ef5855 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -3387,7 +3387,7 @@ SbxVariable* SbiRuntime::FindElement( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt OUString aName( pImg->GetString( static_cast<short>( nOp1 & 0x7FFF ) ) ); // Hacky capture of Evaluate [] syntax // this should be tackled I feel at the pcode level - if ( bIsVBAInterOp && aName.indexOf((sal_Unicode)'[') == 0 ) + if ( bIsVBAInterOp && aName.startsWith("[") ) { // emulate pcode here StepARGC(); diff --git a/codemaker/source/codemaker/global.cxx b/codemaker/source/codemaker/global.cxx index 17c6feca6e3c..bfe77c452af8 100644 --- a/codemaker/source/codemaker/global.cxx +++ b/codemaker/source/codemaker/global.cxx @@ -237,23 +237,16 @@ sal_Bool removeTypeFile(const OString& fileName) return sal_False; } -static sal_Bool isFileUrl(const OString& fileName) -{ - if (fileName.indexOf("file://") == 0 ) - return sal_True; - return sal_False; -} - OUString convertToFileUrl(const OString& fileName) { - if ( isFileUrl(fileName) ) + if ( fileName.startsWith("file://") ) { return OStringToOUString(fileName, osl_getThreadTextEncoding()); } OUString uUrlFileName; OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding()); - if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 ) + if ( fileName.startsWith(".") || fileName.indexOf(SEPARATOR) < 0 ) { OUString uWorkingDir; if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None) diff --git a/connectivity/source/commontools/AutoRetrievingBase.cxx b/connectivity/source/commontools/AutoRetrievingBase.cxx index 78b5f729761e..fd82b6267a50 100644 --- a/connectivity/source/commontools/AutoRetrievingBase.cxx +++ b/connectivity/source/commontools/AutoRetrievingBase.cxx @@ -42,12 +42,10 @@ namespace connectivity { // we need a table name sal_Int32 nIntoIndex = sStmt.indexOf("INTO "); sStmt = sStmt.copy(nIntoIndex+5); - do + while (sStmt.startsWith(" ")); { - if ( sStmt.indexOf(' ') == 0 ) - sStmt = sStmt.copy(1); + sStmt = sStmt.copy(1); } - while (sStmt.indexOf(' ') == 0 ); nIntoIndex = 0; OUString sTableName = sStmt.getToken(0,' ',nIntoIndex); diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx index 2dcb23d338ba..de82465c8dc1 100644 --- a/connectivity/source/commontools/dbtools2.cxx +++ b/connectivity/source/commontools/dbtools2.cxx @@ -385,10 +385,10 @@ OUString createSqlCreateTableStatement( const Reference< XPropertySet >& descri aSql += sKeyStmt; else { - if ( aSql.lastIndexOf(',') == (aSql.getLength()-1) ) - aSql = aSql.replaceAt(aSql.getLength()-1,1,OUString(")")); + if ( aSql.endsWith(",") ) + aSql = aSql.replaceAt(aSql.getLength()-1, 1, ")"); else - aSql += OUString(")"); + aSql += ")"; } return aSql; } diff --git a/connectivity/source/drivers/evoab2/NStatement.cxx b/connectivity/source/drivers/evoab2/NStatement.cxx index 3d89b926e403..d341eddc44a1 100644 --- a/connectivity/source/drivers/evoab2/NStatement.cxx +++ b/connectivity/source/drivers/evoab2/NStatement.cxx @@ -387,7 +387,7 @@ EBookQuery *OCommonStatement::whereAnalysis( const OSQLParseNode* parseTree ) } else if( (aMatchString.indexOf ( WILDCARD ) == aMatchString.lastIndexOf ( WILDCARD ) ) ) { // One occurrence of '%' matches... - if ( aMatchString.indexOf ( WILDCARD ) == 0 ) + if ( aMatchString.startsWith( WILDCARD ) ) pResult = createTest( aColumnName, E_BOOK_QUERY_ENDS_WITH, aMatchString.copy( 1 ) ); else if ( aMatchString.indexOf ( WILDCARD ) == aMatchString.getLength() - 1 ) pResult = createTest( aColumnName, E_BOOK_QUERY_BEGINS_WITH, aMatchString.copy( 0, aMatchString.getLength() - 1 ) ); @@ -398,7 +398,7 @@ EBookQuery *OCommonStatement::whereAnalysis( const OSQLParseNode* parseTree ) pResult = e_book_query_not( pResult, TRUE ); } else if( aMatchString.getLength() >= 3 && - aMatchString.indexOf ( WILDCARD ) == 0 && + aMatchString.startsWith( WILDCARD ) && aMatchString.indexOf ( WILDCARD, 1) == aMatchString.getLength() - 1 ) { // one '%' at the start and another at the end pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, aMatchString.copy (1, aMatchString.getLength() - 2) ); diff --git a/connectivity/source/drivers/hsqldb/HTable.cxx b/connectivity/source/drivers/hsqldb/HTable.cxx index 13b636fc645e..be5c8aa74ee1 100644 --- a/connectivity/source/drivers/hsqldb/HTable.cxx +++ b/connectivity/source/drivers/hsqldb/HTable.cxx @@ -328,8 +328,8 @@ OUString OHSQLTable::getAlterTableColumnPart() void OHSQLTable::executeStatement(const OUString& _rStatement ) { OUString sSQL = _rStatement; - if(sSQL.lastIndexOf(',') == (sSQL.getLength()-1)) - sSQL = sSQL.replaceAt(sSQL.getLength()-1,1,OUString(")")); + if(sSQL.endsWith(",")) + sSQL = sSQL.replaceAt(sSQL.getLength()-1, 1, ")"); Reference< XStatement > xStmt = getConnection()->createStatement( ); if ( xStmt.is() ) diff --git a/connectivity/source/drivers/macab/macabutilities.hxx b/connectivity/source/drivers/macab/macabutilities.hxx index a17bda266458..5b151575351d 100644 --- a/connectivity/source/drivers/macab/macabutilities.hxx +++ b/connectivity/source/drivers/macab/macabutilities.hxx @@ -102,7 +102,7 @@ namespace connectivity /* Get the length, and make sure that there is actually a string * here. */ - if(_originalLabel.indexOf("_$!<") == 0) + if(_originalLabel.startsWith("_$!<")) { return _originalLabel.copy(4,_originalLabel.getLength()-8); } diff --git a/connectivity/source/drivers/mork/MQueryHelper.cxx b/connectivity/source/drivers/mork/MQueryHelper.cxx index 3cc5b9320e58..05dd1219f6fc 100644 --- a/connectivity/source/drivers/mork/MQueryHelper.cxx +++ b/connectivity/source/drivers/mork/MQueryHelper.cxx @@ -322,7 +322,7 @@ sal_Int32 MQueryHelper::executeQuery(OConnection* xConnection) resultVector.push_back((currentValue.endsWith(searchedValue)) ? sal_True : sal_False); } else if (evStr->getCond() == MQueryOp::BeginsWith) { SAL_INFO("connectivity.mork", "MQueryOp::BeginsWith; done"); - resultVector.push_back((currentValue.indexOf(searchedValue) == 0) ? sal_True : sal_False); + resultVector.push_back((currentValue.startsWith(searchedValue)) ? sal_True : sal_False); } else if (evStr->getCond() == MQueryOp::Contains) { SAL_INFO("connectivity.mork", "MQueryOp::Contains; done"); resultVector.push_back((currentValue.indexOf(searchedValue) == -1) ? sal_False : sal_True); 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(".") ); diff --git a/connectivity/source/drivers/mozab/MResultSet.cxx b/connectivity/source/drivers/mozab/MResultSet.cxx index 6d94fa7c8dff..15d99ceee51a 100644 --- a/connectivity/source/drivers/mozab/MResultSet.cxx +++ b/connectivity/source/drivers/mozab/MResultSet.cxx @@ -933,8 +933,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 ) @@ -962,20 +962,20 @@ 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()); } - else if ( matchString.indexOf ( WILDCARD ) == matchString.getLength() -1 ) + else if ( matchString.endsWith( WILDCARD ) ) { op = MQueryOp::BeginsWith; - matchString = matchString.replaceAt( matchString.getLength() -1 , 1, OUString() ); + matchString = matchString.replaceAt( matchString.getLength() -1, 1, OUString() ); } else { sal_Int32 pos = matchString.indexOf ( WILDCARD ); - matchString = matchString.replaceAt( pos, 1,OUString(".*") ); + matchString = matchString.replaceAt( pos, 1, ".*" ); op = MQueryOp::RegExp; } @@ -983,16 +983,15 @@ 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(".*") ); + matchString = matchString.replaceAt( pos, 1, ".*" ); } - pos = matchString.indexOf ( MATCHCHAR ); while ( (pos = matchString.indexOf( MATCHCHAR )) != -1 ) { - matchString = matchString.replaceAt( pos, 1, OUString(".") ); + matchString = matchString.replaceAt( pos, 1, "." ); } op = MQueryOp::RegExp; diff --git a/connectivity/source/drivers/mysql/YTable.cxx b/connectivity/source/drivers/mysql/YTable.cxx index efc80a2ae4c9..4938b724fc34 100644 --- a/connectivity/source/drivers/mysql/YTable.cxx +++ b/connectivity/source/drivers/mysql/YTable.cxx @@ -354,8 +354,8 @@ OUString OMySQLTable::getAlterTableColumnPart() void OMySQLTable::executeStatement(const OUString& _rStatement ) { OUString sSQL = _rStatement; - if(sSQL.lastIndexOf(',') == (sSQL.getLength()-1)) - sSQL = sSQL.replaceAt(sSQL.getLength()-1,1,OUString(")")); + if(sSQL.endsWith(",")) + sSQL = sSQL.replaceAt(sSQL.getLength()-1, 1, ")"); Reference< XStatement > xStmt = getConnection()->createStatement( ); if ( xStmt.is() ) diff --git a/cpputools/source/unoexe/unoexe.cxx b/cpputools/source/unoexe/unoexe.cxx index fe1d9766941a..971ce344b08a 100644 --- a/cpputools/source/unoexe/unoexe.cxx +++ b/cpputools/source/unoexe/unoexe.cxx @@ -89,7 +89,7 @@ static sal_Bool readOption( OUString * pValue, const sal_Char * pOpt, throw (RuntimeException) { const OUString dash("-"); - if(aArg.indexOf(dash) != 0) + if(!aArg.startsWith(dash)) return sal_False; OUString aOpt = OUString::createFromAscii( pOpt ); @@ -145,7 +145,7 @@ static sal_Bool readOption( sal_Bool * pbOpt, const sal_Char * pOpt, const OUString dashdash("--"); OUString aOpt = OUString::createFromAscii(pOpt); - if(aArg.indexOf(dashdash) == 0 && aOpt.equals(aArg.copy(2))) + if(aArg.startsWith(dashdash) && aOpt.equals(aArg.copy(2))) { ++(*pnIndex); *pbOpt = sal_True; diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index 35da4cccdfa0..8605ade05212 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -804,7 +804,7 @@ SvxConfigDialog::SvxConfigDialog( { OUString text = ((const SfxStringItem*)pItem)->GetValue(); - if (text.indexOf( ITEM_TOOLBAR_URL ) == 0) + if (text.startsWith( ITEM_TOOLBAR_URL ) ) { SetCurPageId( RID_SVXPAGE_TOOLBARS ); } @@ -3109,7 +3109,7 @@ SvxToolbarConfigPage::SvxToolbarConfigPage( if ( pItem ) { OUString text = ((const SfxStringItem*)pItem)->GetValue(); - if (text.indexOf( ITEM_TOOLBAR_URL ) == 0) + if (text.startsWith( ITEM_TOOLBAR_URL )) { m_aURLToSelect = text.copy( 0 ); } @@ -3754,7 +3754,7 @@ void ToolbarSaveInData::SetSystemStyle( const OUString& rResourceURL, sal_Int32 nStyle ) { - if ( rResourceURL.indexOf( "private" ) == 0 && + if ( rResourceURL.startsWith( "private" ) && m_xPersistentWindowState.is() && m_xPersistentWindowState->hasByName( rResourceURL ) ) { @@ -3793,7 +3793,7 @@ sal_Int32 ToolbarSaveInData::GetSystemStyle( const OUString& rResourceURL ) { sal_Int32 result = 0; - if ( rResourceURL.indexOf( "private" ) == 0 && + if ( rResourceURL.startsWith( "private" ) && m_xPersistentWindowState.is() && m_xPersistentWindowState->hasByName( rResourceURL ) ) { @@ -3827,7 +3827,7 @@ OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL ) { OUString result; - if ( rResourceURL.indexOf( "private" ) == 0 && + if ( rResourceURL.startsWith( "private" ) && m_xPersistentWindowState.is() && m_xPersistentWindowState->hasByName( rResourceURL ) ) { @@ -3853,7 +3853,7 @@ OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL ) } } - if ( rResourceURL.indexOf( ".uno" ) == 0 && + if ( rResourceURL.startsWith( ".uno" ) && m_xCommandToLabelMap.is() && m_xCommandToLabelMap->hasByName( rResourceURL ) ) { @@ -3956,7 +3956,7 @@ SvxEntries* ToolbarSaveInData::GetEntries() aToolbarInfo.insert( ToolbarInfo::value_type( systemname, true )); OUString custom(CUSTOM_TOOLBAR_STR); - if ( systemname.indexOf( custom ) == 0 ) + if ( systemname.startsWith( custom ) ) { pEntry->SetUserDefined( sal_True ); } @@ -4008,7 +4008,7 @@ SvxEntries* ToolbarSaveInData::GetEntries() // custom toolbars of the parent are not visible in the document layer OUString custom(CUSTOM_TOOLBAR_STR); - if ( systemname.indexOf( custom ) == 0 ) + if ( systemname.startsWith( custom ) ) continue; // check if toolbar is already in the document layer @@ -4039,7 +4039,7 @@ SvxEntries* ToolbarSaveInData::GetEntries() pEntry->SetMain( sal_True ); pEntry->SetStyle( GetSystemStyle( url ) ); - if ( systemname.indexOf( custom ) == 0 ) + if ( systemname.startsWith( custom ) ) { pEntry->SetUserDefined( sal_True ); } diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx index 509a3728d7d3..a23418522fd9 100644 --- a/cui/source/customize/cfgutil.cxx +++ b/cui/source/customize/cfgutil.cxx @@ -99,7 +99,7 @@ sal_Bool SfxStylesInfo_Impl::parseStyleCommand(SfxStyleInfo_Impl& aStyle) static sal_Int32 LEN_SPART = CMDURL_SPART_ONLY.getLength(); static sal_Int32 LEN_FPART = CMDURL_FPART_ONLY.getLength(); - if (aStyle.sCommand.indexOf(CMDURL_STYLEPROT_ONLY, 0) != 0) + if (!aStyle.sCommand.startsWith(CMDURL_STYLEPROT_ONLY)) return sal_False; aStyle.sFamily = OUString(); @@ -112,15 +112,15 @@ sal_Bool SfxStylesInfo_Impl::parseStyleCommand(SfxStyleInfo_Impl& aStyle) return sal_False; OUString sArg = sCmdArgs.copy(0, i); - if (sArg.indexOf(CMDURL_SPART_ONLY) == 0) + if (sArg.startsWith(CMDURL_SPART_ONLY)) aStyle.sStyle = sArg.copy(LEN_SPART, sArg.getLength()-LEN_SPART); - else if (sArg.indexOf(CMDURL_FPART_ONLY) == 0) + else if (sArg.startsWith(CMDURL_FPART_ONLY)) aStyle.sFamily = sArg.copy(LEN_FPART, sArg.getLength()-LEN_FPART); sArg = sCmdArgs.copy(i+1, sCmdArgs.getLength()-i-1); - if (sArg.indexOf(CMDURL_SPART_ONLY) == 0) + if (sArg.startsWith(CMDURL_SPART_ONLY)) aStyle.sStyle = sArg.copy(LEN_SPART, sArg.getLength()-LEN_SPART); - else if (sArg.indexOf(CMDURL_FPART_ONLY) == 0) + else if (sArg.startsWith(CMDURL_FPART_ONLY)) aStyle.sFamily = sArg.copy(LEN_FPART, sArg.getLength()-LEN_FPART); if (!(aStyle.sFamily.isEmpty() || aStyle.sStyle.isEmpty())) diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx index e0ca7ef4c89d..ab01f069a0a0 100644 --- a/cui/source/customize/macropg.cxx +++ b/cui/source/customize/macropg.cxx @@ -631,7 +631,7 @@ long _SvxMacroTabPage::GenericHandler_Impl( _SvxMacroTabPage* pThis, PushButton* } bool bDoubleClick = (pBtn == NULL); - bool bUNOAssigned = (sEventURL.indexOf( aVndSunStarUNO ) == 0); + bool bUNOAssigned = sEventURL.startsWith( aVndSunStarUNO ); if( pBtn == pImpl->pDeletePB ) { // delete pressed @@ -895,14 +895,10 @@ AssignComponentDialog::AssignComponentDialog( Window * pParent, const OUString& maOKButton.SetClickHdl(LINK(this, AssignComponentDialog, ButtonHandler)); OUString aMethodName; - if( !maURL.isEmpty() ) + if( maURL.startsWith( aVndSunStarUNO ) ) { - sal_Int32 nIndex = maURL.indexOf( aVndSunStarUNO ); - if( nIndex == 0 ) - { - sal_Int32 nBegin = aVndSunStarUNO.getLength(); - aMethodName = maURL.copy( nBegin ); - } + sal_Int32 nBegin = aVndSunStarUNO.getLength(); + aMethodName = maURL.copy( nBegin ); } maMethodEdit.SetText( aMethodName, Selection( 0, SELECTION_MAX ) ); } diff --git a/cui/source/dialogs/hldoctp.cxx b/cui/source/dialogs/hldoctp.cxx index 373bfbc98b12..1353038d6095 100644 --- a/cui/source/dialogs/hldoctp.cxx +++ b/cui/source/dialogs/hldoctp.cxx @@ -235,7 +235,7 @@ IMPL_LINK_NOARG(SvxHyperlinkDocTp, ClickTargetHdl_Impl) if ( GetPathType ( maStrURL ) == Type_ExistsFile || maStrURL.isEmpty() || maStrURL.equalsIgnoreAsciiCase( sFileScheme ) || - maStrURL.indexOf( sHash ) == 0 ) + maStrURL.startsWith( sHash ) ) { mpMarkWnd->SetError( LERR_NOERROR ); diff --git a/cui/source/dialogs/hlinettp.cxx b/cui/source/dialogs/hlinettp.cxx index bd475341e45a..322ab741519e 100644 --- a/cui/source/dialogs/hlinettp.cxx +++ b/cui/source/dialogs/hlinettp.cxx @@ -371,7 +371,7 @@ IMPL_LINK_NOARG(SvxHyperlinkInternetTp, ClickAnonymousHdl_Impl) // disable login-editfields if checked if ( maCbAnonymous.IsChecked() ) { - if ( maEdLogin.GetText().toAsciiLowerCase().indexOf ( sAnonymous ) == 0 ) + if ( maEdLogin.GetText().toAsciiLowerCase().startsWith( sAnonymous ) ) { maStrOldUser = aEmptyStr; maStrOldPassword = aEmptyStr; diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index fc18ea79d4b3..4f1cca75502c 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -1274,7 +1274,7 @@ IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, Edit*, pEdt) else { aTestStr = pCharClass->lowercase( aTestStr ); - if( aTestStr.indexOf(aWordStr) == 0 && !bTmpSelEntry ) + if( aTestStr.startsWith(aWordStr) && !bTmpSelEntry ) { m_pReplaceTLB->MakeVisible( pEntry ); bTmpSelEntry = sal_True; diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx index a55a961a0395..f5689c2979b7 100644 --- a/dbaccess/source/ui/dlg/sqlmessage.cxx +++ b/dbaccess/source/ui/dlg/sqlmessage.cxx @@ -211,7 +211,7 @@ namespace OUString sErrorMessage( _rErrorMessage ); const OUString sVendorIdentifier( ::connectivity::SQLError::getMessagePrefix() ); - if ( sErrorMessage.indexOf( sVendorIdentifier ) == 0 ) + if ( sErrorMessage.startsWith( sVendorIdentifier ) ) { // characters to strip sal_Int32 nStripLen( sVendorIdentifier.getLength() ); diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 30ba7170bc4d..fecdf380e7e4 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -333,14 +333,14 @@ namespace if ( pData->GetJoinType() != INNER_JOIN && _pEntryTabTo->ExistsAVisitedConn() ) { sal_Bool bBrace = sal_False; - if(!_rJoin.isEmpty() && _rJoin.lastIndexOf(')') == (_rJoin.getLength()-1)) + if(_rJoin.endsWith(")")) { bBrace = sal_True; _rJoin = _rJoin.replaceAt(_rJoin.getLength()-1,1,OUString(' ')); } (_rJoin += C_AND) += BuildJoinCriteria(_xConnection,pData->GetConnLineDataList(),pData); if(bBrace) - _rJoin += OUString(')'); + _rJoin += ")"; _pEntryConn->SetVisited(sal_True); } } @@ -1531,7 +1531,7 @@ namespace // don't display the column name aCondition = aCondition.copy(aColumnName.getLength()); aCondition = aCondition.trim(); - if ( aCondition.indexOf('=',0) == 0 ) // ignore the equal sign + if ( aCondition.startsWith("=") ) // ignore the equal sign aCondition = aCondition.copy(1); if ( SQL_ISRULE(pFunction, general_set_fct ) ) diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx index 778175ba51b7..ad2e2e9b7d77 100644 --- a/extensions/source/ole/oleobjw.cxx +++ b/extensions/source/ole/oleobjw.cxx @@ -492,7 +492,7 @@ Any SAL_CALL IUnknownWrapper_Impl::getValue( const OUString& aPropertyName ) if ( SUCCEEDED( pInfo->GetDocumentation( -1, &sName, NULL, NULL, NULL ) ) ) { OUString sTmp( reinterpret_cast<const sal_Unicode*>(LPCOLESTR(sName))); - if ( sTmp.indexOf('_') == 0 ) + if ( sTmp.startsWith("_") ) sTmp = sTmp.copy(1); // do we own the memory for pTypeLib, msdn doco is vague // I'll assume we do diff --git a/extensions/source/propctrlr/usercontrol.cxx b/extensions/source/propctrlr/usercontrol.cxx index c0ca42f322a8..9433c6d0f559 100644 --- a/extensions/source/propctrlr/usercontrol.cxx +++ b/extensions/source/propctrlr/usercontrol.cxx @@ -283,7 +283,7 @@ namespace pcr OUString sURL; if ( ( _rValue >>= sURL ) ) { - if ( sURL.indexOf( "vnd.sun.star.GraphicObject:" ) == 0 ) + if ( sURL.startsWith( "vnd.sun.star.GraphicObject:" ) ) getTypedControlWindow()->DisplayURL( getTypedControlWindow()->GetPlaceHolder() ); else getTypedControlWindow()->DisplayURL( sURL ); diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx index 61473f6925f8..7da240f92059 100644 --- a/filter/source/graphicfilter/ieps/ieps.cxx +++ b/filter/source/graphicfilter/ieps/ieps.cxx @@ -225,10 +225,10 @@ static bool RenderAsEMF(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &r if (pOut) { rtl::ByteSequence seq; - if (osl_File_E_None == osl_readLine(pOut, (sal_Sequence **)&seq)) + if (osl_File_E_None == osl_readLine(pOut, (sal_Sequence **)&seq)) { - OString line( (const sal_Char *) seq.getConstArray(), seq.getLength() ); - if (line.indexOf(OString("Unsupported output format")) == 0) + OString line( (const sal_Char *) seq.getConstArray(), seq.getLength() ); + if (line.startsWith("Unsupported output format")) bEMFSupported=false; } osl_closeFile(pOut); diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx index e5c72e59e000..8422d62fe79f 100644 --- a/filter/source/msfilter/msvbahelper.cxx +++ b/filter/source/msfilter/msvbahelper.cxx @@ -317,7 +317,7 @@ MacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const OUString& Macro { SvtPathOptions aPathOpt; OUString aAddinPath = aPathOpt.GetAddinPath(); - if( OUString( sDocUrlOrPath ).indexOf( aAddinPath ) == 0 ) + if( sDocUrlOrPath.startsWith( aAddinPath ) ) pFoundShell = pShell; } if( !pFoundShell ) @@ -751,7 +751,7 @@ void applyShortCutKeyBinding ( const uno::Reference< frame::XModel >& rxModel, c if ( !MacroName.isEmpty() ) { OUString aMacroName = MacroName.trim(); - if (0 == aMacroName.indexOf('!')) + if( aMacroName.startsWith("!") ) MacroName = aMacroName.copy(1).trim(); SfxObjectShell* pShell = NULL; if ( rxModel.is() ) diff --git a/framework/source/accelerators/storageholder.cxx b/framework/source/accelerators/storageholder.cxx index efc0722d7274..50a302890161 100644 --- a/framework/source/accelerators/storageholder.cxx +++ b/framework/source/accelerators/storageholder.cxx @@ -554,7 +554,7 @@ OUString StorageHolder::impl_st_normPath(const OUString& sPath) OUString sNormedPath = sPath; // "/bla" => "bla" && "/" => "" (!) - if (sNormedPath.indexOf(PATH_SEPARATOR) == 0) + if (sNormedPath.startsWith(PATH_SEPARATOR)) sNormedPath += sNormedPath.copy(1); // "/" => "" || "" => "" ? diff --git a/framework/source/classes/menumanager.cxx b/framework/source/classes/menumanager.cxx index 4ec18d46d36e..85d6798c3ef9 100644 --- a/framework/source/classes/menumanager.cxx +++ b/framework/source/classes/menumanager.cxx @@ -143,8 +143,8 @@ MenuManager::MenuManager( if ( pPopupMenu ) { AddMenu(pPopupMenu,aItemCommand,nItemId,bDeleteChildren,bDeleteChildren); - if (! (( aItemCommand.getLength() > nAddonsURLPrefixLength ) && - ( aItemCommand.indexOf( ADDONSPOPUPMENU_URL_PREFIX ) == 0 )) ) + if (! ( aItemCommand.getLength() > nAddonsURLPrefixLength && + aItemCommand.startsWith( ADDONSPOPUPMENU_URL_PREFIX ) ) ) { // Create addon popup menu if there exist elements and this is the tools popup menu diff --git a/framework/source/layoutmanager/helpers.cxx b/framework/source/layoutmanager/helpers.cxx index 1ad507d0464c..5cc82710aed0 100644 --- a/framework/source/layoutmanager/helpers.cxx +++ b/framework/source/layoutmanager/helpers.cxx @@ -199,7 +199,7 @@ OUString getElementTypeFromResourceURL( const OUString& aResourceURL ) OUString aType; OUString aUIResourceURL( UIRESOURCE_URL ); - if ( aResourceURL.indexOf( aUIResourceURL ) == 0 ) + if ( aResourceURL.startsWith( aUIResourceURL ) ) { sal_Int32 nIndex = 0; OUString aPathPart = aResourceURL.copy( aUIResourceURL.getLength() ); @@ -214,7 +214,7 @@ OUString getElementTypeFromResourceURL( const OUString& aResourceURL ) void parseResourceURL( const OUString& aResourceURL, OUString& aElementType, OUString& aElementName ) { OUString aUIResourceURL( UIRESOURCE_URL ); - if ( aResourceURL.indexOf( aUIResourceURL ) == 0 ) + if ( aResourceURL.startsWith( aUIResourceURL ) ) { sal_Int32 nIndex = 0; OUString aPathPart = aResourceURL.copy( aUIResourceURL.getLength() ); diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index 3e40ef9edb63..78b7df626479 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -1060,7 +1060,7 @@ void AutoRecovery::implts_readConfig() implts_specifyAppModuleAndFactory(aInfo); implts_specifyDefaultFilterAndExtension(aInfo); - if (pItems[i].indexOf(sRECOVERY_ITEM_BASE_IDENTIFIER)==0) + if (pItems[i].startsWith(sRECOVERY_ITEM_BASE_IDENTIFIER)) { OUString sID = pItems[i].copy(sRECOVERY_ITEM_BASE_IDENTIFIER.getLength()); aInfo.ID = sID.toInt32(); diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx index 215f4454d508..7b2d0fa39591 100644 --- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx +++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx @@ -90,7 +90,7 @@ static const char RESOURCEURL_CUSTOM_ELEMENT[] = "custom_"; static sal_Int16 RetrieveTypeFromResourceURL( const OUString& aResourceURL ) { - if (( aResourceURL.indexOf( RESOURCEURL_PREFIX ) == 0 ) && + if (( aResourceURL.startsWith( RESOURCEURL_PREFIX ) ) && ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE )) { OUString aTmpStr = aResourceURL.copy( RESOURCEURL_PREFIX_SIZE ); @@ -111,7 +111,7 @@ static sal_Int16 RetrieveTypeFromResourceURL( const OUString& aResourceURL ) static OUString RetrieveNameFromResourceURL( const OUString& aResourceURL ) { - if (( aResourceURL.indexOf( RESOURCEURL_PREFIX ) == 0 ) && + if (( aResourceURL.startsWith( RESOURCEURL_PREFIX ) ) && ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE )) { sal_Int32 nIndex = aResourceURL.lastIndexOf( '/' ); diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx index 799a3f3ab207..3b264d9434a2 100644 --- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx +++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx @@ -90,11 +90,11 @@ static const sal_Int32 RESOURCEURL_PREFIX_SIZE = 17; static sal_Int16 RetrieveTypeFromResourceURL( const OUString& aResourceURL ) { - if (( aResourceURL.indexOf( RESOURCEURL_PREFIX ) == 0 ) && + if (( aResourceURL.startsWith( RESOURCEURL_PREFIX ) ) && ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE )) { OUString aTmpStr = aResourceURL.copy( RESOURCEURL_PREFIX_SIZE ); - sal_Int32 nIndex = aTmpStr.indexOf( '/' ); + sal_Int32 nIndex = aTmpStr.indexOf( '/' ); if (( nIndex > 0 ) && ( aTmpStr.getLength() > nIndex )) { OUString aTypeStr( aTmpStr.copy( 0, nIndex )); @@ -111,7 +111,7 @@ static sal_Int16 RetrieveTypeFromResourceURL( const OUString& aResourceURL ) static OUString RetrieveNameFromResourceURL( const OUString& aResourceURL ) { - if (( aResourceURL.indexOf( RESOURCEURL_PREFIX ) == 0 ) && + if (( aResourceURL.startsWith( RESOURCEURL_PREFIX ) ) && ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE )) { sal_Int32 nIndex = aResourceURL.lastIndexOf( '/' ); diff --git a/framework/source/uielement/macrosmenucontroller.cxx b/framework/source/uielement/macrosmenucontroller.cxx index 9db444cf8048..18c5460c3b65 100644 --- a/framework/source/uielement/macrosmenucontroller.cxx +++ b/framework/source/uielement/macrosmenucontroller.cxx @@ -186,7 +186,7 @@ void MacrosMenuController::addScriptItems( PopupMenu* pPopupMenu, sal_uInt16 sta { for ( sal_Int32 index = 0; index < serviceNames.getLength(); index++ ) { - if ( serviceNames[ index ].indexOf( providerKey ) == 0 ) + if ( serviceNames[ index ].startsWith( providerKey ) ) { OUString serviceName = serviceNames[ index ]; OUString aCommand = aCmdBase; diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 47298594ef75..c65abbbeb7a3 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -1297,7 +1297,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF lcl_CheckForChildren(pMenu, nItemId); } else if (( aItemCommand.getLength() > nAddonsURLPrefixLength ) && - ( aItemCommand.indexOf( ADDONSPOPUPMENU_URL_PREFIX ) == 0 )) + ( aItemCommand.startsWith( ADDONSPOPUPMENU_URL_PREFIX ) )) { // A special addon popup menu, must be created with a different ctor MenuBarManager* pSubMenuManager = new MenuBarManager( m_xContext, m_xFrame, m_xURLTransformer,(AddonPopupMenu *)pPopup, bDeleteChildren, bDeleteChildren ); diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx index 8b5837721207..69653823a928 100644 --- a/framework/source/uielement/newmenucontroller.cxx +++ b/framework/source/uielement/newmenucontroller.cxx @@ -133,7 +133,7 @@ void NewMenuController::determineAndSetNewDocAccel( PopupMenu* pPopupMenu, const if ( nId != 0 && pPopupMenu->GetItemType( nId ) != MENUITEM_SEPARATOR ) { aCommand = pPopupMenu->GetItemCommand( nId ); - if ( aCommand.indexOf( m_aEmptyDocURL ) == 0 ) + if ( aCommand.startsWith( m_aEmptyDocURL ) ) { pPopupMenu->SetAccelKey( nId, rKeyCode ); bFound = sal_True; diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx index 7b01a110db80..43c0350ded67 100644 --- a/framework/source/uielement/recentfilesmenucontroller.cxx +++ b/framework/source/uielement/recentfilesmenucontroller.cxx @@ -312,7 +312,7 @@ throw( RuntimeException ) throwIfDisposed(); - if ( aURL.Complete.indexOf( m_aBaseURL ) == 0 ) + if ( aURL.Complete.startsWith( m_aBaseURL ) ) return Reference< XDispatch >( static_cast< OWeakObject* >( this ), UNO_QUERY ); else return Reference< XDispatch >(); @@ -328,7 +328,7 @@ throw( RuntimeException ) throwIfDisposed(); - if ( aURL.Complete.indexOf( m_aBaseURL ) == 0 ) + if ( aURL.Complete.startsWith( m_aBaseURL ) ) { // Parse URL to retrieve entry argument and its value sal_Int32 nQueryPart = aURL.Complete.indexOf( '?', m_aBaseURL.getLength() ); diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx index 87185d6e79b3..d73f3cec6504 100644 --- a/framework/source/uielement/toolbarsmenucontroller.cxx +++ b/framework/source/uielement/toolbarsmenucontroller.cxx @@ -164,7 +164,7 @@ void ToolbarsMenuController::addCommand( rPopupMenu->insertItem( nItemId, aLabel, 0, nItemId ); rPopupMenu->setCommand( nItemId, rCommandURL ); - bool bInternal = ( rCommandURL.indexOf( STATIC_INTERNAL_CMD_PART ) == 0); + bool bInternal = rCommandURL.startsWith( STATIC_INTERNAL_CMD_PART ); if ( !bInternal ) { if ( !getDispatchFromCommandURL( rCommandURL ).is() ) @@ -616,7 +616,7 @@ void SAL_CALL ToolbarsMenuController::itemSelected( const css::awt::MenuEvent& r PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu(); OUString aCmd( pVCLPopupMenu->GetItemCommand( rEvent.MenuId )); - if ( aCmd.indexOf( STATIC_INTERNAL_CMD_PART ) == 0 ) + if ( aCmd.startsWith( STATIC_INTERNAL_CMD_PART ) ) { // Command to restore the visibility of all context sensitive toolbars Reference< XNameReplace > xNameReplace( xPersistentWindowState, UNO_QUERY ); @@ -765,7 +765,7 @@ void SAL_CALL ToolbarsMenuController::itemActivated( const css::awt::MenuEvent& const sal_uInt32 nCount = aCmdVector.size(); for ( sal_uInt32 i = 0; i < nCount; i++ ) { - bool bInternal = ( aCmdVector[i].indexOf( STATIC_INTERNAL_CMD_PART ) == 0); + bool bInternal = aCmdVector[i].startsWith( STATIC_INTERNAL_CMD_PART ); if ( !bInternal ) { diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx index 42cd3890e58a..d930bc58cfd6 100644 --- a/framework/source/uielement/uicommanddescription.cxx +++ b/framework/source/uielement/uicommanddescription.cxx @@ -240,7 +240,7 @@ Any SAL_CALL ConfigurationAccess_UICommand::getByNameImpl( const OUString& rComm fillCache(); } - if ( rCommandURL.indexOf( m_aPrivateResourceURL ) == 0 ) + if ( rCommandURL.startsWith( m_aPrivateResourceURL ) ) { // special keys to retrieve information about a set of commands // SAFE @@ -711,7 +711,7 @@ throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::la } } } - else if ( !m_aPrivateResourceURL.isEmpty() && aName.indexOf( m_aPrivateResourceURL ) == 0 ) + else if ( !m_aPrivateResourceURL.isEmpty() && aName.startsWith( m_aPrivateResourceURL ) ) { // special keys to retrieve information about a set of commands return m_xGenericUICommands->getByName( aName ); diff --git a/framework/source/uifactory/windowcontentfactorymanager.cxx b/framework/source/uifactory/windowcontentfactorymanager.cxx index 672041e6b1e7..b66c473b2d2a 100644 --- a/framework/source/uifactory/windowcontentfactorymanager.cxx +++ b/framework/source/uifactory/windowcontentfactorymanager.cxx @@ -84,7 +84,7 @@ void WindowContentFactoryManager::RetrieveTypeNameFromResourceURL( const OUStrin const sal_Int32 RESOURCEURL_PREFIX_SIZE = 17; const char RESOURCEURL_PREFIX[] = "private:resource/"; - if (( aResourceURL.indexOf( RESOURCEURL_PREFIX ) == 0 ) && + if (( aResourceURL.startsWith( RESOURCEURL_PREFIX ) ) && ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE )) { OUString aTmpStr( aResourceURL.copy( RESOURCEURL_PREFIX_SIZE )); diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx index b71e769008c2..2b1fed680665 100644 --- a/i18npool/source/localedata/LocaleNode.cxx +++ b/i18npool/source/localedata/LocaleNode.cxx @@ -631,7 +631,7 @@ void LCFormatNode::generateCode (const OFileWriter &of) const if ( strFrom == "[CURRENCY]" ) sTheCurrencyReplaceTo = str; // Remember the currency symbol if present. - if (str.indexOfAsciiL( "[$", 2) == 0) + if (str.startsWith( "[$" )) { sal_Int32 nHyphen = str.indexOf( '-'); if (nHyphen >= 3) diff --git a/idlc/source/astscope.cxx b/idlc/source/astscope.cxx index 1c0d4fd84101..ba06611feb1a 100644 --- a/idlc/source/astscope.cxx +++ b/idlc/source/astscope.cxx @@ -25,13 +25,9 @@ using namespace ::rtl; -sal_Bool isGlobal(const OString& scopedName) +bool isGlobal(const OString& scopedName) { - if (scopedName.isEmpty() || (scopedName.indexOf(':') == 0)) - { - return sal_True; - } - return sal_False; + return scopedName.isEmpty() || scopedName.startsWith(":"); } AstScope::AstScope(NodeType nodeType) diff --git a/idlc/source/idlccompile.cxx b/idlc/source/idlccompile.cxx index 8a98af2aa456..8c6701aa292a 100644 --- a/idlc/source/idlccompile.cxx +++ b/idlc/source/idlccompile.cxx @@ -60,7 +60,7 @@ static sal_Char tmpFilePattern[512]; sal_Bool isFileUrl(const OString& fileName) { - if (fileName.indexOf("file://") == 0 ) + if (fileName.startsWith("file://") ) return sal_True; return sal_False; } diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx index 832616f42e6c..b1d75f7e6c86 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx @@ -719,7 +719,7 @@ bool getJREInfoFromBinPath( //make sure argument path does not end with '/' OUString sBinPath = path; - if (path.lastIndexOf('/') == (path.getLength() - 1)) + if (path.endsWith("/")) sBinPath = path.copy(0, path.getLength() - 1); typedef vector<OUString>::const_iterator c_it; @@ -1063,8 +1063,8 @@ Reference<VendorBase> createInstance(createInstance_func pFunc, inline OUString getDirFromFile(const OUString& usFilePath) { - sal_Int32 index= usFilePath.lastIndexOf('/'); - return OUString(usFilePath.getStr(), index); + sal_Int32 index = usFilePath.lastIndexOf('/'); + return usFilePath.copy(0, index); } void createJavaInfoFromPath(vector<rtl::Reference<VendorBase> >& vecInfos) diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx index 8b44727e26ae..1be5fa2eeee9 100644 --- a/l10ntools/source/export.cxx +++ b/l10ntools/source/export.cxx @@ -274,9 +274,9 @@ int Export::Execute( int nToken, const char * pToken ) OString sTestToken(pToken); sTestToken = sTestToken.replaceAll("\t", OString()). replaceAll(" ", OString()); - if (( !bReadOver ) && ( sTestToken.indexOf("#ifndef__RSC_PARSER") == 0 )) + if (( !bReadOver ) && ( sTestToken.startsWith("#ifndef__RSC_PARSER"))) bReadOver = sal_True; - else if (( bReadOver ) && ( sTestToken.indexOf("#endif") == 0 )) + else if (( bReadOver ) && ( sTestToken.startsWith("#endif") )) bReadOver = sal_False; } if ((( nToken < FILTER_LEVEL ) || ( bReadOver )) && diff --git a/lingucomponent/source/lingutil/lingutil.cxx b/lingucomponent/source/lingutil/lingutil.cxx index 4f721635160c..8c4e04f63a05 100644 --- a/lingucomponent/source/lingutil/lingutil.cxx +++ b/lingucomponent/source/lingutil/lingutil.cxx @@ -137,7 +137,7 @@ std::vector< SvtLinguConfigDictionaryEntry > GetOldStyleDics( const char *pDicTy { aItem.getFileStatus(aFileStatus); OUString sPath = aFileStatus.getFileURL(); - if (sPath.lastIndexOf(aSystemSuffix) == sPath.getLength()-aSystemSuffix.getLength()) + if (sPath.endsWith(aSystemSuffix)) { sal_Int32 nStartIndex = sPath.lastIndexOf(sal_Unicode('/')) + 1; if (!sPath.match(aSystemPrefix, nStartIndex)) diff --git a/lotuswordpro/source/filter/lwptools.cxx b/lotuswordpro/source/filter/lwptools.cxx index 77eb3dc7bf63..ea5a6e7eba1f 100644 --- a/lotuswordpro/source/filter/lwptools.cxx +++ b/lotuswordpro/source/filter/lwptools.cxx @@ -207,7 +207,7 @@ sal_Bool LwpTools::IsUnicodePacked(LwpObjectStream* pObjStrm, sal_uInt16 len) sal_Bool LwpTools::isFileUrl(const OString &fileName) { - if (fileName.indexOf("file://") == 0 ) + if (fileName.startsWith("file://") ) return sal_True; return sal_False; } @@ -221,7 +221,7 @@ OUString LwpTools::convertToFileUrl(const OString &fileName) OUString uUrlFileName; OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding()); - if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 ) + if ( fileName.startsWith(".") || fileName.indexOf(SEPARATOR) < 0 ) { OUString uWorkingDir; OSL_VERIFY( osl_getProcessWorkingDir(&uWorkingDir.pData) == osl_Process_E_None ); diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 2dc837b1f746..36412be51e12 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -492,7 +492,7 @@ OUString ChartExport::parseFormula( const OUString& rRange ) OSL_TRACE("ChartExport::parseFormula, parser is invalid"); //FIXME: currently just using simple converter, e.g $Sheet1.$A$1:$C$1 -> Sheet1!$A$1:$C$1 OUString aRange( rRange ); - if( aRange.indexOf('$') == 0 ) + if( aRange.startsWith("$") ) aRange = aRange.copy(1); aRange = aRange.replaceAll(".$", "!$" ); aResult = aRange; diff --git a/registry/tools/regcompare.cxx b/registry/tools/regcompare.cxx index a08a3756c1ec..e3cbfedb7475 100644 --- a/registry/tools/regcompare.cxx +++ b/registry/tools/regcompare.cxx @@ -271,7 +271,7 @@ bool Options_Impl::matchedWithExcludeKey( const OUString& keyName) const StringSet::const_iterator first = m_excludeKeys.begin(), last = m_excludeKeys.end(); for (; first != last; ++first) { - if (keyName.indexOf(*first) == 0) + if (keyName.startsWith(*first)) return true; } } diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 680172fec877..fe362340f98c 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -2197,7 +2197,7 @@ uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstanceWith ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); uno::Reference< uno::XInterface > xRet; - if ( aServiceSpecifier.indexOf( "com.sun.star.document.ImportEmbeddedObjectResolver") == 0 ) + if ( aServiceSpecifier.startsWith( "com.sun.star.document.ImportEmbeddedObjectResolver") ) { uno::Reference< embed::XStorage > xStorage; const uno::Any* pIter = _aArgs.getConstArray(); @@ -2220,7 +2220,7 @@ uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstance( co ::osl::MutexGuard aGuard(m_aMutex); ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); uno::Reference< drawing::XShape > xShape; - if ( aServiceSpecifier.indexOf( "com.sun.star.report." ) == 0 ) + if ( aServiceSpecifier.startsWith( "com.sun.star.report." ) ) { if ( aServiceSpecifier == SERVICE_SHAPE ) xShape.set(SvxUnoDrawMSFactory::createInstance("com.sun.star.drawing.CustomShape"),uno::UNO_QUERY_THROW); @@ -2232,7 +2232,7 @@ uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstance( co else xShape.set(SvxUnoDrawMSFactory::createInstance("com.sun.star.drawing.OLE2Shape"),uno::UNO_QUERY_THROW); } - else if ( aServiceSpecifier.indexOf( "com.sun.star.form.component." ) == 0 ) + else if ( aServiceSpecifier.startsWith( "com.sun.star.form.component." ) ) { xShape.set(m_aProps->m_xContext->getServiceManager()->createInstanceWithContext(aServiceSpecifier,m_aProps->m_xContext),uno::UNO_QUERY); } diff --git a/reportdesign/source/core/misc/reportformula.cxx b/reportdesign/source/core/misc/reportformula.cxx index 94158d8d00eb..689c5d9581cd 100644 --- a/reportdesign/source/core/misc/reportformula.cxx +++ b/reportdesign/source/core/misc/reportformula.cxx @@ -67,7 +67,7 @@ namespace rptui { case Expression: { - if ( _rFieldOrExpression.indexOf( lcl_getExpressionPrefix() ) == 0 ) + if ( _rFieldOrExpression.startsWith( lcl_getExpressionPrefix() ) ) m_sCompleteFormula = _rFieldOrExpression; else m_sCompleteFormula = lcl_getExpressionPrefix() + _rFieldOrExpression; @@ -102,7 +102,7 @@ namespace rptui sal_Int32 nPrefixLen( -1 ); // is it an ordinary expression? - if ( m_sCompleteFormula.indexOf( lcl_getExpressionPrefix( &nPrefixLen ) ) == 0 ) + if ( m_sCompleteFormula.startsWith( lcl_getExpressionPrefix( &nPrefixLen ) ) ) { m_eType = Expression; m_sUndecoratedContent = m_sCompleteFormula.copy( nPrefixLen ); @@ -110,7 +110,7 @@ namespace rptui } /// does it refer to a field? - if ( m_sCompleteFormula.indexOf( lcl_getFieldPrefix( &nPrefixLen ) ) == 0 ) + if ( m_sCompleteFormula.startsWith( lcl_getFieldPrefix( &nPrefixLen ) ) ) { if ( ( m_sCompleteFormula.getLength() >= nPrefixLen + 2 ) && ( m_sCompleteFormula[ nPrefixLen ] == '[' ) diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx index c76a4e34e200..8ab0b4303ec1 100644 --- a/reportdesign/source/filter/xml/xmlExport.cxx +++ b/reportdesign/source/filter/xml/xmlExport.cxx @@ -1458,7 +1458,7 @@ void ORptExport::exportParagraph(const Reference< XReportControlModel >& _xRepor else { - if ( sToken.indexOf('"') == 0 && sToken.lastIndexOf('"') == sToken.getLength()-1 ) + if ( sToken.startsWith("\"") && sToken.endsWith("\"") ) sToken = sToken.copy(1,sToken.getLength()-2); bool bPrevCharIsSpace = false; diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index be3ab4919291..ef35d1ca1b6c 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -2719,7 +2719,7 @@ uno::Any SAL_CALL OReportController::getViewData(void) throw( uno::RuntimeExcept const FeatureState aFeatureState = GetState( nCommandIDs[i] ); OUString sCommandURL( getURLForId( nCommandIDs[i] ).Main ); - OSL_ENSURE( sCommandURL.indexOfAsciiL( ".uno:", 5 ) == 0, "OReportController::getViewData: illegal command URL!" ); + OSL_ENSURE( sCommandURL.startsWith( ".uno:" ), "OReportController::getViewData: illegal command URL!" ); sCommandURL = sCommandURL.copy( 5 ); Any aCommandState; diff --git a/rsc/source/rsc/rsc.cxx b/rsc/source/rsc/rsc.cxx index dc52bdb4f74a..1b94cf11fb91 100644 --- a/rsc/source/rsc/rsc.cxx +++ b/rsc/source/rsc/rsc.cxx @@ -786,7 +786,7 @@ bool RscCompiler::GetImageFilePath( const RscCmdLine::OutputFile& rOutputFile, { OString aSearch(aReplIter->second.toAsciiLowerCase()); OString aSearchIn(aRelPathStr.toAsciiLowerCase()); - if( aSearchIn.indexOf(aSearch) == 0 ) + if( aSearchIn.startsWith(aSearch) ) { sal_Int32 nCopyPos = aReplIter->second.getLength(), nLength = aRelPathStr.getLength(); const sal_Char* pChars = aRelPathStr.getStr(); diff --git a/sal/osl/unx/file_path_helper.cxx b/sal/osl/unx/file_path_helper.cxx index ce1b47b62c90..71c3c3206d16 100644 --- a/sal/osl/unx/file_path_helper.cxx +++ b/sal/osl/unx/file_path_helper.cxx @@ -71,7 +71,7 @@ void SAL_CALL osl_systemPathEnsureSeparator(rtl_uString** ppustrPath) rtl_uString_assign(ppustrPath, path.pData); } - OSL_POSTCOND(path.lastIndexOf(FPH_CHAR_PATH_SEPARATOR) == (path.getLength() - 1), \ + OSL_POSTCOND(path.endsWith(FPH_PATH_SEPARATOR()), \ "osl_systemPathEnsureSeparator: Post condition failed"); } } diff --git a/sal/osl/w32/path_helper.cxx b/sal/osl/w32/path_helper.cxx index b91c1874c4b7..c58d70dd18e4 100644 --- a/sal/osl/w32/path_helper.cxx +++ b/sal/osl/w32/path_helper.cxx @@ -54,7 +54,7 @@ void osl_systemPathEnsureSeparator(/*inout*/ rtl_uString** ppustrPath) rtl_uString_assign(ppustrPath, path.pData); } - OSL_POSTCOND(path.lastIndexOf(BACKSLASH) == (path.getLength() - 1), \ + OSL_POSTCOND(path.endsWith(BACKSLASH), \ "osl_systemPathEnsureSeparator: Post condition failed"); } diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx index 54966aca78c9..50268ff49a57 100644 --- a/sal/qa/osl/file/osl_File.cxx +++ b/sal/qa/osl/file/osl_File.cxx @@ -322,9 +322,9 @@ inline sal_Bool isURL( const sal_Char *pathname ) /** simple version to judge if a file name or directory name is a URL or a system path, just to see if it is start with "file:///";. */ -inline sal_Bool isURL( const ::rtl::OUString pathname ) +inline bool isURL( const ::rtl::OUString pathname ) { - return ( ( pathname.indexOf( aPreURL ) == 0 ) ? sal_True : sal_False ); + return pathname.startsWith( aPreURL ); } /** concat two part to form a URL or system path, add PATH_SEPARATOR between them if necessary, add "file:///" to beginning if necessary. @@ -339,10 +339,8 @@ inline void concatURL( ::rtl::OUString & pathname1, const ::rtl::OUString & path pathname1 = aPathName.copy( 0 ); } - sal_Int32 index = 0; //check if '/' is in the end of pathname1 or at the begin of pathname2; - if ( ( ( index = pathname1.lastIndexOf( aSlashURL ) ) != ( pathname1.getLength() - 1 ) ) && - ( ( index = pathname2.indexOf( aSlashURL ) ) != 0 ) ) + if ( !pathname1.endsWith( aSlashURL ) && !pathname2.startsWith( aSlashURL ) ) pathname1 += aSlashURL; pathname1 += pathname2; } diff --git a/sal/qa/osl/module/osl_Module.cxx b/sal/qa/osl/module/osl_Module.cxx index 2b51bdfbc5fa..d6358d4c692c 100644 --- a/sal/qa/osl/module/osl_Module.cxx +++ b/sal/qa/osl/module/osl_Module.cxx @@ -70,10 +70,9 @@ inline ::rtl::OUString getDllURL( void ) return dllPath; } -inline sal_Bool isURL( const ::rtl::OUString pathname ) +inline bool isURL( const ::rtl::OUString pathname ) { - ::rtl::OUString aPreURL( "file:///" ); - return ( ( pathname.indexOf( aPreURL ) == 0 ) ? sal_True : sal_False ); + return pathname.startsWith( "file:///" ); } /** create a temp test directory using OUString name of full qualified URL or system path. diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 117f2a096372..c0d6f0d1c0fc 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1072,12 +1072,12 @@ bool ScConditionEntry::IsValid( double nArg, const ScAddress& rPos ) const { OUString aStr = OUString::number(nVal1); OUString aStr2 = OUString::number(nArg); - bValid = aStr2.indexOf(aStr) == 0; + bValid = aStr2.startsWith(aStr); } else { OUString aStr2 = OUString::number(nArg); - bValid = aStr2.indexOf(aStrVal1) == 0; + bValid = aStr2.startsWith(aStrVal1); } break; case SC_COND_ENDS_WITH: @@ -1178,7 +1178,7 @@ bool ScConditionEntry::IsValidStr( const OUString& rArg, const ScAddress& rPos ) bValid = !bValid; break; case SC_COND_BEGINS_WITH: - bValid = rArg.indexOf(aUpVal1) == 0; + bValid = rArg.startsWith(aUpVal1); break; case SC_COND_ENDS_WITH: bValid = rArg.endsWith(aUpVal1); diff --git a/sc/source/ui/vba/vbaname.cxx b/sc/source/ui/vba/vbaname.cxx index f7ce25376d3f..fc5592b75276 100644 --- a/sc/source/ui/vba/vbaname.cxx +++ b/sc/source/ui/vba/vbaname.cxx @@ -118,7 +118,7 @@ void ScVbaName::setContent( const OUString& rContent, const formula::FormulaGra OUString sContent( rContent ); if ( bRemoveEquals ) { - if (sContent.indexOf('=') == 0) + if (sContent.startsWith("=")) sContent = sContent.copy(1); } ScNamedRangeObj* pNamedRange = dynamic_cast< ScNamedRangeObj* >( mxNamedRange.get() ); diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 681a582279aa..b533561d4a42 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -891,7 +891,7 @@ protected: // always compile it in that grammar. Perhaps // css.sheet.FormulaParser should be used in future to directly // pass formula tokens when that API stabilizes. - if ( m_eGrammar != formula::FormulaGrammar::GRAM_PODF_A1 && ( sFormula.trim().indexOf('=') == 0 ) ) + if ( m_eGrammar != formula::FormulaGrammar::GRAM_PODF_A1 && ( sFormula.trim().startsWith("=") ) ) { uno::Reference< uno::XInterface > xIf( xCell, uno::UNO_QUERY_THROW ); ScCellRangesBase* pUnoRangesBase = dynamic_cast< ScCellRangesBase* >( xIf.get() ); @@ -4333,9 +4333,8 @@ static void lcl_setTableFieldsFromCriteria( OUString& sCriteria1, uno::Reference // *searchtext* - contains // <>*searchtext* - doesn't contain // [>|>=|<=|...]searchtext for GREATER_value, GREATER_EQUAL_value etc. - sal_Int32 nPos = 0; bool bIsNumeric = false; - if ( ( nPos = sCriteria1.indexOf( EQUALS ) ) == 0 ) + if ( sCriteria1.startsWith( EQUALS ) ) { if ( sCriteria1.getLength() == EQUALS.getLength() ) rFilterField.Operator = sheet::FilterOperator2::EMPTY; @@ -4350,7 +4349,7 @@ static void lcl_setTableFieldsFromCriteria( OUString& sCriteria1, uno::Reference } } - else if ( ( nPos = sCriteria1.indexOf( NOTEQUALS ) ) == 0 ) + else if ( sCriteria1.startsWith( NOTEQUALS ) ) { if ( sCriteria1.getLength() == NOTEQUALS.getLength() ) rFilterField.Operator = sheet::FilterOperator2::NOT_EMPTY; @@ -4364,10 +4363,10 @@ static void lcl_setTableFieldsFromCriteria( OUString& sCriteria1, uno::Reference xDescProps->setPropertyValue( "UseRegularExpressions", uno::Any( sal_True ) ); } } - else if ( ( nPos = sCriteria1.indexOf( GREATERTHAN ) ) == 0 ) + else if ( sCriteria1.startsWith( GREATERTHAN ) ) { bIsNumeric = true; - if ( ( nPos = sCriteria1.indexOf( GREATERTHANEQUALS ) ) == 0 ) + if ( sCriteria1.startsWith( GREATERTHANEQUALS ) ) { sCriteria1 = sCriteria1.copy( GREATERTHANEQUALS.getLength() ); rFilterField.Operator = sheet::FilterOperator2::GREATER_EQUAL; @@ -4379,10 +4378,10 @@ static void lcl_setTableFieldsFromCriteria( OUString& sCriteria1, uno::Reference } } - else if ( ( nPos = sCriteria1.indexOf( LESSTHAN ) ) == 0 ) + else if ( sCriteria1.startsWith( LESSTHAN ) ) { bIsNumeric = true; - if ( ( nPos = sCriteria1.indexOf( LESSTHANEQUALS ) ) == 0 ) + if ( sCriteria1.startsWith( LESSTHANEQUALS ) ) { sCriteria1 = sCriteria1.copy( LESSTHANEQUALS.getLength() ); rFilterField.Operator = sheet::FilterOperator2::LESS_EQUAL; diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx index 207368e20181..1a0ec714b2c4 100644 --- a/sc/source/ui/vba/vbawindow.cxx +++ b/sc/source/ui/vba/vbawindow.cxx @@ -331,7 +331,7 @@ ScVbaWindow::getCaption() throw (uno::RuntimeException) { static OUString sDot("."); // starts with title - if ( sName.indexOf( sTitle ) == 0 ) + if ( sName.startsWith( sTitle ) ) // extention starts immediately after if ( sName.match( sDot, sTitle.getLength() ) ) sTitle = sName; diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx index b6750c7eb3e7..907167adeff3 100644 --- a/sc/source/ui/vba/vbaworkbooks.cxx +++ b/sc/source/ui/vba/vbaworkbooks.cxx @@ -256,9 +256,9 @@ bool ScVbaWorkbooks::isSpreadSheetFile( const OUString& sType ) { // include calc_QPro etc. ? ( not for the moment anyway ) - if ( sType.indexOf( "calc_MS" ) == 0 - || sType.indexOf( "calc8" ) == 0 - || sType.indexOf( "calc_StarOffice" ) == 0 ) + if ( sType.startsWith( "calc_MS" ) + || sType.startsWith( "calc8" ) + || sType.startsWith( "calc_StarOffice" ) ) return true; return false; } diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx index cc0f4f9ce230..fc482c45f55e 100644 --- a/scripting/source/basprov/basprov.cxx +++ b/scripting/source/basprov/basprov.cxx @@ -243,7 +243,7 @@ namespace basprov } OUString sDoc = "vnd.sun.star.tdoc"; - if ( m_sScriptingContext.indexOf( sDoc ) == 0 ) + if ( m_sScriptingContext.startsWith( sDoc ) ) { xModel = MiscUtils::tDocUrlToModel( m_sScriptingContext ); // TODO: use ScriptingContantsPool for SCRIPTING_DOC_REF diff --git a/scripting/source/provider/ActiveMSPList.cxx b/scripting/source/provider/ActiveMSPList.cxx index 5b3b71e9bed3..98d18a85500e 100644 --- a/scripting/source/provider/ActiveMSPList.cxx +++ b/scripting/source/provider/ActiveMSPList.cxx @@ -152,7 +152,7 @@ Reference< provider::XScriptProvider > Reference< provider::XScriptProvider > msp; try { - if ( context.indexOf( "vnd.sun.star.tdoc" ) == 0 ) + if ( context.startsWith( "vnd.sun.star.tdoc" ) ) { Reference< frame::XModel > xModel( MiscUtils::tDocUrlToModel( context ) ); diff --git a/scripting/source/provider/MasterScriptProvider.cxx b/scripting/source/provider/MasterScriptProvider.cxx index 19e1134a66af..f93aca5e3387 100644 --- a/scripting/source/provider/MasterScriptProvider.cxx +++ b/scripting/source/provider/MasterScriptProvider.cxx @@ -129,7 +129,7 @@ throw ( Exception, RuntimeException ) if ( args[ 0 ] >>= m_sCtxString ) { invokeArgs[ 0 ] = args[ 0 ]; - if ( m_sCtxString.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.tdoc" ) ) == 0 ) + if ( m_sCtxString.startsWith( "vnd.sun.star.tdoc" ) ) { m_xModel = MiscUtils::tDocUrlToModel( m_sCtxString ); } @@ -411,7 +411,7 @@ MasterScriptProvider::getName() if ( !isPkgProvider() ) { OUString sCtx = getContextString(); - if ( sCtx.indexOf( "vnd.sun.star.tdoc" ) == 0 ) + if ( sCtx.startsWith( "vnd.sun.star.tdoc" ) ) { Reference< frame::XModel > xModel = m_xModel; if ( !xModel.is() ) diff --git a/scripting/source/provider/ProviderCache.cxx b/scripting/source/provider/ProviderCache.cxx index ec5209cda795..71bba4c84e29 100644 --- a/scripting/source/provider/ProviderCache.cxx +++ b/scripting/source/provider/ProviderCache.cxx @@ -159,7 +159,7 @@ ProviderCache::populateCache() throw ( RuntimeException ) for ( sal_Int32 index = 0; index < serviceNames.getLength(); index++ ) { - if ( serviceNames[ index ].indexOf( searchString ) == 0 && !isInBlackList( serviceNames[ index ] ) ) + if ( serviceNames[ index ].startsWith( searchString ) && !isInBlackList( serviceNames[ index ] ) ) { serviceName = serviceNames[ index ]; ProviderDetails details; diff --git a/scripting/source/provider/URIHelper.cxx b/scripting/source/provider/URIHelper.cxx index 6a6d0b7fc48c..0763901957c3 100644 --- a/scripting/source/provider/URIHelper.cxx +++ b/scripting/source/provider/URIHelper.cxx @@ -141,7 +141,7 @@ ScriptingFrameworkURIHelper::initBaseURI() test = OUString("uno_packages"); uri = OUString(SHARE_UNO_PACKAGES_URI); } - else if (m_sLocation.indexOf(TDOC_SCHEME) == 0) + else if (m_sLocation.startsWith(TDOC_SCHEME)) { m_sBaseURI = m_sLocation.concat( SCRIPTS_PART ); m_sLocation = OUString(DOCUMENT ); diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx index 196998a0bcfb..cc0c611e2c2d 100644 --- a/scripting/source/stringresource/stringresource.cxx +++ b/scripting/source/stringresource/stringresource.cxx @@ -1671,7 +1671,7 @@ bool checkNamingSceme( const OUString& aName, const OUString& aNameBase, // Name has to start with NameBase followed // by a '_' and at least one more character - if( aName.indexOf( aNameBase ) == 0 && nNameBaseLen < nNameLen-1 && + if( aName.startsWith( aNameBase ) && nNameBaseLen < nNameLen-1 && aName.getStr()[nNameBaseLen] == '_' ) { bSuccess = true; diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx index 4a77d2a949f7..c02da25b60ca 100644 --- a/sd/source/core/drawdoc2.cxx +++ b/sd/source/core/drawdoc2.cxx @@ -321,7 +321,7 @@ void SdDrawDocument::UpdatePageRelativeURLs(SdPage* pPage, sal_uInt16 nPos, sal_ aURLCopy = aURLCopy.replaceAt(0, aHashSlide.getLength(), ""); bool bNotesLink = ( aURLCopy.getLength() >= sNotes.getLength() + 3 - && aURLCopy.indexOf(sNotes, aURLCopy.getLength() - sNotes.getLength()) == aURLCopy.getLength() - sNotes.getLength() ); + && aURLCopy.endsWith(sNotes) ); if (bNotesLink ^ bNotes) continue; // no compatible link and page diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx index 4ce381f2fe9a..998621904da5 100644 --- a/sd/source/core/drawdoc3.cxx +++ b/sd/source/core/drawdoc3.cxx @@ -1502,7 +1502,7 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum, // #i121863# search in source styles with original style name from source of // evtl. cloned master (not-cloned, renamed for uniqueness) - if( aName.indexOf( aOriginalNewLayoutName ) == 0 ) + if( aName.startsWith( aOriginalNewLayoutName ) ) { // #i121863# build name of evtl. cloned master style to search for if(aOriginalNewLayoutName != aTargetNewLayoutName) diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index b61c9594f30a..26a357081417 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -594,7 +594,7 @@ bool lcl_isFilterNativelySupported(const SfxFilter& rFilter) return true; OUString aName = rFilter.GetFilterName(); - if (aName.indexOf("MS Excel") == 0) + if (aName.startsWith("MS Excel")) // We can handle all Excel variants natively. return true; @@ -622,8 +622,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) } else { - sal_Int32 nIndex = aCommand.indexOf("slot:"); - if ( nIndex == 0 ) + if ( aCommand.startsWith("slot:") ) { sal_uInt16 nSlotId = (sal_uInt16) aCommand.copy(5).toInt32(); if ( nSlotId == SID_OPENDOC ) diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 2448cae5d207..7c7400940989 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -3545,7 +3545,7 @@ static void ConvertSlotsToCommands( SfxObjectShell* pDoc, Reference< container:: if ( rToolbarDefinition->getByIndex( i ) >>= aSeqPropValue ) { GetCommandFromSequence( aCommand, nIndex, aSeqPropValue ); - if ( nIndex >= 0 && ( aCommand.indexOf( aSlotCmd ) == 0 )) + if ( nIndex >= 0 && ( aCommand.startsWith( aSlotCmd ) )) { OUString aSlot( aCommand.copy( 5 )); diff --git a/sfx2/source/menu/virtmenu.cxx b/sfx2/source/menu/virtmenu.cxx index a706f6680b60..545aea704946 100644 --- a/sfx2/source/menu/virtmenu.cxx +++ b/sfx2/source/menu/virtmenu.cxx @@ -656,7 +656,7 @@ bool SfxVirtualMenu::Bind_Impl( Menu *pMenu ) if ( ( nSID == SID_ADDONS ) || ( nSID == SID_ADDONHELP ) || (( (sal_uInt32)aCommand.getLength() > nAddonsPopupPrefixLen ) && - ( aCommand.indexOf( ADDONSPOPUPMENU_URL_PREFIX ) == 0 )) ) + ( aCommand.startsWith( ADDONSPOPUPMENU_URL_PREFIX ) ) ) ) bIsAddonPopupMenu = sal_True; // Create VirtualMenu for Sub-Menu diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index c31595ffe26c..8ad205d8fd06 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -530,7 +530,7 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) OUString aRecipient( pMailRecipient->GetValue() ); OUString aMailToStr("mailto:"); - if ( aRecipient.indexOf( aMailToStr ) == 0 ) + if ( aRecipient.startsWith( aMailToStr ) ) aRecipient = aRecipient.copy( aMailToStr.getLength() ); aModel.AddAddress( aRecipient, SfxMailModel::ROLE_TO ); } diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx index eea82fb4ec53..1fb4d657cad4 100644 --- a/svl/source/numbers/zforscan.cxx +++ b/svl/source/numbers/zforscan.cxx @@ -744,7 +744,7 @@ short ImpSvNumberformatScan::Next_Symbol( const OUString& rStr, // like "R" (Rand) and 'R' (era) if ( nCurrPos >= 0 && nPos-1 + sCurString.getLength() <= rStr.getLength() && - sCurString.indexOf( sKeyword[nTmpType] ) == 0 ) + sCurString.startsWith( sKeyword[nTmpType] ) ) { OUString aTest = pChrCls->uppercase( rStr.copy( nPos-1, sCurString.getLength() ) ); if ( aTest == sCurString ) diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx index ec9de0deba67..f87f783765ab 100644 --- a/svtools/source/control/inettbc.cxx +++ b/svtools/source/control/inettbc.cxx @@ -312,7 +312,7 @@ void SvtMatchContext_Impl::ReadFolder( const OUString& rURL, sal_Bool bPureHomePath = sal_False; #ifdef UNX - bPureHomePath = aText.indexOf( '~' ) == 0 && aText.indexOf( '/' ) == -1; + bPureHomePath = aText.startsWith( "~" ) && aText.indexOf( '/' ) == -1; #endif sal_Bool bExectMatch = bPureHomePath @@ -484,7 +484,7 @@ OUString SvtURLBox::ParseSmart( OUString aText, OUString aBaseURL, const OUStrin INetProtocol eBaseProt = INetURLObject::CompareProtocolScheme( aBaseURL ); // if a base URL is set the string may be parsed relative - if( aText.indexOf( '/' ) == 0 ) + if( aText.startsWith( "/" ) ) { // text starting with slashes means absolute file URLs OUString aTemp = INetURLObject::GetScheme( eBaseProt ); @@ -1296,7 +1296,7 @@ sal_Bool SvtURLBox_Impl::TildeParsing( ) { #ifdef UNX - if( aText.indexOf( '~' ) == 0 ) + if( aText.startsWith( "~" ) ) { OUString aParseTilde; sal_Bool bTrailingSlash = sal_True; // use trailing slash diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx index 96408bfc33d6..89b6eadb768b 100644 --- a/svtools/source/graphic/grfmgr.cxx +++ b/svtools/source/graphic/grfmgr.cxx @@ -1147,7 +1147,7 @@ SvStream& operator<<( SvStream& rOStm, const GraphicObject& rGraphicObj ) GraphicObject GraphicObject::CreateGraphicObjectFromURL( const OUString &rURL ) { const OUString aURL( rURL ), aPrefix( UNO_NAME_GRAPHOBJ_URLPREFIX ); - if( aURL.indexOf( aPrefix ) == 0 ) + if( aURL.startsWith( aPrefix ) ) { // graphic manager url OString aUniqueID(OUStringToOString(rURL.copy(sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX) - 1), RTL_TEXTENCODING_UTF8)); diff --git a/svtools/source/misc/imageresourceaccess.cxx b/svtools/source/misc/imageresourceaccess.cxx index 40df75d7e98f..fe6e4740222e 100644 --- a/svtools/source/misc/imageresourceaccess.cxx +++ b/svtools/source/misc/imageresourceaccess.cxx @@ -126,11 +126,11 @@ namespace svt //-------------------------------------------------------------------- bool GraphicAccess::isSupportedURL( const OUString& _rURL ) { - if ( ( _rURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "private:resource/" ) ) == 0 ) - || ( _rURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "private:graphicrepository/" ) ) == 0 ) - || ( _rURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "private:standardimage/" ) ) == 0 ) - || ( _rURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.GraphicObject:" ) ) == 0 ) - || ( _rURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.extension://" ) ) == 0 ) + if ( _rURL.startsWith( "private:resource/" ) + || _rURL.startsWith( "private:graphicrepository/" ) + || _rURL.startsWith( "private:standardimage/" ) + || _rURL.startsWith( "vnd.sun.star.GraphicObject:" ) + || _rURL.startsWith( "vnd.sun.star.extension://" ) ) return true; return false; diff --git a/svtools/source/uno/popupmenucontrollerbase.cxx b/svtools/source/uno/popupmenucontrollerbase.cxx index 06953fbfa8e9..961d5596ede4 100644 --- a/svtools/source/uno/popupmenucontrollerbase.cxx +++ b/svtools/source/uno/popupmenucontrollerbase.cxx @@ -262,7 +262,7 @@ throw( ::com::sun::star::uno::RuntimeException ) rBHelper.addListener( ::getCppuType( &xControl ), xControl ); aLock.reset(); - if ( aURL.Complete.indexOf( m_aBaseURL ) == 0 ) + if ( aURL.Complete.startsWith( m_aBaseURL ) ) bStatusUpdate = true; aLock.clear(); diff --git a/svx/source/dialog/pfiledlg.cxx b/svx/source/dialog/pfiledlg.cxx index 213808126d0b..62f3db4bfbe7 100644 --- a/svx/source/dialog/pfiledlg.cxx +++ b/svx/source/dialog/pfiledlg.cxx @@ -90,8 +90,8 @@ SvxPluginFileDlg::SvxPluginFileDlg (Window *, sal_uInt16 nKind ) aStrPlugMIMEType = aStrPlugMIMEType.toAsciiLowerCase(); aStrPlugExtension = aStrPlugExtension.toAsciiLowerCase(); - if ( ( nKind == SID_INSERT_SOUND && aStrPlugMIMEType.indexOf( sAudio ) == 0 ) || - ( nKind == SID_INSERT_VIDEO && aStrPlugMIMEType.indexOf( sVideo ) == 0 ) ) + if ( ( nKind == SID_INSERT_SOUND && aStrPlugMIMEType.startsWith( sAudio ) ) || + ( nKind == SID_INSERT_VIDEO && aStrPlugMIMEType.startsWith( sVideo ) ) ) { // extension already in the filterlist of the filedlg ? bool bAlreadyExist = false; diff --git a/svx/source/gallery2/galini.cxx b/svx/source/gallery2/galini.cxx index 815653982dd1..45673fc11ad0 100644 --- a/svx/source/gallery2/galini.cxx +++ b/svx/source/gallery2/galini.cxx @@ -47,7 +47,7 @@ OUString GalleryThemeEntry::ReadStrFromIni(const OUString &aKeyName ) sal_Int32 n; // comments - if( aLine.indexOf( '#' ) == 0 ) + if( aLine.startsWith( "#" ) ) continue; // a[en_US] = Bob diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 5fc9a010b62c..7644261ba126 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -2834,7 +2834,7 @@ sal_Bool SwUnoCursorHelper::ConvertSortProperties( bRet = sal_False; } } - else if (0 == rPropName.indexOf("IsSortNumeric") && + else if (rPropName.startsWith("IsSortNumeric") && rPropName.getLength() == 14 && (rPropName.getStr()[13] >= '0' && rPropName.getStr()[13] <= '9')) { @@ -2851,7 +2851,7 @@ sal_Bool SwUnoCursorHelper::ConvertSortProperties( bRet = sal_False; } } - else if (0 == rPropName.indexOf("IsSortAscending") && + else if (rPropName.startsWith("IsSortAscending") && rPropName.getLength() == 16 && (rPropName.getStr()[15] >= '0' && rPropName.getStr()[15] <= '9')) { diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index c658b8598a79..3ca1c8b6d804 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -1702,7 +1702,7 @@ Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServic //! adding the shapes to the draw page). //! For inserting OLE objects the proper way is to use //! "com.sun.star.text.TextEmbeddedObject"! - if (rServiceName.lastIndexOf( ".OLE2Shape" ) == rServiceName.getLength() - 10) + if (rServiceName.endsWith( ".OLE2Shape" )) throw ServiceNotRegisteredException(); // declare service to be not registered with this factory // diff --git a/sw/source/ui/vba/vbaparagraphformat.cxx b/sw/source/ui/vba/vbaparagraphformat.cxx index 196240e49ab9..e47ddcc153f1 100644 --- a/sw/source/ui/vba/vbaparagraphformat.cxx +++ b/sw/source/ui/vba/vbaparagraphformat.cxx @@ -185,7 +185,7 @@ sal_Int32 SAL_CALL SwVbaParagraphFormat::getOutlineLevel() throw (uno::RuntimeEx OUString aHeading; const OUString HEADING = OUString("Heading"); mxParaProps->getPropertyValue("ParaStyleName") >>= aHeading; - if( aHeading.indexOf( HEADING ) == 0 ) + if( aHeading.startsWith( HEADING ) ) { // get the sub string after "Heading" nLevel = aHeading.copy( HEADING.getLength() ).toInt32(); diff --git a/testtools/source/performance/ubtest.cxx b/testtools/source/performance/ubtest.cxx index 4c0ea18c2444..f08a0f92d909 100644 --- a/testtools/source/performance/ubtest.cxx +++ b/testtools/source/performance/ubtest.cxx @@ -936,7 +936,7 @@ static OUString extractParam( const Sequence< OUString > & rArgs, const OUString const OUString * pArgs = rArgs.getConstArray(); for ( sal_Int32 nPos = rArgs.getLength(); nPos--; ) { - if (pArgs[nPos].indexOf( rParam ) == 0 && + if (pArgs[nPos].startsWith( rParam ) && pArgs[nPos].getLength() > (rParam.getLength()+1)) { return pArgs[nPos].copy( rParam.getLength() +1 ); // XXX=bla diff --git a/ucb/source/ucp/ftp/ftpurl.cxx b/ucb/source/ucp/ftp/ftpurl.cxx index ba0e29840dca..60b6dcae0753 100644 --- a/ucb/source/ucp/ftp/ftpurl.cxx +++ b/ucb/source/ucp/ftp/ftpurl.cxx @@ -531,11 +531,9 @@ OUString FTPURL::net_title() const while(true) { OUString url(ident(false,true)); - if(try_more && - 1+url.lastIndexOf(sal_Unicode('/')) != url.getLength()) - url += OUString("/"); // add end-slash - else if(!try_more && - 1+url.lastIndexOf(sal_Unicode('/')) == url.getLength()) + if(try_more && !url.endsWith("/")) + url += "/"; // add end-slash + else if(!try_more && url.endsWith("/")) url = url.copy(0,url.getLength()-1); // remove end-slash SET_URL(url); @@ -550,8 +548,7 @@ OUString FTPURL::net_title() const // analyze the output: // Format of current working directory: // 257 "/bla/bla" is current directory - sal_Int32 index1 = aNetTitle.lastIndexOf( - OUString("257")); + sal_Int32 index1 = aNetTitle.lastIndexOf("257"); index1 = 1+aNetTitle.indexOf(sal_Unicode('"'),index1); sal_Int32 index2 = aNetTitle.indexOf(sal_Unicode('"'),index1); aNetTitle = aNetTitle.copy(index1,index2-index1); @@ -712,8 +709,8 @@ void FTPURL::mkdir(bool ReplaceExisting) const curl_easy_setopt(curl,CURLOPT_POSTQUOTE,slist); OUString url(parent(true)); - if(1+url.lastIndexOf(sal_Unicode('/')) != url.getLength()) - url += OUString("/"); + if(!url.endsWith("/")) + url += "/"; SET_URL(url); CURLcode err = curl_easy_perform(curl); @@ -752,8 +749,8 @@ OUString FTPURL::ren(const OUString& NewTitle) curl_easy_setopt(curl,CURLOPT_QUOTE,0); OUString url(parent(true)); - if(1+url.lastIndexOf(sal_Unicode('/')) != url.getLength()) - url += OUString("/"); + if(!url.endsWith("/")) + url += "/"; SET_URL(url); CURLcode err = curl_easy_perform(curl); @@ -802,8 +799,8 @@ void FTPURL::del() const curl_easy_setopt(curl,CURLOPT_QUOTE,0); OUString url(parent(true)); - if(1+url.lastIndexOf(sal_Unicode('/')) != url.getLength()) - url += OUString("/"); + if(!url.endsWith("/")) + url += "/"; SET_URL(url); CURLcode err = curl_easy_perform(curl); diff --git a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx index 2f10717cc9ce..96b747140109 100644 --- a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx +++ b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx @@ -543,28 +543,25 @@ bool HierarchyDataSource::createConfigPath( { if ( !rInPath.isEmpty() ) { - if ( rInPath.indexOf( '/' ) == 0 ) + if ( rInPath.startsWith( "/" ) ) { OSL_FAIL( "HierarchyDataSource::createConfigPath - " "Leading slash in node path!" ); return false; } - if ( rInPath.lastIndexOf( '/' ) == rInPath.getLength() - 1 ) + if ( rInPath.endsWith( "/" ) ) { OSL_FAIL( "HierarchyDataSource::createConfigPath - " "Trailing slash in node path!" ); return false; } - OUString aOutPath( - CONFIG_DATA_ROOT_KEY "/" ); - aOutPath += rInPath; - rOutPath = aOutPath; + rOutPath = CONFIG_DATA_ROOT_KEY "/" + rInPath; } else { - rOutPath = OUString( CONFIG_DATA_ROOT_KEY ); + rOutPath = CONFIG_DATA_ROOT_KEY; } return true; diff --git a/ucb/source/ucp/tdoc/tdoc_uri.hxx b/ucb/source/ucp/tdoc/tdoc_uri.hxx index 4da9166e17dc..a137b6881ec9 100644 --- a/ucb/source/ucp/tdoc/tdoc_uri.hxx +++ b/ucb/source/ucp/tdoc/tdoc_uri.hxx @@ -115,7 +115,7 @@ inline sal_Bool Uri::isDocument() const inline sal_Bool Uri::isFolder() const { init(); - return ( m_aPath.lastIndexOf( '/' ) == m_aPath.getLength() - 1 ); + return m_aPath.isEmpty() || m_aPath.endsWith( "/" ); } } // namespace tdoc_ucp diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx index cee643a587dc..04e6de0ab990 100644 --- a/ucb/source/ucp/webdav-neon/NeonSession.cxx +++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx @@ -347,9 +347,8 @@ namespace { sal_Int32 nContStart = _rRawString.indexOf( sPartId ); if ( nContStart != -1 ) { - nContStart = nContStart + sPartId.getLength(); - sal_Int32 nContEnd - = _rRawString.indexOf( sal_Unicode( ',' ), nContStart ); + nContStart += sPartId.getLength(); + sal_Int32 nContEnd = _rRawString.indexOf( sal_Unicode( ',' ), nContStart ); sPart = _rRawString.copy( nContStart, nContEnd - nContStart ); } return sPart; @@ -2031,7 +2030,7 @@ NeonSession::isDomainMatch( OUString certHostName ) if (hostName.equalsIgnoreAsciiCase( certHostName ) ) return sal_True; - if ( 0 == certHostName.indexOf( '*' ) && + if ( certHostName.startsWith( "*" ) && hostName.getLength() >= certHostName.getLength() ) { OUString cmpStr = certHostName.copy( 1 ); diff --git a/ucb/source/ucp/webdav/SerfSession.cxx b/ucb/source/ucp/webdav/SerfSession.cxx index 92cd797c4838..3eb5e3cf51ec 100644 --- a/ucb/source/ucp/webdav/SerfSession.cxx +++ b/ucb/source/ucp/webdav/SerfSession.cxx @@ -351,9 +351,8 @@ namespace { sal_Int32 nContStart = _rRawString.indexOf( sPartId ); if ( nContStart != -1 ) { - nContStart = nContStart + sPartId.getLength(); - sal_Int32 nContEnd - = _rRawString.indexOf( sal_Unicode( ',' ), nContStart ); + nContStart += sPartId.getLength(); + sal_Int32 nContEnd = _rRawString.indexOf( sal_Unicode( ',' ), nContStart ); sPart = _rRawString.copy( nContStart, nContEnd - nContStart ); } return sPart; @@ -1547,7 +1546,7 @@ SerfSession::isDomainMatch( OUString certHostName ) if (hostName.equalsIgnoreAsciiCase( certHostName ) ) return sal_True; - if ( 0 == certHostName.indexOf( '*' ) && + if ( certHostName.startsWith( '*' ) && hostName.getLength() >= certHostName.getLength() ) { OUString cmpStr = certHostName.copy( 1 ); diff --git a/unodevtools/source/unodevtools/options.cxx b/unodevtools/source/unodevtools/options.cxx index ec0264635a2b..1697d71a66fc 100644 --- a/unodevtools/source/unodevtools/options.cxx +++ b/unodevtools/source/unodevtools/options.cxx @@ -93,8 +93,8 @@ sal_Bool readOption( sal_Bool * pbOpt, const sal_Char * pOpt, const OUString dash("-"); OUString aOpt = OUString::createFromAscii(pOpt); - if((aArg.indexOf(dash) == 0 && aOpt.equalsIgnoreAsciiCase(aArg.copy(1))) || - (aArg.indexOf(dashdash) == 0 && aOpt.equalsIgnoreAsciiCase(aArg.copy(2))) ) + if((aArg.startsWith(dash) && aOpt.equalsIgnoreAsciiCase(aArg.copy(1))) || + (aArg.startsWith(dashdash) && aOpt.equalsIgnoreAsciiCase(aArg.copy(2))) ) { ++(*pnIndex); *pbOpt = sal_True; diff --git a/unotools/source/config/dynamicmenuoptions.cxx b/unotools/source/config/dynamicmenuoptions.cxx index 8677c39cf257..b432996c76ae 100644 --- a/unotools/source/config/dynamicmenuoptions.cxx +++ b/unotools/source/config/dynamicmenuoptions.cxx @@ -636,7 +636,7 @@ class SelectByPrefix bool operator() ( const OUString& s ) const { // Prefer setup written entries by check first letter of given string. It must be a "s". - return( s.indexOf( PATHPREFIX_SETUP ) == 0 ); + return s.startsWith( PATHPREFIX_SETUP ); } }; diff --git a/unoxml/source/dom/saxbuilder.cxx b/unoxml/source/dom/saxbuilder.cxx index 8e1c69c2d22e..33e79149e647 100644 --- a/unoxml/source/dom/saxbuilder.cxx +++ b/unoxml/source/dom/saxbuilder.cxx @@ -211,7 +211,7 @@ namespace DOM attr_qname = attribs->getNameByIndex(i); attr_value = attribs->getValueByIndex(i); // new prefix mapping - if (attr_qname.indexOf("xmlns:") == 0) + if (attr_qname.startsWith("xmlns:")) { newprefix = attr_qname.copy(attr_qname.indexOf(':')+1); aNSMap.insert(NSMap::value_type(newprefix, attr_value)); diff --git a/uui/source/iahndl-ssl.cxx b/uui/source/iahndl-ssl.cxx index 41117b861a69..b17748fc5faa 100644 --- a/uui/source/iahndl-ssl.cxx +++ b/uui/source/iahndl-ssl.cxx @@ -65,7 +65,7 @@ getContentPart( const OUString& _rRawString ) sal_Int32 nContStart = _rRawString.indexOf( sPartId ); if ( nContStart != -1 ) { - nContStart = nContStart + sPartId.getLength(); + nContStart += sPartId.getLength(); sal_Int32 nContEnd = _rRawString.indexOf( sal_Unicode( ',' ), nContStart ); if ( nContEnd != -1 ) sPart = _rRawString.copy( nContStart, nContEnd - nContStart ); @@ -90,8 +90,8 @@ isDomainMatch( if (hostName.equalsIgnoreAsciiCase( element )) return true; - if ( 0 == element.indexOf( '*' ) && - hostName.getLength() >= element.getLength() ) + if (element.startsWith("*") && + hostName.getLength() >= element.getLength() ) { OUString cmpStr = element.copy( 1 ); if ( hostName.matchIgnoreAsciiCase( diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index d64cf1aa3a5d..056df1f80f0e 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -308,7 +308,7 @@ VbaApplicationBase::getVersion() throw (uno::RuntimeException) uno::Any SAL_CALL VbaApplicationBase::Run( const OUString& MacroName, const uno::Any& varg1, const uno::Any& varg2, const uno::Any& varg3, const uno::Any& varg4, const uno::Any& varg5, const uno::Any& varg6, const uno::Any& varg7, const uno::Any& varg8, const uno::Any& varg9, const uno::Any& varg10, const uno::Any& varg11, const uno::Any& varg12, const uno::Any& varg13, const uno::Any& varg14, const uno::Any& varg15, const uno::Any& varg16, const uno::Any& varg17, const uno::Any& varg18, const uno::Any& varg19, const uno::Any& varg20, const uno::Any& varg21, const uno::Any& varg22, const uno::Any& varg23, const uno::Any& varg24, const uno::Any& varg25, const uno::Any& varg26, const uno::Any& varg27, const uno::Any& varg28, const uno::Any& varg29, const uno::Any& varg30 ) throw (uno::RuntimeException) { OUString aMacroName = MacroName.trim(); - if (0 == aMacroName.indexOf('!')) + if( aMacroName.startsWith("!") ) aMacroName = aMacroName.copy(1).trim(); uno::Reference< frame::XModel > xModel; diff --git a/vbahelper/source/vbahelper/vbacommandbarhelper.cxx b/vbahelper/source/vbahelper/vbacommandbarhelper.cxx index 57a35c053c9c..a95859c781ae 100644 --- a/vbahelper/source/vbahelper/vbacommandbarhelper.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarhelper.cxx @@ -206,7 +206,7 @@ OUString VbaCommandBarHelper::findToolbarByName( const css::uno::Reference< css: for( sal_Int32 i = 0; i < allNames.getLength(); i++ ) { sResourceUrl = allNames[i]; - if(sResourceUrl.indexOf( ITEM_TOOLBAR_URL ) == 0 ) + if(sResourceUrl.startsWith( ITEM_TOOLBAR_URL ) ) { if( hasToolbar( sResourceUrl, sName ) ) return sResourceUrl; diff --git a/vcl/aqua/source/window/salframe.cxx b/vcl/aqua/source/window/salframe.cxx index 3a3c31175b8a..5508e448ca2f 100644 --- a/vcl/aqua/source/window/salframe.cxx +++ b/vcl/aqua/source/window/salframe.cxx @@ -355,7 +355,7 @@ void AquaSalFrame::SetRepresentedURL( const OUString& i_rDocURL ) // #i113170# may not be the main thread if called from UNO API SalData::ensureThreadAutoreleasePool(); - if( i_rDocURL.indexOfAsciiL( "file:", 5 ) == 0 ) + if( i_rDocURL.startsWith( "file:" ) ) { OUString aSysPath; osl_getSystemPathFromFileURL( i_rDocURL.pData, &aSysPath.pData ); diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx index 91e638a592d6..636528a6eff6 100644 --- a/vcl/generic/fontmanager/fontmanager.cxx +++ b/vcl/generic/fontmanager/fontmanager.cxx @@ -360,7 +360,7 @@ bool PrintFontManager::PrintFont::readAfmMetrics( MultiAtomProvider* pProvider, if( m_aStyleName.isEmpty() && pInfo->gfi->fullName && *pInfo->gfi->fullName ) { OUString aFullName( OStringToOUString( pInfo->gfi->fullName, RTL_TEXTENCODING_ISO_8859_1 ) ); - if( aFullName.indexOf( aFamily ) == 0 ) + if( aFullName.startsWith( aFamily ) ) m_aStyleName = WhitespaceToSpace( aFullName.copy( aFamily.getLength() ) ); } @@ -2533,7 +2533,7 @@ std::list< sal_Unicode > PrintFontManager::getUnicodeFromAdobeName( const OStri if( aRet.begin() == aRet.end() ) { - if( rName.getLength() == 7 && rName.indexOf( "uni" ) == 0 ) + if( rName.getLength() == 7 && rName.startsWith( "uni" ) ) { sal_Unicode aCode = (sal_Unicode)rName.copy( 3 ).toUInt32( 16 ); aRet.push_back( aCode ); diff --git a/vcl/source/filter/FilterConfigCache.cxx b/vcl/source/filter/FilterConfigCache.cxx index 1e1301a0caec..b2da4d8ed730 100644 --- a/vcl/source/filter/FilterConfigCache.cxx +++ b/vcl/source/filter/FilterConfigCache.cxx @@ -99,7 +99,7 @@ OUString FilterConfigCache::FilterConfigCacheEntry::GetShortName() if ( lExtensionList.getLength() ) { aShortName = lExtensionList[ 0 ]; - if ( aShortName.indexOf( "*." ) == 0 ) + if ( aShortName.startsWith( "*." ) ) aShortName = aShortName.replaceAt( 0, 2, "" ); } return aShortName; diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index 1fd56cbe37e1..2d1636b026e1 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -552,7 +552,7 @@ OUString PPDParser::getPPDFile( const OUString& rFile ) if( aStream.IsOpen() ) { OString aLine = aStream.ReadLine(); - if (aLine.indexOfL(RTL_CONSTASCII_STRINGPARAM("*PPD-Adobe")) == 0) + if (aLine.startsWith("*PPD-Adobe")) aRet = aStream.GetFileName(); else { diff --git a/vcl/unx/generic/printer/printerinfomanager.cxx b/vcl/unx/generic/printer/printerinfomanager.cxx index 9f4dfa2870d7..539f64f1de04 100644 --- a/vcl/unx/generic/printer/printerinfomanager.cxx +++ b/vcl/unx/generic/printer/printerinfomanager.cxx @@ -1259,7 +1259,7 @@ static void lpgetSysQueueTokenHandler( while( it != i_rLines.end() ) { OString aClean( WhitespaceToSpace( *it ) ); - if( aClean.indexOf( aAllAttr, 0 ) == 0 ) + if( aClean.startsWith( aAllAttr ) ) { // insert the comma separated entries into the set of printers to use sal_Int32 nPos = aAllAttr.getLength(); diff --git a/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx index f9adefcd37c3..18d2750b40d0 100644 --- a/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx +++ b/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx @@ -86,7 +86,7 @@ void SAL_CALL SalGtkFolderPicker::setDisplayDirectory( const OUString& aDirector aTxt = unicodetouri(OUString("file:///.")); } - if( !aTxt.isEmpty() && aTxt.lastIndexOf('/') == aTxt.getLength() - 1 ) + if( aTxt.endsWith("/") ) aTxt = aTxt.copy( 0, aTxt.getLength() - 1 ); OSL_TRACE( "setting path to %s", aTxt.getStr() ); diff --git a/vcl/unx/gtk/fpicker/SalGtkPicker.cxx b/vcl/unx/gtk/fpicker/SalGtkPicker.cxx index 8cddab043376..aa280df9ffde 100644 --- a/vcl/unx/gtk/fpicker/SalGtkPicker.cxx +++ b/vcl/unx/gtk/fpicker/SalGtkPicker.cxx @@ -197,7 +197,7 @@ void SAL_CALL SalGtkPicker::implsetDisplayDirectory( const OUString& aDirectory aTxt = unicodetouri(OUString("file:///.")); } - if( aTxt.lastIndexOf('/') == aTxt.getLength() - 1 ) + if( aTxt.endsWith("/") ) aTxt = aTxt.copy( 0, aTxt.getLength() - 1 ); OSL_TRACE( "setting path to %s", aTxt.getStr() ); diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx index e6242d6bb004..fa8b213bbed0 100644 --- a/xmloff/source/chart/SchXMLTools.cxx +++ b/xmloff/source/chart/SchXMLTools.cxx @@ -798,11 +798,11 @@ bool isDocumentGeneratedWithOpenOfficeOlderThan2_0( const ::com::sun::star::uno: { bool bResult = false; OUString aGenerator( lcl_getGeneratorFromModelOrItsParent(xChartModel) ); - if( ( aGenerator.indexOf( "OpenOffice.org 1" ) == 0 ) - || ( aGenerator.indexOf( "StarOffice 6" ) == 0 ) - || ( aGenerator.indexOf( "StarOffice 7" ) == 0 ) - || ( aGenerator.indexOf( "StarSuite 6" ) == 0 ) - || ( aGenerator.indexOf( "StarSuite 7" ) == 0 ) + if( aGenerator.startsWith( "OpenOffice.org 1" ) + || aGenerator.startsWith( "StarOffice 6" ) + || aGenerator.startsWith( "StarOffice 7" ) + || aGenerator.startsWith( "StarSuite 6" ) + || aGenerator.startsWith( "StarSuite 7" ) ) bResult= true; return bResult; |