summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-12-10 08:31:13 +0200
committerNoel Grandin <noel@peralex.com>2013-12-12 13:15:24 +0200
commitfb847101519ad74c02183672c04ebf1d700aae83 (patch)
treefa391cb75ed11817804bb4b9fbafa7ee265b8dbe
parent1957303363ea9bd308b5781da09beaa09df7420c (diff)
simplify - use OUString::startsWith where possible
Convert code like if( !aStr.isEmpty() && aStr[0] == 'x' ) to if( aStr.startsWith("x") ) Change-Id: Iabc3a44ed3be2d29eed876e0eeef212ccd271edf
-rw-r--r--configmgr/source/access.cxx2
-rw-r--r--desktop/source/deployment/misc/dp_misc.cxx2
-rw-r--r--editeng/source/editeng/eehtml.cxx5
-rw-r--r--i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx2
-rw-r--r--i18npool/source/localedata/LocaleNode.cxx2
-rw-r--r--oox/source/core/filterbase.cxx2
-rw-r--r--oox/source/dump/dumperbase.cxx6
-rw-r--r--sal/qa/osl/security/osl_Security.cxx2
-rw-r--r--sc/source/filter/oox/worksheetbuffer.cxx2
-rw-r--r--sc/source/filter/oox/worksheethelper.cxx2
-rw-r--r--sc/source/ui/formdlg/formula.cxx2
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx2
-rw-r--r--sc/source/ui/view/viewdata.cxx2
-rw-r--r--sd/source/core/anminfo.cxx2
-rw-r--r--sd/source/ui/docshell/docshel4.cxx4
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx2
-rw-r--r--sfx2/source/appl/appopen.cxx2
-rw-r--r--sfx2/source/bastyp/fltfnc.cxx2
-rw-r--r--sfx2/source/dialog/splitwin.cxx2
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx2
-rw-r--r--starmath/source/parse.cxx2
-rw-r--r--stoc/source/uriproc/UriReferenceFactory.cxx4
-rw-r--r--svl/source/misc/urihelper.cxx2
-rw-r--r--toolkit/source/awt/vclxwindows.cxx2
-rw-r--r--vcl/unx/generic/printer/ppdparser.cxx2
25 files changed, 29 insertions, 32 deletions
diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx
index a6a80350edb1..616bd0e31cc0 100644
--- a/configmgr/source/access.cxx
+++ b/configmgr/source/access.cxx
@@ -2021,7 +2021,7 @@ rtl::Reference< ChildAccess > Access::getUnmodifiedChild(
rtl::Reference< ChildAccess > Access::getSubChild(OUString const & path) {
sal_Int32 i = 0;
// For backwards compatibility, allow absolute paths where meaningful:
- if (!path.isEmpty() && path[0] == '/') {
+ if( path.startsWith("/") ) {
++i;
if (!getRootAccess().is()) {
return rtl::Reference< ChildAccess >();
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx
index b7720e130a17..5d64ce217137 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -266,7 +266,7 @@ OUString makeURL( OUString const & baseURL, OUString const & relPath_ )
else
buf.append( baseURL );
OUString relPath(relPath_);
- if (!relPath.isEmpty() && relPath[ 0 ] == '/')
+ if( relPath.startsWith("/") )
relPath = relPath.copy( 1 );
if (!relPath.isEmpty())
{
diff --git a/editeng/source/editeng/eehtml.cxx b/editeng/source/editeng/eehtml.cxx
index b945521e8cff..f09f9fde687f 100644
--- a/editeng/source/editeng/eehtml.cxx
+++ b/editeng/source/editeng/eehtml.cxx
@@ -190,8 +190,7 @@ void EditHTMLParser::NextToken( int nToken )
StartPara( false );
OUString aText = aToken;
- if ( !aText.isEmpty() && ( aText[ 0 ] == ' ' )
- && ThrowAwayBlank() && !IsReadPRE() )
+ if ( aText.startsWith(" ") && ThrowAwayBlank() && !IsReadPRE() )
aText = aText.copy( 1 );
if ( pCurAnchor )
@@ -784,7 +783,7 @@ void EditHTMLParser::AnchorStart()
if ( !aRef.isEmpty() )
{
OUString aURL = aRef;
- if ( !aURL.isEmpty() && ( aURL[ 0 ] != '#' ) )
+ if ( aURL.startsWith("#") )
{
INetURLObject aTargetURL;
INetURLObject aRootURL( aBaseURL );
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index bd926d1a8df7..c9ba6b2158d3 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -525,7 +525,7 @@ static
int should_ignore( OUString s )
{
// return true if blank or null
- return s.equalsAscii(" ") || (!s.isEmpty() && s[0]==0);
+ return s == " " || (!s.isEmpty() && s[0]==0);
}
static
diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx
index 73d7812b804f..69360de102a8 100644
--- a/i18npool/source/localedata/LocaleNode.cxx
+++ b/i18npool/source/localedata/LocaleNode.cxx
@@ -162,7 +162,7 @@ void print_OUString( const OUString& s )
bool is_empty_string( const OUString& s )
{
- return s.isEmpty() || (s.getLength()==1 && s[0]=='\n');
+ return s.isEmpty() || s == "\n";
}
void print_indent( int depth )
diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx
index 30a54d85eb0e..ce6d3fd14168 100644
--- a/oox/source/core/filterbase.cxx
+++ b/oox/source/core/filterbase.cxx
@@ -314,7 +314,7 @@ OUString FilterBase::getAbsoluteUrl( const OUString& rUrl ) const
/* (5) handle URLs relative to current drive, e.g. the URL '/path1/file1'
relative to the base URL 'file:///C:/path2/file2' does not result in
the expected 'file:///C:/path1/file1', but in 'file:///path1/file1'. */
- if( !aUrl.isEmpty() && (aUrl[ 0 ] == '/') &&
+ if( aUrl.startsWith("/") &&
mxImpl->maFileUrl.match( aFilePrefix ) &&
lclIsDosDrive( mxImpl->maFileUrl, nFilePrefixLen ) )
{
diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx
index d0dd3495140f..fc46d830d688 100644
--- a/oox/source/dump/dumperbase.cxx
+++ b/oox/source/dump/dumperbase.cxx
@@ -1085,7 +1085,7 @@ OUString FlagsList::implGetName( const Config& /*rCfg*/, sal_Int64 nKey ) const
if( !getFlag( mnIgnore, nMask ) )
{
const OUString& rFlagName = aIt->second;
- bool bOnOff = !rFlagName.isEmpty() && rFlagName[ 0 ] == ':';
+ bool bOnOff = rFlagName.startsWith(":");
bool bFlag = getFlag( nKey, nMask );
if( bOnOff )
{
@@ -1094,7 +1094,7 @@ OUString FlagsList::implGetName( const Config& /*rCfg*/, sal_Int64 nKey ) const
}
else
{
- bool bNegated = !rFlagName.isEmpty() && rFlagName[ 0 ] == '!';
+ bool bNegated = rFlagName.startsWith("!");
sal_Int32 nBothSep = bNegated ? rFlagName.indexOf( '!', 1 ) : -1;
if( bFlag )
{
@@ -1412,7 +1412,7 @@ void SharedConfigData::createUnitConverter( const OUString& rData )
if( aDataVec.size() >= 2 )
{
OUString aFactor = aDataVec[ 1 ];
- bool bRecip = !aFactor.isEmpty() && aFactor[ 0 ] == '/';
+ bool bRecip = aFactor.startsWith("/");
if( bRecip )
aFactor = aFactor.copy( 1 );
double fFactor;
diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx
index e9ad1a75aade..6fb065ad91af 100644
--- a/sal/qa/osl/security/osl_Security.cxx
+++ b/sal/qa/osl/security/osl_Security.cxx
@@ -629,7 +629,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
{
rtl::OUString arg;
rtl_getAppCommandArg(i, &arg.pData);
- if( !arg.isEmpty() && arg[ 0 ] == '-' )
+ if( arg.startsWith("-") )
continue;
if( argsCount >= 3 )
{
diff --git a/sc/source/filter/oox/worksheetbuffer.cxx b/sc/source/filter/oox/worksheetbuffer.cxx
index c9e5e57f153c..53f45b9c4bb0 100644
--- a/sc/source/filter/oox/worksheetbuffer.cxx
+++ b/sc/source/filter/oox/worksheetbuffer.cxx
@@ -111,7 +111,7 @@ OUString WorksheetBuffer::getCalcSheetName( sal_Int32 nWorksheet ) const
void WorksheetBuffer::convertSheetNameRef( OUString& sSheetNameRef ) const
{
// convert '#SheetName!A1' to '#SheetName.A1'
- if( !sSheetNameRef.isEmpty() && (sSheetNameRef[ 0 ] == '#') )
+ if( sSheetNameRef.startsWith("#") )
{
sal_Int32 nSepPos = sSheetNameRef.lastIndexOf( '!' );
if( nSepPos > 0 )
diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx
index 32fc416cb089..597456059399 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -1039,7 +1039,7 @@ OUString WorksheetGlobals::getHyperlinkUrl( const HyperlinkModel& rHyperlink ) c
OUString aUrl = aUrlBuffer.makeStringAndClear();
// convert '#SheetName!A1' to '#SheetName.A1'
- if( !aUrl.isEmpty() && (aUrl[ 0 ] == '#') )
+ if( aUrl.startsWith("#") )
{
sal_Int32 nSepPos = aUrl.lastIndexOf( '!' );
if( nSepPos > 0 )
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index 3dccb81fe1ed..48d7c7c05269 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -169,7 +169,7 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
if ( !bEdit )
{
OUString aNewFormula('=');
- if ( !aFormula.isEmpty() && aFormula[0] == '=' )
+ if ( aFormula.startsWith("=") )
aNewFormula = aFormula;
pScMod->InputReplaceSelection( aNewFormula );
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index a948a01c777a..ddf3dbdde909 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1391,7 +1391,7 @@ static OUString lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPos, sal
sal_Bool bIsNumberFormat(pFormatter->IsNumberFormat(aTempString, nNumFmt, fDummy));
if ( bIsNumberFormat )
aTempString = "'" + aTempString;
- else if ( !aTempString.isEmpty() && aTempString[0] == '\'' )
+ else if ( aTempString.startsWith("'") )
{
// if the string starts with a "'", add another one because setFormula
// strips one (like text input, except for "text" number formats)
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 4e3e0650c3ea..1b6daf0a5d6a 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -1328,7 +1328,7 @@ void ScViewData::EditGrowY( sal_Bool bInitial )
// Subsequent calls with empty text might involve changed attributes (including
// font height), so they are treated like normal text.
OUString aText = pEngine->GetText( 0 );
- if ( ( aText.isEmpty() && bInitial ) || (!aText.isEmpty() && aText[0] == '=') )
+ if ( ( aText.isEmpty() && bInitial ) || aText.startsWith("=") )
nAllowedExtra = SC_GROWY_BIG_EXTRA;
}
diff --git a/sd/source/core/anminfo.cxx b/sd/source/core/anminfo.cxx
index f833422cfc1e..1f897a0dfbd8 100644
--- a/sd/source/core/anminfo.cxx
+++ b/sd/source/core/anminfo.cxx
@@ -132,7 +132,7 @@ OUString SdAnimationInfo::GetBookmark()
sBookmark = pURLField->GetURL();
}
- if( (meClickAction == ::com::sun::star::presentation::ClickAction_BOOKMARK) && !sBookmark.isEmpty() && (sBookmark[0] == '#') )
+ if( (meClickAction == ::com::sun::star::presentation::ClickAction_BOOKMARK) && sBookmark.startsWith("#") )
sBookmark = sBookmark.copy( 1 );
return sBookmark;
diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx
index eeae1004450b..5304db5940ae 100644
--- a/sd/source/ui/docshell/docshel4.cxx
+++ b/sd/source/ui/docshell/docshel4.cxx
@@ -873,7 +873,7 @@ sal_Bool DrawDocShell::GetObjectIsmarked(const OUString& rBookmark)
OUString aBookmark( rBookmark );
- if( !rBookmark.isEmpty() && rBookmark[0] == sal_Unicode('#') )
+ if( rBookmark.startsWith("#") )
aBookmark = rBookmark.copy( 1 );
// Ist das Bookmark eine Seite?
@@ -979,7 +979,7 @@ sal_Bool DrawDocShell::GotoTreeBookmark(const OUString& rBookmark)
OUString aBookmark( rBookmark );
- if( !rBookmark.isEmpty() && rBookmark[0] == sal_Unicode('#') )
+ if( rBookmark.startsWith("#") )
aBookmark = rBookmark.copy( 1 );
// Ist das Bookmark eine Seite?
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 2aa7af5cdf56..e15ef7f7a344 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -1558,7 +1558,7 @@ sal_Int32 ImplPDFGetBookmarkPage( const OUString& rBookmark, SdDrawDocument& rDo
OUString aBookmark( rBookmark );
- if( !rBookmark.isEmpty() && rBookmark[ 0 ] == '#' )
+ if( rBookmark.startsWith("#") )
aBookmark = rBookmark.copy( 1 );
// is the bookmark a page ?
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index e8e23c5d1a4c..c15ce4296198 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -1051,7 +1051,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
// make URL ready
SFX_REQUEST_ARG( rReq, pURLItem, SfxStringItem, SID_FILE_NAME, sal_False );
aFileName = pURLItem->GetValue();
- if( !aFileName.isEmpty() && aFileName[0] == '#' ) // Mark without URL
+ if( aFileName.startsWith("#") ) // Mark without URL
{
SfxViewFrame *pView = pTargetFrame ? pTargetFrame->GetCurrentViewFrame() : 0;
if ( !pView )
diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx
index 65974d01b0f7..fd1c75d2c60b 100644
--- a/sfx2/source/bastyp/fltfnc.cxx
+++ b/sfx2/source/bastyp/fltfnc.cxx
@@ -747,7 +747,7 @@ const SfxFilter* SfxFilterMatcher::GetFilter4Extension( const OUString& rExt, Sf
// Use extension without dot!
OUString sExt( rExt );
- if ( !sExt.isEmpty() && ( sExt[0] == (sal_Unicode)'.' ))
+ if ( sExt.startsWith(".") )
sExt = sExt.copy(1);
com::sun::star::uno::Sequence < com::sun::star::beans::NamedValue > aSeq(1);
diff --git a/sfx2/source/dialog/splitwin.cxx b/sfx2/source/dialog/splitwin.cxx
index 15ffacfb8716..f229df6e8fe5 100644
--- a/sfx2/source/dialog/splitwin.cxx
+++ b/sfx2/source/dialog/splitwin.cxx
@@ -272,7 +272,7 @@ SfxSplitWindow::SfxSplitWindow( Window* pParent, SfxChildAlignment eAl,
OUString aTemp;
if ( aUserItem >>= aTemp )
aWinData = aTemp;
- if ( !aWinData.isEmpty() && aWinData[0] == 'V' )
+ if ( aWinData.startsWith("V") )
{
pEmptyWin->nState = (sal_uInt16) aWinData.getToken( 1, ',' ).toInt32();
if ( pEmptyWin->nState & 2 )
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index f7196d83a520..14ca59fbfded 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -290,7 +290,7 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument
OSL_ENSURE(!uri.isEmpty(), "GetDMA: empty uri?");
if (!uri.isEmpty() && !uri.endsWithAsciiL("/", 1))
{
- uri = uri + OUString("/");
+ uri = uri + "/";
}
m_xDocumentMetadata = new ::sfx2::DocumentMetadataAccess(
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index b5e37655e42b..9b8fc8da2f72 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -2295,7 +2295,7 @@ void SmParser::Special()
// conversion of symbol names for 6.0 (XML) file format
// (name change on import / export.
// UI uses localized names XML file format does not.)
- if (!rName.isEmpty() && rName[0] == '%')
+ if( rName.startsWith("%") )
{
if (IsImportSymbolNames())
{
diff --git a/stoc/source/uriproc/UriReferenceFactory.cxx b/stoc/source/uriproc/UriReferenceFactory.cxx
index 903e2c0ffcb5..121c761d5a88 100644
--- a/stoc/source/uriproc/UriReferenceFactory.cxx
+++ b/stoc/source/uriproc/UriReferenceFactory.cxx
@@ -185,9 +185,7 @@ css::uno::Reference< css::uri::XUriReference > parseGeneric(
OUString const & scheme, OUString const & schemeSpecificPart)
{
bool isAbsolute = !scheme.isEmpty();
- bool isHierarchical
- = !isAbsolute
- || (!schemeSpecificPart.isEmpty() && schemeSpecificPart[0] == '/');
+ bool isHierarchical = !isAbsolute || schemeSpecificPart.startsWith("/");
bool hasAuthority = false;
OUString authority;
OUString path;
diff --git a/svl/source/misc/urihelper.cxx b/svl/source/misc/urihelper.cxx
index f147f1a810a3..d2c1783f9fe0 100644
--- a/svl/source/misc/urihelper.cxx
+++ b/svl/source/misc/urihelper.cxx
@@ -62,7 +62,7 @@ OUString URIHelper::SmartRel2Abs(INetURLObject const & rTheBaseURIRef,
INetURLObject::FSysStyle eStyle)
{
// Backwards compatibility:
- if (!rTheRelURIRef.isEmpty() && rTheRelURIRef[0] == '#')
+ if( rTheRelURIRef.startsWith("#") )
return rTheRelURIRef;
INetURLObject aAbsURIRef;
diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx
index e7a2e84ec7e2..5da5369ff2e6 100644
--- a/toolkit/source/awt/vclxwindows.cxx
+++ b/toolkit/source/awt/vclxwindows.cxx
@@ -2157,7 +2157,7 @@ void SAL_CALL VCLXListBox::itemListChanged( const EventObject& i_rEvent ) throw
for ( sal_Int32 i=0; i<aItems.getLength(); ++i )
{
OUString aLocalizationKey( aItems[i].First );
- if ( xStringResourceResolver.is() && !aLocalizationKey.isEmpty() && aLocalizationKey[0] == '&' )
+ if ( xStringResourceResolver.is() && aLocalizationKey.startsWith("&") )
{
aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
}
diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx
index 57c9ff5649c1..c09414c5043e 100644
--- a/vcl/unx/generic/printer/ppdparser.cxx
+++ b/vcl/unx/generic/printer/ppdparser.cxx
@@ -680,7 +680,7 @@ PPDParser::PPDParser( const OUString& rFile ) :
while( ! aStream.IsEof() )
{
OString aCurLine = aStream.ReadLine();
- if (!aCurLine.isEmpty() && aCurLine[0] == '*')
+ if( aCurLine.startsWith("*") )
{
if (aCurLine.matchIgnoreAsciiCase(OString("*include:")))
{