From ae25807a8462e71433798283f29b2ff82ba3a9df Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 30 Jun 2011 22:54:36 +0100 Subject: ByteString::CreateFromInt32 -> OString::valueOf --- sot/source/base/factory.cxx | 7 ++-- tools/bootstrp/mkunroll/mkunroll.cxx | 2 +- tools/source/generic/config.cxx | 33 +++++++++------- tools/source/inet/inetmsg.cxx | 47 +++++++++++++---------- tools/source/rc/resmgr.cxx | 74 ++++++++++++++++++++---------------- tools/source/ref/errinf.cxx | 36 ++++++++++-------- tools/source/ref/pstm.cxx | 20 +++++----- 7 files changed, 124 insertions(+), 95 deletions(-) diff --git a/sot/source/base/factory.cxx b/sot/source/base/factory.cxx index 01d098e62a75..79393375138d 100644 --- a/sot/source/base/factory.cxx +++ b/sot/source/base/factory.cxx @@ -39,6 +39,7 @@ #include #include #include +#include /************** class SotData_Impl *********************************************/ /************************************************************************* @@ -78,9 +79,9 @@ void SotFactory::DeInit() if( pSotData->nSvObjCount ) { #ifdef DBG_UTIL - ByteString aStr( "Objects alive: " ); - aStr.Append( ByteString::CreateFromInt32( pSotData->nSvObjCount ) ); - DBG_WARNING( aStr.GetBuffer() ); + rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Objects alive: ")); + aStr.append(static_cast(pSotData->nSvObjCount)); + DBG_WARNING(aStr.getStr()); #endif return; } diff --git a/tools/bootstrp/mkunroll/mkunroll.cxx b/tools/bootstrp/mkunroll/mkunroll.cxx index ff958ba8e717..c1b0252a65ca 100644 --- a/tools/bootstrp/mkunroll/mkunroll.cxx +++ b/tools/bootstrp/mkunroll/mkunroll.cxx @@ -212,7 +212,7 @@ void MkFilter::Filter() { MkLine *pMkLine = (*pLine->pPrivateTnrLst)[ i ]; ByteString aLine = pMkLine->aLine; - while( aLine.SearchAndReplace( aTnr, ByteString::CreateFromInt32( n )) != (sal_uInt16)-1 ) ; + while( aLine.SearchAndReplace( aTnr, rtl::OString::valueOf(static_cast(n)) ) != (sal_uInt16)-1 ) ; fputs( aLine.GetBuffer(), pOut ); fprintf( stderr, "o" ); } diff --git a/tools/source/generic/config.cxx b/tools/source/generic/config.cxx index 6c533459f2a7..2075bf49e300 100644 --- a/tools/source/generic/config.cxx +++ b/tools/source/generic/config.cxx @@ -45,6 +45,7 @@ #include #include #include +#include #define MAXBUFLEN 1024 // Fuer Buffer bei VOS-Funktionen @@ -1188,13 +1189,15 @@ sal_uInt16 Config::GetKeyCount() const ByteString Config::GetKeyName( sal_uInt16 nKey ) const { #ifdef DBG_UTIL - ByteString aTraceStr( "Config::GetKeyName( " ); - aTraceStr += ByteString::CreateFromInt32(nKey); - aTraceStr += " ) from "; - aTraceStr += GetGroup(); - aTraceStr += " in "; - aTraceStr += ByteString( maFileName, RTL_TEXTENCODING_UTF8 ); - OSL_TRACE( "%s", aTraceStr.GetBuffer() ); + rtl::OStringBuffer aTraceStr( + RTL_CONSTASCII_STRINGPARAM("Config::GetKeyName( ")); + aTraceStr.append(static_cast(nKey)); + aTraceStr.append(RTL_CONSTASCII_STRINGPARAM(" ) from ")); + aTraceStr.append(GetGroup()); + aTraceStr.append(RTL_CONSTASCII_STRINGPARAM(" in ")); + aTraceStr.append(rtl::OUStringToOString( + maFileName, RTL_TEXTENCODING_UTF8)); + OSL_TRACE("%s", aTraceStr.getStr()); #endif // Key suchen und Name zurueckgeben @@ -1223,13 +1226,15 @@ ByteString Config::GetKeyName( sal_uInt16 nKey ) const ByteString Config::ReadKey( sal_uInt16 nKey ) const { #ifdef DBG_UTIL - ByteString aTraceStr( "Config::ReadKey( " ); - aTraceStr += ByteString::CreateFromInt32( nKey ); - aTraceStr += " ) from "; - aTraceStr += GetGroup(); - aTraceStr += " in "; - aTraceStr += ByteString( maFileName, RTL_TEXTENCODING_UTF8 ); - OSL_TRACE( "%s", aTraceStr.GetBuffer() ); + rtl::OStringBuffer aTraceStr( + RTL_CONSTASCII_STRINGPARAM("Config::ReadKey( ")); + aTraceStr.append(static_cast(nKey)); + aTraceStr.append(RTL_CONSTASCII_STRINGPARAM(" ) from ")); + aTraceStr.append(GetGroup()); + aTraceStr.append(RTL_CONSTASCII_STRINGPARAM(" in ")); + aTraceStr.append(rtl::OUStringToOString(maFileName, + RTL_TEXTENCODING_UTF8)); + OSL_TRACE("%s", aTraceStr.getStr()); #endif // Key suchen und Value zurueckgeben diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx index 2fc9f5fcb8e3..0bec115de6d6 100644 --- a/tools/source/inet/inetmsg.cxx +++ b/tools/source/inet/inetmsg.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -367,41 +368,47 @@ sal_Bool INetRFC822Message::GenerateDateField ( (rDateTime.GetHour() > 23) ) return sal_False; // Prepare output string. - ByteString rDateField; + rtl::OStringBuffer aDateField; // Insert Date. - rDateField += wkdays[(sal_uInt16)(rDateTime.GetDayOfWeek())]; - rDateField += ", "; + aDateField.append(wkdays[(sal_uInt16)(rDateTime.GetDayOfWeek())]); + aDateField.append(RTL_CONSTASCII_STRINGPARAM(", ")); sal_uInt16 nNum = rDateTime.GetDay(); - if (nNum < 10) rDateField += '0'; - rDateField += ByteString::CreateFromInt32(nNum); - rDateField += ' '; + if (nNum < 10) + aDateField.append('0'); + aDateField.append(static_cast(nNum)); + aDateField.append(' '); - rDateField += months[(sal_uInt16)(rDateTime.GetMonth() - 1)]; - rDateField += ' '; + aDateField.append(months[(sal_uInt16)(rDateTime.GetMonth() - 1)]); + aDateField.append(' '); - rDateField += ByteString::CreateFromInt32(rDateTime.GetYear()); - rDateField += ' '; + aDateField.append(static_cast(rDateTime.GetYear())); + aDateField.append(' '); // Insert Time. nNum = rDateTime.GetHour(); - if (nNum < 10) rDateField += '0'; - rDateField += ByteString::CreateFromInt32(nNum); - rDateField += ':'; + if (nNum < 10) + aDateField.append('0'); + aDateField.append(static_cast(nNum)); + aDateField.append(':'); nNum = rDateTime.GetMin(); - if (nNum < 10) rDateField += '0'; - rDateField += ByteString::CreateFromInt32(nNum); - rDateField += ':'; + if (nNum < 10) + aDateField.append('0'); + aDateField.append(static_cast(nNum)); + aDateField.append(':'); nNum = rDateTime.GetSec(); - if (nNum < 10) rDateField += '0'; - rDateField += ByteString::CreateFromInt32(nNum); - rDateField += " GMT"; + if (nNum < 10) + aDateField.append('0'); + aDateField.append(static_cast(nNum)); + aDateField.append(RTL_CONSTASCII_STRINGPARAM(" GMT")); // Done. - rDateFieldW = UniString (rDateField, RTL_TEXTENCODING_ASCII_US); + rDateFieldW = rtl::OStringToOUString(aDateField.makeStringAndClear(), + RTL_TEXTENCODING_ASCII_US); + return sal_True; } diff --git a/tools/source/rc/resmgr.cxx b/tools/source/rc/resmgr.cxx index d4b7225a22d4..8b53ebb81823 100644 --- a/tools/source/rc/resmgr.cxx +++ b/tools/source/rc/resmgr.cxx @@ -590,19 +590,20 @@ InternalResMgr::~InternalResMgr() { SvFileStream aStm( UniString( pLogFile, RTL_TEXTENCODING_ASCII_US ), STREAM_WRITE ); aStm.Seek( STREAM_SEEK_TO_END ); - ByteString aLine( "FileName: " ); - aLine.Append( ByteString( OUStringToOString( aFileName, RTL_TEXTENCODING_UTF8 ) ) ); - aStm.WriteLine( aLine ); + rtl::OStringBuffer aLine(RTL_CONSTASCII_STRINGPARAM("FileName: ")); + aLine.append(rtl::OUStringToOString(aFileName, + RTL_TEXTENCODING_UTF8)); + aStm.WriteLine(aLine.makeStringAndClear()); for( boost::unordered_map::const_iterator it = pResUseDump->begin(); it != pResUseDump->end(); ++it ) { sal_uInt64 nKeyId = it->first; - aLine.Assign( "Type/Id: " ); - aLine.Append( ByteString::CreateFromInt32( sal::static_int_cast< sal_Int32 >((nKeyId >> 32) & 0xFFFFFFFF) ) ); - aLine.Append( '/' ); - aLine.Append( ByteString::CreateFromInt32( sal::static_int_cast< sal_Int32 >(nKeyId & 0xFFFFFFFF) ) ); - aStm.WriteLine( aLine ); + aLine.append(RTL_CONSTASCII_STRINGPARAM("Type/Id: ")); + aLine.append(sal::static_int_cast< sal_Int32 >((nKeyId >> 32) & 0xFFFFFFFF)); + aLine.append('/'); + aLine.append(sal::static_int_cast< sal_Int32 >(nKeyId & 0xFFFFFFFF)); + aStm.WriteLine(aLine.makeStringAndClear()); } } } @@ -817,31 +818,37 @@ void ResMgr::RscError_Impl( const sal_Char* pMessage, ResMgr* pResMgr, ResMgr* pNewResMgr = new ResMgr( pImp ); - ByteString aStr = OUStringToOString( pResMgr->GetFileName(), RTL_TEXTENCODING_UTF8 ); - if ( aStr.Len() ) - aStr += '\n'; + rtl::OStringBuffer aStr(rtl::OUStringToOString(pResMgr->GetFileName(), + RTL_TEXTENCODING_UTF8)); - aStr.Append( "Class: " ); - aStr.Append( ByteString( GetTypeRes_Impl( ResId( nRT, *pNewResMgr ) ), RTL_TEXTENCODING_UTF8 ) ); - aStr.Append( ", Id: " ); - aStr.Append( ByteString::CreateFromInt32( (long)nId ) ); - aStr.Append( ". " ); - aStr.Append( pMessage ); + if (aStr.getLength()) + aStr.append('\n'); - aStr.Append( "\nResource Stack\n" ); + aStr.append(RTL_CONSTASCII_STRINGPARAM("Class: ")); + aStr.append(rtl::OUStringToOString(GetTypeRes_Impl(ResId(nRT, *pNewResMgr)), + RTL_TEXTENCODING_UTF8)); + aStr.append(RTL_CONSTASCII_STRINGPARAM(", Id: ")); + aStr.append(static_cast(nId)); + aStr.append(RTL_CONSTASCII_STRINGPARAM(". ")); + aStr.append(pMessage); + + aStr.append(RTL_CONSTASCII_STRINGPARAM("\nResource Stack\n")); while( nDepth > 0 ) { - aStr.Append( "Class: " ); - aStr.Append( ByteString( GetTypeRes_Impl( ResId( rResStack[nDepth].pResource->GetRT(), *pNewResMgr ) ), RTL_TEXTENCODING_UTF8 ) ); - aStr.Append( ", Id: " ); - aStr.Append( ByteString::CreateFromInt32( (long)rResStack[nDepth].pResource->GetId() ) ); + aStr.append(RTL_CONSTASCII_STRINGPARAM("Class: ")); + aStr.append(rtl::OUStringToOString(GetTypeRes_Impl( + ResId(rResStack[nDepth].pResource->GetRT(), *pNewResMgr)), + RTL_TEXTENCODING_UTF8)); + aStr.append(RTL_CONSTASCII_STRINGPARAM(", Id: ")); + aStr.append(static_cast( + rResStack[nDepth].pResource->GetId())); nDepth--; } // clean up delete pNewResMgr; - OSL_FAIL( aStr.GetBuffer() ); + OSL_FAIL(aStr.getStr()); } #endif @@ -1207,15 +1214,18 @@ sal_Bool ResMgr::GetResource( const ResId& rId, const Resource* pResObj ) if( pFallbackResMgr ) { pTop->Flags |= RC_FALLBACK_DOWN; - #ifdef DBG_UTIL - ByteString aMess( "found resource " ); - aMess.Append( ByteString::CreateFromInt32( nId ) ); - aMess.Append( " in fallback " ); - aMess.Append( ByteString( OUStringToOString( pFallbackResMgr->GetFileName(), osl_getThreadTextEncoding() ) ) ); - aMess.Append( "\n" ); - RscError_Impl( aMess.GetBuffer(), - this, nRT, nId, aStack, nCurStack-1 ); - #endif +#ifdef DBG_UTIL + rtl::OStringBuffer aMess( + RTL_CONSTASCII_STRINGPARAM("found resource ")); + aMess.append(static_cast(nId)); + aMess.append(RTL_CONSTASCII_STRINGPARAM(" in fallback ")); + aMess.append(rtl::OUStringToOString( + pFallbackResMgr->GetFileName(), + osl_getThreadTextEncoding())); + aMess.append('\n'); + RscError_Impl(aMess.getStr(), + this, nRT, nId, aStack, nCurStack-1); +#endif } else { diff --git a/tools/source/ref/errinf.cxx b/tools/source/ref/errinf.cxx index 9ad9b71dcba3..9a3dece87cf9 100644 --- a/tools/source/ref/errinf.cxx +++ b/tools/source/ref/errinf.cxx @@ -34,6 +34,7 @@ #include #include #include +#include class ErrorHandler; @@ -429,30 +430,33 @@ sal_Bool SimpleErrorHandler::CreateString( const ErrorInfo *pInfo, String &rStr, sal_uInt16 &) const { sal_uIntPtr nId = pInfo->GetErrorCode(); - ByteString aStr; - aStr="Id "; - aStr+=ByteString::CreateFromInt32(nId); - aStr+=" only handled by SimpleErrorHandler"; - aStr+="\nErrorCode: "; - aStr+=ByteString::CreateFromInt32(nId & ((1L << ERRCODE_CLASS_SHIFT) - 1 )); - aStr+="\nErrorClass: "; - aStr+=ByteString::CreateFromInt32((nId & ERRCODE_CLASS_MASK) >> ERRCODE_CLASS_SHIFT); - aStr+="\nErrorArea: "; - aStr+=ByteString::CreateFromInt32((nId & ERRCODE_ERROR_MASK & - ~((1 << ERRCODE_AREA_SHIFT ) -1 ) ) >> ERRCODE_AREA_SHIFT); + rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Id ")); + aStr.append(static_cast(nId)); + aStr.append(RTL_CONSTASCII_STRINGPARAM( + " only handled by SimpleErrorHandler")); + aStr.append(RTL_CONSTASCII_STRINGPARAM("\nErrorCode: ")); + aStr.append(static_cast( + nId & ((1L << ERRCODE_CLASS_SHIFT) - 1 ))); + aStr.append(RTL_CONSTASCII_STRINGPARAM("\nErrorClass: ")); + aStr.append(static_cast( + (nId & ERRCODE_CLASS_MASK) >> ERRCODE_CLASS_SHIFT)); + aStr.append(RTL_CONSTASCII_STRINGPARAM("\nErrorArea: ")); + aStr.append(static_cast((nId & ERRCODE_ERROR_MASK & + ~((1 << ERRCODE_AREA_SHIFT ) -1 ) ) >> ERRCODE_AREA_SHIFT)); DynamicErrorInfo *pDyn=PTR_CAST(DynamicErrorInfo,pInfo); if(pDyn) { - aStr+="\nDId "; - aStr+=ByteString::CreateFromInt32((sal_uIntPtr)*pDyn); + aStr.append(RTL_CONSTASCII_STRINGPARAM("\nDId ")); + aStr.append(static_cast(*pDyn)); } StandardErrorInfo *pStd=PTR_CAST(StandardErrorInfo,pInfo); if(pStd) { - aStr+="\nXId "; - aStr+=ByteString::CreateFromInt32(pStd->GetExtendedErrorCode()); + aStr.append(RTL_CONSTASCII_STRINGPARAM("\nXId ")); + aStr.append(static_cast(pStd->GetExtendedErrorCode())); } - rStr = String( aStr, RTL_TEXTENCODING_ASCII_US ); + rStr = rtl::OStringToOUString(aStr.makeStringAndClear(), + RTL_TEXTENCODING_ASCII_US); return sal_True; } diff --git a/tools/source/ref/pstm.cxx b/tools/source/ref/pstm.cxx index 0507048ad12c..51692e966848 100644 --- a/tools/source/ref/pstm.cxx +++ b/tools/source/ref/pstm.cxx @@ -762,10 +762,11 @@ sal_uInt32 SvPersistStream::ReadObj if( !pFunc ) { #ifdef DBG_UTIL - ByteString aStr( "no class with id: " ); - aStr += ByteString::CreateFromInt32( nClassId ); - aStr += " registered"; - DBG_WARNING( aStr.GetBuffer() ); + rtl::OStringBuffer aStr( + RTL_CONSTASCII_STRINGPARAM("no class with id: " )); + aStr.append(static_cast(nClassId)); + aStr.append(RTL_CONSTASCII_STRINGPARAM(" registered")); + DBG_WARNING(aStr.getStr()); #else (void)nObjLen; #endif @@ -790,11 +791,12 @@ sal_uInt32 SvPersistStream::ReadObj #ifdef DBG_UTIL if( nObjLen + nObjPos != Tell() ) { - ByteString aStr( "false object len: read = " ); - aStr += ByteString::CreateFromInt32( (long)(Tell() - nObjPos) ); - aStr += ", should = "; - aStr += ByteString::CreateFromInt32( nObjLen ); - OSL_FAIL( aStr.GetBuffer() ); + rtl::OStringBuffer aStr( + RTL_CONSTASCII_STRINGPARAM("false object len: read = ")); + aStr.append(static_cast((long)(Tell() - nObjPos))); + aStr.append(RTL_CONSTASCII_STRINGPARAM(", should = ")); + aStr.append(static_cast(nObjLen)); + OSL_FAIL(aStr.getStr()); } #endif rpObj->RestoreNoDelete(); -- cgit