From d6bf32bab10e1bb115aea0c6e5d6ac1753760fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 24 Jan 2012 23:10:47 +0000 Subject: [PATCH] make padmin ByteString free --- padmin/source/adddlg.cxx | 73 ++++++++++++++++++------------------- padmin/source/cmddlg.cxx | 4 +- padmin/source/newppdlg.cxx | 6 +-- vcl/workben/outdevgrind.cxx | 3 +- 4 files changed, 42 insertions(+), 44 deletions(-) diff --git a/padmin/source/adddlg.cxx b/padmin/source/adddlg.cxx index 9db6d152e324..382924c37b7f 100644 --- a/padmin/source/adddlg.cxx +++ b/padmin/source/adddlg.cxx @@ -498,15 +498,15 @@ APOldPrinterPage::APOldPrinterPage( AddPrinterDialog* pParent ) // read defaults aConfig.SetGroup( "Xprinter,PostScript" ); - ByteString aDefPageSize( aConfig.ReadKey( "PageSize" ) ); - ByteString aDefOrientation( aConfig.ReadKey( "Orientation" ) ); - ByteString aDefMarginLeft( aConfig.ReadKey( "MarginLeft" ) ); - ByteString aDefMarginRight( aConfig.ReadKey( "MarginRight" ) ); - ByteString aDefMarginTop( aConfig.ReadKey( "MarginTop" ) ); - ByteString aDefMarginBottom( aConfig.ReadKey( "MarginBottom" ) ); - ByteString aDefScale( aConfig.ReadKey( "Scale" ) ); - ByteString aDefCopies( aConfig.ReadKey( "Copies" ) ); - ByteString aDefDPI( aConfig.ReadKey( "DPI" ) ); + rtl::OString aDefPageSize( aConfig.ReadKey( "PageSize" ) ); + rtl::OString aDefOrientation( aConfig.ReadKey( "Orientation" ) ); + rtl::OString aDefMarginLeft( aConfig.ReadKey( "MarginLeft" ) ); + rtl::OString aDefMarginRight( aConfig.ReadKey( "MarginRight" ) ); + rtl::OString aDefMarginTop( aConfig.ReadKey( "MarginTop" ) ); + rtl::OString aDefMarginBottom( aConfig.ReadKey( "MarginBottom" ) ); + rtl::OString aDefScale( aConfig.ReadKey( "Scale" ) ); + rtl::OString aDefCopies( aConfig.ReadKey( "Copies" ) ); + rtl::OString aDefDPI( aConfig.ReadKey( "DPI" ) ); using comphelper::string::getToken; @@ -540,8 +540,8 @@ APOldPrinterPage::APOldPrinterPage( AddPrinterDialog* pParent ) // read the command aConfig.SetGroup( "ports" ); - ByteString aCommand( aConfig.ReadKey( aPort ) ); - if( ! aCommand.Len() ) + rtl::OString aCommand( aConfig.ReadKey( aPort ) ); + if (aCommand.isEmpty()) { String aText( PaResId( RID_TXT_PRINTERWITHOUTCOMMAND ) ); aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), rtl::OStringToOUString(aPrinter, aEncoding) ); @@ -603,23 +603,22 @@ APOldPrinterPage::APOldPrinterPage( AddPrinterDialog* pParent ) aValue = aConfig.ReadKey( "Orientation", aDefOrientation ); if (!aValue.isEmpty()) - aInfo.m_eOrientation = aValue.equalsIgnoreAsciiCase( "landscape" ) == COMPARE_EQUAL ? orientation::Landscape : orientation::Portrait; + aInfo.m_eOrientation = aValue.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("landscape")) ? orientation::Landscape : orientation::Portrait; int nGroupKeys = aConfig.GetKeyCount(); for( int nPPDKey = 0; nPPDKey < nGroupKeys; nPPDKey++ ) { - ByteString aPPDKey( aConfig.GetKeyName( nPPDKey ) ); + rtl::OString aPPDKey( aConfig.GetKeyName( nPPDKey ) ); // ignore page region // there are some ppd keys in old Xpdefaults that // should never have been writte because they are defaults // PageRegion leads to problems in conjunction // with a not matching PageSize - if( aPPDKey.CompareTo( "PPD_", 4 ) == COMPARE_EQUAL && - aPPDKey != "PPD_PageRegion" - ) + if (comphelper::string::matchL(aPPDKey, RTL_CONSTASCII_STRINGPARAM("PPD_")) && + !aPPDKey.equalsL(RTL_CONSTASCII_STRINGPARAM("PPD_PageRegion"))) { aValue = aConfig.ReadKey( nPPDKey ); - aPPDKey.Erase( 0, 4 ); - const PPDKey* pKey = aInfo.m_pParser->getKey( String( aPPDKey, RTL_TEXTENCODING_ISO_8859_1 ) ); + aPPDKey = aPPDKey.copy(4); + const PPDKey* pKey = aInfo.m_pParser->getKey( rtl::OStringToOUString(aPPDKey, RTL_TEXTENCODING_ISO_8859_1) ); const PPDValue* pValue = pKey ? ( aValue.equalsL(RTL_CONSTASCII_STRINGPARAM("*nil")) ? NULL : pKey->getValue(rtl::OStringToOUString(aValue, RTL_TEXTENCODING_ISO_8859_1)) ) : NULL; if( pKey ) aInfo.m_aContext.setValue( pKey, pValue, true ); @@ -1097,40 +1096,40 @@ String AddPrinterDialog::uniquePrinterName( const String& rBase ) String AddPrinterDialog::getOldPrinterLocation() { static const char* pHome = getenv( "HOME" ); - String aRet; - ByteString aFileName; + rtl::OString aFileName; rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); if( pHome ) { - aFileName = pHome; - aFileName.Append( "/.Xpdefaults" ); - if( access( aFileName.GetBuffer(), F_OK ) ) + aFileName = rtl::OStringBuffer().append(pHome). + append(RTL_CONSTASCII_STRINGPARAM("/.Xpdefaults")). + makeStringAndClear(); + if (access(aFileName.getStr(), F_OK)) { - aFileName = pHome; - aFileName.Append( "/.sversionrc" ); - Config aSVer( String( aFileName, aEncoding ) ); + aFileName = rtl::OStringBuffer().append(pHome). + append(RTL_CONSTASCII_STRINGPARAM("/.sversionrc")). + makeStringAndClear(); + Config aSVer(rtl::OStringToOUString(aFileName, aEncoding)); aSVer.SetGroup( "Versions" ); aFileName = aSVer.ReadKey( "StarOffice 5.2" ); - if( aFileName.Len() ) - aFileName.Append( "/share/xp3/Xpdefaults" ); + if (!aFileName.isEmpty()) + aFileName = aFileName + rtl::OString(RTL_CONSTASCII_STRINGPARAM("/share/xp3/Xpdefaults")); else if( - (aFileName = aSVer.ReadKey( "StarOffice 5.1" ) ).Len() + (aFileName = aSVer.ReadKey( "StarOffice 5.1" ) ).getLength() || - (aFileName = aSVer.ReadKey( "StarOffice 5.0" ) ).Len() + (aFileName = aSVer.ReadKey( "StarOffice 5.0" ) ).getLength() || - (aFileName = aSVer.ReadKey( "StarOffice 4.0" ) ).Len() + (aFileName = aSVer.ReadKey( "StarOffice 4.0" ) ).getLength() ) { - aFileName.Append( "/xp3/Xpdefaults" ); + aFileName = aFileName + rtl::OString(RTL_CONSTASCII_STRINGPARAM("/xp3/Xpdefaults")); } - if( aFileName.Len() && access( aFileName.GetBuffer(), F_OK ) ) - aFileName.Erase(); + if (!aFileName.isEmpty() && access(aFileName.getStr(), F_OK)) + aFileName = rtl::OString(); } } - if( aFileName.Len() ) - aRet = String( aFileName, aEncoding ); - return aRet; + + return !aFileName.isEmpty() ? rtl::OStringToOUString(aFileName, aEncoding) : rtl::OUString(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/padmin/source/cmddlg.cxx b/padmin/source/cmddlg.cxx index 4a54aab5b0c5..74ba8008dac3 100644 --- a/padmin/source/cmddlg.cxx +++ b/padmin/source/cmddlg.cxx @@ -82,7 +82,7 @@ void CommandStore::getSystemPdfCommands( ::std::list< String >& rCommands ) int nLen = strlen( pBuffer ); if( pBuffer[nLen-1] == '\n' ) // strip newline pBuffer[--nLen] = 0; - aCommand = String( ByteString( pBuffer ), aEncoding ); + aCommand = rtl::OUString(pBuffer, nLen, aEncoding); if( ( ( aCommand.GetChar( 0 ) == '/' ) || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '/' ) || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '.' && aCommand.GetChar( 2 ) == '/' ) ) @@ -105,7 +105,7 @@ void CommandStore::getSystemPdfCommands( ::std::list< String >& rCommands ) int nLen = strlen( pBuffer ); if( pBuffer[nLen-1] == '\n' ) // strip newline pBuffer[--nLen] = 0; - aCommand = String( ByteString( pBuffer ), aEncoding ); + aCommand = rtl::OUString(pBuffer, nLen, aEncoding); if( ( ( aCommand.GetChar( 0 ) == '/' ) || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '/' ) || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '.' && aCommand.GetChar( 2 ) == '/' ) ) diff --git a/padmin/source/newppdlg.cxx b/padmin/source/newppdlg.cxx index 593c09cb6c35..de04c7331a56 100644 --- a/padmin/source/newppdlg.cxx +++ b/padmin/source/newppdlg.cxx @@ -80,9 +80,9 @@ PPDImportDialog::PPDImportDialog( Window* pParent ) : m_aPathBox.SetText( rtl::OStringToOUString(rConfig.ReadKey("LastDir"), RTL_TEXTENCODING_UTF8) ); for (sal_Int32 i = 0; i < 11; ++i) { - ByteString aEntry(rConfig.ReadKey(rtl::OString::valueOf(i))); - if( aEntry.Len() ) - m_aPathBox.InsertEntry( String( aEntry, RTL_TEXTENCODING_UTF8 ) ); + rtl::OString aEntry(rConfig.ReadKey(rtl::OString::valueOf(i))); + if (!aEntry.isEmpty()) + m_aPathBox.InsertEntry(rtl::OStringToOUString(aEntry, RTL_TEXTENCODING_UTF8)); } m_aOKBtn.SetClickHdl( LINK( this, PPDImportDialog, ClickBtnHdl ) ); diff --git a/vcl/workben/outdevgrind.cxx b/vcl/workben/outdevgrind.cxx index 77b7c5be719a..ab9b6cd51198 100644 --- a/vcl/workben/outdevgrind.cxx +++ b/vcl/workben/outdevgrind.cxx @@ -123,8 +123,7 @@ void setupMethodStubs( functor_vector_type& res ) aPoly3.Rotate( aPoly3.GetBoundRect().Center(), 900 ); - const String aString( ByteString("This is a test"), - RTL_TEXTENCODING_ASCII_US ); + const String aString(RTL_CONSTASCII_USTRINGPARAM("This is a test")); const LineInfo aLineInfo(LINE_SOLID,5); // unfortunately, VDevs have inaccessible copy constructors