[PATCH] make use of startsWith()

Thomas Arnhold (via Code Review) gerrit at gerrit.libreoffice.org
Fri Mar 8 05:13:02 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2599

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/99/2599/1

make use of startsWith()

Change-Id: Ie70097de550ddd1cddc6714f8f86f9723cb36679
---
M connectivity/source/drivers/ado/ADriver.cxx
M connectivity/source/drivers/calc/CDriver.cxx
M connectivity/source/drivers/dbase/DDriver.cxx
M connectivity/source/drivers/file/FDriver.cxx
M connectivity/source/drivers/flat/EDriver.cxx
M connectivity/source/drivers/jdbc/JDriver.cxx
M connectivity/source/drivers/kab/KDriver.cxx
M connectivity/source/drivers/macab/MacabDriver.cxx
M connectivity/source/drivers/odbcbase/ODriver.cxx
M connectivity/source/parse/sqlbison.y
M dbaccess/source/ui/dlg/directsql.cxx
M framework/inc/queries.h
M odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.cxx
M svtools/source/dialogs/filedlg2.cxx
M sw/source/core/unocore/unofield.cxx
M unotools/source/config/dynamicmenuoptions.cxx
M vcl/headless/svpelement.cxx
M vcl/source/app/svdata.cxx
M vcl/test/dndtest.cxx
M vcl/workben/svpclient.cxx
M writerfilter/source/dmapper/DomainMapper_Impl.cxx
M xmlhelp/source/cxxhelp/provider/db.hxx
M xmloff/source/core/xmlexp.cxx
M xmloff/source/core/xmlimp.cxx
M xmloff/source/style/XMLClipPropertyHandler.cxx
M xmloff/source/transform/TransformerBase.cxx
M xmlscript/source/xml_helper/xml_impctx.cxx
M xmlsecurity/source/helper/xsecparser.cxx
28 files changed, 46 insertions(+), 55 deletions(-)



diff --git a/connectivity/source/drivers/ado/ADriver.cxx b/connectivity/source/drivers/ado/ADriver.cxx
index fc51c3d..cbcc556 100644
--- a/connectivity/source/drivers/ado/ADriver.cxx
+++ b/connectivity/source/drivers/ado/ADriver.cxx
@@ -141,7 +141,7 @@
 sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url )
         throw(SQLException, RuntimeException)
 {
-    return (!url.compareTo(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:ado:")),9));
+    return url.startsWith("sdbc:ado:");
 }
 // -----------------------------------------------------------------------------
 void ODriver::impl_checkURL_throw(const ::rtl::OUString& _sUrl)
diff --git a/connectivity/source/drivers/calc/CDriver.cxx b/connectivity/source/drivers/calc/CDriver.cxx
index d5da23c..27ea3e1 100644
--- a/connectivity/source/drivers/calc/CDriver.cxx
+++ b/connectivity/source/drivers/calc/CDriver.cxx
@@ -78,7 +78,7 @@
 sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url )
                 throw(SQLException, RuntimeException)
 {
-    return url.compareTo(::rtl::OUString("sdbc:calc:"),10) == 0;
+    return url.startsWith("sdbc:calc:");
 }
 
 Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/dbase/DDriver.cxx b/connectivity/source/drivers/dbase/DDriver.cxx
index 36290b8..6da0aa4 100644
--- a/connectivity/source/drivers/dbase/DDriver.cxx
+++ b/connectivity/source/drivers/dbase/DDriver.cxx
@@ -70,7 +70,7 @@
 // --------------------------------------------------------------------------------
 sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url ) throw(SQLException, RuntimeException)
 {
-    return !url.compareTo(::rtl::OUString("sdbc:dbase:"),11);
+    return url.startsWith("sdbc:dbase:");
 }
 // -----------------------------------------------------------------------------
 Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/file/FDriver.cxx b/connectivity/source/drivers/file/FDriver.cxx
