[Libreoffice-commits] .: 2 commits - vcl/generic

Caolán McNamara caolan at kemper.freedesktop.org
Tue Jan 10 05:33:39 PST 2012


 vcl/generic/print/genprnpsp.cxx      |   47 ++++++++++++++++-------------------
 vcl/generic/print/genpspgraphics.cxx |   16 ++++++-----
 2 files changed, 31 insertions(+), 32 deletions(-)

New commits:
commit 5e3612b1d5923845bf955231278f45b4e3089951
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jan 10 13:32:36 2012 +0000

    can drop intermediate strings now

diff --git a/vcl/generic/print/genprnpsp.cxx b/vcl/generic/print/genprnpsp.cxx
index 83b3418..18980a4 100644
--- a/vcl/generic/print/genprnpsp.cxx
+++ b/vcl/generic/print/genprnpsp.cxx
@@ -357,10 +357,9 @@ static bool sendAFax( const OUString& rFaxNumber, const OUString& rFileName, con
     {
         while( aFaxNumbers.begin() != aFaxNumbers.end() && bSuccess )
         {
-            OUString aCmdLine( rCommand );
             OUString aFaxNumber( aFaxNumbers.front() );
             aFaxNumbers.pop_front();
-            aCmdLine = comphelper::string::replace( aCmdLine, OUString( RTL_CONSTASCII_USTRINGPARAM( "(PHONE)" ) ), aFaxNumber );
+            OUString aCmdLine = comphelper::string::replace( rCommand, OUString( RTL_CONSTASCII_USTRINGPARAM( "(PHONE)" ) ), aFaxNumber );
 #if OSL_DEBUG_LEVEL > 1
             fprintf( stderr, "sending fax to \"%s\"\n", OUStringToOString( aFaxNumber, osl_getThreadTextEncoding() ).getStr() );
 #endif
@@ -383,8 +382,7 @@ static bool sendAFax( const OUString& rFaxNumber, const OUString& rFileName, con
 static bool createPdf( const OUString& rToFile, const OUString& rFromFile, const OUString& rCommandLine )
 {
 #if defined( UNX )
-    OUString aCommandLine( rCommandLine );
-    aCommandLine = comphelper::string::replace( aCommandLine, OUString( RTL_CONSTASCII_USTRINGPARAM( "(OUTFILE)" ) ), rToFile );
+    OUString aCommandLine = comphelper::string::replace( rCommandLine, OUString( RTL_CONSTASCII_USTRINGPARAM( "(OUTFILE)" ) ), rToFile );
 
     return passFileToCommandLine( rFromFile, aCommandLine );
 #else
commit 6dc465535784fa8964fbd7d1b12eaecadf027cdc
Author: Christina Rossmanith <ChrRossmanith at web.de>
Date:   Tue Jan 10 10:42:55 2012 +0100

    Replace (Byte)String with rtl::O(U)String

diff --git a/vcl/generic/print/genprnpsp.cxx b/vcl/generic/print/genprnpsp.cxx
index 747b0ec..83b3418 100644
--- a/vcl/generic/print/genprnpsp.cxx
+++ b/vcl/generic/print/genprnpsp.cxx
@@ -83,7 +83,7 @@ extern "C"
 {
 typedef int(*setupFunction)(PrinterInfo&);
 static setupFunction pSetupFunction         = NULL;
-typedef int(*faxFunction)(String&);
+typedef int(*faxFunction)(OUString&);
 static faxFunction pFaxNrFunction           = NULL;
 }
 
@@ -170,7 +170,7 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
 
     pJobSetup->mnPaperBin = 0;
     if( rData.m_pParser )
-        pKey                    = rData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) );
+        pKey                    = rData.m_pParser->getKey( OUString( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) );
     if( pKey )
         pValue                  = rData.m_aContext.getValue( pKey );
     if( pKey && pValue )
@@ -190,7 +190,7 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
 
     pJobSetup->meDuplexMode = DUPLEX_UNKNOWN;
     if( rData.m_pParser )
-        pKey = rData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) );
+        pKey = rData.m_pParser->getKey( OUString( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) );
     if( pKey )
         pValue = rData.m_aContext.getValue( pKey );
     if( pKey && pValue )
@@ -231,7 +231,7 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
 
 // Needs a cleaner abstraction ...
 #if defined( UNX )
-static bool passFileToCommandLine( const String& rFilename, const String& rCommandLine, bool bRemoveFile = true )
+static bool passFileToCommandLine( const OUString& rFilename, const OUString& rCommandLine, bool bRemoveFile = true )
 {
     bool bSuccess = false;
 
@@ -315,19 +315,19 @@ static bool passFileToCommandLine( const String& rFilename, const String& rComma
 }
 #endif
 
-static bool sendAFax( const String& rFaxNumber, const String& rFileName, const String& rCommand )
+static bool sendAFax( const OUString& rFaxNumber, const OUString& rFileName, const OUString& rCommand )
 {
 #if defined( UNX )
     std::list< OUString > aFaxNumbers;
 
-    if( ! rFaxNumber.Len() )
+    if( rFaxNumber.isEmpty() )
     {
         getPaLib();
         if( pFaxNrFunction )
         {
-            String aNewNr;
+            OUString aNewNr;
             if( pFaxNrFunction( aNewNr ) )
-                aFaxNumbers.push_back( OUString( aNewNr ) );
+                aFaxNumbers.push_back( aNewNr );
         }
     }
     else
@@ -357,11 +357,10 @@ static bool sendAFax( const String& rFaxNumber, const String& rFileName, const S
     {
         while( aFaxNumbers.begin() != aFaxNumbers.end() && bSuccess )
         {
-            String aCmdLine( rCommand );
-            String aFaxNumber( aFaxNumbers.front() );
+            OUString aCmdLine( rCommand );
+            OUString aFaxNumber( aFaxNumbers.front() );
             aFaxNumbers.pop_front();
-            while( aCmdLine.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "(PHONE)" ) ), aFaxNumber ) != STRING_NOTFOUND )
-                ;
+            aCmdLine = comphelper::string::replace( aCmdLine, OUString( RTL_CONSTASCII_USTRINGPARAM( "(PHONE)" ) ), aFaxNumber );
 #if OSL_DEBUG_LEVEL > 1
             fprintf( stderr, "sending fax to \"%s\"\n", OUStringToOString( aFaxNumber, osl_getThreadTextEncoding() ).getStr() );
 #endif
@@ -381,12 +380,12 @@ static bool sendAFax( const String& rFaxNumber, const String& rFileName, const S
 #endif
 }
 
-static bool createPdf( const String& rToFile, const String& rFromFile, const String& rCommandLine )
+static bool createPdf( const OUString& rToFile, const OUString& rFromFile, const OUString& rCommandLine )
 {
 #if defined( UNX )
-    String aCommandLine( rCommandLine );
-    while( aCommandLine.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "(OUTFILE)" ) ), rToFile ) != STRING_NOTFOUND )
-        ;
+    OUString aCommandLine( rCommandLine );
+    aCommandLine = comphelper::string::replace( aCommandLine, OUString( RTL_CONSTASCII_USTRINGPARAM( "(OUTFILE)" ) ), rToFile );
+
     return passFileToCommandLine( rFromFile, aCommandLine );
 #else
     (void)rToFile; (void)rFromFile; (void)rCommandLine;
@@ -537,7 +536,7 @@ void PspSalInfoPrinter::InitPaperFormats( const ImplJobSetup* )
 
     if( m_aJobData.m_pParser )
     {
-        const PPDKey* pKey = m_aJobData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) );
+        const PPDKey* pKey = m_aJobData.m_pParser->getKey( OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) );
         if( pKey )
         {
             int nValues = pKey->countValues();
@@ -668,7 +667,7 @@ sal_Bool PspSalInfoPrinter::SetData(
         // merge papersize if necessary
         if( nSetDataFlags & SAL_JOBSET_PAPERSIZE )
         {
-            String aPaper;
+            OUString aPaper;
 
             if( pJobSetup->mePaperFormat == PAPER_USER )
                 aPaper = aData.m_pParser->matchPaper(
@@ -677,7 +676,7 @@ sal_Bool PspSalInfoPrinter::SetData(
             else
                 aPaper = rtl::OStringToOUString(PaperInfo::toPSName(pJobSetup->mePaperFormat), RTL_TEXTENCODING_ISO_8859_1);
 
-            pKey = aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) );
+            pKey = aData.m_pParser->getKey( OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) );
             pValue = pKey ? pKey->getValueCaseInsensitive( aPaper ) : NULL;
 
             // some PPD files do not specify the standard paper names (e.g. C5 instead of EnvC5)
@@ -698,7 +697,7 @@ sal_Bool PspSalInfoPrinter::SetData(
         // merge paperbin if necessary
         if( nSetDataFlags & SAL_JOBSET_PAPERBIN )
         {
-            pKey = aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) );
+            pKey = aData.m_pParser->getKey( OUString( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) );
             if( pKey )
             {
                 int nPaperBin = pJobSetup->mnPaperBin;
@@ -722,22 +721,22 @@ sal_Bool PspSalInfoPrinter::SetData(
         // merge duplex if necessary
         if( nSetDataFlags & SAL_JOBSET_DUPLEXMODE )
         {
-            pKey = aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) );
+            pKey = aData.m_pParser->getKey( OUString( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) );
             if( pKey )
             {
                 pValue = NULL;
                 switch( pJobSetup->meDuplexMode )
                 {
                 case DUPLEX_OFF:
-                    pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "None" ) ) );
+                    pValue = pKey->getValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "None" ) ) );
                     if( pValue == NULL )
