diff options
Diffstat (limited to 'tools/source/stream')
-rw-r--r-- | tools/source/stream/cachestr.cxx | 32 | ||||
-rwxr-xr-x[-rw-r--r--] | tools/source/stream/stream.cxx | 170 | ||||
-rw-r--r-- | tools/source/stream/strmos2.cxx | 100 | ||||
-rw-r--r-- | tools/source/stream/strmunx.cxx | 6 | ||||
-rw-r--r-- | tools/source/stream/strmwnt.cxx | 78 | ||||
-rw-r--r-- | tools/source/stream/vcompat.cxx | 6 |
6 files changed, 214 insertions, 178 deletions
diff --git a/tools/source/stream/cachestr.cxx b/tools/source/stream/cachestr.cxx index 0233dc25fb52..17270048fcf4 100644 --- a/tools/source/stream/cachestr.cxx +++ b/tools/source/stream/cachestr.cxx @@ -43,13 +43,13 @@ |* *************************************************************************/ -SvCacheStream::SvCacheStream( ULONG nMaxMemSize ) +SvCacheStream::SvCacheStream( sal_uIntPtr nMaxMemSize ) { if( !nMaxMemSize ) nMaxMemSize = 20480; - SvStream::bIsWritable = TRUE; + SvStream::bIsWritable = sal_True; nMaxSize = nMaxMemSize; - bPersistent = FALSE; + bPersistent = sal_False; pSwapStream = 0; pCurrentStream = new SvMemoryStream( nMaxMemSize ); pTempFile = 0; @@ -66,8 +66,8 @@ SvCacheStream::SvCacheStream( ULONG nMaxMemSize ) *************************************************************************/ SvCacheStream::SvCacheStream( const String &rFileName, - ULONG nExpectedSize, - ULONG nMaxMemSize ) + sal_uIntPtr nExpectedSize, + sal_uIntPtr nMaxMemSize ) { if( !nMaxMemSize ) nMaxMemSize = 20480; @@ -77,9 +77,9 @@ SvCacheStream::SvCacheStream( const String &rFileName, else if( !nExpectedSize ) nExpectedSize = 4096; - SvStream::bIsWritable = TRUE; + SvStream::bIsWritable = sal_True; nMaxSize = nMaxMemSize; - bPersistent = TRUE; + bPersistent = sal_True; aFileName = rFileName; pSwapStream = 0; pCurrentStream = new SvMemoryStream( nExpectedSize ); @@ -105,7 +105,7 @@ SvCacheStream::~SvCacheStream() if( pSwapStream && !bPersistent && pTempFile ) { // temporaeres File loeschen - pTempFile->EnableKillingFile( TRUE ); + pTempFile->EnableKillingFile( sal_True ); } delete pTempFile; @@ -145,7 +145,7 @@ void SvCacheStream::SwapOut() } } - ULONG nPos = pCurrentStream->Tell(); + sal_uIntPtr nPos = pCurrentStream->Tell(); pCurrentStream->Seek( 0 ); if( !pSwapStream ) pSwapStream = new SvFileStream( aFileName, STREAM_READWRITE | STREAM_TRUNC ); @@ -167,7 +167,7 @@ void SvCacheStream::SwapOut() |* *************************************************************************/ -ULONG SvCacheStream::GetData( void* pData, ULONG nSize ) +sal_uIntPtr SvCacheStream::GetData( void* pData, sal_uIntPtr nSize ) { return pCurrentStream->Read( pData, nSize ); } @@ -182,7 +182,7 @@ ULONG SvCacheStream::GetData( void* pData, ULONG nSize ) |* *************************************************************************/ -ULONG SvCacheStream::PutData( const void* pData, ULONG nSize ) +sal_uIntPtr SvCacheStream::PutData( const void* pData, sal_uIntPtr nSize ) { // lieber unnoetig auslagern als unnoetig umkopieren if( pCurrentStream != pSwapStream @@ -201,7 +201,7 @@ ULONG SvCacheStream::PutData( const void* pData, ULONG nSize ) |* *************************************************************************/ -ULONG SvCacheStream::SeekPos( ULONG nPos ) +sal_uIntPtr SvCacheStream::SeekPos( sal_uIntPtr nPos ) { return pCurrentStream->Seek( nPos ); } @@ -253,7 +253,7 @@ const void* SvCacheStream::GetBuffer() |* *************************************************************************/ -void SvCacheStream::SetSize( ULONG nSize ) +void SvCacheStream::SetSize( sal_uIntPtr nSize ) { pCurrentStream->SetStreamSize( nSize ); } @@ -268,13 +268,13 @@ void SvCacheStream::SetSize( ULONG nSize ) |* *************************************************************************/ -ULONG SvCacheStream::GetSize() +sal_uIntPtr SvCacheStream::GetSize() { // ACHTUNG: SvMemoryStream::GetSize() gibt Groesse // des allozierten Buffers zurueck Flush(); - ULONG nTemp = Tell(); - ULONG nLength = Seek( STREAM_SEEK_TO_END ); + sal_uIntPtr nTemp = Tell(); + sal_uIntPtr nLength = Seek( STREAM_SEEK_TO_END ); Seek( nTemp ); return nLength; } diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index 9fdef8436f1a..5d0da0f3e29d 100644..100755 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -101,7 +101,7 @@ inline static void SwapDouble( double& r ) { if( sizeof(double) != 8 ) { - DBG_ASSERT( FALSE, "Can only swap 8-Byte-doubles\n" ); + DBG_ASSERT( sal_False, "Can only swap 8-Byte-doubles\n" ); } else { @@ -144,7 +144,7 @@ if( (tmp==STREAM_IO_WRITE) && sizeof(datatype) <= nBufFree)\ if( nBufActualPos > nBufActualLen )\ nBufActualLen = nBufActualPos;\ pBufPos += sizeof(datatype);\ - bIsDirty = TRUE;\ + bIsDirty = sal_True;\ }\ else\ Write( (char*)&value, sizeof(datatype) );\ @@ -420,7 +420,7 @@ void SvStream::ImpInit() eStreamCharSet = osl_getThreadTextEncoding(); // eTargetCharSet = osl_getThreadTextEncoding(); nCryptMask = 0; - bIsEof = FALSE; + bIsEof = sal_False; #if defined UNX eLineDelimiter = LINEEND_LF; // UNIX-Format #else @@ -431,9 +431,9 @@ void SvStream::ImpInit() nBufFilePos = 0; nBufActualPos = 0; - bIsDirty = FALSE; - bIsConsistent = TRUE; - bIsWritable = TRUE; + bIsDirty = sal_False; + bIsConsistent = sal_True; + bIsWritable = sal_True; pRWBuf = 0; pBufPos = 0; @@ -536,7 +536,7 @@ sal_uInt16 SvStream::IsA() const void SvStream::ClearError() { - bIsEof = FALSE; + bIsEof = sal_False; nError = SVSTREAM_OK; } @@ -570,13 +570,13 @@ void SvStream::SetError( sal_uInt32 nErrorCode ) void SvStream::SetNumberFormatInt( sal_uInt16 nNewFormat ) { nNumberFormatInt = nNewFormat; - bSwap = FALSE; + bSwap = sal_False; #ifdef OSL_BIGENDIAN if( nNumberFormatInt == NUMBERFORMAT_INT_LITTLEENDIAN ) - bSwap = TRUE; + bSwap = sal_True; #else if( nNumberFormatInt == NUMBERFORMAT_INT_BIGENDIAN ) - bSwap = TRUE; + bSwap = sal_True; #endif } @@ -609,8 +609,8 @@ void SvStream::SetBufferSize( sal_uInt16 nBufferSize ) nBufActualPos = 0; nBufSize = nBufferSize; if( nBufSize ) - pRWBuf = new BYTE[ nBufSize ]; - bIsConsistent = TRUE; + pRWBuf = new sal_uInt8[ nBufSize ]; + bIsConsistent = sal_True; pBufPos = pRWBuf; eIOMode = STREAM_IO_DONTKNOW; if( !bDontSeek ) @@ -633,11 +633,11 @@ void SvStream::ClearBuffer() nBufActualPos = 0; nBufFilePos = 0; pBufPos = pRWBuf; - bIsDirty = FALSE; - bIsConsistent = TRUE; + bIsDirty = sal_False; + bIsConsistent = sal_True; eIOMode = STREAM_IO_DONTKNOW; - bIsEof = FALSE; + bIsEof = sal_False; } /************************************************************************* @@ -678,7 +678,7 @@ sal_Bool SvStream::ReadByteStringLine( String& rStr, rtl_TextEncoding eSrcCharSe sal_Bool SvStream::ReadLine( ByteString& rStr ) { sal_Char buf[256+1]; - sal_Bool bEnd = FALSE; + sal_Bool bEnd = sal_False; sal_Size nOldFilePos = Tell(); sal_Char c = 0; sal_Size nTotalLen = 0; @@ -694,8 +694,8 @@ sal_Bool SvStream::ReadLine( ByteString& rStr ) if ( rStr.Len() == 0 ) { // der allererste Blockread hat fehlgeschlagen -> Abflug - bIsEof = TRUE; - return FALSE; + bIsEof = sal_True; + return sal_False; } else break; @@ -707,7 +707,7 @@ sal_Bool SvStream::ReadLine( ByteString& rStr ) c = buf[j]; if ( c == '\n' || c == '\r' ) { - bEnd = TRUE; + bEnd = sal_True; break; } // erAck 26.02.01: Old behavior was no special treatment of '\0' @@ -727,7 +727,7 @@ sal_Bool SvStream::ReadLine( ByteString& rStr ) } if ( !bEnd && !GetError() && rStr.Len() ) - bEnd = TRUE; + bEnd = sal_True; nOldFilePos += nTotalLen; if( Tell() > nOldFilePos ) @@ -745,14 +745,14 @@ sal_Bool SvStream::ReadLine( ByteString& rStr ) } if ( bEnd ) - bIsEof = FALSE; + bIsEof = sal_False; return bEnd; } sal_Bool SvStream::ReadUniStringLine( String& rStr ) { sal_Unicode buf[256+1]; - sal_Bool bEnd = FALSE; + sal_Bool bEnd = sal_False; sal_Size nOldFilePos = Tell(); sal_Unicode c = 0; sal_Size nTotalLen = 0; @@ -771,8 +771,8 @@ sal_Bool SvStream::ReadUniStringLine( String& rStr ) if ( rStr.Len() == 0 ) { // der allererste Blockread hat fehlgeschlagen -> Abflug - bIsEof = TRUE; - return FALSE; + bIsEof = sal_True; + return sal_False; } else break; @@ -786,7 +786,7 @@ sal_Bool SvStream::ReadUniStringLine( String& rStr ) c = buf[j]; if ( c == '\n' || c == '\r' ) { - bEnd = TRUE; + bEnd = sal_True; break; } // erAck 26.02.01: Old behavior was no special treatment of '\0' @@ -806,7 +806,7 @@ sal_Bool SvStream::ReadUniStringLine( String& rStr ) } if ( !bEnd && !GetError() && rStr.Len() ) - bEnd = TRUE; + bEnd = sal_True; nOldFilePos += nTotalLen * sizeof(sal_Unicode); if( Tell() > nOldFilePos ) @@ -824,7 +824,7 @@ sal_Bool SvStream::ReadUniStringLine( String& rStr ) } if ( bEnd ) - bIsEof = FALSE; + bIsEof = sal_False; return bEnd; } @@ -848,7 +848,7 @@ sal_Bool SvStream::ReadCString( ByteString& rStr ) rStr.Erase(); sal_Char buf[ 256 + 1 ]; - sal_Bool bEnd = FALSE; + sal_Bool bEnd = sal_False; sal_Size nFilePos = Tell(); while( !bEnd && !GetError() ) @@ -1032,7 +1032,7 @@ sal_Bool SvStream::WriteUniOrByteChar( sal_Unicode ch, rtl_TextEncoding eDestCha sal_Bool SvStream::StartWritingUnicodeText() { - SetEndianSwap( FALSE ); // write native format + SetEndianSwap( sal_False ); // write native format // BOM, Byte Order Mark, U+FEFF, see // http://www.unicode.org/faq/utf_bom.html#BOM // Upon read: 0xfeff(-257) => no swap; 0xfffe(-2) => swap @@ -1046,21 +1046,59 @@ sal_Bool SvStream::StartWritingUnicodeText() |* *************************************************************************/ -sal_Bool SvStream::StartReadingUnicodeText() +sal_Bool SvStream::StartReadingUnicodeText( rtl_TextEncoding eReadBomCharSet ) { + if (!( eReadBomCharSet == RTL_TEXTENCODING_DONTKNOW || + eReadBomCharSet == RTL_TEXTENCODING_UNICODE || + eReadBomCharSet == RTL_TEXTENCODING_UTF8)) + return sal_True; // nothing to read + + bool bTryUtf8 = false; sal_uInt16 nFlag; + sal_sSize nBack = sizeof(nFlag); *this >> nFlag; switch ( nFlag ) { case 0xfeff : - // native + // native UTF-16 + if ( eReadBomCharSet == RTL_TEXTENCODING_DONTKNOW || + eReadBomCharSet == RTL_TEXTENCODING_UNICODE) + nBack = 0; break; case 0xfffe : - SetEndianSwap( !bSwap ); + // swapped UTF-16 + if ( eReadBomCharSet == RTL_TEXTENCODING_DONTKNOW || + eReadBomCharSet == RTL_TEXTENCODING_UNICODE) + { + SetEndianSwap( !bSwap ); + nBack = 0; + } + break; + case 0xefbb : + if (nNumberFormatInt == NUMBERFORMAT_INT_BIGENDIAN && + (eReadBomCharSet == RTL_TEXTENCODING_DONTKNOW || + eReadBomCharSet == RTL_TEXTENCODING_UTF8)) + bTryUtf8 = true; + break; + case 0xbbef : + if (nNumberFormatInt == NUMBERFORMAT_INT_LITTLEENDIAN && + (eReadBomCharSet == RTL_TEXTENCODING_DONTKNOW || + eReadBomCharSet == RTL_TEXTENCODING_UTF8)) + bTryUtf8 = true; break; default: - SeekRel( -((sal_sSize)sizeof(nFlag)) ); // no BOM, pure data + ; // nothing + } + if (bTryUtf8) + { + sal_uChar nChar; + nBack += sizeof(nChar); + *this >> nChar; + if (nChar == 0xbf) + nBack = 0; // it is UTF-8 } + if (nBack) + SeekRel( -nBack ); // no BOM, pure data return nError == SVSTREAM_OK; } @@ -1375,7 +1413,7 @@ SvStream& SvStream::operator<< ( signed char v ) if( nBufActualPos > nBufActualLen ) // Append ? nBufActualLen = nBufActualPos; nBufFree--; // = sizeof(char); - bIsDirty = TRUE; + bIsDirty = sal_True; } else Write( (char*)&v, sizeof(signed char) ); @@ -1396,7 +1434,7 @@ SvStream& SvStream::operator<< ( char v ) if( nBufActualPos > nBufActualLen ) // Append ? nBufActualLen = nBufActualPos; nBufFree--; // = sizeof(char); - bIsDirty = TRUE; + bIsDirty = sal_True; } else Write( (char*)&v, sizeof(char) ); @@ -1415,7 +1453,7 @@ SvStream& SvStream::operator<< ( unsigned char v ) if( nBufActualPos > nBufActualLen ) // Append ? nBufActualLen = nBufActualPos; nBufFree--; - bIsDirty = TRUE; + bIsDirty = sal_True; } else Write( (char*)&v, sizeof(char) ); @@ -1616,7 +1654,7 @@ sal_Size SvStream::Read( void* pData, sal_Size nCount ) CryptAndWriteBuffer(pRWBuf, nBufActualLen); else PutData( pRWBuf, nBufActualLen ); - bIsDirty = FALSE; + bIsDirty = sal_False; } // passt der Datenblock in den Puffer ? @@ -1661,10 +1699,10 @@ sal_Size SvStream::Read( void* pData, sal_Size nCount ) } } } - bIsEof = FALSE; + bIsEof = sal_False; nBufFree = nBufActualLen - nBufActualPos; if( nCount != nSaveCount && nError != ERRCODE_IO_PENDING ) - bIsEof = TRUE; + bIsEof = sal_True; if( nCount == nSaveCount && nError == ERRCODE_IO_PENDING ) nError = ERRCODE_NONE; return nCount; @@ -1712,7 +1750,7 @@ sal_Size SvStream::Write( const void* pData, sal_Size nCount ) nBufActualLen = nBufActualPos; pBufPos += nCount; - bIsDirty = TRUE; + bIsDirty = sal_True; } else { @@ -1724,7 +1762,7 @@ sal_Size SvStream::Write( const void* pData, sal_Size nCount ) CryptAndWriteBuffer( pRWBuf, (sal_Size)nBufActualLen ); else PutData( pRWBuf, nBufActualLen ); - bIsDirty = FALSE; + bIsDirty = sal_False; } // passt der Block in den Puffer ? @@ -1752,7 +1790,7 @@ sal_Size SvStream::Write( const void* pData, sal_Size nCount ) nBufActualPos = (sal_uInt16)nCount; pBufPos = pRWBuf + nCount; nBufActualLen = (sal_uInt16)nCount; - bIsDirty = TRUE; + bIsDirty = sal_True; } } nBufFree = nBufSize - nBufActualPos; @@ -1774,7 +1812,7 @@ sal_Size SvStream::Seek( sal_Size nFilePos ) { eIOMode = STREAM_IO_DONTKNOW; - bIsEof = FALSE; + bIsEof = sal_False; if( !pRWBuf ) { nBufFilePos = SeekPos( nFilePos ); @@ -1800,7 +1838,7 @@ sal_Size SvStream::Seek( sal_Size nFilePos ) CryptAndWriteBuffer( pRWBuf, nBufActualLen ); else PutData( pRWBuf, nBufActualLen ); - bIsDirty = FALSE; + bIsDirty = sal_False; } nBufActualLen = 0; nBufActualPos = 0; @@ -1836,7 +1874,7 @@ void SvStream::Flush() else if( PutData( pRWBuf, nBufActualLen ) != nBufActualLen ) SetError( SVSTREAM_WRITE_ERROR ); - bIsDirty = FALSE; + bIsDirty = sal_False; } if( bIsWritable ) FlushData(); @@ -1880,9 +1918,9 @@ SvStream& SvStream::PutBack( char aCh ) CryptAndWriteBuffer( pRWBuf, nBufActualLen ); else PutData( pRWBuf, nBufActualLen ); - bIsDirty = FALSE; + bIsDirty = sal_False; } - bIsConsistent = FALSE; // Puffer enthaelt jetzt TRASH + bIsConsistent = sal_False; // Puffer enthaelt jetzt TRASH if( nBufActualPos ) { // 1. Fall @@ -1911,7 +1949,7 @@ SvStream& SvStream::PutBack( char aCh ) *pRWBuf = aCh; } eIOMode = STREAM_IO_DONTKNOW; - bIsEof = FALSE; + bIsEof = sal_False; return *this; } @@ -1954,7 +1992,7 @@ void SvStream::RefreshBuffer() CryptAndWriteBuffer( pRWBuf, (sal_Size)nBufActualLen ); else PutData( pRWBuf, nBufActualLen ); - bIsDirty = FALSE; + bIsDirty = sal_False; } SeekPos( nBufFilePos ); nBufActualLen = (sal_uInt16)GetData( pRWBuf, nBufSize ); @@ -1962,7 +2000,7 @@ void SvStream::RefreshBuffer() nError = ERRCODE_NONE; if( nCryptMask ) EncryptBuffer(pRWBuf, (sal_Size)nBufActualLen); - bIsConsistent = TRUE; + bIsConsistent = sal_True; eIOMode = STREAM_IO_DONTKNOW; } @@ -2038,7 +2076,7 @@ SvStream& SvStream::ReadNumber( long& rLong ) rLong = strtol( buf, &pEndPtr, (int)nRadix ); nFPtr += ( (sal_Size)pEndPtr - (sal_Size)(&(buf[0])) ); Seek( nFPtr ); - bIsEof = FALSE; + bIsEof = sal_False; return *this; } @@ -2063,7 +2101,7 @@ SvStream& SvStream::ReadNumber( sal_uInt32& rUInt32 ) rUInt32 = strtoul( buf, &pEndPtr, (int)nRadix ); nFPtr += ( (sal_uIntPtr)pEndPtr - (sal_uIntPtr)buf ); Seek( nFPtr ); - bIsEof = FALSE; + bIsEof = sal_False; return *this; } @@ -2088,7 +2126,7 @@ SvStream& SvStream::ReadNumber( double& rDouble ) rDouble = strtod( buf, &pEndPtr ); nFPtr += ( (sal_Size)pEndPtr - (sal_Size)buf ); Seek( nFPtr ); - bIsEof = FALSE; + bIsEof = sal_False; return *this; } @@ -2251,7 +2289,7 @@ sal_Bool SvStream::EncryptBuffer(void* pStart, sal_Size nLen) aCh ^= nMask; *pTemp = aCh; } - return TRUE; + return sal_True; } /************************************************************************* @@ -2432,12 +2470,12 @@ SvMemoryStream::SvMemoryStream( void* pBuffer, sal_Size bufSize, StreamMode eMode ) { if( eMode & STREAM_WRITE ) - bIsWritable = TRUE; + bIsWritable = sal_True; else - bIsWritable = FALSE; + bIsWritable = sal_False; nEndOfData = bufSize; - bOwnsData = FALSE; - pBuf = (BYTE *) pBuffer; + bOwnsData = sal_False; + pBuf = (sal_uInt8 *) pBuffer; nResize = 0L; nSize = bufSize; nPos = 0L; @@ -2456,8 +2494,8 @@ SvMemoryStream::SvMemoryStream( void* pBuffer, sal_Size bufSize, SvMemoryStream::SvMemoryStream( sal_Size nInitSize, sal_Size nResizeOffset ) { - bIsWritable = TRUE; - bOwnsData = TRUE; + bIsWritable = sal_True; + bOwnsData = sal_True; nEndOfData = 0L; nResize = nResizeOffset; nPos = 0; @@ -2535,7 +2573,7 @@ void* SvMemoryStream::SetBuffer( void* pNewBuf, sal_Size nCount, else pResult = pBuf; - pBuf = (BYTE *) pNewBuf; + pBuf = (sal_uInt8 *) pNewBuf; nPos = 0; nSize = nCount; nResize = 0; @@ -2723,7 +2761,7 @@ void SvMemoryStream::ResetError() sal_Bool SvMemoryStream::AllocateMemory( sal_Size nNewSize ) { - pBuf = new BYTE[nNewSize]; + pBuf = new sal_uInt8[nNewSize]; return( pBuf != 0 ); } @@ -2739,18 +2777,18 @@ sal_Bool SvMemoryStream::AllocateMemory( sal_Size nNewSize ) sal_Bool SvMemoryStream::ReAllocateMemory( long nDiff ) { - sal_Bool bRetVal = FALSE; + sal_Bool bRetVal = sal_False; long nTemp = (long)nSize; nTemp += nDiff; sal_Size nNewSize = (sal_Size)nTemp; if( nNewSize ) { - BYTE* pNewBuf = new BYTE[nNewSize]; + sal_uInt8* pNewBuf = new sal_uInt8[nNewSize]; if( pNewBuf ) { - bRetVal = TRUE; // Success! + bRetVal = sal_True; // Success! if( nNewSize < nSize ) // Verkleinern ? { memcpy( pNewBuf, pBuf, (size_t)nNewSize ); @@ -2772,7 +2810,7 @@ sal_Bool SvMemoryStream::ReAllocateMemory( long nDiff ) } else { - bRetVal = TRUE; + bRetVal = sal_True; FreeMemory(); pBuf = 0; nSize = 0; diff --git a/tools/source/stream/strmos2.cxx b/tools/source/stream/strmos2.cxx index a35fc7731767..bfe1f9750f4d 100644 --- a/tools/source/stream/strmos2.cxx +++ b/tools/source/stream/strmos2.cxx @@ -59,20 +59,20 @@ class StreamData { public: HFILE hFile; - BOOL bIsEof; + sal_Bool bIsEof; StreamData() { hFile = 0; - bIsEof = TRUE; + bIsEof = sal_True; } }; // ----------------------------------------------------------------------- -ULONG GetSvError( APIRET nPMError ) +sal_uIntPtr GetSvError( APIRET nPMError ) { - static struct { APIRET pm; ULONG sv; } errArr[] = + static struct { APIRET pm; sal_uIntPtr sv; } errArr[] = { { ERROR_FILE_NOT_FOUND, SVSTREAM_FILE_NOT_FOUND }, { ERROR_PATH_NOT_FOUND, SVSTREAM_PATH_NOT_FOUND }, @@ -93,7 +93,7 @@ ULONG GetSvError( APIRET nPMError ) { 0xFFFF, SVSTREAM_GENERALERROR } }; - ULONG nRetVal = SVSTREAM_GENERALERROR; // Standardfehler + sal_uIntPtr nRetVal = SVSTREAM_GENERALERROR; // Standardfehler int i=0; do { @@ -120,9 +120,9 @@ ULONG GetSvError( APIRET nPMError ) SvFileStream::SvFileStream( const String& rFileName, StreamMode nOpenMode ) { - bIsOpen = FALSE; + bIsOpen = sal_False; nLockCounter = 0; - bIsWritable = FALSE; + bIsWritable = sal_False; pInstanceData = new StreamData; SetBufferSize( 8192 ); @@ -146,9 +146,9 @@ SvFileStream::SvFileStream( const String& rFileName, StreamMode nOpenMode ) SvFileStream::SvFileStream() { - bIsOpen = FALSE; + bIsOpen = sal_False; nLockCounter = 0; - bIsWritable = FALSE; + bIsWritable = sal_False; pInstanceData = new StreamData; SetBufferSize( 8192 ); } @@ -180,9 +180,9 @@ SvFileStream::~SvFileStream() |* *************************************************************************/ -ULONG SvFileStream::GetFileHandle() const +sal_uIntPtr SvFileStream::GetFileHandle() const { - return (ULONG)pInstanceData->hFile; + return (sal_uIntPtr)pInstanceData->hFile; } /************************************************************************* @@ -195,7 +195,7 @@ ULONG SvFileStream::GetFileHandle() const |* *************************************************************************/ -USHORT SvFileStream::IsA() const +sal_uInt16 SvFileStream::IsA() const { return ID_FILESTREAM; } @@ -210,7 +210,7 @@ USHORT SvFileStream::IsA() const |* *************************************************************************/ -ULONG SvFileStream::GetData( void* pData, ULONG nSize ) +sal_uIntPtr SvFileStream::GetData( void* pData, sal_uIntPtr nSize ) { #ifdef DBG_UTIL ByteString aTraceStr( "SvFileStream::GetData(): " ); @@ -220,7 +220,7 @@ ULONG SvFileStream::GetData( void* pData, ULONG nSize ) DBG_TRACE( aTraceStr.GetBuffer() ); #endif - ULONG nCount = 0L; + sal_uIntPtr nCount = 0L; if( IsOpen() ) { APIRET nResult; @@ -241,7 +241,7 @@ ULONG SvFileStream::GetData( void* pData, ULONG nSize ) |* *************************************************************************/ -ULONG SvFileStream::PutData( const void* pData, ULONG nSize ) +sal_uIntPtr SvFileStream::PutData( const void* pData, sal_uIntPtr nSize ) { #ifdef DBG_UTIL ByteString aTraceStr( "SvFileStrean::PutData: " ); @@ -251,7 +251,7 @@ ULONG SvFileStream::PutData( const void* pData, ULONG nSize ) DBG_TRACE( aTraceStr.GetBuffer() ); #endif - ULONG nCount = 0L; + sal_uIntPtr nCount = 0L; if( IsOpen() ) { APIRET nResult; @@ -274,9 +274,9 @@ ULONG SvFileStream::PutData( const void* pData, ULONG nSize ) |* *************************************************************************/ -ULONG SvFileStream::SeekPos( ULONG nPos ) +sal_uIntPtr SvFileStream::SeekPos( sal_uIntPtr nPos ) { - ULONG nNewPos = 0L; + sal_uIntPtr nNewPos = 0L; if( IsOpen() ) { APIRET nResult; @@ -306,9 +306,9 @@ ULONG SvFileStream::SeekPos( ULONG nPos ) |* *************************************************************************/ /* -ULONG SvFileStream::Tell() +sal_uIntPtr SvFileStream::Tell() { - ULONG nPos = 0L; + sal_uIntPtr nPos = 0L; if( IsOpen() ) { @@ -352,9 +352,9 @@ void SvFileStream::FlushData() |* *************************************************************************/ -sal_Bool SvFileStream::LockRange( ULONG nByteOffset, ULONG nBytes ) +sal_Bool SvFileStream::LockRange( sal_uIntPtr nByteOffset, sal_uIntPtr nBytes ) { - sal_Bool bRetVal = FALSE; + sal_Bool bRetVal = sal_False; if( IsOpen() ) { APIRET nResult; @@ -373,7 +373,7 @@ sal_Bool SvFileStream::LockRange( ULONG nByteOffset, ULONG nBytes ) if( nResult ) SetError(::GetSvError(nResult) ); else - bRetVal = TRUE; + bRetVal = sal_True; } return bRetVal; } @@ -388,9 +388,9 @@ sal_Bool SvFileStream::LockRange( ULONG nByteOffset, ULONG nBytes ) |* *************************************************************************/ -sal_Bool SvFileStream::UnlockRange( ULONG nByteOffset, ULONG nBytes ) +sal_Bool SvFileStream::UnlockRange( sal_uIntPtr nByteOffset, sal_uIntPtr nBytes ) { - sal_Bool bRetVal = FALSE; + sal_Bool bRetVal = sal_False; if( IsOpen() ) { APIRET nResult; @@ -409,7 +409,7 @@ sal_Bool SvFileStream::UnlockRange( ULONG nByteOffset, ULONG nBytes ) if( nResult ) SetError(::GetSvError(nResult) ); else - bRetVal = TRUE; + bRetVal = sal_True; } return bRetVal; } @@ -426,19 +426,19 @@ sal_Bool SvFileStream::UnlockRange( ULONG nByteOffset, ULONG nBytes ) sal_Bool SvFileStream::LockFile() { - sal_Bool bRetVal = FALSE; + sal_Bool bRetVal = sal_False; if( !nLockCounter ) { if( LockRange( 0L, LONG_MAX ) ) { nLockCounter = 1; - bRetVal = TRUE; + bRetVal = sal_True; } } else { nLockCounter++; - bRetVal = TRUE; + bRetVal = sal_True; } return bRetVal; } @@ -455,7 +455,7 @@ sal_Bool SvFileStream::LockFile() sal_Bool SvFileStream::UnlockFile() { - sal_Bool bRetVal = FALSE; + sal_Bool bRetVal = sal_False; if( nLockCounter > 0) { if( nLockCounter == 1) @@ -463,13 +463,13 @@ sal_Bool SvFileStream::UnlockFile() if( UnlockRange( 0L, LONG_MAX ) ) { nLockCounter = 0; - bRetVal = TRUE; + bRetVal = sal_True; } } else { nLockCounter--; - bRetVal = TRUE; + bRetVal = sal_True; } } return bRetVal; @@ -486,7 +486,7 @@ sal_Bool SvFileStream::UnlockFile() *************************************************************************/ #if 0 -BOOL createLongNameEA ( const PCSZ pszPath, ULONG ulAttributes, const String& aLongName ); +sal_Bool createLongNameEA ( const PCSZ pszPath, sal_uIntPtr ulAttributes, const String& aLongName ); #endif void SvFileStream::Open( const String& rFilename, StreamMode nOpenMode ) @@ -500,7 +500,7 @@ void SvFileStream::Open( const String& rFilename, StreamMode nOpenMode ) String aRealPart; String aVirtualPath; ItemIDPath aVirtualURL; - ULONG nDivider = 0; + sal_uIntPtr nDivider = 0; String aVirtualString(rFilename); @@ -534,10 +534,10 @@ void SvFileStream::Open( const String& rFilename, StreamMode nOpenMode ) Close(); SvStream::ClearBuffer(); - ULONG nActionTaken; - ULONG nOpenAction = 0L; - ULONG nShareBits = 0L; - ULONG nReadWriteBits = 0L; + sal_uIntPtr nActionTaken; + sal_uIntPtr nOpenAction = 0L; + sal_uIntPtr nShareBits = 0L; + sal_uIntPtr nReadWriteBits = 0L; eStreamMode = nOpenMode; eStreamMode &= ~STREAM_TRUNC; // beim ReOpen nicht cutten @@ -592,7 +592,7 @@ void SvFileStream::Open( const String& rFilename, StreamMode nOpenMode ) // // resolves long FAT names used by OS2 // - BOOL bIsLongOS2=FALSE; + sal_Bool bIsLongOS2=sal_False; if (Folder::IsAvailable()) { DirEntry aDirEntry(rFilename); @@ -601,7 +601,7 @@ void SvFileStream::Open( const String& rFilename, StreamMode nOpenMode ) // in kurzen Pfad wandeln ItemIDPath aItemIDPath(rFilename); aParsedFilename = aItemIDPath.GetHostNotationPath(); - bIsLongOS2 = TRUE; + bIsLongOS2 = sal_True; } } #endif @@ -623,7 +623,7 @@ void SvFileStream::Open( const String& rFilename, StreamMode nOpenMode ) if( nRet == ERROR_TOO_MANY_OPEN_FILES ) { long nToAdd = 10; - ULONG nCurMaxFH; + sal_uIntPtr nCurMaxFH; nRet = DosSetRelMaxFH( &nToAdd, &nCurMaxFH ); nRet = DosOpen( aFileNameA.GetBuffer(), &pInstanceData->hFile, &nActionTaken, 0L, FILE_NORMAL, nOpenAction, @@ -641,15 +641,15 @@ void SvFileStream::Open( const String& rFilename, StreamMode nOpenMode ) if( nRet ) { - bIsOpen = FALSE; + bIsOpen = sal_False; SetError(::GetSvError(nRet) ); } else { - bIsOpen = TRUE; - pInstanceData->bIsEof = FALSE; + bIsOpen = sal_True; + pInstanceData->bIsEof = sal_False; if( nReadWriteBits != OPEN_ACCESS_READONLY ) - bIsWritable = TRUE; + bIsWritable = sal_True; } #if 0 @@ -714,10 +714,10 @@ void SvFileStream::Close() DosClose( pInstanceData->hFile ); } - bIsOpen = FALSE; + bIsOpen = sal_False; nLockCounter= 0; - bIsWritable = FALSE; - pInstanceData->bIsEof = TRUE; + bIsWritable = sal_False; + pInstanceData->bIsEof = sal_True; SvStream::ClearBuffer(); SvStream::ClearError(); } @@ -747,7 +747,7 @@ void SvFileStream::ResetError() |* *************************************************************************/ -void SvFileStream::SetSize( ULONG nSize ) +void SvFileStream::SetSize( sal_uIntPtr nSize ) { if( IsOpen() ) { @@ -756,5 +756,3 @@ void SvFileStream::SetSize( ULONG nSize ) SetError( ::GetSvError( nRet ) ); } } - - diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx index f3c5d642ed6e..87e3cea4c0c7 100644 --- a/tools/source/stream/strmunx.cxx +++ b/tools/source/stream/strmunx.cxx @@ -123,7 +123,7 @@ sal_Bool InternalStreamLock::LockFile( sal_Size nStart, sal_Size nEnd, SvFileStr InternalStreamLock* pLock = NULL; InternalStreamLockList &rLockList = LockList::get(); - for( ULONG i = 0; i < rLockList.Count(); ++i ) + for( sal_uIntPtr i = 0; i < rLockList.Count(); ++i ) { pLock = rLockList.GetObject( i ); if( aStat.st_ino == pLock->m_aStat.st_ino ) @@ -167,7 +167,7 @@ void InternalStreamLock::UnlockFile( sal_Size nStart, sal_Size nEnd, SvFileStrea InternalStreamLockList &rLockList = LockList::get(); if( nStart == 0 && nEnd == 0 ) { - for( ULONG i = 0; i < rLockList.Count(); ++i ) + for( sal_uIntPtr i = 0; i < rLockList.Count(); ++i ) { if( ( pLock = rLockList.GetObject( i ) )->m_pStream == pStream ) { @@ -177,7 +177,7 @@ void InternalStreamLock::UnlockFile( sal_Size nStart, sal_Size nEnd, SvFileStrea } return; } - for( ULONG i = 0; i < rLockList.Count(); ++i ) + for( sal_uIntPtr i = 0; i < rLockList.Count(); ++i ) { if( ( pLock = rLockList.GetObject( i ) )->m_pStream == pStream && nStart == pLock->m_nStartPos && nEnd == pLock->m_nEndPos ) diff --git a/tools/source/stream/strmwnt.cxx b/tools/source/stream/strmwnt.cxx index d9e7da92296b..20443e268964 100644 --- a/tools/source/stream/strmwnt.cxx +++ b/tools/source/stream/strmwnt.cxx @@ -63,9 +63,9 @@ public: // ----------------------------------------------------------------------- -static ULONG GetSvError( DWORD nWntError ) +static sal_uIntPtr GetSvError( DWORD nWntError ) { - static struct { DWORD wnt; ULONG sv; } errArr[] = + static struct { DWORD wnt; sal_uIntPtr sv; } errArr[] = { { ERROR_SUCCESS, SVSTREAM_OK }, { ERROR_ACCESS_DENIED, SVSTREAM_ACCESS_DENIED }, @@ -105,7 +105,7 @@ static ULONG GetSvError( DWORD nWntError ) { (DWORD)0xFFFFFFFF, SVSTREAM_GENERALERROR } }; - ULONG nRetVal = SVSTREAM_GENERALERROR; // Standardfehler + sal_uIntPtr nRetVal = SVSTREAM_GENERALERROR; // Standardfehler int i=0; do { @@ -131,9 +131,9 @@ static ULONG GetSvError( DWORD nWntError ) SvFileStream::SvFileStream( const String& rFileName, StreamMode nMode ) { - bIsOpen = FALSE; + bIsOpen = sal_False; nLockCounter = 0; - bIsWritable = FALSE; + bIsWritable = sal_False; pInstanceData = new StreamData; SetBufferSize( 8192 ); @@ -157,9 +157,9 @@ SvFileStream::SvFileStream( const String& rFileName, StreamMode nMode ) SvFileStream::SvFileStream() { - bIsOpen = FALSE; + bIsOpen = sal_False; nLockCounter = 0; - bIsWritable = FALSE; + bIsWritable = sal_False; pInstanceData = new StreamData; SetBufferSize( 8192 ); @@ -192,9 +192,9 @@ SvFileStream::~SvFileStream() |* *************************************************************************/ -ULONG SvFileStream::GetFileHandle() const +sal_uIntPtr SvFileStream::GetFileHandle() const { - return (ULONG)pInstanceData->hFile; + return (sal_uIntPtr)pInstanceData->hFile; } /************************************************************************* @@ -207,7 +207,7 @@ ULONG SvFileStream::GetFileHandle() const |* *************************************************************************/ -USHORT SvFileStream::IsA() const +sal_uInt16 SvFileStream::IsA() const { return ID_FILESTREAM; } @@ -222,7 +222,7 @@ USHORT SvFileStream::IsA() const |* *************************************************************************/ -ULONG SvFileStream::GetData( void* pData, ULONG nSize ) +sal_uIntPtr SvFileStream::GetData( void* pData, sal_uIntPtr nSize ) { DWORD nCount = 0; if( IsOpen() ) @@ -230,7 +230,7 @@ ULONG SvFileStream::GetData( void* pData, ULONG nSize ) bool bResult = ReadFile(pInstanceData->hFile,(LPVOID)pData,nSize,&nCount,NULL); if( !bResult ) { - ULONG nTestError = GetLastError(); + sal_uIntPtr nTestError = GetLastError(); SetError(::GetSvError( nTestError ) ); } } @@ -247,7 +247,7 @@ ULONG SvFileStream::GetData( void* pData, ULONG nSize ) |* *************************************************************************/ -ULONG SvFileStream::PutData( const void* pData, ULONG nSize ) +sal_uIntPtr SvFileStream::PutData( const void* pData, sal_uIntPtr nSize ) { DWORD nCount = 0; if( IsOpen() ) @@ -268,7 +268,7 @@ ULONG SvFileStream::PutData( const void* pData, ULONG nSize ) |* *************************************************************************/ -ULONG SvFileStream::SeekPos( ULONG nPos ) +sal_uIntPtr SvFileStream::SeekPos( sal_uIntPtr nPos ) { DWORD nNewPos = 0; if( IsOpen() ) @@ -287,7 +287,7 @@ ULONG SvFileStream::SeekPos( ULONG nPos ) } else SetError( SVSTREAM_GENERALERROR ); - return (ULONG)nNewPos; + return (sal_uIntPtr)nNewPos; } /************************************************************************* @@ -300,9 +300,9 @@ ULONG SvFileStream::SeekPos( ULONG nPos ) |* *************************************************************************/ /* -ULONG SvFileStream::Tell() +sal_uIntPtr SvFileStream::Tell() { - ULONG nPos = 0L; + sal_uIntPtr nPos = 0L; if( IsOpen() ) { @@ -347,7 +347,7 @@ void SvFileStream::FlushData() |* *************************************************************************/ -BOOL SvFileStream::LockRange( ULONG nByteOffset, ULONG nBytes ) +sal_Bool SvFileStream::LockRange( sal_uIntPtr nByteOffset, sal_uIntPtr nBytes ) { bool bRetVal = false; if( IsOpen() ) @@ -369,7 +369,7 @@ BOOL SvFileStream::LockRange( ULONG nByteOffset, ULONG nBytes ) |* *************************************************************************/ -BOOL SvFileStream::UnlockRange( ULONG nByteOffset, ULONG nBytes ) +sal_Bool SvFileStream::UnlockRange( sal_uIntPtr nByteOffset, sal_uIntPtr nBytes ) { bool bRetVal = false; if( IsOpen() ) @@ -391,21 +391,21 @@ BOOL SvFileStream::UnlockRange( ULONG nByteOffset, ULONG nBytes ) |* *************************************************************************/ -BOOL SvFileStream::LockFile() +sal_Bool SvFileStream::LockFile() { - BOOL bRetVal = FALSE; + sal_Bool bRetVal = sal_False; if( !nLockCounter ) { if( LockRange( 0L, LONG_MAX ) ) { nLockCounter = 1; - bRetVal = TRUE; + bRetVal = sal_True; } } else { nLockCounter++; - bRetVal = TRUE; + bRetVal = sal_True; } return bRetVal; } @@ -420,9 +420,9 @@ BOOL SvFileStream::LockFile() |* *************************************************************************/ -BOOL SvFileStream::UnlockFile() +sal_Bool SvFileStream::UnlockFile() { - BOOL bRetVal = FALSE; + sal_Bool bRetVal = sal_False; if( nLockCounter > 0) { if( nLockCounter == 1) @@ -430,13 +430,13 @@ BOOL SvFileStream::UnlockFile() if( UnlockRange( 0L, LONG_MAX ) ) { nLockCounter = 0; - bRetVal = TRUE; + bRetVal = sal_True; } } else { nLockCounter--; - bRetVal = TRUE; + bRetVal = sal_True; } } return bRetVal; @@ -555,7 +555,7 @@ void SvFileStream::Open( const String& rFilename, StreamMode nMode ) if( (pInstanceData->hFile==INVALID_HANDLE_VALUE) && (nAccessMode & GENERIC_WRITE)) { - ULONG nErr = ::GetSvError( GetLastError() ); + sal_uIntPtr nErr = ::GetSvError( GetLastError() ); if(nErr==SVSTREAM_ACCESS_DENIED || nErr==SVSTREAM_SHARING_VIOLATION) { nMode &= (~STREAM_WRITE); @@ -580,15 +580,15 @@ void SvFileStream::Open( const String& rFilename, StreamMode nMode ) if( GetLastError() != ERROR_SUCCESS ) { - bIsOpen = FALSE; + bIsOpen = sal_False; SetError(::GetSvError( GetLastError() ) ); } else { - bIsOpen = TRUE; - // pInstanceData->bIsEof = FALSE; + bIsOpen = sal_True; + // pInstanceData->bIsEof = sal_False; if( nAccessMode & GENERIC_WRITE ) - bIsWritable = TRUE; + bIsWritable = sal_True; } SetErrorMode( nOldErrorMode ); } @@ -631,9 +631,9 @@ void SvFileStream::Close() Flush(); CloseHandle( pInstanceData->hFile ); } - bIsOpen = FALSE; + bIsOpen = sal_False; nLockCounter= 0; - bIsWritable = FALSE; + bIsWritable = sal_False; SvStream::ClearBuffer(); SvStream::ClearError(); } @@ -663,24 +663,24 @@ void SvFileStream::ResetError() |* *************************************************************************/ -void SvFileStream::SetSize( ULONG nSize ) +void SvFileStream::SetSize( sal_uIntPtr nSize ) { if( IsOpen() ) { - int bError = FALSE; + int bError = sal_False; HANDLE hFile = pInstanceData->hFile; - ULONG nOld = SetFilePointer( hFile, 0L, NULL, FILE_CURRENT ); + sal_uIntPtr nOld = SetFilePointer( hFile, 0L, NULL, FILE_CURRENT ); if( nOld != 0xffffffff ) { if( SetFilePointer(hFile,nSize,NULL,FILE_BEGIN ) != 0xffffffff) { bool bSucc = SetEndOfFile( hFile ); if( !bSucc ) - bError = TRUE; + bError = sal_True; } if( SetFilePointer( hFile,nOld,NULL,FILE_BEGIN ) == 0xffffffff) - bError = TRUE; + bError = sal_True; } if( bError ) SetError(::GetSvError( GetLastError() ) ); diff --git a/tools/source/stream/vcompat.cxx b/tools/source/stream/vcompat.cxx index 8430eb17659b..fcbab9b98826 100644 --- a/tools/source/stream/vcompat.cxx +++ b/tools/source/stream/vcompat.cxx @@ -36,7 +36,7 @@ // - VersionCompat - // ----------------- -VersionCompat::VersionCompat( SvStream& rStm, USHORT nStreamMode, USHORT nVersion ) : +VersionCompat::VersionCompat( SvStream& rStm, sal_uInt16 nStreamMode, sal_uInt16 nVersion ) : mpRWStm ( &rStm ), mnStmMode ( nStreamMode ), mnVersion ( nVersion ) @@ -64,7 +64,7 @@ VersionCompat::~VersionCompat() { if( STREAM_WRITE == mnStmMode ) { - const UINT32 nEndPos = mpRWStm->Tell(); + const sal_uInt32 nEndPos = mpRWStm->Tell(); mpRWStm->Seek( mnCompatPos ); *mpRWStm << ( nEndPos - mnTotalSize ); @@ -72,7 +72,7 @@ VersionCompat::~VersionCompat() } else { - const UINT32 nReadSize = mpRWStm->Tell() - mnCompatPos; + const sal_uInt32 nReadSize = mpRWStm->Tell() - mnCompatPos; if( mnTotalSize > nReadSize ) mpRWStm->SeekRel( mnTotalSize - nReadSize ); |