index f4e0e6f..21a0d9d 100644
--- a/connectivity/source/drivers/file/FDriver.cxx
+++ b/connectivity/source/drivers/file/FDriver.cxx
@@ -118,7 +118,7 @@
                 throw(SQLException, RuntimeException)
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen at sun.com", "OFileDriver::acceptsURL" );
-    return (!url.compareTo(::rtl::OUString("sdbc:file:"),10));
+    return url.startsWith("sdbc:file:");
 }
 // --------------------------------------------------------------------------------
 Sequence< DriverPropertyInfo > SAL_CALL OFileDriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/flat/EDriver.cxx b/connectivity/source/drivers/flat/EDriver.cxx
index 1398fea..86bf8fe 100644
--- a/connectivity/source/drivers/flat/EDriver.cxx
+++ b/connectivity/source/drivers/flat/EDriver.cxx
@@ -74,7 +74,7 @@
 sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url )
                 throw(SQLException, RuntimeException)
 {
-    return url.compareTo(::rtl::OUString("sdbc:flat:"),10) == 0;
+    return url.startsWith("sdbc:flat:");
 }
 // -----------------------------------------------------------------------------
 Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/jdbc/JDriver.cxx b/connectivity/source/drivers/jdbc/JDriver.cxx
index 7aa056e..2e03671 100644
--- a/connectivity/source/drivers/jdbc/JDriver.cxx
+++ b/connectivity/source/drivers/jdbc/JDriver.cxx
@@ -118,8 +118,7 @@
     // I feel responsible for all jdbc url's
     sal_Bool bEnabled = sal_False;
     OSL_VERIFY_EQUALS( jfw_getEnabled( &bEnabled ), JFW_E_NONE, "error in jfw_getEnabled" );
