Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hi,

while replacing ByteString with OString I came across some getLength() calls which might be replaced with isEmpty(). Hope Olivier won't be annoyed :-)

Some reviewing would be nice to be sure the logic didn't get inverted accidently.I have git push access - so reviewing would be sufficient.

Christina
From ed04863f8e7daeb00058b00a664b810b0bc204f6 Mon Sep 17 00:00:00 2001
From: Christina Rossmanith <ChrRossmanith@web.de>
Date: Thu, 12 Jan 2012 15:23:07 +0100
Subject: [PATCH 2/2] Replace getLength() with isEmpty() in vcl/generic/fontmanager

---
 vcl/generic/fontmanager/fontcache.cxx   |    4 ++--
 vcl/generic/fontmanager/fontconfig.cxx  |   16 ++++++++--------
 vcl/generic/fontmanager/fontmanager.cxx |   24 ++++++++++++------------
 vcl/generic/fontmanager/helper.cxx      |   12 ++++++------
 4 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/vcl/generic/fontmanager/fontcache.cxx b/vcl/generic/fontmanager/fontcache.cxx
index 5df9b03..ec93599 100644
--- a/vcl/generic/fontmanager/fontcache.cxx
+++ b/vcl/generic/fontmanager/fontcache.cxx
@@ -176,7 +176,7 @@ void FontCache::flush()
                 for( ::std::list< int >::const_iterator name_it = (*it)->m_aAliases.begin(); 
name_it != (*it)->m_aAliases.end(); ++name_it )
                 {
                     const OUString& rAdd( pAtoms->getString( ATOM_FAMILYNAME, *name_it ) );
-                    if( rAdd.getLength() )
+                    if( !rAdd.isEmpty() )
                     {
                         aLine.append(';');
                         aLine.append(OUStringToOString(rAdd, RTL_TEXTENCODING_UTF8));
@@ -233,7 +233,7 @@ void FontCache::flush()
                         break;
                     default: break;
                 }
-                if( (*it)->m_aStyleName.getLength() )
+                if( !(*it)->m_aStyleName.isEmpty() )
                 {
                     aLine.append(';');
                     aLine.append(OUStringToOString((*it)->m_aStyleName, RTL_TEXTENCODING_UTF8));
diff --git a/vcl/generic/fontmanager/fontconfig.cxx b/vcl/generic/fontmanager/fontconfig.cxx
index 4d02a76..49944fe 100644
--- a/vcl/generic/fontmanager/fontconfig.cxx
+++ b/vcl/generic/fontmanager/fontconfig.cxx
@@ -764,7 +764,7 @@ bool PrintFontManager::Substitute( FontSelectPattern &rPattern, rtl::OUString& r
     FcPatternAddString(pPattern, FC_FAMILY, pTargetNameUtf8);
 
     const rtl::OString aLangAttrib = MsLangId::convertLanguageToIsoByteString(rPattern.meLanguage);
-    if( aLangAttrib.getLength() )
+    if( !aLangAttrib.isEmpty() )
     {
         const FcChar8* pLangAttribUtf8;
         if (aLangAttrib.equalsIgnoreAsciiCase(OString(RTL_CONSTASCII_STRINGPARAM("pa-in"))))
@@ -775,7 +775,7 @@ bool PrintFontManager::Substitute( FontSelectPattern &rPattern, rtl::OUString& r
     }
 
     // Add required Unicode characters, if any
-    if ( rMissingCodes.getLength() )
+    if ( !rMissingCodes.isEmpty() )
     {
        FcCharSet *unicodes = FcCharSetCreate();
        for( sal_Int32 nStrIndex = 0; nStrIndex < rMissingCodes.getLength(); )
@@ -853,7 +853,7 @@ bool PrintFontManager::Substitute( FontSelectPattern &rPattern, rtl::OUString& r
             }
 
             // update rMissingCodes by removing resolved unicodes
-            if( rMissingCodes.getLength() > 0 )
+            if( !rMissingCodes.isEmpty() )
             {
                 sal_uInt32* pRemainingCodes = (sal_uInt32*)alloca( rMissingCodes.getLength() * 
sizeof(sal_uInt32) );
                 int nRemainingLen = 0;
@@ -918,7 +918,7 @@ ImplFontOptions* PrintFontManager::getFontOptions(
     boost::unordered_map< rtl::OString, rtl::OString, rtl::OStringHash >::const_iterator aI = 
rWrapper.m_aLocalizedToCanonical.find(sFamily);
     if (aI != rWrapper.m_aLocalizedToCanonical.end())
         sFamily = aI->second;
-    if( sFamily.getLength() )
+    if( !sFamily.isEmpty() )
         FcPatternAddString(pPattern, FC_FAMILY, (FcChar8*)sFamily.getStr());
 
     addtopattern(pPattern, rInfo.m_eItalic, rInfo.m_eWeight, rInfo.m_eWidth, rInfo.m_ePitch);
@@ -985,22 +985,22 @@ bool PrintFontManager::matchFont( FastPrintFontInfo& rInfo, const 
com::sun::star
 
     OString aLangAttrib;
     // populate pattern with font characteristics
-    if( rLocale.Language.getLength() )
+    if( !rLocale.Language.isEmpty() )
     {
         OUStringBuffer aLang(6);
         aLang.append( rLocale.Language );
-        if( rLocale.Country.getLength() )
+        if( !rLocale.Country.isEmpty() )
         {
             aLang.append( sal_Unicode('-') );
             aLang.append( rLocale.Country );
         }
         aLangAttrib = OUStringToOString( aLang.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
     }
-    if( aLangAttrib.getLength() )
+    if( !aLangAttrib.isEmpty() )
         FcPatternAddString(pPattern, FC_LANG, (FcChar8*)aLangAttrib.getStr());
 
     OString aFamily = OUStringToOString( rInfo.m_aFamilyName, RTL_TEXTENCODING_UTF8 );
-    if( aFamily.getLength() )
+    if( !aFamily.isEmpty() )
         FcPatternAddString(pPattern, FC_FAMILY, (FcChar8*)aFamily.getStr());
 
     addtopattern(pPattern, rInfo.m_eItalic, rInfo.m_eWeight, rInfo.m_eWidth, rInfo.m_ePitch);
diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx
index 37f0bf7..ed9f8c6 100644
--- a/vcl/generic/fontmanager/fontmanager.cxx
+++ b/vcl/generic/fontmanager/fontmanager.cxx
@@ -788,7 +788,7 @@ bool PrintFontManager::PrintFont::readAfmMetrics( const OString& rFileName, Mult
     if( ! m_nFamilyName )
     {
         aFamily = OStringToOUString( pInfo->gfi->familyName, RTL_TEXTENCODING_ISO_8859_1 );
-        if( ! aFamily.getLength() )
+        if( aFamily.isEmpty() )
         {
             aFamily = OStringToOUString( pInfo->gfi->fontName, RTL_TEXTENCODING_ISO_8859_1 );
             sal_Int32 nIndex  = 0;
@@ -802,7 +802,7 @@ bool PrintFontManager::PrintFont::readAfmMetrics( const OString& rFileName, Mult
 
     // style name: if fullname begins with family name
     // interpret the rest of fullname as style
-    if( ! m_aStyleName.getLength() && pInfo->gfi->fullName && *pInfo->gfi->fullName )
+    if( m_aStyleName.isEmpty() && pInfo->gfi->fullName && *pInfo->gfi->fullName )
     {
         OUString aFullName( OStringToOUString( pInfo->gfi->fullName, RTL_TEXTENCODING_ISO_8859_1 ) 
);
         if( aFullName.indexOf( aFamily ) == 0 )
@@ -1693,12 +1693,12 @@ OString PrintFontManager::getXLFD( PrintFont* pFont ) const
 {
     if( pFont->m_eType == fonttype::Type1 )
     {
-        if( static_cast<Type1FontFile*>(pFont)->m_aXLFD.getLength() )
+        if( ! static_cast<Type1FontFile*>(pFont)->m_aXLFD.isEmpty() )
             return static_cast<Type1FontFile*>(pFont)->m_aXLFD;
     }
     if( pFont->m_eType == fonttype::TrueType )
     {
-        if( static_cast<TrueTypeFontFile*>(pFont)->m_aXLFD.getLength() )
+        if( ! static_cast<TrueTypeFontFile*>(pFont)->m_aXLFD.isEmpty() )
             return static_cast<TrueTypeFontFile*>(pFont)->m_aXLFD;
     }
 
@@ -1894,7 +1894,7 @@ void PrintFontManager::analyzeTrueTypeFamilyName( void* pTTFont, ::std::list< 
OU
         }
         DisposeNameRecords( pNameRecords, nNameRecords );
     }
-    if( aFamily.getLength() )
+    if( !aFamily.isEmpty() )
     {
         rNames.push_front( aFamily );
         for( ::std::set< OUString >::const_iterator it = aSet.begin(); it != aSet.end(); ++it )
@@ -1945,7 +1945,7 @@ bool PrintFontManager::analyzeTrueTypeFile( PrintFont* pFont ) const
         }
         for( ::std::list< OUString >::iterator it = aNames.begin(); it != aNames.end(); ++it )
         {
-            if( it->getLength() )
+            if( !it->isEmpty() )
             {
                 int nAlias = m_pAtoms->getAtom( ATOM_FAMILYNAME, *it, sal_True );
                 if( nAlias != pFont->m_nFamilyName )
@@ -2161,7 +2161,7 @@ void PrintFontManager::initialize()
 
     // search for the fonts in SAL_PRIVATE_FONTPATH first; those are
     // the fonts installed with the office
-    if( rSalPrivatePath.getLength() )
+    if( !rSalPrivatePath.isEmpty() )
     {
         OString aPath = rtl::OUStringToOString( rSalPrivatePath, aEncoding );
         const bool bAreFCSubstitutionsEnabled = AreFCSubstitutionsEnabled();
@@ -2170,7 +2170,7 @@ void PrintFontManager::initialize()
         {
             OString aToken = aPath.getToken( 0, ';', nIndex );
             normPath( aToken );
-            if (!aToken.getLength())
+            if ( aToken.isEmpty() )
             {
                 continue;
             }
@@ -3275,7 +3275,7 @@ int PrintFontManager::importFonts( const ::std::list< OString >& rFiles, bool 
bL
             // copy font file
             if( nError )
             {
-                if( aAfmCopied.getLength() )
+                if( !aAfmCopied.isEmpty() )
                     File::remove( aAfmCopied );
                 if( pCallback )
                     pCallback->importFontFailed( aTo.PathToFileName(), 
ImportFontCallback::FontCopyFailed );
@@ -3441,7 +3441,7 @@ bool PrintFontManager::getFileDuplicates( fontID nFont, ::std::list< fontID 
& r
         return false;
 
     OString aFile( getFontFileSysPath( nFont ) );
-    if( ! aFile.getLength() )
+    if( aFile.isEmpty() )
         return false;
 
     for( ::boost::unordered_map< fontID, PrintFont* >::const_iterator it = m_aFonts.begin(); it != 
m_aFonts.end(); ++it )
@@ -3491,7 +3491,7 @@ bool PrintFontManager::removeFonts( const ::std::list< fontID >& rFonts )
             fprintf( stderr, "succeeded\n" );
 #endif
             OString aAfm( getAfmFile( pFont ) );
-            if( aAfm.getLength() )
+            if( !aAfm.isEmpty() )
             {
 #if OSL_DEBUG_LEVEL > 1
                 fprintf( stderr, "unlink( \"%s\" )\n", aAfm.getStr() );
@@ -3567,7 +3567,7 @@ bool PrintFontManager::getAlternativeFamilyNames( fontID nFont, ::std::list< 
OUS
                     continue;
 
                 OUString aFamily( convertTrueTypeName( pNameRecords+i ) );
-                if( aFamily.getLength()
+                if( !aFamily.isEmpty()
                     &&
                     m_pAtoms->getAtom( ATOM_FAMILYNAME, aFamily, sal_True ) != pFont->m_nFamilyName
                     )
diff --git a/vcl/generic/fontmanager/helper.cxx b/vcl/generic/fontmanager/helper.cxx
index dc54f08..b0e4238 100644
--- a/vcl/generic/fontmanager/helper.cxx
+++ b/vcl/generic/fontmanager/helper.cxx
@@ -157,7 +157,7 @@ void psp::getPrinterPathList( std::list< OUString >& rPathList, const char* pSub
     do
     {
         OString aDir( aPath.getToken( 0, ':', nIndex ) );
-        if( ! aDir.getLength() )
+        if( aDir.isEmpty() )
             continue;
 
         if( pSubDir )
@@ -201,14 +201,14 @@ OUString psp::getFontPath()
 {
     static OUString aPath;
 
-    if( ! aPath.getLength() )
+    if( aPath.isEmpty() )
     {
         OUStringBuffer aPathBuffer( 512 );
 
         OUString aConfigPath( getOfficePath( psp::ConfigPath ) );
         OUString aNetPath( getOfficePath( psp::NetPath ) );
         OUString aUserPath( getOfficePath( psp::UserPath ) );
-        if( aConfigPath.getLength() )
+        if( !aConfigPath.isEmpty() )
         {
             // #i53530# Path from CustomDataUrl will completely
             // replace net and user paths if the path exists
@@ -225,16 +225,16 @@ OUString psp::getFontPath()
                 aPathBuffer.appendAscii("/share/fonts");
             }
         }
-        if( aConfigPath.getLength() == 0 )
+        if( aConfigPath.isEmpty() )
         {
-            if( aNetPath.getLength() )
+            if( !aNetPath.isEmpty() )
             {
                 aPathBuffer.append( aNetPath );
                 aPathBuffer.appendAscii( "/share/fonts/truetype;");
                 aPathBuffer.append( aNetPath );
                 aPathBuffer.appendAscii( "/share/fonts/type1;" );
             }
-            if( aUserPath.getLength() )
+            if( !aUserPath.isEmpty() )
             {
                 aPathBuffer.append( aUserPath );
                 aPathBuffer.appendAscii( "/user/fonts" );
-- 
1.7.4.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.