summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-10-25 16:43:20 +0200
committerNoel Grandin <noel@peralex.com>2013-10-31 08:34:21 +0200
commite2451bd729d0f1d795a5b689deba65bc4e9d92c6 (patch)
tree4f2356107b0e58db7afda0fc324b9eac49ff68c0 /sfx2
parent460b52838fdad0352188bdd877b69cbb5f17ca63 (diff)
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
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/appopen.cxx5
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx2
-rw-r--r--sfx2/source/menu/virtmenu.cxx2
-rw-r--r--sfx2/source/view/viewsh.cxx2
4 files changed, 5 insertions, 6 deletions
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 );
}