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>
diff --git a/connectivity/source/drivers/dbase/DIndex.cxx b/connectivity/source/drivers/dbase/DIndex.cxx
index 5321748..4063c79 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 0f6fb73..06f21b9 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 13f802a..4b261ef 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 d17a070..f8a191a 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 5153e517a..f091326 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 37244ae..a831734 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 58a3bd2..a989dc5 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 756783a..cfaa4b6 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 607d642..f25ed36 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 036b47b..b02f1c9 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 9410a18..4e726a2 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 b872768..c658de6 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