diff options
author | Oliver Bolte <obo@openoffice.org> | 2006-03-22 09:12:06 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2006-03-22 09:12:06 +0000 |
commit | 5fc0596e780cef1d9916718d7d4f10b6d45cb932 (patch) | |
tree | c76537360ca818ab0a3c20c27640bafe9e96aa13 /psprint | |
parent | 05881b8bbc17bf6f0006c347b33e8ede9598fb71 (diff) |
INTEGRATION: CWS vcl55 (1.24.32); FILE MERGED
2006/03/07 17:58:11 pl 1.24.32.1: #i58360# use getPrinterPathList
Diffstat (limited to 'psprint')
-rw-r--r-- | psprint/source/helper/helper.cxx | 108 |
1 files changed, 58 insertions, 50 deletions
diff --git a/psprint/source/helper/helper.cxx b/psprint/source/helper/helper.cxx index 75ca477bc92c..382ea36027ab 100644 --- a/psprint/source/helper/helper.cxx +++ b/psprint/source/helper/helper.cxx @@ -4,9 +4,9 @@ * * $RCSfile: helper.cxx,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: rt $ $Date: 2005-11-11 11:45:18 $ + * last change: $Author: obo $ $Date: 2006-03-22 10:12:06 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -108,63 +108,57 @@ const OUString& getOfficePath( enum whichOfficePath ePath ) return aEmpty; } -static OUString getEnvironmentPath( const char* pKey, sal_Unicode cPrefix ) +static OString getEnvironmentPath( const char* pKey ) { - OUString aPath; + OString aPath; const char* pValue = getenv( pKey ); if( pValue && *pValue ) { - aPath = OUString( String( cPrefix ) ); - aPath += OUString( pValue, strlen( pValue ), gsl_getSystemTextEncoding() ); + aPath = OString( pValue ); } return aPath; } } // namespace psp -const OUString& psp::getPrinterPath() +void psp::getPrinterPathList( std::list< OUString >& rPathList, const char* pSubDir ) { - static OUString aPath; - - if( ! aPath.getLength() ) - { - OUString aNetPath = getOfficePath( psp::NetPath ); - OUString aUserPath = getOfficePath( psp::UserPath ); + rPathList.clear(); + rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); #ifdef MACOSX - // For CUPS printing, add /etc/cups/ppd to pull in autogenerated printer PPDs - aPath += OUString( RTL_CONSTASCII_USTRINGPARAM(MACXP_CUPS_PPD_DIR) ); + // For CUPS printing, add /etc/cups/ppd to pull in autogenerated printer PPDs + rPathList.push_back( OUString( RTL_CONSTASCII_USTRINGPARAM(MACXP_CUPS_PPD_DIR) ) ); #endif - if( aNetPath.getLength() ) + OUStringBuffer aPathBuffer( 256 ); + + // append net path + aPathBuffer.append( getOfficePath( psp::NetPath ) ); + if( aPathBuffer.getLength() ) + { + aPathBuffer.appendAscii( "/share/psprint" ); + if( pSubDir ) { - if( aPath.getLength() ) - aPath += OUString( RTL_CONSTASCII_USTRINGPARAM( ":" ) ); - aPath += aNetPath; - aPath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/share/psprint" ) ); + aPathBuffer.append( sal_Unicode('/') ); + aPathBuffer.appendAscii( pSubDir ); } - if( aUserPath.getLength() ) + rPathList.push_back( aPathBuffer.makeStringAndClear() ); + } + // append user path + aPathBuffer.append( getOfficePath( psp::UserPath ) ); + if( aPathBuffer.getLength() ) + { + aPathBuffer.appendAscii( "/user/psprint" ); + if( pSubDir ) { - if( aPath.getLength() ) - aPath += OUString( RTL_CONSTASCII_USTRINGPARAM( ":" ) ); - aPath += aUserPath; - aPath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/psprint" ) ); + aPathBuffer.append( sal_Unicode('/') ); + aPathBuffer.appendAscii( pSubDir ); } - aPath += ::psp::getEnvironmentPath( "SAL_PSPRINT", (sal_Unicode)':' ); - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "initalizing printer path to \"%s\"\n", OUStringToOString( aPath, RTL_TEXTENCODING_ISO_8859_1 ).getStr() ); -#endif + rPathList.push_back( aPathBuffer.makeStringAndClear() ); } - return aPath; -} - -void psp::getPrinterPathList( std::list< OUString >& rPathList, const char* pSubDir ) -{ - rPathList.clear(); - rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); - OString aPath( OUStringToOString( getPrinterPath(), aEncoding ) ); + OString aPath( getEnvironmentPath("SAL_PSPRINT") ); sal_Int32 nIndex = 0; do { @@ -212,6 +206,8 @@ const OUString& psp::getFontPath() if( ! aPath.getLength() ) { + OUStringBuffer aPathBuffer( 512 ); + OUString aConfigPath = getOfficePath( psp::ConfigPath ); OUString aNetPath = getOfficePath( psp::NetPath ); OUString aUserPath = getOfficePath( psp::UserPath ); @@ -219,30 +215,40 @@ const OUString& psp::getFontPath() { // #i53530# Path from CustomDataUrl will completely // replace net and user paths if the path exists - aPath = aConfigPath; - aPath += OUString( RTL_CONSTASCII_USTRINGPARAM("/share/fonts") ); + aPathBuffer.append(aConfigPath); + aPathBuffer.appendAscii("/share/fonts"); // check existance of config path struct stat aStat; - if( 0 != stat( OUStringToOString( aPath, osl_getThreadTextEncoding() ).getStr(), &aStat ) + if( 0 != stat( OUStringToOString( aPathBuffer.makeStringAndClear(), osl_getThreadTextEncoding() ).getStr(), &aStat ) || ! S_ISDIR( aStat.st_mode ) ) aConfigPath = OUString(); + else + { + aPathBuffer.append(aConfigPath); + aPathBuffer.appendAscii("/share/fonts"); + } } if( aConfigPath.getLength() == 0 ) { if( aNetPath.getLength() ) { - aPath = aNetPath; - aPath += OUString( RTL_CONSTASCII_USTRINGPARAM("/share/fonts/truetype;") ); - aPath += aNetPath; - aPath += OUString( RTL_CONSTASCII_USTRINGPARAM("/share/fonts/type1;") ); + aPathBuffer.append( aNetPath ); + aPathBuffer.appendAscii( "/share/fonts/truetype;"); + aPathBuffer.append( aNetPath ); + aPathBuffer.appendAscii( "/share/fonts/type1;" ); } if( aUserPath.getLength() ) { - aPath += aUserPath; - aPath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/fonts" ) ); + aPathBuffer.append( aUserPath ); + aPathBuffer.appendAscii( "/user/fonts" ); } } - aPath += ::psp::getEnvironmentPath( "SAL_FONTPATH_PRIVATE", (sal_Unicode)';' ); + OString aEnvPath( getEnvironmentPath( "SAL_FONTPATH_PRIVATE" ) ); + if( aEnvPath.getLength() ) + { + aPathBuffer.append( sal_Unicode(';') ); + aPathBuffer.append( OStringToOUString( aEnvPath, osl_getThreadTextEncoding() ) ); + } // append jre/jdk fonts if possible OString aJREpath; @@ -278,9 +284,11 @@ const OUString& psp::getFontPath() if( aJREpath.getLength() ) { - aPath += OUString( RTL_CONSTASCII_USTRINGPARAM( ";" ) ); - aPath += OStringToOUString( aJREpath, osl_getThreadTextEncoding() ); + aPathBuffer.append( sal_Unicode(';') ); + aPathBuffer.append( OStringToOUString( aJREpath, osl_getThreadTextEncoding() ) ); } + + aPath = aPathBuffer.makeStringAndClear(); #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, "initalizing font path to \"%s\"\n", OUStringToOString( aPath, RTL_TEXTENCODING_ISO_8859_1 ).getStr() ); #endif |