Kaydet (Commit) e2451bd7 authored tarafından Noel Grandin's avatar Noel Grandin

Convert indexOf->startsWith and lastIndexOf->endsWith

This is both an optimisation and a cleanup.

This converts code like
   aStr.indexOf("XX") == 0
to
  aStr.startsWith("XX")
and converts code like
  aStr.lastIndexOf("XXX") == aStr.getLength() - 3
to
  aStr.endsWith("XXX")

Note that in general
  aStr.lastIndexOf("X") == aStr.getLength() - 1
converts to
  aStr.isEmpty() || aStr.endsWith("X")
so I used the surrounding context to determine if aStr could be empty
when modifying the code.

Change-Id: I22cb8ca7c2a4d0288b001f72adb27fd63af87669
üst 460b5283
......@@ -820,7 +820,7 @@ bool DialogWindow::SaveDialog()
if( aExtension == "properties" || aExtension == "default" )
{
if( aPureName.indexOf( aDialogName_ ) == 0 )
if( aPureName.startsWith( aDialogName_ ) )
{
try
{
......
......@@ -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();
......
......@@ -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)
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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) );
......
......@@ -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() )
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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(".") );
......
......@@ -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;
......
......@@ -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() )
......
......@@ -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;
......
......@@ -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 );
}
......
......@@ -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()))
......
......@@ -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 ) );
}
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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;
......
......@@ -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() );
......
......@@ -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 ) )
......
......@@ -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
......
......@@ -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 );
......
......@@ -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);
......
......@@ -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() )
......
......@@ -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);
// "/" => "" || "" => "" ?
......
......@@ -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
......
......@@ -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() );
......
......@@ -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();
......
......@@ -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( '/' );
......
......@@ -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( '/' );