[Libreoffice-commits] core.git: connectivity/source sal/osl sc/source stoc/source ucb/source writerfilter/source

Noel Grandin noel at peralex.com
Fri Jul 10 01:09:25 PDT 2015


 connectivity/source/drivers/file/fcode.cxx          |    7 +------
 connectivity/source/drivers/postgresql/pq_tools.cxx |   16 ++++------------
 sal/osl/all/debugbase.cxx                           |    3 +--
 sal/osl/unx/file_stat.cxx                           |    4 +---
 sal/osl/w32/file_dirvol.cxx                         |    4 +---
 sc/source/filter/oox/workbookhelper.cxx             |    5 ++---
 stoc/source/security/permissions.cxx                |    6 ++----
 ucb/source/ucp/file/prov.cxx                        |    2 +-
 writerfilter/source/dmapper/PropertyMap.cxx         |   15 +++++----------
 9 files changed, 18 insertions(+), 44 deletions(-)

New commits:
commit 54013188b24a1a02491a2853f731461253065424
Author: Noel Grandin <noel at peralex.com>
Date:   Wed Jul 8 15:02:31 2015 +0200

    cleanup some unnecessary direct usage of the OString/OUString C API.
    
    Change-Id: I6edee95aae1c169ce70063562a0c1b287e0c4735
    Reviewed-on: https://gerrit.libreoffice.org/16861
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/connectivity/source/drivers/file/fcode.cxx b/connectivity/source/drivers/file/fcode.cxx
index 9679391..e4c1426 100644
--- a/connectivity/source/drivers/file/fcode.cxx
+++ b/connectivity/source/drivers/file/fcode.cxx
@@ -305,12 +305,7 @@ bool OOp_COMPARE::operate(const OOperand* pLeft, const OOperand* pRight) const
         case DataType::LONGVARCHAR:
         {
             OUString sLH = aLH, sRH = aRH;
-            sal_Int32 nRes = rtl_ustr_compareIgnoreAsciiCase_WithLength
-                (
-                 sLH.pData->buffer,
-                 sLH.pData->length,
-                 sRH.pData->buffer,
-                 sRH.pData->length );
+            sal_Int32 nRes = sLH.compareToIgnoreAsciiCase(sRH);
             switch(aPredicateType)
             {
                 case SQLFilterOperator::EQUAL:          bResult = (nRes == 0); break;
diff --git a/connectivity/source/drivers/postgresql/pq_tools.cxx b/connectivity/source/drivers/postgresql/pq_tools.cxx
index 4d75e8c3..ae9b304 100644
--- a/connectivity/source/drivers/postgresql/pq_tools.cxx
+++ b/connectivity/source/drivers/postgresql/pq_tools.cxx
@@ -769,9 +769,7 @@ OString extractSingleTableFromSelect( const OStringVector &vec )
             token ++;
         }
 
-        if( token < vec.size() && rtl_str_compare_WithLength(
-                vec[token].getStr(), vec[token].getLength(),
-                RTL_CONSTASCII_STRINGPARAM("(") ) )
+        if( token < vec.size() && vec[token] == "(" )
         {
             // it is a table or a function name
             OStringBuffer buf(128);
@@ -783,9 +781,7 @@ OString extractSingleTableFromSelect( const OStringVector &vec )
 
             if( token < vec.size() )
             {
-                if( rtl_str_compare_WithLength(
-                        vec[token].getStr(), vec[token].getLength(),
-                        RTL_CONSTASCII_STRINGPARAM( "." ) ) == 0 )
+                if( vec[token] == "." )
                 {
                     buf.append( vec[token] );
                     token ++;
@@ -803,9 +799,7 @@ OString extractSingleTableFromSelect( const OStringVector &vec )
             ret = buf.makeStringAndClear();
             // now got my table candidate
 
-            if( token < vec.size() && rtl_str_compare_WithLength(
-                    vec[token].getStr(), vec[token].getLength(),
-                    RTL_CONSTASCII_STRINGPARAM( "(" ) ) == 0 )
+            if( token < vec.size() && vec[token] == "(" )
             {
                 // whoops, it is a function
                 ret.clear();
@@ -823,9 +817,7 @@ OString extractSingleTableFromSelect( const OStringVector &vec )
 
                 if( token < vec.size() )
                 {
-                    if( rtl_str_compare_WithLength(
-                            vec[token].getStr(), vec[token].getLength(),
-                            RTL_CONSTASCII_STRINGPARAM( "," ) ) == 0 )
+                    if( vec[token] == "," )
                     {
                         // whoops, multiple tables are used
                         ret.clear();
diff --git a/sal/osl/all/debugbase.cxx b/sal/osl/all/debugbase.cxx
index ae097ee..0f233f8 100644
--- a/sal/osl/all/debugbase.cxx
+++ b/sal/osl/all/debugbase.cxx
@@ -91,8 +91,7 @@ bool SAL_CALL osl_detail_ObjectRegistry_storeAddresses( char const* pName )
         return false;
     // check for "all":
     rtl::OString const& rFirst = rVec[0];
-    if (rtl_str_compare_WithLength( rFirst.getStr(), rFirst.getLength(),
-                                    RTL_CONSTASCII_STRINGPARAM("all") ) == 0)
+    if ( rFirst == "all" )
         return true;
     OStringVec::const_iterator const iEnd( rVec.end() );
     return std::find_if( rVec.begin(), iEnd,
diff --git a/sal/osl/unx/file_stat.cxx b/sal/osl/unx/file_stat.cxx
index 7818282..72d64f1 100644
--- a/sal/osl/unx/file_stat.cxx
+++ b/sal/osl/unx/file_stat.cxx
@@ -427,9 +427,7 @@ SAL_CALL osl_identicalDirectoryItem( oslDirectoryItem a, oslDirectoryItem b)
     if (a == b)
         return sal_True;
     /* same name => same item, unless renaming / moving madness has occurred */
-    if (rtl_ustr_compare_WithLength(
-                pA->m_ustrFilePath->buffer, pA->m_ustrFilePath->length,
-                pB->m_ustrFilePath->buffer, pB->m_ustrFilePath->length ) == 0)
+    if (pA->m_ustrFilePath == pB->m_ustrFilePath)
         return sal_True;
 
     struct stat a_stat, b_stat;
diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index bd5bb02..5f8aef4 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -1151,9 +1151,7 @@ SAL_CALL osl_identicalDirectoryItem( oslDirectoryItem a, oslDirectoryItem b)
     if (a == b)
         return sal_True;
     /* same name => same item, unless renaming / moving madness has occurred */
-    if (rtl_ustr_compare_WithLength(
-                pA->m_pFullPath->buffer, pA->m_pFullPath->length,
-                pB->m_pFullPath->buffer, pB->m_pFullPath->length ) == 0)
+    if (pA->m_pFullPath == pB->m_pFullPath)
         return sal_True;
 
     // FIXME: as/when/if this is used in anger on Windows we could
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index d264e56..1ced0d0 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -106,9 +106,8 @@ using ::oox::core::XmlFilterBase;
 
 bool IgnoreCaseCompare::operator()( const OUString& rName1, const OUString& rName2 ) const
 {
-    // there is no wrapper in OUString, TODO: compare with collator
-    return ::rtl_ustr_compareIgnoreAsciiCase_WithLength(
-        rName1.getStr(), rName1.getLength(), rName2.getStr(), rName2.getLength() ) < 0;
+    // TODO: compare with collator
+    return rName1.compareToIgnoreAsciiCase(rName2 ) < 0;
 }
 
 class WorkbookGlobals : boost::noncopyable
diff --git a/stoc/source/security/permissions.cxx b/stoc/source/security/permissions.cxx
index d6f0f79..21397f9 100644
--- a/stoc/source/security/permissions.cxx
+++ b/stoc/source/security/permissions.cxx
@@ -380,8 +380,7 @@ bool FilePermission::implies( Permission const & perm ) const
     if (m_url.getLength() > demanded.m_url.getLength())
         return false;
     // check /- wildcard: all files and recursive in that path
-    if (1 < m_url.getLength() &&
-        0 == ::rtl_ustr_ascii_compare_WithLength( m_url.getStr() + m_url.getLength() - 2, 2, "/-" ))
+    if (m_url.endsWith("/-"))
     {
         // demanded url must start with granted path (including path trailing path sep)
         sal_Int32 len = m_url.getLength() -1;
@@ -394,8 +393,7 @@ bool FilePermission::implies( Permission const & perm ) const
 #endif
     }
     // check /* wildcard: all files in that path (not recursive!)
-    if (1 < m_url.getLength() &&
-        0 == ::rtl_ustr_ascii_compare_WithLength( m_url.getStr() + m_url.getLength() - 2, 2, "/*" ))
+    if (m_url.endsWith("/*"))
     {
         // demanded url must start with granted path (including path trailing path sep)
         sal_Int32 len = m_url.getLength() -1;
diff --git a/ucb/source/ucp/file/prov.cxx b/ucb/source/ucp/file/prov.cxx
index 6f14d05..e0159ad 100644
--- a/ucb/source/ucp/file/prov.cxx
+++ b/ucb/source/ucp/file/prov.cxx
@@ -259,7 +259,7 @@ FileProvider::compareContentIds(
                     error = osl::FileBase::getSystemPathFromFileURL( aStatus2.getFileURL(), aPath2 );
 
                 if ( error == osl::FileBase::E_None )
-                    iComp = rtl_ustr_compareIgnoreAsciiCase( aPath1.getStr(), aPath2.getStr() );
+                    iComp = aPath1.compareToIgnoreAsciiCase( aPath2 );
             }
 #endif
         }
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index e289538..3a30cf3 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -484,27 +484,22 @@ SectionPropertyMap::~SectionPropertyMap()
 
 OUString lcl_FindUnusedPageStyleName(const uno::Sequence< OUString >& rPageStyleNames)
 {
-    static const sal_Char cDefaultStyle[] = "Converted";
-    //find the hightest number x in each style with the name "cDefaultStyle+x" and
+    static const char DEFAULT_STYLE[] = "Converted";
+    //find the highest number x in each style with the name "DEFAULT_STYLE+x" and
     //return an incremented name
     sal_Int32 nMaxIndex = 0;
-    const sal_Int32 nDefaultLength = sizeof(cDefaultStyle)/sizeof(sal_Char) - 1;
-    const OUString sDefaultStyle( cDefaultStyle, nDefaultLength, RTL_TEXTENCODING_ASCII_US );
 
     const OUString* pStyleNames = rPageStyleNames.getConstArray();
     for( sal_Int32 nStyle = 0; nStyle < rPageStyleNames.getLength(); ++nStyle)
     {
-        if( pStyleNames[nStyle].getLength() > nDefaultLength &&
-                !rtl_ustr_compare_WithLength( sDefaultStyle.getStr(), nDefaultLength, pStyleNames[nStyle].getStr(), nDefaultLength))
+        if( pStyleNames[nStyle].startsWith(DEFAULT_STYLE) )
         {
-            sal_Int32 nIndex = pStyleNames[nStyle].copy( nDefaultLength ).toInt32();
+            sal_Int32 nIndex = pStyleNames[nStyle].copy( strlen(DEFAULT_STYLE) ).toInt32();
             if( nIndex > nMaxIndex)
                 nMaxIndex = nIndex;
         }
     }
-    OUString sRet( sDefaultStyle );
-    sRet += OUString::number( nMaxIndex + 1);
-    return sRet;
+    return DEFAULT_STYLE + OUString::number( nMaxIndex + 1);
 }
 
 


More information about the Libreoffice-commits mailing list