summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-07-11 10:31:38 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-07-11 13:55:30 +0200
commit65e4a776e8315fd61fd67ad00d28985b11f0b79e (patch)
tree1ab7a2947d47807086e0477a8d3ad35c2e75dd48
parenta7b7614c7cab42cd0839752635db81e25e1e50a1 (diff)
simplify some OUString::copy calls
Change-Id: Ifa228ca02ea79a1309e1875414028aade7e5f12d Reviewed-on: https://gerrit.libreoffice.org/39801 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--connectivity/source/drivers/dbase/DIndex.cxx2
-rw-r--r--connectivity/source/drivers/mork/MConnection.cxx2
-rw-r--r--filter/source/svg/svgreader.cxx8
-rw-r--r--l10ntools/source/po.cxx2
-rw-r--r--oox/source/vml/vmlshape.cxx2
-rw-r--r--sc/source/filter/excel/xehelper.cxx6
-rw-r--r--sw/source/filter/xml/xmltexti.cxx2
-rw-r--r--ucb/source/ucp/webdav-neon/webdavprovider.cxx2
-rw-r--r--ucb/source/ucp/webdav/webdavprovider.cxx2
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx4
-rw-r--r--xmlhelp/source/treeview/tvread.cxx16
-rw-r--r--xmloff/source/style/xmlnumfi.cxx6
12 files changed, 24 insertions, 30 deletions
diff --git a/connectivity/source/drivers/dbase/DIndex.cxx b/connectivity/source/drivers/dbase/DIndex.cxx
index 532174820dbb..4063c79576bb 100644
--- a/connectivity/source/drivers/dbase/DIndex.cxx
+++ b/connectivity/source/drivers/dbase/DIndex.cxx
@@ -463,7 +463,7 @@ bool ODbaseIndex::DropImpl()
{
// References the Key to an Index-file?
aKeyName = aInfFile.GetKeyName( nKey );
- if (aKeyName.copy(0,3) == "NDX")
+ if (aKeyName.startsWith("NDX"))
{
if(sEntry == OStringToOUString(aInfFile.ReadKey(aKeyName),m_pTable->getConnection()->getTextEncoding()))
{
diff --git a/connectivity/source/drivers/mork/MConnection.cxx b/connectivity/source/drivers/mork/MConnection.cxx
index 0f6fb73b1a34..06f21b944074 100644
--- a/connectivity/source/drivers/mork/MConnection.cxx
+++ b/connectivity/source/drivers/mork/MConnection.cxx
@@ -71,7 +71,7 @@ void OConnection::construct(const OUString& url)
sal_Int32 nLen = url.indexOf(':');
nLen = url.indexOf(':',nLen+1);
- OSL_ENSURE( url.copy( 0, nLen ) == "sdbc:address", "OConnection::construct: invalid start of the URI - should never have survived XDriver::acceptsURL!" );
+ OSL_ENSURE( url.startsWith("sdbc:address:"), "OConnection::construct: invalid start of the URI - should never have survived XDriver::acceptsURL!" );
OUString aAddrbookURI(url.copy(nLen+1));
// Get Scheme
diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx
index 13f802a86705..4b261efb8097 100644
--- a/filter/source/svg/svgreader.cxx
+++ b/filter/source/svg/svgreader.cxx
@@ -236,7 +236,7 @@ struct AnnotatingVisitor
{
const OUString sValue(xNode->getNodeValue());
ElementRefMapType::iterator aFound=maGradientIdMap.end();
- if ( sValue.copy(0,1) == "#" )
+ if ( sValue.startsWith("#") )
aFound = maGradientIdMap.find(sValue.copy(1));
else
aFound = maGradientIdMap.find(sValue);
@@ -279,7 +279,7 @@ struct AnnotatingVisitor
{
const OUString sValue(xNode->getNodeValue());
ElementRefMapType::iterator aFound=maGradientIdMap.end();
- if ( sValue.copy(0,1) == "#" )
+ if ( sValue.startsWith("#") )
aFound = maGradientIdMap.find(sValue.copy(1));
else
aFound = maGradientIdMap.find(sValue);
@@ -315,7 +315,7 @@ struct AnnotatingVisitor
{
OUString sValue(xNode->getNodeValue());
ElementRefMapType::iterator aFound=maElementIdMap.end();
- if ( sValue.copy(0,1) == "#" )
+ if ( sValue.startsWith("#") )
sValue = sValue.copy(1);
aFound = maElementIdMap.find(sValue);
bool bFound = aFound != maElementIdMap.end();
@@ -988,7 +988,7 @@ struct AnnotatingVisitor
case XML_HREF:
{
ElementRefMapType::iterator aFound=maStopIdMap.end();
- if ( sValue.copy(0,1) == "#" )
+ if ( sValue.startsWith("#") )
aFound = maStopIdMap.find(sValue.copy(1));
else
aFound = maStopIdMap.find(sValue);
diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx
index d17a0708f242..f8a191adb10d 100644
--- a/l10ntools/source/po.cxx
+++ b/l10ntools/source/po.cxx
@@ -86,7 +86,7 @@ namespace
sal_Int32 nIndex = 0;
while((nIndex=sResult.indexOf("\\n",nIndex))!=-1)
{
- if( sResult.copy(nIndex-1,3)!="\\\\n" &&
+ if( !sResult.match("\\\\n", nIndex-1) &&
nIndex!=sResult.getLength()-3)
{
sResult = sResult.replaceAt(nIndex,2,"\\n\"\n\"");
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 5153e517a214..f091326e0c1e 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -987,7 +987,7 @@ Reference< XShape > BezierShape::implConvertAndInsert( const Reference< XShapes
{
// If we have an 'x' in the last part of the path it means it is closed...
sal_Int32 nPos = maShapeModel.maVmlPath.lastIndexOf(',');
- if ( nPos != -1 && maShapeModel.maVmlPath.copy(nPos).indexOf('x') != -1 )
+ if ( nPos != -1 && maShapeModel.maVmlPath.indexOf(nPos, 'x') != -1 )
{
const_cast<BezierShape*>( this )->setService( "com.sun.star.drawing.ClosedBezierShape" );
}
diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx
index 37244ae8ae80..a8317347e022 100644
--- a/sc/source/filter/excel/xehelper.cxx
+++ b/sc/source/filter/excel/xehelper.cxx
@@ -888,13 +888,13 @@ OUString lclEncodeDosUrl(
OUString aOldUrl = rUrl;
aBuf.append(EXC_URLSTART_ENCODED);
- if ( aOldUrl.getLength() > 2 && aOldUrl.copy(0,2) == "\\\\" )
+ if ( aOldUrl.getLength() > 2 && aOldUrl.startsWith("\\\\") )
{
// UNC
aBuf.append(EXC_URL_DOSDRIVE).append('@');
aOldUrl = aOldUrl.copy(2);
}
- else if ( aOldUrl.getLength() > 2 && aOldUrl.copy(1,2) == ":\\" )
+ else if ( aOldUrl.getLength() > 2 && aOldUrl.match(":\\", 1) )
{
// drive letter
sal_Unicode cThisDrive = rBase.isEmpty() ? ' ' : rBase[0];
@@ -916,7 +916,7 @@ OUString lclEncodeDosUrl(
sal_Int32 nPos = -1;
while((nPos = aOldUrl.indexOf('\\')) != -1)
{
- if ( aOldUrl.copy(0,2) == ".." )
+ if ( aOldUrl.startsWith("..") )
// parent dir (NOTE: the MS-XLS spec doesn't mention this, and
// Excel seems confused by this token).
aBuf.append(EXC_URL_PARENTDIR);
diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx
index 58a3bd20f4b8..a989dc57ad29 100644
--- a/sw/source/filter/xml/xmltexti.cxx
+++ b/sw/source/filter/xml/xmltexti.cxx
@@ -241,7 +241,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOLEObject(
SwFrameFormat *pFrameFormat = nullptr;
SwOLENode *pOLENd = nullptr;
- if( rHRef.copy( 0, nPos ) == "vnd.sun.star.ServiceName" )
+ if( rHRef.startsWith("vnd.sun.star.ServiceName:") )
{
bool bInsert = false;
SvGlobalName aClassName;
diff --git a/ucb/source/ucp/webdav-neon/webdavprovider.cxx b/ucb/source/ucp/webdav-neon/webdavprovider.cxx
index 756783ac1a0d..cfaa4b6ef579 100644
--- a/ucb/source/ucp/webdav-neon/webdavprovider.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavprovider.cxx
@@ -142,7 +142,7 @@ ContentProvider::queryContent(
if ( aURL.getLength() < ( aScheme.getLength() + 3 ) )
throw ucb::IllegalIdentifierException();
- if ( aURL.copy( aScheme.getLength(), 3 ) != "://" )
+ if ( !aURL.match("://", aScheme.getLength()) )
throw ucb::IllegalIdentifierException();
uno::Reference< ucb::XContentIdentifier > xCanonicId;
diff --git a/ucb/source/ucp/webdav/webdavprovider.cxx b/ucb/source/ucp/webdav/webdavprovider.cxx
index 607d64236c78..f25ed36a3c76 100644
--- a/ucb/source/ucp/webdav/webdavprovider.cxx
+++ b/ucb/source/ucp/webdav/webdavprovider.cxx
@@ -131,7 +131,7 @@ ContentProvider::queryContent(
if ( aURL.getLength() < ( aScheme.getLength() + 3 ) )
throw ucb::IllegalIdentifierException();
- if ( aURL.copy( aScheme.getLength(), 3 ) != "://" )
+ if ( !aURL.match( aScheme.getLength(), "://") )
throw ucb::IllegalIdentifierException();
uno::Reference< ucb::XContentIdentifier > xCanonicId;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 036b47b73fcd..b02f1c96a083 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -64,11 +64,11 @@ util::DateTime getDateTimeFromUserProp(const OUString& rString)
{
aRet.Year = rString.copy(0, 4).toInt32();
- if (nLen >= 8 && rString.copy(4, 2) == ". ")
+ if (nLen >= 8 && rString.match(". ", 4))
{
aRet.Month = rString.copy(6, 2).toInt32();
- if (nLen >= 12 && rString.copy(8, 2) == ". ")
+ if (nLen >= 12 && rString.match(". ", 8))
aRet.Day = rString.copy(10, 2).toInt32();
}
}
diff --git a/xmlhelp/source/treeview/tvread.cxx b/xmlhelp/source/treeview/tvread.cxx
index 9410a1886757..4e726a2bf2b6 100644
--- a/xmlhelp/source/treeview/tvread.cxx
+++ b/xmlhelp/source/treeview/tvread.cxx
@@ -301,11 +301,9 @@ TVRead::hasByName( const OUString& aName )
Any SAL_CALL
TVRead::getByHierarchicalName( const OUString& aName )
{
- sal_Int32 idx;
-
- if( ( idx = aName.indexOf( '/' ) ) != -1 &&
- aName.copy( 0,idx ) == "Children" )
- return Children->getByHierarchicalName( aName.copy( 1 + idx ) );
+ OUString aRest;
+ if( aName.startsWith("Children/", &aRest) )
+ return Children->getByHierarchicalName( aRest );
return getByName( aName );
}
@@ -313,11 +311,9 @@ TVRead::getByHierarchicalName( const OUString& aName )
sal_Bool SAL_CALL
TVRead::hasByHierarchicalName( const OUString& aName )
{
- sal_Int32 idx;
-
- if( ( idx = aName.indexOf( '/' ) ) != -1 &&
- aName.copy( 0,idx ) == "Children" )
- return Children->hasByHierarchicalName( aName.copy( 1 + idx ) );
+ OUString aRest;
+ if( aName.startsWith("Children/", &aRest) )
+ return Children->hasByHierarchicalName( aRest );
return hasByName( aName );
}
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index b8727681a3da..c658de6d3a04 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -2151,16 +2151,14 @@ void SvXMLNumFormatContext::AddCondition( const sal_Int32 nIndex )
OUString rCondition = aMyConditions[nIndex].sCondition;
SvNumberFormatter* pFormatter = pData->GetNumberFormatter();
sal_uInt32 l_nKey = pData->GetKeyForName( rApplyName );
- OUString sValue("value()"); //! define constant
- sal_Int32 nValLen = sValue.getLength();
+ OUString sRealCond;
if ( pFormatter && l_nKey != NUMBERFORMAT_ENTRY_NOT_FOUND &&
- rCondition.copy( 0, nValLen ) == sValue )
+ rCondition.startsWith("value()", &sRealCond) )
{
//! test for valid conditions
//! test for default conditions
- OUString sRealCond = rCondition.copy( nValLen, rCondition.getLength() - nValLen );
bool bDefaultCond = false;
//! collect all conditions first and adjust default to >=0, >0 or <0 depending on count