-    static const ::rtl::OUString s_sJdbcPrefix(  "jdbc:" );
-    return bEnabled && 0 == url.compareTo(s_sJdbcPrefix, 5);
+    return bEnabled && url.startsWith("jdbc:");
 }
 // -------------------------------------------------------------------------
 Sequence< DriverPropertyInfo > SAL_CALL java_sql_Driver::getPropertyInfo( const ::rtl::OUString& url,
diff --git a/connectivity/source/drivers/kab/KDriver.cxx b/connectivity/source/drivers/kab/KDriver.cxx
index b9765c0..d086838 100644
--- a/connectivity/source/drivers/kab/KDriver.cxx
+++ b/connectivity/source/drivers/kab/KDriver.cxx
@@ -408,7 +408,7 @@
         return sal_False;
 
     // here we have to look whether we support this URL format
-    return (!url.compareTo(::rtl::OUString("sdbc:address:kab:"), 16));
+    return url.startsWith("sdbc:address:kab:");
 }
 // --------------------------------------------------------------------------------
 Sequence< DriverPropertyInfo > SAL_CALL KabDriver::getPropertyInfo( const ::rtl::OUString&, const Sequence< PropertyValue >& ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/macab/MacabDriver.cxx b/connectivity/source/drivers/macab/MacabDriver.cxx
index 7365e3d..4a54766 100644
--- a/connectivity/source/drivers/macab/MacabDriver.cxx
+++ b/connectivity/source/drivers/macab/MacabDriver.cxx
@@ -276,7 +276,7 @@
         return sal_False;
 
     // here we have to look whether we support this URL format
-    return (!url.compareTo(::rtl::OUString("sdbc:address:macab:"), 18));
+    return url.startsWith("sdbc:address:macab:");
 }
 // --------------------------------------------------------------------------------
 Sequence< DriverPropertyInfo > SAL_CALL MacabDriver::getPropertyInfo( const ::rtl::OUString&, const Sequence< PropertyValue >& ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/odbcbase/ODriver.cxx b/connectivity/source/drivers/odbcbase/ODriver.cxx
index e5c2cf1..ba46945 100644
--- a/connectivity/source/drivers/odbcbase/ODriver.cxx
+++ b/connectivity/source/drivers/odbcbase/ODriver.cxx
@@ -118,7 +118,7 @@
 sal_Bool SAL_CALL ODBCDriver::acceptsURL( const ::rtl::OUString& url )
         throw(SQLException, RuntimeException)
 {
-    return (!url.compareTo(::rtl::OUString("sdbc:odbc:"),10));
+    return url.startsWith("sdbc:odbc:");
 }
 // --------------------------------------------------------------------------------
 Sequence< DriverPropertyInfo > SAL_CALL ODBCDriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y
index a0f7d43..338d738 100644
--- a/connectivity/source/parse/sqlbison.y
+++ b/connectivity/source/parse/sqlbison.y
@@ -4739,7 +4739,7 @@
 	if (!aStr.getLength())
 	{
 		aStr = yytname[YYTRANSLATE(nTokenID)];
-		if(!aStr.compareTo("SQL_TOKEN_",10))
+		if(aStr.startsWith("SQL_TOKEN_"))
 			aStr = aStr.copy(10);
 	}
 	return aStr;
diff --git a/dbaccess/source/ui/dlg/directsql.cxx b/dbaccess/source/ui/dlg/directsql.cxx
index e6babf0..96bafbc 100644
--- a/dbaccess/source/ui/dlg/directsql.cxx
+++ b/dbaccess/source/ui/dlg/directsql.cxx
@@ -229,7 +229,7 @@
             m_aOutput.SetText(rtl::OUString());
             if (xStatement.is())
             {
-                if (::rtl::OUString(_rStatement).toAsciiUpperCase().compareTo(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT")),6)==0 && m_pShowOutput->IsChecked())
+                if (OUString(_rStatement).toAsciiUpperCase().startsWith("SELECT") && m_pShowOutput->IsChecked())
                 {
                     // execute it as a query
                     xResultSet = xStatement->executeQuery(_rStatement);
diff --git a/framework/inc/queries.h b/framework/inc/queries.h
index 24e0a74..b839910 100644
--- a/framework/inc/queries.h
+++ b/framework/inc/queries.h
@@ -264,27 +264,27 @@
             {
                 sParam = sNewQuery.getToken( 0, SEPERATOR_QUERYPARAM, nToken );
                 // "default_first"
-                if( sParam.compareTo( QUERYPARAM_DEFAULT_FIRST, QUERYPARAM_DEFAULT_FIRST.getLength() ) == 0 )
+                if( sParam.startsWith( QUERYPARAM_DEFAULT_FIRST ) )
                 {
                     m_bDefaultFirst = sal_True;
                 }
                 // "use_order"
-                else if( sParam.compareTo( QUERYPARAM_USE_ORDER, QUERYPARAM_USE_ORDER.getLength() ) == 0 )
+                else if( sParam.startsWith( QUERYPARAM_USE_ORDER ) )
                 {
                     m_bUseOrder = sal_True;
                 }
                 // "descending"
-                else if( sParam.compareTo( QUERYPARAM_DESCENDING, QUERYPARAM_DESCENDING.getLength() ) == 0 )
+                else if( sParam.startsWith( QUERYPARAM_DESCENDING ) )
                 {
                     m_bDescending = sal_True;
                 }
                 // "case_sensitive"
-                else if( sParam.compareTo( QUERYPARAM_CASE_SENSITIVE, QUERYPARAM_CASE_SENSITIVE.getLength() ) == 0 )
+                else if( sParam.startsWith( QUERYPARAM_CASE_SENSITIVE ) )
                 {
                     m_bCaseSensitive = sal_True;
                 }
                 // "iflags=<mask>"
-                else if( sParam.compareTo( QUERYPARAM_IFLAGS, QUERYPARAM_IFLAGS.getLength() ) == 0 )
+                else if( sParam.startsWith( QUERYPARAM_IFLAGS ) )
                 {
                     sal_Int32       nSubToken  = 0;
                     sParam.getToken( 0, SEPERATOR_QUERYPARAMVALUE, nSubToken );
@@ -294,7 +294,7 @@
                     }
                 }
                 // "eflags=<mask>"
-                else if( sParam.compareTo( QUERYPARAM_EFLAGS, QUERYPARAM_EFLAGS.getLength() ) == 0 )
+                else if( sParam.startsWith( QUERYPARAM_EFLAGS ) )
                 {
                     sal_Int32       nSubToken  = 0;
                     sParam.getToken( 0, SEPERATOR_QUERYPARAMVALUE, nSubToken );
@@ -304,17 +304,16 @@
                     }
                 }
                 // "sort_prop=<[name,uiname]>"
-                else if( sParam.compareTo( QUERYPARAM_SORT_PROP, QUERYPARAM_SORT_PROP.getLength() ) == 0 )
+                else if( sParam.startsWith( QUERYPARAM_SORT_PROP ) )
                 {
                     sal_Int32       nSubToken  = 0;
                     sParam.getToken( 0, SEPERATOR_QUERYPARAMVALUE, nSubToken );
                     if( nSubToken > 0 )
                     {
                         OUString sParamValue = sParam.getToken( 0, SEPERATOR_QUERYPARAMVALUE, nSubToken );
-                        if( sParamValue.compareTo( QUERYPARAMVALUE_SORT_PROP_NAME, QUERYPARAMVALUE_SORT_PROP_NAME.getLength() ) == 0 )
+                        if( sParamValue.startsWith( QUERYPARAMVALUE_SORT_PROP_NAME ) )
                             m_eSortProp = E_NAME;
-                        else
-                        if( sParamValue.compareTo( QUERYPARAMVALUE_SORT_PROP_UINAME, QUERYPARAMVALUE_SORT_PROP_UINAME.getLength() ) == 0 )
+                        else if( sParamValue.startsWith( QUERYPARAMVALUE_SORT_PROP_UINAME ) )
                             m_eSortProp = E_UINAME;
                     }
                 }
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.cxx
index 4556ac4..762453b 100644
--- a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.cxx
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.cxx
@@ -134,7 +134,7 @@
 {
     // here we have to look if we support this url format
     // change the URL format to your needs, but please aware that the first on who accepts the URl wins.
-    return (!url.compareTo(::rtl::OUString("sdbc:skeleton:"),14));
+    return url.startsWith("sdbc:skeleton:");
 }
 // --------------------------------------------------------------------------------
 Sequence< DriverPropertyInfo > SAL_CALL SkeletonDriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
diff --git a/svtools/source/dialogs/filedlg2.cxx b/svtools/source/dialogs/filedlg2.cxx
index 210dfd4..44e5985 100644
--- a/svtools/source/dialogs/filedlg2.cxx
+++ b/svtools/source/dialogs/filedlg2.cxx
@@ -71,7 +71,7 @@
                 aEntry = comphelper::string::stripStart(aEntry, ' ').toAsciiUpperCase();
                 OUString aCompare = OUString(cCharCode).toAsciiUpperCase();
 
-                if ( aEntry.compareTo( aCompare, 1 ) == 0 )
+                if ( aEntry.startsWith( aCompare ) )
                 {
                     SelectEntryPos ( (i + nCurrentPos) % nEntries );
                     break;
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 106e777..3af6dfc 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -1001,7 +1001,7 @@
     {
         OUString sSource = bQuery ? sTypeName : sProgName;
         OUString sDest = bQuery ? sProgName : sTypeName;
-        if(!rFormula.compareTo(sSource, sSource.getLength()))
+        if(rFormula.startsWith(sSource))
         {
             OUString sTmpFormula = sDest;
             sTmpFormula += rFormula.copy(sSource.getLength());
diff --git a/unotools/source/config/dynamicmenuoptions.cxx b/unotools/source/config/dynamicmenuoptions.cxx
index 9696ef8..78042d6 100644
--- a/unotools/source/config/dynamicmenuoptions.cxx
+++ b/unotools/source/config/dynamicmenuoptions.cxx
@@ -197,7 +197,7 @@
                                                      pItem!=lUserEntries.end()  ;
                                                      ++pItem                    )
             {
-                if( pItem->sName.compareTo( PATHPREFIX_USER, 1 ) == 0 )
+                if( pItem->sName.startsWith( PATHPREFIX_USER ) )
                 {
                     OUString  sNr      = pItem->sName.copy( 1, pItem->sName.getLength()-1 );
                     sal_Int32 nCheckNr = sNr.toInt32();
diff --git a/vcl/headless/svpelement.cxx b/vcl/headless/svpelement.cxx
index ee5fb00..5458fe8 100644
--- a/vcl/headless/svpelement.cxx
+++ b/vcl/headless/svpelement.cxx
@@ -163,7 +163,7 @@
     while( read( nFile, &c, 1 ) && c != '\n' )
         aBuf.append( sal_Char(c) );
     rtl::OString aCommand( aBuf.makeStringAndClear() );
-    if( aCommand.compareTo( "list", 4 ) == 0 )
+    if( aCommand.startsWith( "list" ) )
     {
         boost::unordered_map< rtl::OString, std::list<SvpElement*>, rtl::OStringHash > aMap;
         for( std::list< SvpElement* >::const_iterator it = m_aElements.begin();
@@ -186,7 +186,7 @@
             }
         }
     }
-    else if( aCommand.compareTo( "get", 3 ) == 0 )
+    else if( aCommand.startsWith( "get" ) )
     {
         sal_IntPtr aId = aCommand.copy( 3 ).toInt64( 16 );
         SvpElement* pElement = reinterpret_cast<SvpElement*>(aId);
@@ -212,7 +212,7 @@
             }
         }
     }
-    else if( aCommand.compareTo( "quit", 4 ) == 0 )
+    else if( aCommand.startsWith( "quit" ) )
     {
         Application::Quit();
         close( m_nSocket );
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index 164384a..8aa8d70 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -455,11 +455,11 @@
             rtl::OUString aTitle;
             rtl::OUStringBuffer aMessage(ResId(SV_ACCESSERROR_BRIDGE_MSG, *pResMgr).toString());
 
-            if( 0 == e.Message.compareTo(::rtl::OUString("ClassNotFound"), 13) )
+            if( e.Message.startsWith("ClassNotFound") )
             {
                 aTitle = ResId(SV_ACCESSERROR_MISSING_BRIDGE, *pResMgr).toString();
             }
-            else if( 0 == e.Message.compareTo(::rtl::OUString("NoSuchMethod"), 12) )
+            else if( e.Message.startsWith("NoSuchMethod") )
             {
                 aTitle = ResId(SV_ACCESSERROR_WRONG_VERSION, *pResMgr).toString();
             }
diff --git a/vcl/test/dndtest.cxx b/vcl/test/dndtest.cxx
index c2756dc..83c9887 100644
--- a/vcl/test/dndtest.cxx
+++ b/vcl/test/dndtest.cxx
@@ -152,7 +152,7 @@
 
         osl_getCommandArg( n, &aArg.pData );
 
-        if( aArg.compareTo( OUString("-r"), 2 ) == 0 )
+        if( aArg.startsWith( "-r" ) )
         {
             if ( n + 1 < nmax )
                 osl_getCommandArg( ++n, &aRegistry.pData );
diff --git a/vcl/workben/svpclient.cxx b/vcl/workben/svpclient.cxx
index fa28ecb..12ce0cc2 100644
--- a/vcl/workben/svpclient.cxx
+++ b/vcl/workben/svpclient.cxx
@@ -185,7 +185,7 @@
         if( ! aLine.getLength() || *aLine.getStr() == '#' )
             continue;
 
-        if( aLine.compareTo( "ElementType: ", 13 ) == 0 )
+        if( aLine.startsWith( "ElementType: " ) )
             aElementType = rtl::OStringToOUString( aLine.copy( 13 ), RTL_TEXTENCODING_ASCII_US );
         else
         {
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 92be387..423019c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2867,10 +2867,10 @@
                         nSpaceIndex = aCommand.indexOf(' ');
                         if(nSpaceIndex > 0)
                             aCommand = aCommand.copy(nSpaceIndex).trim();
-                        if (aCommand.compareTo("\\s", 2) == 0)
+                        if (aCommand.startsWith("\\s"))
                         {
                             aCommand = aCommand.copy(2);
-                            if (aCommand.compareTo("\\do", 3) == 0)
+                            if (aCommand.startsWith("\\do"))
                             {
                                 aCommand = aCommand.copy(3);
                                 sal_Int32 nStartIndex = aCommand.indexOf('(');
diff --git a/xmlhelp/source/cxxhelp/provider/db.hxx b/xmlhelp/source/cxxhelp/provider/db.hxx
index 6c42e5f..429fd24 100644
--- a/xmlhelp/source/cxxhelp/provider/db.hxx
+++ b/xmlhelp/source/cxxhelp/provider/db.hxx
@@ -110,7 +110,7 @@
                 , m_nItRead( -1 )
                 , m_iItPos( -1 )
         {
-            OSL_ASSERT(!rFileURL.compareTo("file:", 5));
+            OSL_ASSERT(rFileURL.startsWith("file:"));
         }
         ~Hdf()
             { releaseHashMap(); }
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index 81afbf3..c578286 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -1854,8 +1854,7 @@
 OUString SvXMLExport::AddEmbeddedGraphicObject( const OUString& rGraphicObjectURL )
 {
     OUString sRet( rGraphicObjectURL );
-    if( 0 == rGraphicObjectURL.compareTo( msGraphicObjectProtocol,
-                                          msGraphicObjectProtocol.getLength() ) &&
+    if( rGraphicObjectURL.startsWith( msGraphicObjectProtocol ) &&
         mxGraphicResolver.is() )
     {
         if( (getExportFlags() & EXPORT_EMBEDDED) == 0 )
@@ -1874,8 +1873,7 @@
     sal_Bool bRet = sal_False;
 
     if( (getExportFlags() & EXPORT_EMBEDDED) != 0 &&
-        0 == rGraphicObjectURL.compareTo( msGraphicObjectProtocol,
-                                          msGraphicObjectProtocol.getLength() ) &&
+        rGraphicObjectURL.startsWith( msGraphicObjectProtocol ) &&
         mxGraphicResolver.is() )
     {
         Reference< XBinaryStreamResolver > xStmResolver( mxGraphicResolver, UNO_QUERY );
@@ -1898,10 +1896,8 @@
 OUString SvXMLExport::AddEmbeddedObject( const OUString& rEmbeddedObjectURL )
 {
     OUString sRet;
-    if( (0 == rEmbeddedObjectURL.compareTo( msEmbeddedObjectProtocol,
-                msEmbeddedObjectProtocol.getLength() ) ||
-         0 == rEmbeddedObjectURL.compareTo( msGraphicObjectProtocol,
-                msGraphicObjectProtocol.getLength() ) ) &&
+    if( (rEmbeddedObjectURL.startsWith( msEmbeddedObjectProtocol ) ||
+         rEmbeddedObjectURL.startsWith( msGraphicObjectProtocol ) ) &&
         mxEmbeddedResolver.is() )
     {
         sRet =
@@ -1916,10 +1912,8 @@
 sal_Bool SvXMLExport::AddEmbeddedObjectAsBase64( const OUString& rEmbeddedObjectURL )
 {
     sal_Bool bRet = sal_False;
-    if( (0 == rEmbeddedObjectURL.compareTo( msEmbeddedObjectProtocol,
-                msEmbeddedObjectProtocol.getLength() ) ||
-         0 == rEmbeddedObjectURL.compareTo( msGraphicObjectProtocol,
-                msGraphicObjectProtocol.getLength() ) ) &&
+    if( (rEmbeddedObjectURL.startsWith( msEmbeddedObjectProtocol ) ||
+         rEmbeddedObjectURL.startsWith( msGraphicObjectProtocol ) ) &&
         mxEmbeddedResolver.is() )
     {
         Reference < XNameAccess > xNA( mxEmbeddedResolver, UNO_QUERY );
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 2edbac4..04f7a51 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -639,7 +639,7 @@
             }
         }
         else if( ( rAttrName.getLength() >= 5 ) &&
-            ( rAttrName.compareTo( GetXMLToken(XML_XMLNS), 5 ) == 0 ) &&
+            ( rAttrName.startsWith( GetXMLToken(XML_XMLNS) ) ) &&
             ( rAttrName.getLength() == 5 || ':' == rAttrName[5] ) )
         {
             if( !pRewindMap )
diff --git a/xmloff/source/style/XMLClipPropertyHandler.cxx b/xmloff/source/style/XMLClipPropertyHandler.cxx
index e55e6ee..ec0e1d5 100644
--- a/xmloff/source/style/XMLClipPropertyHandler.cxx
+++ b/xmloff/source/style/XMLClipPropertyHandler.cxx
@@ -66,7 +66,7 @@
     sal_Bool bRet = sal_False;
     sal_Int32 nLen = rStrImpValue.getLength();
     if( nLen > 6 &&
-        0 == rStrImpValue.compareTo( GetXMLToken(XML_RECT), 4 ) &&
+        rStrImpValue.startsWith( GetXMLToken(XML_RECT)) &&
         rStrImpValue[4] == '(' &&
         rStrImpValue[nLen-1] == ')' )
     {
diff --git a/xmloff/source/transform/TransformerBase.cxx b/xmloff/source/transform/TransformerBase.cxx
index 67c8e5b..4adfc97 100644
--- a/xmloff/source/transform/TransformerBase.cxx
+++ b/xmloff/source/transform/TransformerBase.cxx
@@ -242,7 +242,7 @@
     {
         const OUString& rAttrName = xAttrList->getNameByIndex( i );
         if( ( rAttrName.getLength() >= 5 ) &&
-            ( rAttrName.compareTo( GetXMLToken(XML_XMLNS), 5 ) == 0 ) &&
+            ( rAttrName.startsWith( GetXMLToken(XML_XMLNS) ) ) &&
             ( rAttrName.getLength() == 5 || ':' == rAttrName[5] ) )
         {
             if( !pRewindMap )
@@ -1340,8 +1340,7 @@
             break;
         case '.':
             // a rel path
-            if( 0 == rURI.compareTo( m_aExtPathPrefix,
-                                     m_aExtPathPrefix.getLength() ) )
+            if( rURI.startsWith( m_aExtPathPrefix ) )
             {
                 // an external URI; remove '../'
                 rURI = rURI.copy( m_aExtPathPrefix.getLength() );
diff --git a/xmlscript/source/xml_helper/xml_impctx.cxx b/xmlscript/source/xml_helper/xml_impctx.cxx
index 5c2dec3..9189e53 100644
--- a/xmlscript/source/xml_helper/xml_impctx.cxx
+++ b/xmlscript/source/xml_helper/xml_impctx.cxx
@@ -563,7 +563,7 @@
         pQNames[ nPos ] = xAttribs->getNameByIndex( nPos );
         OUString const & rQAttributeName = pQNames[ nPos ];
 
-        if (rQAttributeName.compareTo( m_sXMLNS, 5 ) == 0)
+        if (rQAttributeName.startsWith( m_sXMLNS ))
         {
             if (rQAttributeName.getLength() == 5) // set default namespace
             {
diff --git a/xmlsecurity/source/helper/xsecparser.cxx b/xmlsecurity/source/helper/xsecparser.cxx
index ce6cedd..bb8aec5 100644
--- a/xmlsecurity/source/helper/xsecparser.cxx
+++ b/xmlsecurity/source/helper/xsecparser.cxx
@@ -106,7 +106,7 @@
             rtl::OUString ouUri = xAttribs->getValueByName(rtl::OUString(RTL_ASCII_USTRINGPARAM(ATTR_URI)));
             DBG_ASSERT( ouUri != NULL, "URI == NULL" );
 
-            if (0 == ouUri.compareTo(rtl::OUString(RTL_ASCII_USTRINGPARAM(CHAR_FRAGMENT)),1))
+            if (ouUri.startsWith(CHAR_FRAGMENT))
             {
                 /*
                 * remove the first character '#' from the attribute value

-- 
To view, visit https://gerrit.libreoffice.org/2599
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie70097de550ddd1cddc6714f8f86f9723cb36679
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Thomas Arnhold <thomas at arnhold.org>



More information about the LibreOffice mailing list