summaryrefslogtreecommitdiff
path: root/psprint/source
diff options
context:
space:
mode:
authorPhilipp Lohmann <pl@openoffice.org>2001-05-11 14:05:03 +0000
committerPhilipp Lohmann <pl@openoffice.org>2001-05-11 14:05:03 +0000
commit98f83048884726c97b84ae38881f632b5577ae21 (patch)
tree4f7a2950535601c2df2e2c22f4e98db315551e3f /psprint/source
parentc09fc17b082c007a8f673edf9d4d3be2ee2d2747 (diff)
rtl string api changes
Diffstat (limited to 'psprint/source')
-rw-r--r--psprint/source/fontmanager/fontmanager.cxx52
-rw-r--r--psprint/source/printer/printerinfomanager.cxx23
2 files changed, 43 insertions, 32 deletions
diff --git a/psprint/source/fontmanager/fontmanager.cxx b/psprint/source/fontmanager/fontmanager.cxx
index b9291478610a..9d1883bbade0 100644
--- a/psprint/source/fontmanager/fontmanager.cxx
+++ b/psprint/source/fontmanager/fontmanager.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: fontmanager.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: pl $ $Date: 2001-05-11 14:17:41 $
+ * last change: $Author: pl $ $Date: 2001-05-11 15:05:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -505,10 +505,10 @@ bool PrintFontManager::PrintFont::readAfmMetrics( const OString& rFileName, Mult
// encoding - only set if unknown
// try to parse the font name and decide wether it might be a
// japanese font. Who invented this PITA ?
- int nTokens = aPSName.getTokenCount( '-' );
- if( m_aEncoding == RTL_TEXTENCODING_DONTKNOW && nTokens > 2 &&
- ( ! aPSName.getToken( nTokens-1, '-' ).compareToAscii( "H" ) ||
- ! aPSName.getToken( nTokens-1, '-' ).compareToAscii( "V" ) )
+ OUString aPSNameLastToken( aPSName.copy( aPSName.lastIndexOf( '-' )+1 ) );
+ if( m_aEncoding == RTL_TEXTENCODING_DONTKNOW &&
+ ( ! aPSNameLastToken.compareToAscii( "H" ) ||
+ ! aPSNameLastToken.compareToAscii( "V" ) )
)
{
static const char* pEncs[] =
@@ -525,12 +525,18 @@ bool PrintFontManager::PrintFont::readAfmMetrics( const OString& rFileName, Mult
};
for( int enc = 0; enc < sizeof( aEncs )/sizeof(aEncs[0]) && m_aEncoding == RTL_TEXTENCODING_DONTKNOW; enc++ )
- for( int i = 1; i < nTokens-1 && m_aEncoding == RTL_TEXTENCODING_DONTKNOW; i++ )
+ {
+ sal_Int32 nIndex = 0, nOffset = 1;
+ do
{
- OUString aEncoding( aPSName.getToken( i, '-' ) );
- if( ! aEncoding.compareToAscii( pEncs[enc] ) )
+ OUString aToken( aPSName.getToken( nOffset, '-', nIndex ) );
+ if( nIndex == -1 )
+ break;
+ nOffset = 0;
+ if( ! aToken.compareToAscii( pEncs[enc] ) )
m_aEncoding = aEncs[ enc ];
- }
+ } while( nIndex != -1 );
+ }
// default is jis
if( m_aEncoding == RTL_TEXTENCODING_DONTKNOW )
@@ -854,7 +860,7 @@ bool PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, bo
OString aDir( getDirectory( nDirID ) );
- ByteString aExt( rFontFile.getToken( rFontFile.getTokenCount( '.' )-1, '.' ) );
+ ByteString aExt( rFontFile.copy( rFontFile.lastIndexOf( '.' )+1 ) );
if( aExt.EqualsIgnoreCaseAscii( "pfb" ) || aExt.EqualsIgnoreCaseAscii( "pfa" ) )
{
// check for corresponding afm metric
@@ -1445,11 +1451,11 @@ void PrintFontManager::initialize( void* pInitDisplay )
#endif
// part two - look for metrics for builtin printer fonts
- OUString aPath( getPrinterPath() );
- nPaths = aPath.getTokenCount( ':' );
- for( i = 0; i < nPaths; i++ )
+ OString aPath( OUStringToOString( getPrinterPath(), aEncoding ) );
+ sal_Int32 nIndex = 0;
+ do
{
- OString aDir( OUStringToOString( aPath.getToken( i, ':' ), aEncoding ) );
+ OString aDir( aPath.getToken( 0, ':', nIndex ) );
aDir += "/"PRINTER_METRICDIR;
DIR* pDIR = opendir( aDir.getStr() );
if( pDIR )
@@ -1476,8 +1482,8 @@ void PrintFontManager::initialize( void* pInitDisplay )
)
{
OString aFileName( pDirEntry->d_name, strlen( pDirEntry->d_name ) );
- OString aExt( aFileName.getToken( aFileName.getTokenCount( '.' )-1, '.' ) );
- if( aExt.equalsIgnoreCase( "afm" ) )
+ OString aExt( aFileName.copy( aFileName.lastIndexOf( '.' )+1 ) );
+ if( aExt.equalsIgnoreAsciiCase( "afm" ) )
{
BuiltinFont* pFont = new BuiltinFont;
pFont->m_nDirectory = nDirAtom;
@@ -1553,7 +1559,7 @@ void PrintFontManager::initialize( void* pInitDisplay )
}
closedir( pDIR );
}
- }
+ } while( nIndex != -1 );
#ifdef DEBUG
aStep2 = times( &tms );
@@ -1663,7 +1669,7 @@ void PrintFontManager::getFontList( ::std::list< fontID >& rFontIDs, const PPDPa
if( ! equalEncoding(pFont->m_aEncoding, (*bit)->m_aEncoding) )
continue;
const OUString& rBuiltinFamily( m_pAtoms->getString( ATOM_FAMILYNAME, (*bit)->m_nFamilyName ) );
- if( rFontFamily.equalsIgnoreCase( rBuiltinFamily ) )
+ if( rFontFamily.equalsIgnoreAsciiCase( rBuiltinFamily ) )
{
// remove double
rFontIDs.erase( font_it );
@@ -1823,8 +1829,12 @@ family::type PrintFontManager::matchFamilyName( const ::rtl::OUString& rFamily )
{
sal_uInt32 nCurrent = (nLower + nUpper) / 2;
const family_t* pHaystack = pFamilyMatch + nCurrent;
- sal_Int32 nComparison = rtl_str_compareIgnoreCase_WithLength(
- aFamily.getStr(), pHaystack->mpName, pHaystack->mnLength );
+ sal_Int32 nComparison =
+ rtl_str_compareIgnoreAsciiCase_WithLength
+ (
+ aFamily.getStr(), aFamily.getLength(),
+ pHaystack->mpName, pHaystack->mnLength
+ );
if( nComparison < 0 )
nUpper = nCurrent;
diff --git a/psprint/source/printer/printerinfomanager.cxx b/psprint/source/printer/printerinfomanager.cxx
index f9e467dbd6c5..8a6448b65cef 100644
--- a/psprint/source/printer/printerinfomanager.cxx
+++ b/psprint/source/printer/printerinfomanager.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: printerinfomanager.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: pl $ $Date: 2001-05-08 11:46:03 $
+ * last change: $Author: pl $ $Date: 2001-05-11 15:05:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -144,7 +144,6 @@ void PrinterInfoManager::initialize()
m_aPrinters.clear();
m_aWatchFiles.clear();
OUString aPrinterPath( getPrinterPath() );
- int nPaths = aPrinterPath.getTokenCount( ':' );
OUString aDefaultPrinter;
// first initialize the global defaults
@@ -157,9 +156,10 @@ void PrinterInfoManager::initialize()
m_aGlobalDefaults.m_pParser = PPDParser::getParser( String( RTL_CONSTASCII_USTRINGPARAM( "SGENPRT" ) ) );
m_aGlobalDefaults.m_aContext.setParser( m_aGlobalDefaults.m_pParser );
- for( int nCur = 0; m_aGlobalDefaults.m_pParser && nCur < nPaths; nCur++ )
+ sal_Int32 nIndex = 0;
+ while( nIndex != -1 && m_aGlobalDefaults.m_pParser )
{
- INetURLObject aFile( aPrinterPath.getToken( nCur, ':' ), INET_PROT_FILE, INetURLObject::ENCODE_ALL );
+ INetURLObject aFile( aPrinterPath.getToken( 0, ':', nIndex ), INET_PROT_FILE, INetURLObject::ENCODE_ALL );
aFile.Append( String( RTL_CONSTASCII_USTRINGPARAM( PRINT_FILENAME ) ) );
Config aConfig( aFile.PathToFileName() );
if( aConfig.HasGroup( GLOBAL_DEFAULTS_GROUP ) )
@@ -230,9 +230,10 @@ void PrinterInfoManager::initialize()
}
// now collect all available printers
- for( int i = 0; i < nPaths; i++ )
+ nIndex = 0;
+ while( nIndex != -1 )
{
- INetURLObject aDir( aPrinterPath.getToken( i, ':' ), INET_PROT_FILE, INetURLObject::ENCODE_ALL );
+ INetURLObject aDir( aPrinterPath.getToken( 0, ':', nIndex ), INET_PROT_FILE, INetURLObject::ENCODE_ALL );
INetURLObject aFile( aDir );
aFile.Append( String( RTL_CONSTASCII_USTRINGPARAM( PRINT_FILENAME ) ) );
@@ -742,20 +743,20 @@ void PrinterInfoManager::fillFontSubstitutions( PrinterInfo& rInfo ) const
::std::list< FastPrintFontInfo >::const_iterator it;
for( it = aFonts.begin(); it != aFonts.end(); ++it )
if( it->m_eType == fonttype::Builtin )
- aPrinterFonts[ it->m_aFamilyName.toLowerCase() ].push_back( *it );
+ aPrinterFonts[ it->m_aFamilyName.toAsciiLowerCase() ].push_back( *it );
// map lower case, so build a local copy of the font substitutions
::std::hash_map< OUString, OUString, OUStringHash > aSubstitutions;
::std::hash_map< OUString, OUString, OUStringHash >::const_iterator subst;
for( subst = rInfo.m_aFontSubstitutes.begin(); subst != rInfo.m_aFontSubstitutes.end(); ++subst )
{
- OUString aFamily( subst->first.toLowerCase() );
+ OUString aFamily( subst->first.toAsciiLowerCase() );
// first look if there is a builtin of this family
// in this case override the substitution table
if( aPrinterFonts.find( aFamily ) != aPrinterFonts.end() )
aSubstitutions[ aFamily ] = aFamily;
else
- aSubstitutions[ aFamily ] = subst->second.toLowerCase();
+ aSubstitutions[ aFamily ] = subst->second.toAsciiLowerCase();
}
@@ -764,7 +765,7 @@ void PrinterInfoManager::fillFontSubstitutions( PrinterInfo& rInfo ) const
{
if( it->m_eType != fonttype::Builtin )
{
- OUString aFamily( it->m_aFamilyName.toLowerCase() );
+ OUString aFamily( it->m_aFamilyName.toAsciiLowerCase() );
subst = aSubstitutions.find( aFamily );
if( subst != aSubstitutions.end() )
{