[Libreoffice-commits] core.git: connectivity/source filter/source l10ntools/source oox/source sc/source sw/source ucb/source writerfilter/source xmlhelp/source xmloff/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Jul 11 11:55:59 UTC 2017


 connectivity/source/drivers/dbase/DIndex.cxx     |    2 +-
 connectivity/source/drivers/mork/MConnection.cxx |    2 +-
 filter/source/svg/svgreader.cxx                  |    8 ++++----
 l10ntools/source/po.cxx                          |    2 +-
 oox/source/vml/vmlshape.cxx                      |    2 +-
 sc/source/filter/excel/xehelper.cxx              |    6 +++---
 sw/source/filter/xml/xmltexti.cxx                |    2 +-
 ucb/source/ucp/webdav-neon/webdavprovider.cxx    |    2 +-
 ucb/source/ucp/webdav/webdavprovider.cxx         |    2 +-
 writerfilter/source/rtftok/rtfdocumentimpl.cxx   |    4 ++--
 xmlhelp/source/treeview/tvread.cxx               |   16 ++++++----------
 xmloff/source/style/xmlnumfi.cxx                 |    6 ++----
 12 files changed, 24 insertions(+), 30 deletions(-)

New commits:
commit 65e4a776e8315fd61fd67ad00d28985b11f0b79e
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jul 11 10:31:38 2017 +0200

    simplify some OUString::copy calls
    
    Change-Id: Ifa228ca02ea79a1309e1875414028aade7e5f12d
    Reviewed-on: https://gerrit.libreoffice.org/39801
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

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


More information about the Libreoffice-commits mailing list