From cc8144faafa0518334075090b0c8f90d0b2a2fde Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 6 May 2021 20:08:11 +0200 Subject: convert sal_uLong in sot Change-Id: I51027e731ce6581ebea08b1f5eb88472c3c27550 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115190 Tested-by: Jenkins Reviewed-by: Noel Grandin --- include/sot/stg.hxx | 33 ++++++++++++++++----------------- include/sot/storinfo.hxx | 7 +++---- sot/qa/cppunit/test_sot.cxx | 16 ++++++++-------- sot/source/base/exchange.cxx | 2 +- sot/source/sdstor/stg.cxx | 14 +++++++------- sot/source/sdstor/stgcache.cxx | 2 +- sot/source/sdstor/stgdir.cxx | 12 ++++++------ sot/source/sdstor/stgole.cxx | 4 ++-- sot/source/sdstor/storage.cxx | 6 +++--- sot/source/sdstor/ucbstorage.cxx | 30 +++++++++++++++--------------- 10 files changed, 62 insertions(+), 64 deletions(-) diff --git a/include/sot/stg.hxx b/include/sot/stg.hxx index 5ccb55b5ce6d..ce4d28efbd79 100644 --- a/include/sot/stg.hxx +++ b/include/sot/stg.hxx @@ -20,7 +20,6 @@ #ifndef INCLUDED_SOT_STG_HXX #define INCLUDED_SOT_STG_HXX -#include #include #include #include @@ -58,13 +57,13 @@ public: class BaseStorageStream : public StorageBase { public: - virtual sal_uLong Read( void * pData, sal_uLong nSize ) = 0; - virtual sal_uLong Write( const void* pData, sal_uLong nSize ) = 0; + virtual sal_Int32 Read( void * pData, sal_Int32 nSize ) = 0; + virtual sal_Int32 Write( const void* pData, sal_Int32 nSize ) = 0; virtual sal_uInt64 Seek( sal_uInt64 nPos ) = 0; - virtual sal_uLong Tell() = 0; + virtual sal_uInt64 Tell() = 0; virtual void Flush() = 0; - virtual bool SetSize( sal_uLong nNewSize ) = 0; - virtual sal_uLong GetSize() const = 0; + virtual bool SetSize( sal_uInt64 nNewSize ) = 0; + virtual sal_uInt64 GetSize() const = 0; virtual void CopyTo( BaseStorageStream * pDestStm ) = 0; virtual bool Commit() = 0; virtual bool Equals( const BaseStorageStream& rStream ) const = 0; @@ -126,18 +125,18 @@ protected: class StorageStream final : public BaseStorageStream, public OLEStorageBase { //friend class Storage; - sal_uLong nPos; // current position + sal_uInt64 nPos; // current position virtual ~StorageStream() override; public: StorageStream( StgIo*, StgDirEntry*, StreamMode ); - virtual sal_uLong Read( void * pData, sal_uLong nSize ) override; - virtual sal_uLong Write( const void* pData, sal_uLong nSize ) override; + virtual sal_Int32 Read( void * pData, sal_Int32 nSize ) override; + virtual sal_Int32 Write( const void* pData, sal_Int32 nSize ) override; virtual sal_uInt64 Seek( sal_uInt64 nPos ) override; - virtual sal_uLong Tell() override { return nPos; } + virtual sal_uInt64 Tell() override { return nPos; } virtual void Flush() override; - virtual bool SetSize( sal_uLong nNewSize ) override; - virtual sal_uLong GetSize() const override; + virtual bool SetSize( sal_uInt64 nNewSize ) override; + virtual sal_uInt64 GetSize() const override; virtual void CopyTo( BaseStorageStream * pDestStm ) override; virtual bool Commit() final override; virtual bool Validate( bool=false ) const override; @@ -214,13 +213,13 @@ public: UCBStorageStream( const OUString& rName, StreamMode nMode, bool bDirect, bool bRepair, css::uno::Reference< css::ucb::XProgressHandler > const & xProgress ); UCBStorageStream( UCBStorageStream_Impl* ); - virtual sal_uLong Read( void * pData, sal_uLong nSize ) override; - virtual sal_uLong Write( const void* pData, sal_uLong nSize ) override; + virtual sal_Int32 Read( void * pData, sal_Int32 nSize ) override; + virtual sal_Int32 Write( const void* pData, sal_Int32 nSize ) override; virtual sal_uInt64 Seek( sal_uInt64 nPos ) override; - virtual sal_uLong Tell() override; + virtual sal_uInt64 Tell() override; virtual void Flush() override; - virtual bool SetSize( sal_uLong nNewSize ) override; - virtual sal_uLong GetSize() const override; + virtual bool SetSize( sal_uInt64 nNewSize ) override; + virtual sal_uInt64 GetSize() const override; virtual void CopyTo( BaseStorageStream * pDestStm ) override; virtual bool Commit() override; virtual bool Validate( bool=false ) const override; diff --git a/include/sot/storinfo.hxx b/include/sot/storinfo.hxx index 213e6635b494..8b9866549c07 100644 --- a/include/sot/storinfo.hxx +++ b/include/sot/storinfo.hxx @@ -21,7 +21,6 @@ #define INCLUDED_SOT_STORINFO_HXX #include -#include #include #include #include @@ -33,13 +32,13 @@ class SvStorageInfo { friend class SotStorage; OUString aName; - sal_uLong nSize; + sal_uInt64 nSize; bool bStream; bool bStorage; public: SvStorageInfo(const StgDirEntry&); - SvStorageInfo(const OUString& rName, sal_uLong nSz, bool bIsStorage) + SvStorageInfo(const OUString& rName, sal_uInt64 nSz, bool bIsStorage) : aName(rName) , nSize(nSz) , bStream(!bIsStorage) @@ -50,7 +49,7 @@ public: const OUString& GetName() const { return aName; } bool IsStream() const { return bStream; } bool IsStorage() const { return bStorage; } - sal_uLong GetSize() const { return nSize; } + sal_uInt64 GetSize() const { return nSize; } }; typedef std::vector SvStorageInfoList; diff --git a/sot/qa/cppunit/test_sot.cxx b/sot/qa/cppunit/test_sot.cxx index ce8b7c8c8307..74f0771851d5 100644 --- a/sot/qa/cppunit/test_sot.cxx +++ b/sot/qa/cppunit/test_sot.cxx @@ -45,7 +45,7 @@ namespace bool checkStream( const tools::SvRef &xObjStor, const OUString &rStreamName, - sal_uLong nSize ); + sal_uInt64 nSize ); bool checkStorage( const tools::SvRef &xObjStor ); virtual bool load(const OUString &, @@ -65,27 +65,27 @@ namespace bool SotTest::checkStream( const tools::SvRef &xObjStor, const OUString &rStreamName, - sal_uLong nSize ) + sal_uInt64 nSize ) { unsigned char *pData = static_cast(malloc( nSize )); - sal_uLong nReadableSize = 0; + sal_uInt64 nReadableSize = 0; if( !pData ) return true; { // Read the data in one block tools::SvRef xStream( xObjStor->OpenSotStream( rStreamName ) ); xStream->Seek(0); - sal_uLong nRemaining = xStream->GetSize() - xStream->Tell(); + sal_uInt64 nRemaining = xStream->GetSize() - xStream->Tell(); CPPUNIT_ASSERT_EQUAL_MESSAGE( "check size", nSize, nRemaining ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "check size #2", static_cast(nSize), xStream->remainingSize()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "check size #2", nSize, xStream->remainingSize()); // Read as much as we can, a corrupted FAT chain can cause real grief here nReadableSize = xStream->ReadBytes(static_cast(pData), nSize); } { // Read the data backwards as well tools::SvRef xStream( xObjStor->OpenSotStream( rStreamName ) ); - for( sal_uLong i = nReadableSize; i > 0; i-- ) + for( sal_uInt64 i = nReadableSize; i > 0; i-- ) { CPPUNIT_ASSERT_MESSAGE( "sot reading error", !xStream->GetError() ); unsigned char c; @@ -154,8 +154,8 @@ namespace CPPUNIT_ASSERT_MESSAGE("stream failed to open", !xObjStor->GetError()); CPPUNIT_ASSERT_MESSAGE("error in opened stream", !xStream->GetError()); - sal_uLong nPos = xStream->GetSize(); - CPPUNIT_ASSERT_EQUAL_MESSAGE("odd stream length", static_cast(13312), nPos); + sal_uInt64 nPos = xStream->GetSize(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("odd stream length", static_cast(13312), nPos); xStream->Seek(STREAM_SEEK_TO_END); CPPUNIT_ASSERT_MESSAGE("error seeking to end", !xStream->GetError()); diff --git a/sot/source/base/exchange.cxx b/sot/source/base/exchange.cxx index d00565d618fd..091dd7a10e13 100644 --- a/sot/source/base/exchange.cxx +++ b/sot/source/base/exchange.cxx @@ -360,7 +360,7 @@ bool SotExchange::GetFormatDataFlavor( SotClipboardFormatId nFormat, DataFlavor& /************************************************************************* |* -|* SotExchange::GetFormatMimeType( sal_uLong nFormat ) +|* SotExchange::GetFormatMimeType( SotClipboardFormatId nFormat ) |* *************************************************************************/ diff --git a/sot/source/sdstor/stg.cxx b/sot/source/sdstor/stg.cxx index 398e3fdb53d1..3bf969f5150e 100644 --- a/sot/source/sdstor/stg.cxx +++ b/sot/source/sdstor/stg.cxx @@ -180,12 +180,12 @@ bool StorageStream::Equals( const BaseStorageStream& rStream ) const return pOther && ( pOther->pEntry == pEntry ); } -sal_uLong StorageStream::Read( void* pData, sal_uLong nSize ) +sal_Int32 StorageStream::Read( void* pData, sal_Int32 nSize ) { if( Validate() ) { pEntry->Seek( nPos ); - nSize = pEntry->Read( pData, static_cast(nSize) ); + nSize = pEntry->Read( pData, nSize ); pIo->MoveError( *this ); nPos += nSize; } @@ -194,12 +194,12 @@ sal_uLong StorageStream::Read( void* pData, sal_uLong nSize ) return nSize; } -sal_uLong StorageStream::Write( const void* pData, sal_uLong nSize ) +sal_Int32 StorageStream::Write( const void* pData, sal_Int32 nSize ) { if( Validate( true ) ) { pEntry->Seek( nPos ); - nSize = pEntry->Write( pData, static_cast(nSize) ); + nSize = pEntry->Write( pData, nSize ); pIo->MoveError( *this ); nPos += nSize; } @@ -225,11 +225,11 @@ void StorageStream::Flush() Commit(); } -bool StorageStream::SetSize( sal_uLong nNewSize ) +bool StorageStream::SetSize( sal_uInt64 nNewSize ) { if( Validate( true ) ) { - bool b = pEntry->SetSize( static_cast(nNewSize) ); + bool b = pEntry->SetSize( nNewSize ); pIo->MoveError( *this ); return b; } @@ -237,7 +237,7 @@ bool StorageStream::SetSize( sal_uLong nNewSize ) return false; } -sal_uLong StorageStream::GetSize() const +sal_uInt64 StorageStream::GetSize() const { if( Validate() ) return pEntry->GetSize(); diff --git a/sot/source/sdstor/stgcache.cxx b/sot/source/sdstor/stgcache.cxx index ba5610f706b5..301769385f64 100644 --- a/sot/source/sdstor/stgcache.cxx +++ b/sot/source/sdstor/stgcache.cxx @@ -74,7 +74,7 @@ bool StgPage::IsPageGreater( const StgPage *pA, const StgPage *pB ) // The disk cache holds the cached sectors. The sector type differ according // to their purpose. -static sal_Int32 lcl_GetPageCount( sal_uLong nFileSize, short nPageSize ) +static sal_Int32 lcl_GetPageCount( sal_uInt64 nFileSize, short nPageSize ) { // return (nFileSize >= 512) ? (nFileSize - 512) / nPageSize : 0; // #i61980# real life: last page may be incomplete, return number of *started* pages diff --git a/sot/source/sdstor/stgdir.cxx b/sot/source/sdstor/stgdir.cxx index f7047dc28600..312b07870952 100644 --- a/sot/source/sdstor/stgdir.cxx +++ b/sot/source/sdstor/stgdir.cxx @@ -494,7 +494,7 @@ void StgDirEntry::Copy( BaseStorageStream& rDest ) if( !(rDest.SetSize( n ) && n) ) return; - sal_uLong Pos = rDest.Tell(); + sal_uInt64 Pos = rDest.Tell(); sal_uInt8 aTempBytes[ 4096 ]; void* p = static_cast( aTempBytes ); Seek( 0 ); @@ -549,7 +549,7 @@ bool StgDirEntry::Strm2Tmp() { if( !m_pTmpStrm ) { - sal_uLong n = 0; + sal_uInt64 n = 0; if( m_pCurStrm ) { // It was already committed once @@ -575,10 +575,10 @@ bool StgDirEntry::Strm2Tmp() m_pStgStrm->Pos2Page( 0 ); while( n ) { - sal_uLong nn = n; + sal_uInt64 nn = n; if( nn > 4096 ) nn = 4096; - if( static_cast(m_pStgStrm->Read( p, nn )) != nn ) + if( static_cast(m_pStgStrm->Read( p, nn )) != nn ) break; if (m_pTmpStrm->WriteBytes( p, nn ) != nn) break; @@ -624,7 +624,7 @@ bool StgDirEntry::Tmp2Strm() sal_uInt64 n = m_pTmpStrm->GetSize(); std::unique_ptr pNewStrm; StgIo& rIo = m_pStgStrm->GetIo(); - sal_uLong nThreshold = static_cast(rIo.m_aHdr.GetThreshold()); + sal_uInt64 nThreshold = rIo.m_aHdr.GetThreshold(); if( n < nThreshold ) pNewStrm.reset(new StgSmallStrm( rIo, STG_EOF )); else @@ -640,7 +640,7 @@ bool StgDirEntry::Tmp2Strm() nn = 4096; if (m_pTmpStrm->ReadBytes( p, nn ) != nn) break; - if( static_cast(pNewStrm->Write( p, nn )) != nn ) + if( static_cast(pNewStrm->Write( p, nn )) != nn ) break; n -= nn; } diff --git a/sot/source/sdstor/stgole.cxx b/sot/source/sdstor/stgole.cxx index 3ae8fe4209ec..bee4feb8842d 100644 --- a/sot/source/sdstor/stgole.cxx +++ b/sot/source/sdstor/stgole.cxx @@ -112,11 +112,11 @@ bool StgCompObjStream::Load() if ( nLen1 > 0 ) { // higher bits are ignored - sal_uLong nStrLen = ::std::min( nLen1, sal_Int32(0xFFFE) ); + sal_Int32 nStrLen = ::std::min( nLen1, sal_Int32(0xFFFE) ); std::unique_ptr p(new char[ nStrLen+1 ]); p[nStrLen] = 0; - if (ReadBytes( p.get(), nStrLen ) == nStrLen) + if (static_cast(ReadBytes( p.get(), nStrLen )) == nStrLen) { //The encoding here is "ANSI", which is pretty useless seeing as //the actual codepage used doesn't seem to be specified/stored diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx index 60bcb6dc8bd6..596a59d59785 100644 --- a/sot/source/sdstor/storage.cxx +++ b/sot/source/sdstor/storage.cxx @@ -82,10 +82,10 @@ void SotTempStream::CopyTo( SotTempStream * pDestStm ) constexpr int BUFSIZE = 64 * 1024; std::unique_ptr pMem(new sal_uInt8[ BUFSIZE ]); - sal_uLong nRead; + sal_Int32 nRead; while (0 != (nRead = ReadBytes(pMem.get(), BUFSIZE))) { - if (nRead != pDestStm->WriteBytes(pMem.get(), nRead)) + if (nRead != static_cast(pDestStm->WriteBytes(pMem.get(), nRead))) { SetError( SVSTREAM_GENERALERROR ); break; @@ -139,7 +139,7 @@ std::size_t SotStorageStream::PutData(const void* pData, std::size_t const nSize sal_uInt64 SotStorageStream::SeekPos(sal_uInt64 nPos) { - sal_uLong nRet = pOwnStm->Seek( nPos ); + sal_uInt64 nRet = pOwnStm->Seek( nPos ); SetError( pOwnStm->GetError() ); return nRet; } diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx index 1db842a557cb..7b26fa936db2 100644 --- a/sot/source/sdstor/ucbstorage.cxx +++ b/sot/source/sdstor/ucbstorage.cxx @@ -425,7 +425,7 @@ public: sal_Int16 Commit(); // if modified and committed: transfer an XInputStream to the content void Revert(); // discard all changes BaseStorage* CreateStorage();// create an OLE Storage on the UCBStorageStream - sal_uLong GetSize(); + sal_uInt64 GetSize(); sal_uInt64 ReadSourceWriteTemporary( sal_uInt64 aLength ); // read aLength from source and copy to temporary, // no seeking is produced @@ -523,7 +523,7 @@ struct UCBStorageElement_Impl { OUString m_aName; // the actual URL relative to the root "folder" OUString m_aOriginalName;// the original name in the content - sal_uLong m_nSize; + sal_uInt64 m_nSize; bool m_bIsFolder; // Only true when it is a UCBStorage ! bool m_bIsStorage; // Also true when it is an OLEStorage ! bool m_bIsRemoved; // element will be removed on commit @@ -532,7 +532,7 @@ struct UCBStorageElement_Impl UCBStorageStream_ImplRef m_xStream; // reference to the "real" stream UCBStorageElement_Impl( const OUString& rName, - bool bIsFolder = false, sal_uLong nSize = 0 ) + bool bIsFolder = false, sal_uInt64 nSize = 0 ) : m_aName( rName ) , m_aOriginalName( rName ) , m_nSize( nSize ) @@ -754,7 +754,7 @@ void UCBStorageStream_Impl::ReadSourceWriteTemporary() try { - sal_uLong aReaded; + sal_Int32 aReaded; do { aReaded = m_rSource->readBytes( aData, 32000 ); @@ -784,11 +784,11 @@ sal_uInt64 UCBStorageStream_Impl::ReadSourceWriteTemporary(sal_uInt64 aLength) try { - sal_uLong aReaded = 32000; + sal_Int32 aReaded = 32000; for (sal_uInt64 nInd = 0; nInd < aLength && aReaded == 32000 ; nInd += 32000) { - sal_uLong aToCopy = std::min( aLength - nInd, 32000 ); + sal_Int32 aToCopy = std::min( aLength - nInd, 32000 ); aReaded = m_rSource->readBytes( aData, aToCopy ); aResult += m_pStream->WriteBytes(aData.getArray(), aReaded); } @@ -990,7 +990,7 @@ void UCBStorageStream_Impl::ResetError() m_pAntiImpl->ResetError(); } -sal_uLong UCBStorageStream_Impl::GetSize() +sal_uInt64 UCBStorageStream_Impl::GetSize() { if( !Init() ) return 0; @@ -1216,13 +1216,13 @@ UCBStorageStream::~UCBStorageStream() pImp->ReleaseRef(); } -sal_uLong UCBStorageStream::Read( void * pData, sal_uLong nSize ) +sal_Int32 UCBStorageStream::Read( void * pData, sal_Int32 nSize ) { //return pImp->m_pStream->Read( pData, nSize ); return pImp->GetData( pData, nSize ); } -sal_uLong UCBStorageStream::Write( const void* pData, sal_uLong nSize ) +sal_Int32 UCBStorageStream::Write( const void* pData, sal_Int32 nSize ) { return pImp->PutData( pData, nSize ); } @@ -1233,7 +1233,7 @@ sal_uInt64 UCBStorageStream::Seek( sal_uInt64 nPos ) return pImp->Seek( nPos ); } -sal_uLong UCBStorageStream::Tell() +sal_uInt64 UCBStorageStream::Tell() { if( !pImp->Init() ) return 0; @@ -1246,7 +1246,7 @@ void UCBStorageStream::Flush() Commit(); } -bool UCBStorageStream::SetSize( sal_uLong nNewSize ) +bool UCBStorageStream::SetSize( sal_uInt64 nNewSize ) { pImp->SetSize( nNewSize ); return !pImp->GetError(); @@ -1322,7 +1322,7 @@ void UCBStorageStream::CopyTo( BaseStorageStream* pDestStm ) pDestStm->Seek( 0 ); while( n ) { - sal_uInt32 nn = n; + sal_Int32 nn = n; if( nn > 4096 ) nn = 4096; if( Read( p.get(), nn ) != nn ) @@ -1360,7 +1360,7 @@ bool UCBStorageStream::SetProperty( const OUString& rName, const css::uno::Any& return false; } -sal_uLong UCBStorageStream::GetSize() const +sal_uInt64 UCBStorageStream::GetSize() const { return pImp->GetSize(); } @@ -1699,7 +1699,7 @@ void UCBStorage_Impl::ReadContent() bool bIsFolder( xRow->getBoolean(2) ); sal_Int64 nSize = xRow->getLong(4); - UCBStorageElement_Impl* pElement = new UCBStorageElement_Impl( aTitle, bIsFolder, static_cast(nSize) ); + UCBStorageElement_Impl* pElement = new UCBStorageElement_Impl( aTitle, bIsFolder, nSize ); m_aChildrenList.emplace_back( pElement ); bool bIsOfficeDocument = m_bIsLinked || ( m_aClassId != SvGlobalName() ); @@ -2338,7 +2338,7 @@ void UCBStorage::FillInfoList( SvStorageInfoList* pList ) const if ( !pElement->m_bIsRemoved ) { // problem: what about the size of a substorage ?! - sal_uLong nSize = pElement->m_nSize; + sal_uInt64 nSize = pElement->m_nSize; if ( pElement->m_xStream.is() ) nSize = pElement->m_xStream->GetSize(); SvStorageInfo aInfo( pElement->m_aName, nSize, pElement->m_bIsStorage ); -- cgit