diff options
Diffstat (limited to 'vcl/unx/generic/printer')
-rw-r--r-- | vcl/unx/generic/printer/cupsmgr.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/generic/printer/jobdata.cxx | 69 | ||||
-rw-r--r-- | vcl/unx/generic/printer/ppdparser.cxx | 45 | ||||
-rw-r--r-- | vcl/unx/generic/printer/printerinfomanager.cxx | 41 |
4 files changed, 84 insertions, 73 deletions
diff --git a/vcl/unx/generic/printer/cupsmgr.cxx b/vcl/unx/generic/printer/cupsmgr.cxx index a850ec14bb28..1e8c378c8166 100644 --- a/vcl/unx/generic/printer/cupsmgr.cxx +++ b/vcl/unx/generic/printer/cupsmgr.cxx @@ -436,7 +436,7 @@ extern "C" { static void lcl_signal_action(int nSignal) { - fprintf( stderr, "Signal %d during fontconfig initialization called, ignoring fontconfig\n", nSignal ); + fprintf( stderr, "Signal %d during cups initialization called, ignoring cups\n", nSignal ); siglongjmp( aViolationBuffer, 1 ); } } diff --git a/vcl/unx/generic/printer/jobdata.cxx b/vcl/unx/generic/printer/jobdata.cxx index 03d676470ecb..872e880adc61 100644 --- a/vcl/unx/generic/printer/jobdata.cxx +++ b/vcl/unx/generic/printer/jobdata.cxx @@ -34,7 +34,8 @@ #include "tools/stream.hxx" -#include "sal/alloca.h" +#include <sal/alloca.h> +#include <rtl/strbuf.hxx> using namespace psp; @@ -122,48 +123,52 @@ bool JobData::getStreamBuffer( void*& pData, int& bytes ) return false; SvMemoryStream aStream; - ByteString aLine; // write header job data aStream.WriteLine( "JobData 1" ); - aLine = "printer="; - aLine += ByteString( String( m_aPrinterName ), RTL_TEXTENCODING_UTF8 ); - aStream.WriteLine( aLine ); + rtl::OStringBuffer aLine; + + aLine.append(RTL_CONSTASCII_STRINGPARAM("printer=")); + aLine.append(rtl::OUStringToOString(m_aPrinterName, RTL_TEXTENCODING_UTF8)); + aStream.WriteLine(aLine.makeStringAndClear()); - aLine = "orientation="; - aLine += m_eOrientation == orientation::Landscape ? "Landscape" : "Portrait"; - aStream.WriteLine( aLine ); + aLine.append(RTL_CONSTASCII_STRINGPARAM("orientation=")); + if (m_eOrientation == orientation::Landscape) + aLine.append(RTL_CONSTASCII_STRINGPARAM("Landscape")); + else + aLine.append(RTL_CONSTASCII_STRINGPARAM("Portrait")); + aStream.WriteLine(aLine.makeStringAndClear()); - aLine = "copies="; - aLine += ByteString::CreateFromInt32( m_nCopies ); - aStream.WriteLine( aLine ); + aLine.append(RTL_CONSTASCII_STRINGPARAM("copies=")); + aLine.append(static_cast<sal_Int32>(m_nCopies)); + aStream.WriteLine(aLine.makeStringAndClear()); - aLine = "margindajustment="; - aLine += ByteString::CreateFromInt32( m_nLeftMarginAdjust ); - aLine += ','; - aLine += ByteString::CreateFromInt32( m_nRightMarginAdjust ); - aLine += ','; - aLine += ByteString::CreateFromInt32( m_nTopMarginAdjust ); - aLine += ','; - aLine += ByteString::CreateFromInt32( m_nBottomMarginAdjust ); - aStream.WriteLine( aLine ); + aLine.append(RTL_CONSTASCII_STRINGPARAM("margindajustment=")); + aLine.append(static_cast<sal_Int32>(m_nLeftMarginAdjust)); + aLine.append(','); + aLine.append(static_cast<sal_Int32>(m_nRightMarginAdjust)); + aLine.append(','); + aLine.append(static_cast<sal_Int32>(m_nTopMarginAdjust)); + aLine.append(','); + aLine.append(static_cast<sal_Int32>(m_nBottomMarginAdjust)); + aStream.WriteLine(aLine.makeStringAndClear()); - aLine = "colordepth="; - aLine += ByteString::CreateFromInt32( m_nColorDepth ); - aStream.WriteLine( aLine ); + aLine.append(RTL_CONSTASCII_STRINGPARAM("colordepth=")); + aLine.append(static_cast<sal_Int32>(m_nColorDepth)); + aStream.WriteLine(aLine.makeStringAndClear()); - aLine = "pslevel="; - aLine += ByteString::CreateFromInt32( m_nPSLevel ); - aStream.WriteLine( aLine ); + aLine.append(RTL_CONSTASCII_STRINGPARAM("pslevel=")); + aLine.append(static_cast<sal_Int32>(m_nPSLevel)); + aStream.WriteLine(aLine.makeStringAndClear()); - aLine = "pdfdevice="; - aLine += ByteString::CreateFromInt32( m_nPDFDevice ); - aStream.WriteLine( aLine ); + aLine.append(RTL_CONSTASCII_STRINGPARAM("pdfdevice=")); + aLine.append(static_cast<sal_Int32>(m_nPDFDevice)); + aStream.WriteLine(aLine.makeStringAndClear()); - aLine = "colordevice="; - aLine += ByteString::CreateFromInt32( m_nColorDevice ); - aStream.WriteLine( aLine ); + aLine.append(RTL_CONSTASCII_STRINGPARAM("colordevice=")); + aLine.append(static_cast<sal_Int32>(m_nColorDevice)); + aStream.WriteLine(aLine.makeStringAndClear()); // now append the PPDContext stream buffer aStream.WriteLine( "PPDContexData" ); diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index 3246e18fc806..91643d6646b2 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -696,7 +696,7 @@ PPDParser::PPDParser( const String& rFile ) : m_pTranslator( new PPDTranslator() ) { // read in the file - std::list< ByteString > aLines; + std::list< rtl::OString > aLines; PPDDecompressStream aStream( m_aFile ); bool bLanguageEncoding = false; if( aStream.IsOpen() ) @@ -897,11 +897,11 @@ static sal_uInt8 getNibble( sal_Char cChar ) return nRet; } -String PPDParser::handleTranslation( const ByteString& i_rString, bool bIsGlobalized ) +String PPDParser::handleTranslation(const rtl::OString& i_rString, bool bIsGlobalized) { - int nOrigLen = i_rString.Len(); + sal_Int32 nOrigLen = i_rString.getLength(); OStringBuffer aTrans( nOrigLen ); - const sal_Char* pStr = i_rString.GetBuffer(); + const sal_Char* pStr = i_rString.getStr(); const sal_Char* pEnd = pStr + nOrigLen; while( pStr < pEnd ) { @@ -923,9 +923,9 @@ String PPDParser::handleTranslation( const ByteString& i_rString, bool bIsGlobal return OStringToOUString( aTrans.makeStringAndClear(), bIsGlobalized ? RTL_TEXTENCODING_UTF8 : m_aFileEncoding ); } -void PPDParser::parse( ::std::list< ByteString >& rLines ) +void PPDParser::parse( ::std::list< rtl::OString >& rLines ) { - std::list< ByteString >::iterator line = rLines.begin(); + std::list< rtl::OString >::iterator line = rLines.begin(); PPDParser::hash_type::const_iterator keyit; while( line != rLines.end() ) { @@ -1027,7 +1027,7 @@ void PPDParser::parse( ::std::list< ByteString >& rLines ) { // copy the newlines also aLine += '\n'; - aLine += *line; + aLine += ByteString(*line); ++line; } } @@ -1142,7 +1142,9 @@ void PPDParser::parse( ::std::list< ByteString >& rLines ) if( nPos != STRING_NOTFOUND ) { aKey.Erase( nPos ); - String aOption( WhitespaceToSpace( aLine.Copy( nPos+9 ) ), RTL_TEXTENCODING_MS_1252 ); + rtl::OUString aOption(rtl::OStringToOUString( + WhitespaceToSpace(aLine.Copy(nPos+9)), + RTL_TEXTENCODING_MS_1252)); keyit = m_aKeys.find( aKey ); if( keyit != m_aKeys.end() ) { @@ -1171,7 +1173,7 @@ void PPDParser::parse( ::std::list< ByteString >& rLines ) } } -void PPDParser::parseOpenUI( const ByteString& rLine ) +void PPDParser::parseOpenUI(const rtl::OString& rLine) { String aTranslation; ByteString aKey = rLine; @@ -1202,7 +1204,8 @@ void PPDParser::parseOpenUI( const ByteString& rLine ) pKey->m_bUIOption = true; m_pTranslator->insertKey( pKey->getKey(), aTranslation ); - ByteString aValue = WhitespaceToSpace( rLine.GetToken( 1, ':' ) ); + sal_Int32 nIndex = 0; + ByteString aValue = WhitespaceToSpace( rLine.getToken( 1, ':', nIndex ) ); if( aValue.CompareIgnoreCaseToAscii( "boolean" ) == COMPARE_EQUAL ) pKey->m_eUIType = PPDKey::Boolean; else if( aValue.CompareIgnoreCaseToAscii( "pickmany" ) == COMPARE_EQUAL ) @@ -1211,16 +1214,16 @@ void PPDParser::parseOpenUI( const ByteString& rLine ) pKey->m_eUIType = PPDKey::PickOne; } -void PPDParser::parseOrderDependency( const ByteString& rLine ) +void PPDParser::parseOrderDependency(const rtl::OString& rLine) { - ByteString aLine( rLine ); - int nPos = aLine.Search( ':' ); - if( nPos != STRING_NOTFOUND ) - aLine.Erase( 0, nPos+1 ); + rtl::OString aLine(rLine); + sal_Int32 nPos = aLine.indexOf(':'); + if( nPos != -1 ) + aLine = aLine.copy( nPos+1 ); - int nOrder = GetCommandLineToken( 0, aLine ).ToInt32(); + sal_Int32 nOrder = GetCommandLineToken( 0, aLine ).toInt32(); ByteString aSetup = GetCommandLineToken( 1, aLine ); - String aKey( GetCommandLineToken( 2, aLine ), RTL_TEXTENCODING_MS_1252 ); + String aKey(rtl::OStringToOUString(GetCommandLineToken(2, aLine), RTL_TEXTENCODING_MS_1252)); if( aKey.GetChar( 0 ) != '*' ) return; // invalid order depency aKey.Erase( 0, 1 ); @@ -1250,12 +1253,12 @@ void PPDParser::parseOrderDependency( const ByteString& rLine ) pKey->m_eSetupType = PPDKey::AnySetup; } -void PPDParser::parseConstraint( const ByteString& rLine ) +void PPDParser::parseConstraint( const rtl::OString& rLine ) { bool bFailed = false; - String aLine( rLine, RTL_TEXTENCODING_MS_1252 ); - aLine.Erase( 0, rLine.Search( ':' )+1 ); + String aLine(rtl::OStringToOUString(rLine, RTL_TEXTENCODING_MS_1252)); + aLine.Erase(0, rLine.indexOf(':') + 1); PPDConstraint aConstraint; int nTokens = GetCommandLineTokenCount( aLine ); for( int i = 0; i < nTokens; i++ ) @@ -1291,7 +1294,7 @@ void PPDParser::parseConstraint( const ByteString& rLine ) if( ! aConstraint.m_pKey1 || ! aConstraint.m_pKey2 || bFailed ) { #ifdef __DEBUG - fprintf( stderr, "Warning: constraint \"%s\" is invalid\n", rLine.GetStr() ); + fprintf( stderr, "Warning: constraint \"%s\" is invalid\n", rLine.getStr() ); #endif } else diff --git a/vcl/unx/generic/printer/printerinfomanager.cxx b/vcl/unx/generic/printer/printerinfomanager.cxx index e29855c939d1..144821173962 100644 --- a/vcl/unx/generic/printer/printerinfomanager.cxx +++ b/vcl/unx/generic/printer/printerinfomanager.cxx @@ -772,30 +772,30 @@ bool PrinterInfoManager::writePrinterConfig() pConfig->DeleteGroup( it->second.m_aGroup ); // else some old keys may remain pConfig->SetGroup( it->second.m_aGroup ); - ByteString aValue( String( it->second.m_aInfo.m_aDriverName ), RTL_TEXTENCODING_UTF8 ); - aValue += '/'; - aValue += ByteString( String( it->first ), RTL_TEXTENCODING_UTF8 ); - pConfig->WriteKey( "Printer", aValue ); + rtl::OStringBuffer aValue(rtl::OUStringToOString(it->second.m_aInfo.m_aDriverName, RTL_TEXTENCODING_UTF8)); + aValue.append('/'); + aValue.append(rtl::OUStringToOString(it->first, RTL_TEXTENCODING_UTF8)); + pConfig->WriteKey("Printer", aValue.makeStringAndClear()); pConfig->WriteKey( "DefaultPrinter", it->first == m_aDefaultPrinter ? "1" : "0" ); pConfig->WriteKey( "Location", ByteString( String( it->second.m_aInfo.m_aLocation ), RTL_TEXTENCODING_UTF8 ) ); pConfig->WriteKey( "Comment", ByteString( String( it->second.m_aInfo.m_aComment ), RTL_TEXTENCODING_UTF8 ) ); pConfig->WriteKey( "Command", ByteString( String( it->second.m_aInfo.m_aCommand ), RTL_TEXTENCODING_UTF8 ) ); pConfig->WriteKey( "QuickCommand", ByteString( String( it->second.m_aInfo.m_aQuickCommand ), RTL_TEXTENCODING_UTF8 ) ); pConfig->WriteKey( "Features", ByteString( String( it->second.m_aInfo.m_aFeatures ), RTL_TEXTENCODING_UTF8 ) ); - pConfig->WriteKey( "Copies", ByteString::CreateFromInt32( it->second.m_aInfo.m_nCopies ) ); + pConfig->WriteKey("Copies", rtl::OString::valueOf(static_cast<sal_Int32>(it->second.m_aInfo.m_nCopies))); pConfig->WriteKey( "Orientation", it->second.m_aInfo.m_eOrientation == orientation::Landscape ? "Landscape" : "Portrait" ); - pConfig->WriteKey( "PSLevel", ByteString::CreateFromInt32( it->second.m_aInfo.m_nPSLevel ) ); - pConfig->WriteKey( "PDFDevice", ByteString::CreateFromInt32( it->second.m_aInfo.m_nPDFDevice ) ); - pConfig->WriteKey( "ColorDevice", ByteString::CreateFromInt32( it->second.m_aInfo.m_nColorDevice ) ); - pConfig->WriteKey( "ColorDepth", ByteString::CreateFromInt32( it->second.m_aInfo.m_nColorDepth ) ); - aValue = ByteString::CreateFromInt32( it->second.m_aInfo.m_nLeftMarginAdjust ); - aValue += ','; - aValue += ByteString::CreateFromInt32( it->second.m_aInfo.m_nRightMarginAdjust ); - aValue += ','; - aValue += ByteString::CreateFromInt32( it->second.m_aInfo.m_nTopMarginAdjust ); - aValue += ','; - aValue += ByteString::CreateFromInt32( it->second.m_aInfo.m_nBottomMarginAdjust ); - pConfig->WriteKey( "MarginAdjust", aValue ); + pConfig->WriteKey("PSLevel", rtl::OString::valueOf(static_cast<sal_Int32>(it->second.m_aInfo.m_nPSLevel))); + pConfig->WriteKey("PDFDevice", rtl::OString::valueOf(static_cast<sal_Int32>(it->second.m_aInfo.m_nPDFDevice))); + pConfig->WriteKey("ColorDevice", rtl::OString::valueOf(static_cast<sal_Int32>(it->second.m_aInfo.m_nColorDevice))); + pConfig->WriteKey("ColorDepth", rtl::OString::valueOf(static_cast<sal_Int32>(it->second.m_aInfo.m_nColorDepth))); + aValue.append(static_cast<sal_Int32>(it->second.m_aInfo.m_nLeftMarginAdjust)); + aValue.append(','); + aValue.append(static_cast<sal_Int32>(it->second.m_aInfo.m_nRightMarginAdjust)); + aValue.append(','); + aValue.append(static_cast<sal_Int32>(it->second.m_aInfo.m_nTopMarginAdjust)); + aValue.append(','); + aValue.append(static_cast<sal_Int32>(it->second.m_aInfo.m_nBottomMarginAdjust)); + pConfig->WriteKey("MarginAdjust", aValue.makeStringAndClear()); if( it->second.m_aInfo.m_aDriverName.compareToAscii( "CUPS:", 5 ) != 0 ) { @@ -807,8 +807,11 @@ bool PrinterInfoManager::writePrinterConfig() aKey += ByteString( pKey->getKey(), RTL_TEXTENCODING_ISO_8859_1 ); const PPDValue* pValue = it->second.m_aInfo.m_aContext.getValue( pKey ); - aValue = pValue ? ByteString( pValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 ) : ByteString( "*nil" ); - pConfig->WriteKey( aKey, aValue ); + if (pValue) + aValue.append(rtl::OUStringToOString(pValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1)); + else + aValue.append(RTL_CONSTASCII_STRINGPARAM("*nil")); + pConfig->WriteKey(aKey, aValue.makeStringAndClear()); } } |