diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2013-07-01 10:33:48 -0500 |
---|---|---|
committer | Fridrich Strba <fridrich@documentfoundation.org> | 2013-07-02 07:31:30 +0000 |
commit | 6a08067902ddc0ec61a7c7b4b0035b303f643a50 (patch) | |
tree | cd49d1824cd169d9d224925b836eaa70de27414e /unotools/source/ucbhelper | |
parent | 82a1d75ee59c46e6bb361b98c520cc4eff2e770c (diff) |
OUString convertion for unotools
Change-Id: Ifae7f344e3827875e32afa3cda23c771f5735707
Reviewed-on: https://gerrit.libreoffice.org/4659
Tested-by: LibreOffice gerrit bot <gerrit@libreoffice.org>
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'unotools/source/ucbhelper')
-rw-r--r-- | unotools/source/ucbhelper/tempfile.cxx | 112 | ||||
-rw-r--r-- | unotools/source/ucbhelper/ucblockbytes.cxx | 54 | ||||
-rw-r--r-- | unotools/source/ucbhelper/ucbstreamhelper.cxx | 24 |
3 files changed, 95 insertions, 95 deletions
diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx index 798f61be5816..bbfe67f9254d 100644 --- a/unotools/source/ucbhelper/tempfile.cxx +++ b/unotools/source/ucbhelper/tempfile.cxx @@ -49,10 +49,10 @@ namespace utl struct TempFile_Impl { - String aName; - String aURL; + OUString aName; + OUString aURL; SvStream* pStream; - sal_Bool bIsDirectory; + bool bIsDirectory; TempFile_Impl() : pStream(0) @@ -62,7 +62,7 @@ struct TempFile_Impl OUString getParentName( const OUString& aFileName ) { sal_Int32 lastIndex = aFileName.lastIndexOf( sal_Unicode('/') ); - OUString aParent = aFileName.copy( 0,lastIndex ); + OUString aParent = aFileName.copy( 0, lastIndex ); if( aParent[ aParent.getLength()-1] == sal_Unicode(':') && aParent.getLength() == 6 ) aParent += OUString("/"); @@ -73,11 +73,11 @@ OUString getParentName( const OUString& aFileName ) return aParent; } -sal_Bool ensuredir( const OUString& rUnqPath ) +bool ensuredir( const OUString& rUnqPath ) { OUString aPath; if ( rUnqPath.isEmpty() ) - return sal_False; + return false; // remove trailing slash if ( rUnqPath[ rUnqPath.getLength() - 1 ] == sal_Unicode( '/' ) ) @@ -98,11 +98,11 @@ umask(old_mode); #endif aDirectory.close(); if( nError == osl::File::E_None ) - return sal_True; + return true; // try to create the directory nError = osl::Directory::create( aPath ); - sal_Bool bSuccess = ( nError == osl::File::E_None || nError == osl::FileBase::E_EXIST ); + bool bSuccess = ( nError == osl::File::E_None || nError == osl::FileBase::E_EXIST ); if( !bSuccess ) { // perhaps parent(s) don't exist @@ -124,10 +124,10 @@ umask(old_mode); return bSuccess; } -String ConstructTempDir_Impl( const String* pParent ) +OUString ConstructTempDir_Impl( const OUString* pParent ) { - String aName; - if ( pParent && pParent->Len() ) + OUString aName; + if ( pParent && !pParent->isEmpty() ) { com::sun::star::uno::Reference< com::sun::star::ucb::XUniversalContentBroker > pBroker( @@ -154,7 +154,7 @@ String ConstructTempDir_Impl( const String* pParent ) } } - if ( !aName.Len() ) + if ( aName.isEmpty() ) { OUString &rTempNameBase_Impl = TempNameBase_Impl::get(); if (rTempNameBase_Impl.isEmpty()) @@ -172,30 +172,29 @@ String ConstructTempDir_Impl( const String* pParent ) } // Make sure that directory ends with a separator - xub_StrLen i = aName.Len(); - if( i>0 && aName.GetChar(i-1) != '/' ) - aName += '/'; + sal_Int32 i = aName.getLength(); + if( i>0 && aName[i-1] != '/' ) + aName += "/"; return aName; } -void CreateTempName_Impl( String& rName, sal_Bool bKeep, sal_Bool bDir = sal_True ) +void CreateTempName_Impl( OUString& rName, bool bKeep, bool bDir = true ) { // add a suitable tempname // 36 ** 6 == 2176782336 unsigned const nRadix = 36; unsigned long const nMax = (nRadix*nRadix*nRadix*nRadix*nRadix*nRadix); - String aName( rName ); - aName += OUString( "lu" ); + OUString aName = rName + "lu"; - rName.Erase(); + rName = ""; static unsigned long u = Time::GetSystemTicks() % nMax; for ( unsigned long nSeed = u; ++u != nSeed; ) { u %= nMax; - String aTmp( aName ); + OUString aTmp( aName ); aTmp += OUString::valueOf(static_cast<sal_Int64>(u), nRadix); - aTmp += OUString( ".tmp" ); + aTmp += ".tmp" ; if ( bDir ) { @@ -252,26 +251,27 @@ void CreateTempName_Impl( String& rName, sal_Bool bKeep, sal_Bool bDir = sal_Tru } } -void lcl_createName(TempFile_Impl& _rImpl,const String& rLeadingChars,sal_Bool _bStartWithZero, const String* pExtension, const String* pParent, sal_Bool bDirectory) +void lcl_createName(TempFile_Impl& _rImpl,const OUString& rLeadingChars, bool _bStartWithZero, + const OUString* pExtension, const OUString* pParent, bool bDirectory) { _rImpl.bIsDirectory = bDirectory; // get correct directory - String aName = ConstructTempDir_Impl( pParent ); + OUString aName = ConstructTempDir_Impl( pParent ); - sal_Bool bUseNumber = _bStartWithZero; + bool bUseNumber = _bStartWithZero; // now use special naming scheme ( name takes leading chars and an index counting up from zero aName += rLeadingChars; for ( sal_Int32 i=0;; i++ ) { - String aTmp( aName ); + OUString aTmp( aName ); if ( bUseNumber ) aTmp += OUString::number( i ); - bUseNumber = sal_True; + bUseNumber = true; if ( pExtension ) aTmp += *pExtension; else - aTmp += OUString( ".tmp" ); + aTmp += ".tmp" ; if ( bDirectory ) { FileBase::RC err = Directory::create( aTmp ); @@ -320,24 +320,24 @@ umask(old_mode); } -String TempFile::CreateTempName( const String* pParent ) +OUString TempFile::CreateTempName( const OUString* pParent ) { // get correct directory - String aName = ConstructTempDir_Impl( pParent ); + OUString aName = ConstructTempDir_Impl( pParent ); // get TempFile name with default naming scheme - CreateTempName_Impl( aName, sal_False ); + CreateTempName_Impl( aName, false ); // convert to file URL OUString aTmp; - if ( aName.Len() ) + if ( !aName.isEmpty() ) FileBase::getSystemPathFromFileURL( aName, aTmp ); return aTmp; } -TempFile::TempFile( const String* pParent, sal_Bool bDirectory ) +TempFile::TempFile( const OUString* pParent, bool bDirectory ) : pImp( new TempFile_Impl ) - , bKillingFileEnabled( sal_False ) + , bKillingFileEnabled( false ) { pImp->bIsDirectory = bDirectory; @@ -345,20 +345,20 @@ TempFile::TempFile( const String* pParent, sal_Bool bDirectory ) pImp->aName = ConstructTempDir_Impl( pParent ); // get TempFile with default naming scheme - CreateTempName_Impl( pImp->aName, sal_True, bDirectory ); + CreateTempName_Impl( pImp->aName, true, bDirectory ); } -TempFile::TempFile( const String& rLeadingChars, const String* pExtension, const String* pParent, sal_Bool bDirectory) +TempFile::TempFile( const OUString& rLeadingChars, const OUString* pExtension, const OUString* pParent, bool bDirectory) : pImp( new TempFile_Impl ) - , bKillingFileEnabled( sal_False ) + , bKillingFileEnabled( false ) { - lcl_createName(*pImp,rLeadingChars,sal_True, pExtension, pParent, bDirectory); + lcl_createName(*pImp, rLeadingChars, true, pExtension, pParent, bDirectory); } -TempFile::TempFile( const String& rLeadingChars,sal_Bool _bStartWithZero, const String* pExtension, const String* pParent, sal_Bool bDirectory) +TempFile::TempFile( const OUString& rLeadingChars, bool _bStartWithZero, const OUString* pExtension, const OUString* pParent, bool bDirectory) : pImp( new TempFile_Impl ) - , bKillingFileEnabled( sal_False ) + , bKillingFileEnabled( false ) { - lcl_createName(*pImp,rLeadingChars,_bStartWithZero, pExtension, pParent, bDirectory); + lcl_createName(*pImp, rLeadingChars, _bStartWithZero, pExtension, pParent, bDirectory); } TempFile::~TempFile() @@ -380,21 +380,21 @@ TempFile::~TempFile() delete pImp; } -sal_Bool TempFile::IsValid() const +bool TempFile::IsValid() const { - return pImp->aName.Len() != 0; + return !(pImp->aName.isEmpty()); } -String TempFile::GetFileName() const +OUString TempFile::GetFileName() const { OUString aTmp; FileBase::getSystemPathFromFileURL( pImp->aName, aTmp ); return aTmp; } -String TempFile::GetURL() const +OUString TempFile::GetURL() const { - if ( !pImp->aURL.Len() ) + if ( pImp->aURL.isEmpty() ) { OUString aTmp; LocalFileHelper::ConvertPhysicalNameToURL( GetFileName(), aTmp ); @@ -408,8 +408,8 @@ SvStream* TempFile::GetStream( StreamMode eMode ) { if ( !pImp->pStream ) { - if ( GetURL().Len() ) - pImp->pStream = UcbStreamHelper::CreateStream( pImp->aURL, eMode, sal_True /* bFileExists */ ); + if ( !GetURL().isEmpty() ) + pImp->pStream = UcbStreamHelper::CreateStream( pImp->aURL, eMode, true /* bFileExists */ ); else pImp->pStream = new SvMemoryStream( eMode ); } @@ -426,37 +426,37 @@ void TempFile::CloseStream() } } -String TempFile::SetTempNameBaseDirectory( const String &rBaseName ) +OUString TempFile::SetTempNameBaseDirectory( const OUString &rBaseName ) { - if( !rBaseName.Len() ) - return String(); + if( rBaseName.isEmpty() ) + return OUString(); OUString aUnqPath( rBaseName ); // remove trailing slash - if ( rBaseName.GetChar( rBaseName.Len() - 1 ) == sal_Unicode( '/' ) ) - aUnqPath = rBaseName.Copy( 0, rBaseName.Len() - 1 ); + if ( rBaseName[ rBaseName.getLength() - 1 ] == sal_Unicode( '/' ) ) + aUnqPath = rBaseName.copy( 0, rBaseName.getLength() - 1 ); // try to create the directory - sal_Bool bRet = sal_False; + bool bRet = false; osl::FileBase::RC err = osl::Directory::create( aUnqPath ); if ( err != FileBase::E_None && err != FileBase::E_EXIST ) // perhaps parent(s) don't exist bRet = ensuredir( aUnqPath ); else - bRet = sal_True; + bRet = true; // failure to create base directory means returning an empty string OUString aTmp; if ( bRet ) { // append own internal directory - bRet = sal_True; + bRet = true; OUString &rTempNameBase_Impl = TempNameBase_Impl::get(); rTempNameBase_Impl = rBaseName; rTempNameBase_Impl += OUString('/'); - TempFile aBase( NULL, sal_True ); + TempFile aBase( NULL, true ); if ( aBase.IsValid() ) // use it in case of success rTempNameBase_Impl = aBase.pImp->aName; diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx index 73a10f77b9b1..ca4e57839389 100644 --- a/unotools/source/ucbhelper/ucblockbytes.cxx +++ b/unotools/source/ucbhelper/ucblockbytes.cxx @@ -194,10 +194,10 @@ void SAL_CALL UcbPropertiesChangeListener_Impl::propertiesChange ( const Sequenc sal_Int32 k, m = aHead.getLength(); for (k = 0; k < m; k++) { - String aName( aHead[k].Name ); - String aValue( aHead[k].Value ); + OUString aName( aHead[k].Name ); + OUString aValue( aHead[k].Value ); - if (aName.CompareIgnoreCaseToAscii("Expires") == COMPARE_EQUAL) + if (aName.compareToIgnoreAsciiCaseAscii("Expires") == 0) { DateTime aExpires (0, 0); if (INetRFC822Message::ParseDateField (aValue, aExpires)) @@ -878,7 +878,7 @@ void SAL_CALL Moderator::onTerminated() Function for opening UCB contents synchronously, but with handled timeout; */ -static sal_Bool _UCBOpenContentSync( +static bool _UCBOpenContentSync( UcbLockBytesRef xLockBytes, Reference < XContent > xContent, const Command& rArg, @@ -888,7 +888,7 @@ static sal_Bool _UCBOpenContentSync( UcbLockBytesHandlerRef xHandler ); -static sal_Bool UCBOpenContentSync( +static bool UCBOpenContentSync( UcbLockBytesRef xLockBytes, Reference < XContent > xContent, const Command& rArg, @@ -917,8 +917,8 @@ static sal_Bool UCBOpenContentSync( return _UCBOpenContentSync( xLockBytes,xContent,rArg,xSink,xInteract,xProgress,xHandler); - if ( (aScheme.compareToAscii( "http" ) != COMPARE_EQUAL) || - (aScheme.compareToAscii( "https" ) != COMPARE_EQUAL) ) + if ( (aScheme.compareToAscii( "http" ) != 0) || + (aScheme.compareToAscii( "https" ) != 0) ) xLockBytes->SetStreamValid_Impl(); Reference< XPropertiesChangeListener > xListener; @@ -1137,7 +1137,7 @@ static sal_Bool UCBOpenContentSync( /** Function for opening UCB contents synchronously */ -static sal_Bool _UCBOpenContentSync( +static bool _UCBOpenContentSync( UcbLockBytesRef xLockBytes, Reference < XContent > xContent, const Command& rArg, @@ -1154,7 +1154,7 @@ static sal_Bool _UCBOpenContentSync( // http protocol must be handled in a special way: during the opening process the input stream may change // only the last inputstream after notifying the document headers is valid - if ( aScheme.compareToAscii("http") != COMPARE_EQUAL ) + if ( aScheme.compareToAscii("http") != 0 ) xLockBytes->SetStreamValid_Impl(); Reference< XPropertiesChangeListener > xListener = new UcbPropertiesChangeListener_Impl( xLockBytes ); @@ -1235,11 +1235,11 @@ UcbLockBytes::UcbLockBytes( UcbLockBytesHandler* pHandler ) , m_pCommandThread( NULL ) , m_xHandler( pHandler ) , m_nError( ERRCODE_NONE ) - , m_bTerminated (sal_False) - , m_bDontClose( sal_False ) - , m_bStreamValid (sal_False) + , m_bTerminated (false) + , m_bDontClose( false ) + , m_bStreamValid (false) { - SetSynchronMode( sal_True ); + SetSynchronMode( true ); } //---------------------------------------------------------------------------- @@ -1280,19 +1280,19 @@ UcbLockBytes::~UcbLockBytes() Reference < XInputStream > UcbLockBytes::getInputStream() { osl::MutexGuard aGuard( m_aMutex ); - m_bDontClose = sal_True; + m_bDontClose = true; return m_xInputStream; } //---------------------------------------------------------------------------- -sal_Bool UcbLockBytes::setStream_Impl( const Reference<XStream>& aStream ) +bool UcbLockBytes::setStream_Impl( const Reference<XStream>& aStream ) { osl::MutexGuard aGuard( m_aMutex ); if ( aStream.is() ) { m_xOutputStream = aStream->getOutputStream(); - setInputStream_Impl( aStream->getInputStream(), sal_False ); + setInputStream_Impl( aStream->getInputStream(), false ); m_xSeekable = Reference < XSeekable > ( aStream, UNO_QUERY ); } else @@ -1304,9 +1304,9 @@ sal_Bool UcbLockBytes::setStream_Impl( const Reference<XStream>& aStream ) return m_xInputStream.is(); } -sal_Bool UcbLockBytes::setInputStream_Impl( const Reference<XInputStream> &rxInputStream, sal_Bool bSetXSeekable ) +bool UcbLockBytes::setInputStream_Impl( const Reference<XInputStream> &rxInputStream, bool bSetXSeekable ) { - sal_Bool bRet = sal_False; + bool bRet = false; try { @@ -1345,7 +1345,7 @@ sal_Bool UcbLockBytes::setInputStream_Impl( const Reference<XInputStream> &rxInp void UcbLockBytes::SetStreamValid_Impl() { - m_bStreamValid = sal_True; + m_bStreamValid = true; if ( m_xInputStream.is() ) m_aInitialized.set(); } @@ -1353,7 +1353,7 @@ void UcbLockBytes::SetStreamValid_Impl() //---------------------------------------------------------------------------- void UcbLockBytes::terminate_Impl() { - m_bTerminated = sal_True; + m_bTerminated = true; m_aInitialized.set(); m_aTerminated.set(); @@ -1637,13 +1637,13 @@ UcbLockBytesRef UcbLockBytes::CreateLockBytes( const Reference < XContent >& xCo Reference< XProgressHandler > xProgressHdl = new ProgressHandler_Impl( LINK( &xLockBytes, UcbLockBytes, DataAvailHdl ) ); - sal_Bool bError = UCBOpenContentSync( xLockBytes, - xContent, - aCommand, - xSink, - xInteractionHandler, - xProgressHdl, - pHandler ); + bool bError = UCBOpenContentSync( xLockBytes, + xContent, + aCommand, + xSink, + xInteractionHandler, + xProgressHdl, + pHandler ); if ( xLockBytes->GetError() == ERRCODE_NONE && ( bError || !xLockBytes->getInputStream().is() ) ) { diff --git a/unotools/source/ucbhelper/ucbstreamhelper.cxx b/unotools/source/ucbhelper/ucbstreamhelper.cxx index e4c763cd2434..4c1d57619e8f 100644 --- a/unotools/source/ucbhelper/ucbstreamhelper.cxx +++ b/unotools/source/ucbhelper/ucbstreamhelper.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <tools/string.hxx> +#include <rtl/ustring.hxx> #include <unotools/ucblockbytes.hxx> #include <unotools/ucbstreamhelper.hxx> #include <comphelper/processfactory.hxx> @@ -40,9 +40,9 @@ using namespace ::com::sun::star::beans; namespace utl { -static SvStream* lcl_CreateStream( const String& rFileName, StreamMode eOpenMode, - Reference < XInteractionHandler > xInteractionHandler, - UcbLockBytesHandler* pHandler, sal_Bool bEnsureFileExists ) +static SvStream* lcl_CreateStream( const OUString& rFileName, StreamMode eOpenMode, + Reference < XInteractionHandler > xInteractionHandler, + UcbLockBytesHandler* pHandler, bool bEnsureFileExists ) { SvStream* pStream = NULL; Reference< XUniversalContentBroker > ucb( @@ -140,22 +140,22 @@ static SvStream* lcl_CreateStream( const String& rFileName, StreamMode eOpenMode //============================================================================ -SvStream* UcbStreamHelper::CreateStream( const String& rFileName, StreamMode eOpenMode, - UcbLockBytesHandler* pHandler ) +SvStream* UcbStreamHelper::CreateStream( const OUString& rFileName, StreamMode eOpenMode, + UcbLockBytesHandler* pHandler ) { return lcl_CreateStream( rFileName, eOpenMode, Reference < XInteractionHandler >(), pHandler, sal_True /* bEnsureFileExists */ ); } -SvStream* UcbStreamHelper::CreateStream( const String& rFileName, StreamMode eOpenMode, - Reference < XInteractionHandler > xInteractionHandler, - UcbLockBytesHandler* pHandler ) +SvStream* UcbStreamHelper::CreateStream( const OUString& rFileName, StreamMode eOpenMode, + Reference < XInteractionHandler > xInteractionHandler, + UcbLockBytesHandler* pHandler ) { return lcl_CreateStream( rFileName, eOpenMode, xInteractionHandler, pHandler, sal_True /* bEnsureFileExists */ ); } -SvStream* UcbStreamHelper::CreateStream( const String& rFileName, StreamMode eOpenMode, - sal_Bool bFileExists, - UcbLockBytesHandler* pHandler ) +SvStream* UcbStreamHelper::CreateStream( const OUString& rFileName, StreamMode eOpenMode, + bool bFileExists, + UcbLockBytesHandler* pHandler ) { return lcl_CreateStream( rFileName, eOpenMode, Reference < XInteractionHandler >(), pHandler, !bFileExists ); } |