-                        pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "SimplexNoTumble" ) ) );
+                        pValue = pKey->getValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "SimplexNoTumble" ) ) );
                     break;
                 case DUPLEX_SHORTEDGE:
-                    pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "DuplexTumble" ) ) );
+                    pValue = pKey->getValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DuplexTumble" ) ) );
                     break;
                 case DUPLEX_LONGEDGE:
-                    pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "DuplexNoTumble" ) ) );
+                    pValue = pKey->getValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DuplexNoTumble" ) ) );
                     break;
                 case DUPLEX_UNKNOWN:
                 default:
diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx
index 2c56403..4d869c5 100644
--- a/vcl/generic/print/genpspgraphics.cxx
+++ b/vcl/generic/print/genpspgraphics.cxx
@@ -60,6 +60,8 @@
 #include <graphite_serverfont.hxx>
 #endif
 
+#include "comphelper/string.hxx"
+
 using namespace psp;
 
 using ::rtl::OUString;
@@ -1164,10 +1166,10 @@ ImplDevFontAttributes GenPspGraphics::Info2DevFontAttributes( const psp::FastPri
 #if OSL_DEBUG_LEVEL > 2
     if( bHasMapNames )
     {
-        ByteString aOrigName( aDFA.maName, osl_getThreadTextEncoding() );
-        ByteString aAliasNames( aDFA.maMapNames, osl_getThreadTextEncoding() );
+        rtl::OString aOrigName(rtl::OUStringToOString(aDFA.maName, osl_getThreadTextEncoding()));
+        rtl::OString aAliasNames(rtl::OUStringToOString(aDFA.maMapNames, osl_getThreadTextEncoding()));
         fprintf( stderr, "using alias names \"%s\" for font family \"%s\"\n",
-            aAliasNames.GetBuffer(), aOrigName.GetBuffer() );
+            aAliasNames.getStr(), aOrigName.getStr() );
     }
 #endif
 
@@ -1184,9 +1186,9 @@ void GenPspGraphics::AnnounceFonts( ImplDevFontList* pFontList, const psp::FastP
     {
         // asian type 1 fonts are not known
         psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
-        ByteString aFileName( rMgr.getFontFileSysPath( aInfo.m_nID ) );
-        int nPos = aFileName.SearchBackward( '_' );
-        if( nPos == STRING_NOTFOUND || aFileName.GetChar( nPos+1 ) == '.' )
+        OString aFileName( rMgr.getFontFileSysPath( aInfo.m_nID ) );
+        int nPos = aFileName.lastIndexOf( '_' );
+        if( nPos == -1 || aFileName[nPos+1] == '.' )
             nQuality += 5;
         else
         {
@@ -1219,7 +1221,7 @@ void GenPspGraphics::AnnounceFonts( ImplDevFontList* pFontList, const psp::FastP
             }
 
             if( pLangBoost )
-                if( aFileName.Copy( nPos+1, 3 ).EqualsIgnoreCaseAscii( pLangBoost ) )
+                if( aFileName.copy( nPos+1, 3 ).equalsIgnoreAsciiCase( pLangBoost ) )
                     nQuality += 10;
         }
     }


More information about the Libreoffice-commits mailing list