diff options
author | Noel Grandin <noel@peralex.com> | 2015-01-07 09:28:42 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-01-07 11:20:44 +0200 |
commit | 7f8f277b94704a289fbbd1b836e4e5d66311580d (patch) | |
tree | 2400b7306a0a2a3ea63aee2e5bfc336b52102635 /sot | |
parent | 8db77209e0755d21d9efc34f70a2978d1df5d2c6 (diff) |
fdo#84938: convert STREAM_ #defines to 'enum class'
Change-Id: Ibbf14c7e9a5c1883c1311d4c86f948f74f8e473e
Diffstat (limited to 'sot')
-rw-r--r-- | sot/qa/cppunit/test_sot.cxx | 4 | ||||
-rw-r--r-- | sot/source/base/formats.cxx | 2 | ||||
-rw-r--r-- | sot/source/sdstor/stg.cxx | 62 | ||||
-rw-r--r-- | sot/source/sdstor/stgcache.cxx | 6 | ||||
-rw-r--r-- | sot/source/sdstor/stgdir.cxx | 12 | ||||
-rw-r--r-- | sot/source/sdstor/stgelem.cxx | 4 | ||||
-rw-r--r-- | sot/source/sdstor/stgio.cxx | 2 | ||||
-rw-r--r-- | sot/source/sdstor/stgole.cxx | 6 | ||||
-rw-r--r-- | sot/source/sdstor/storage.cxx | 22 | ||||
-rw-r--r-- | sot/source/sdstor/ucbstorage.cxx | 121 | ||||
-rw-r--r-- | sot/source/unoolestorage/xolesimplestorage.cxx | 2 |
11 files changed, 109 insertions, 134 deletions
diff --git a/sot/qa/cppunit/test_sot.cxx b/sot/qa/cppunit/test_sot.cxx index 92ade70a11a4..c1ebb1bebc9c 100644 --- a/sot/qa/cppunit/test_sot.cxx +++ b/sot/qa/cppunit/test_sot.cxx @@ -106,7 +106,7 @@ namespace const OUString &rURL, const OUString &, unsigned int, unsigned int, unsigned int) { - SvFileStream aStream(rURL, STREAM_READ); + SvFileStream aStream(rURL, StreamMode::READ); SotStorageRef xObjStor = new SotStorage(aStream); if (!xObjStor.Is() || xObjStor->GetError()) return false; @@ -125,7 +125,7 @@ namespace void SotTest::testSize() { OUString aURL(getURLFromSrc("/sot/qa/cppunit/data/pass/fdo84229-1.compound")); - SvFileStream aStream(aURL, STREAM_READ); + SvFileStream aStream(aURL, StreamMode::READ); SotStorageRef xObjStor = new SotStorage(aStream); CPPUNIT_ASSERT_MESSAGE("sot storage failed to open", xObjStor.Is() && !xObjStor->GetError()); diff --git a/sot/source/base/formats.cxx b/sot/source/base/formats.cxx index 75ce447086eb..0640771cf82e 100644 --- a/sot/source/base/formats.cxx +++ b/sot/source/base/formats.cxx @@ -1426,7 +1426,7 @@ static sal_uInt16 GetTransferableAction_Impl( if( aAny.hasValue() ) { Sequence< sal_Int8 > aSeq; aAny >>= aSeq; - SvMemoryStream aMemStm( (void*) aSeq.getConstArray(), aSeq.getLength(), STREAM_READ ); + SvMemoryStream aMemStm( (void*) aSeq.getConstArray(), aSeq.getLength(), StreamMode::READ ); FileList aFileList; ReadFileList( aMemStm, aFileList ); diff --git a/sot/source/sdstor/stg.cxx b/sot/source/sdstor/stg.cxx index 551b00a3c156..1d6c22255242 100644 --- a/sot/source/sdstor/stg.cxx +++ b/sot/source/sdstor/stg.cxx @@ -34,12 +34,12 @@ static long nTmpCount = 0; -// The internal open mode is STREAM_READ | STREAM_TRUNC, which is silly +// The internal open mode is StreamMode::READ | STREAM_TRUNC, which is silly // by itself. It inhibits the checking of sharing modes and is used // during CopyTo() and MoveTo() for opening a stream in read mode // although it may be open in DENYALL mode -#define INTERNAL_MODE ( STREAM_READ | STREAM_TRUNC ) +#define INTERNAL_MODE ( StreamMode::READ | StreamMode::TRUNC ) ///////////////////////// class StorageBase @@ -50,7 +50,7 @@ TYPEINIT1( BaseStorage, StorageBase ); StorageBase::StorageBase() : m_bAutoCommit( false ) { - m_nMode = STREAM_READ; + m_nMode = StreamMode::READ; m_nError = SVSTREAM_OK; } @@ -127,7 +127,7 @@ bool OLEStorageBase::Validate_Impl( bool bWrite ) const && pIo->pTOC && pEntry && !pEntry->bInvalid - && ( !bWrite || !pEntry->bDirect || ( nStreamMode & STREAM_WRITE ) ) ) + && ( !bWrite || !pEntry->bDirect || ( nStreamMode & StreamMode::WRITE ) ) ) return true; return false; } @@ -136,14 +136,14 @@ bool OLEStorageBase::ValidateMode_Impl( StreamMode m, StgDirEntry* p ) const { if( m == INTERNAL_MODE ) return true; - sal_uInt16 nCurMode = ( p && p->nRefCnt ) ? p->nMode : 0xFFFF; - if( ( m & 3 ) == STREAM_READ ) + StreamMode nCurMode = ( p && p->nRefCnt ) ? p->nMode : StreamMode::SHARE_DENYALL; + if( ( m & STREAM_READWRITE ) == StreamMode::READ ) { // only SHARE_DENYWRITE or SHARE_DENYALL allowed - if( ( ( m & STREAM_SHARE_DENYWRITE ) - && ( nCurMode & STREAM_SHARE_DENYWRITE ) ) - || ( ( m & STREAM_SHARE_DENYALL ) - && ( nCurMode & STREAM_SHARE_DENYALL ) ) ) + if( ( ( m & StreamMode::SHARE_DENYWRITE ) + && ( nCurMode & StreamMode::SHARE_DENYWRITE ) ) + || ( ( m & StreamMode::SHARE_DENYALL ) + && ( nCurMode & StreamMode::SHARE_DENYALL ) ) ) return true; } else @@ -151,8 +151,8 @@ bool OLEStorageBase::ValidateMode_Impl( StreamMode m, StgDirEntry* p ) const // only SHARE_DENYALL allowed // storages open in r/o mode are OK, since only // the commit may fail - if( ( m & STREAM_SHARE_DENYALL ) - && ( nCurMode & STREAM_SHARE_DENYALL ) ) + if( ( m & StreamMode::SHARE_DENYALL ) + && ( nCurMode & StreamMode::SHARE_DENYALL ) ) return true; } return false; @@ -176,7 +176,7 @@ StorageStream::StorageStream( StgIo* p, StgDirEntry* q, StreamMode m ) } } else - m &= ~STREAM_READWRITE; + m &= ~StreamMode(STREAM_READWRITE); m_nMode = m; } @@ -185,7 +185,7 @@ StorageStream::~StorageStream() // Do an auto-commit if the entry is open in direct mode if( m_bAutoCommit ) Commit(); - if( pEntry && pEntry->nRefCnt && pEntry->bDirect && (m_nMode & STREAM_WRITE) ) + if( pEntry && pEntry->nRefCnt && pEntry->bDirect && (m_nMode & StreamMode::WRITE) ) pEntry->Commit(); } @@ -260,7 +260,7 @@ bool StorageStream::Commit() { if( !Validate() ) return false; - if( !( m_nMode & STREAM_WRITE ) ) + if( !( m_nMode & StreamMode::WRITE ) ) { SetError( SVSTREAM_ACCESS_DENIED ); return false; @@ -378,7 +378,7 @@ Storage::Storage( const OUString& rFile, StreamMode m, bool bDirect ) m_nMode = m; if( pIo->Open( aName, m ) ) { - Init( ( m & ( STREAM_TRUNC | STREAM_NOCREATE ) ) == STREAM_TRUNC ); + Init( ( m & ( StreamMode::TRUNC | StreamMode::NOCREATE ) ) == StreamMode::TRUNC ); if( pEntry ) { pEntry->bDirect = bDirect; @@ -399,9 +399,9 @@ Storage::Storage( SvStream& r, bool bDirect ) : OLEStorageBase( new StgIo, NULL, m_nMode ) , bIsRoot( false ) { - m_nMode = STREAM_READ; + m_nMode = StreamMode::READ; if( r.IsWritable() ) - m_nMode = STREAM_READ | STREAM_WRITE; + m_nMode = StreamMode::READ | StreamMode::WRITE; if( r.GetError() == SVSTREAM_OK ) { pIo->SetStrm( &r, false ); @@ -427,7 +427,7 @@ Storage::Storage( SvStream& r, bool bDirect ) Storage::Storage( UCBStorageStream& rStrm, bool bDirect ) : OLEStorageBase( new StgIo, NULL, m_nMode ), bIsRoot( false ) { - m_nMode = STREAM_READ; + m_nMode = StreamMode::READ; if ( rStrm.GetError() != SVSTREAM_OK ) { @@ -446,7 +446,7 @@ Storage::Storage( UCBStorageStream& rStrm, bool bDirect ) } if( pStream->IsWritable() ) - m_nMode = STREAM_READ | STREAM_WRITE; + m_nMode = StreamMode::READ | StreamMode::WRITE; pIo->SetStrm( &rStrm ); @@ -509,7 +509,7 @@ Storage::Storage( StgIo* p, StgDirEntry* q, StreamMode m ) if( q ) q->aEntry.GetName( aName ); else - m &= ~STREAM_READWRITE; + m &= ~StreamMode(STREAM_READWRITE); m_nMode = m; if( q && q->nRefCnt == 1 ) q->nMode = m; @@ -523,7 +523,7 @@ Storage::~Storage() if( pEntry ) { // Do an auto-commit if the entry is open in direct mode - if( pEntry->nRefCnt && pEntry->bDirect && (m_nMode & STREAM_WRITE) ) + if( pEntry->nRefCnt && pEntry->bDirect && (m_nMode & StreamMode::WRITE) ) Commit(); if( pEntry->nRefCnt == 1 ) pEntry->Invalidate(); @@ -588,7 +588,7 @@ BaseStorage* Storage::OpenStorage( const OUString& rName, StreamMode m, bool bDi StgDirEntry* p = pIo->pTOC->Find( *pEntry, rName ); if( !p ) { - if( !( m & STREAM_NOCREATE ) ) + if( !( m & StreamMode::NOCREATE ) ) { bool bTemp = false; // create a new storage @@ -603,7 +603,7 @@ BaseStorage* Storage::OpenStorage( const OUString& rName, StreamMode m, bool bDi p->bTemp = bTemp; } if( !p ) - pIo->SetError( ( m & STREAM_WRITE ) + pIo->SetError( ( m & StreamMode::WRITE ) ? SVSTREAM_CANNOT_MAKE : SVSTREAM_FILE_NOT_FOUND ); } else if( !ValidateMode( m, p ) ) @@ -619,14 +619,14 @@ BaseStorage* Storage::OpenStorage( const OUString& rName, StreamMode m, bool bDi p->bDirect = bDirect; // Dont check direct conflict if opening readonly - if( p && (m & STREAM_WRITE )) + if( p && (m & StreamMode::WRITE )) { if( p->bDirect != bDirect ) SetError( SVSTREAM_ACCESS_DENIED ); } Storage* pStg = new Storage( pIo, p, m ); pIo->MoveError( *pStg ); - if( m & STREAM_WRITE ) pStg->m_bAutoCommit = true; + if( m & StreamMode::WRITE ) pStg->m_bAutoCommit = true; return pStg; } @@ -647,7 +647,7 @@ BaseStorageStream* Storage::OpenStream( const OUString& rName, StreamMode m, boo bool bTemp = false; if( !p ) { - if( !( m & STREAM_NOCREATE ) ) + if( !( m & StreamMode::NOCREATE ) ) { // create a new stream // make a name if the stream is temporary (has no name) @@ -660,7 +660,7 @@ BaseStorageStream* Storage::OpenStream( const OUString& rName, StreamMode m, boo p = pIo->pTOC->Create( *pEntry, aNewName, STG_STREAM ); } if( !p ) - pIo->SetError( ( m & STREAM_WRITE ) + pIo->SetError( ( m & StreamMode::WRITE ) ? SVSTREAM_CANNOT_MAKE : SVSTREAM_FILE_NOT_FOUND ); } else if( !ValidateMode( m, p ) ) @@ -728,7 +728,7 @@ bool Storage::CopyTo( const OUString& rElem, BaseStorage* pDest, const OUString& { // copy the entire storage BaseStorage* p1 = OpenStorage( rElem, INTERNAL_MODE ); - BaseStorage* p2 = pDest->OpenOLEStorage( rNew, STREAM_WRITE | STREAM_SHARE_DENYALL, pEntry->bDirect ); + BaseStorage* p2 = pDest->OpenOLEStorage( rNew, StreamMode::WRITE | StreamMode::SHARE_DENYALL, pEntry->bDirect ); if ( p2 ) { @@ -757,7 +757,7 @@ bool Storage::CopyTo( const OUString& rElem, BaseStorage* pDest, const OUString& { // stream copy BaseStorageStream* p1 = OpenStream( rElem, INTERNAL_MODE ); - BaseStorageStream* p2 = pDest->OpenStream( rNew, STREAM_WRITE | STREAM_SHARE_DENYALL, pEntry->bDirect ); + BaseStorageStream* p2 = pDest->OpenStream( rNew, StreamMode::WRITE | StreamMode::SHARE_DENYALL, pEntry->bDirect ); if ( p2 ) { @@ -900,7 +900,7 @@ bool Storage::Commit() bool bRes = true; if( !Validate() ) return false; - if( !( m_nMode & STREAM_WRITE ) ) + if( !( m_nMode & StreamMode::WRITE ) ) { SetError( SVSTREAM_ACCESS_DENIED ); return false; diff --git a/sot/source/sdstor/stgcache.cxx b/sot/source/sdstor/stgcache.cxx index 2e3d33b1e3e0..7b96e4f456ea 100644 --- a/sot/source/sdstor/stgcache.cxx +++ b/sot/source/sdstor/stgcache.cxx @@ -283,12 +283,12 @@ void StgCache::SetDirty( const rtl::Reference< StgPage > &xPage ) bool StgCache::Open( const OUString& rName, StreamMode nMode ) { // do not open in exclusive mode! - if( nMode & STREAM_SHARE_DENYALL ) - nMode = ( ( nMode & ~STREAM_SHARE_DENYALL ) | STREAM_SHARE_DENYWRITE ); + if( nMode & StreamMode::SHARE_DENYALL ) + nMode = ( ( nMode & ~StreamMode::SHARE_DENYALL ) | StreamMode::SHARE_DENYWRITE ); SvFileStream* pFileStrm = new SvFileStream( rName, nMode ); // SvStream "Feature" Write Open auch erfolgreich, wenns nicht klappt bool bAccessDenied = false; - if( ( nMode & STREAM_WRITE ) && !pFileStrm->IsWritable() ) + if( ( nMode & StreamMode::WRITE ) && !pFileStrm->IsWritable() ) { pFileStrm->Close(); bAccessDenied = true; diff --git a/sot/source/sdstor/stgdir.cxx b/sot/source/sdstor/stgdir.cxx index df59391314c1..84fcf770287c 100644 --- a/sot/source/sdstor/stgdir.cxx +++ b/sot/source/sdstor/stgdir.cxx @@ -73,7 +73,7 @@ void StgDirEntry::InitMembers() nPos = nEntry = nRefCnt = 0; - nMode = STREAM_READ; + nMode = StreamMode::READ; bDirect = true; bInvalid = bCreated = @@ -307,7 +307,7 @@ sal_Int32 StgDirEntry::GetSize() bool StgDirEntry::SetSize( sal_Int32 nNewSize ) { if ( - !( nMode & STREAM_WRITE ) || + !( nMode & StreamMode::WRITE ) || (!bDirect && !pTmpStrm && !Strm2Tmp()) ) { @@ -418,9 +418,9 @@ sal_Int32 StgDirEntry::Seek( sal_Int32 nNew ) // try to enlarge, the readonly streams should not allow this if( nNew > nSize ) { - if ( !( nMode & STREAM_WRITE ) || !SetSize( nNew ) ) + if ( !( nMode & StreamMode::WRITE ) || !SetSize( nNew ) ) { - SAL_WARN_IF(!(nMode & STREAM_WRITE), "sot", + SAL_WARN_IF(!(nMode & StreamMode::WRITE), "sot", "Trying to resize readonly stream by seeking, could be a wrong offset: " << nNew); return nPos; } @@ -461,7 +461,7 @@ sal_Int32 StgDirEntry::Read( void* p, sal_Int32 nLen ) sal_Int32 StgDirEntry::Write( const void* p, sal_Int32 nLen ) { - if( nLen <= 0 || !( nMode & STREAM_WRITE ) ) + if( nLen <= 0 || !( nMode & StreamMode::WRITE ) ) return 0; // Was this stream committed internally and reopened in direct mode? @@ -524,7 +524,7 @@ void StgDirEntry::Copy( BaseStorageStream& rDest ) bool StgDirEntry::Commit() { - // OSL_ENSURE( nMode & STREAM_WRITE, "Trying to commit readonly stream!" ); + // OSL_ENSURE( nMode & StreamMode::WRITE, "Trying to commit readonly stream!" ); aSave = aEntry; bool bRes = true; diff --git a/sot/source/sdstor/stgelem.cxx b/sot/source/sdstor/stgelem.cxx index 45ad9679a744..2c6cd6245c87 100644 --- a/sot/source/sdstor/stgelem.cxx +++ b/sot/source/sdstor/stgelem.cxx @@ -367,7 +367,7 @@ bool StgEntry::Load( const void* pFrom, sal_uInt32 nBufSize ) if ( nBufSize < 128 ) return false; - SvMemoryStream r( (sal_Char*) pFrom, nBufSize, STREAM_READ ); + SvMemoryStream r( (sal_Char*) pFrom, nBufSize, StreamMode::READ ); for( short i = 0; i < 32; i++ ) r.ReadUInt16( nName[ i ] ); // 00 name as WCHAR r.ReadUInt16( nNameLen ) // 40 size of name in bytes including 00H @@ -413,7 +413,7 @@ bool StgEntry::Load( const void* pFrom, sal_uInt32 nBufSize ) void StgEntry::Store( void* pTo ) { - SvMemoryStream r( (sal_Char *)pTo, 128, STREAM_WRITE ); + SvMemoryStream r( (sal_Char *)pTo, 128, StreamMode::WRITE ); for( short i = 0; i < 32; i++ ) r.WriteUInt16( nName[ i ] ); // 00 name as WCHAR r.WriteUInt16( nNameLen ) // 40 size of name in bytes including 00H diff --git a/sot/source/sdstor/stgio.cxx b/sot/source/sdstor/stgio.cxx index a1c41b7f0be8..953bee3c4cb0 100644 --- a/sot/source/sdstor/stgio.cxx +++ b/sot/source/sdstor/stgio.cxx @@ -363,7 +363,7 @@ sal_uLong StgIo::ValidateFATs() StgIo aIo; if( aIo.Open( pFileStrm->GetFileName(), - STREAM_READ | STREAM_SHARE_DENYNONE) && + StreamMode::READ | StreamMode::SHARE_DENYNONE) && aIo.Load() ) { pV = new Validator( aIo ); diff --git a/sot/source/sdstor/stgole.cxx b/sot/source/sdstor/stgole.cxx index ac98f71fbd88..254cfe51277e 100644 --- a/sot/source/sdstor/stgole.cxx +++ b/sot/source/sdstor/stgole.cxx @@ -32,9 +32,9 @@ StgInternalStream::StgInternalStream( BaseStorage& rStg, const OUString& rName, bool bWr ) { bIsWritable = true; - sal_uInt16 nMode = bWr - ? STREAM_WRITE | STREAM_SHARE_DENYALL - : STREAM_READ | STREAM_SHARE_DENYWRITE | STREAM_NOCREATE; + StreamMode nMode = bWr + ? StreamMode::WRITE | StreamMode::SHARE_DENYALL + : StreamMode::READ | StreamMode::SHARE_DENYWRITE | StreamMode::NOCREATE; pStrm = rStg.OpenStream( rName, nMode ); // set the error code right here in the stream diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx index 0294a6ca4ea4..30262d25fc49 100644 --- a/sot/source/sdstor/storage.cxx +++ b/sot/source/sdstor/storage.cxx @@ -84,7 +84,7 @@ SotStorageStream::SotStorageStream( const OUString & rName, StreamMode nMode, : SvStream( MakeLockBytes_Impl( rName, nMode ) ) , pOwnStm( NULL ) { - if( nMode & STREAM_WRITE ) + if( nMode & StreamMode::WRITE ) bIsWritable = true; else bIsWritable = false; @@ -96,7 +96,7 @@ SotStorageStream::SotStorageStream( BaseStorageStream * pStm ) { if( pStm ) { - if( STREAM_WRITE & pStm->GetMode() ) + if( StreamMode::WRITE & pStm->GetMode() ) bIsWritable = true; else bIsWritable = false; @@ -345,7 +345,7 @@ SotStorage::SotStorage() // ??? What's this ??? } -#define ERASEMASK ( STREAM_TRUNC | STREAM_WRITE | STREAM_SHARE_DENYALL ) +#define ERASEMASK ( StreamMode::TRUNC | StreamMode::WRITE | StreamMode::SHARE_DENYALL ) #include <com/sun/star/uno/Reference.h> #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <ucbhelper/content.hxx> @@ -420,7 +420,7 @@ void SotStorage::CreateStorage( bool bForceUCBStorage, StreamMode nMode, Storage { // detect special disk spanned storages if ( UCBStorage::IsDiskSpannedFile( m_pStorStm ) ) - nMode |= STORAGE_DISKSPANNED_MODE; + nStorageMode |= STORAGE_DISKSPANNED_MODE; // UCBStorage always works directly on the UCB content, so discard the stream first DELETEZ( m_pStorStm ); @@ -751,7 +751,7 @@ SotStorageStream * SotStorage::OpenSotStream( const OUString & rEleName, { // volle Ole-Patches einschalten // egal was kommt, nur exclusiv gestattet - nMode |= STREAM_SHARE_DENYALL; + nMode |= StreamMode::SHARE_DENYALL; ErrCode nE = m_pOwnStg->GetError(); BaseStorageStream * p = m_pOwnStg->OpenStream( rEleName, nMode, (nStorageMode & STORAGE_TRANSACTED) ? false : true ); @@ -759,7 +759,7 @@ SotStorageStream * SotStorage::OpenSotStream( const OUString & rEleName, if( !nE ) m_pOwnStg->ResetError(); // kein Fehler setzen - if( nMode & STREAM_TRUNC ) + if( nMode & StreamMode::TRUNC ) pStm->SetSize( 0 ); } else @@ -775,7 +775,7 @@ SotStorage * SotStorage::OpenSotStorage( const OUString & rEleName, DBG_ASSERT( Owner(), "must be owner" ); if( m_pOwnStg ) { - nMode |= STREAM_SHARE_DENYALL; + nMode |= StreamMode::SHARE_DENYALL; ErrCode nE = m_pOwnStg->GetError(); BaseStorage * p = m_pOwnStg->OpenStorage(rEleName, nMode, !transacted); if( p ) @@ -914,11 +914,11 @@ SotStorage* SotStorage::OpenOLEStorage( const com::sun::star::uno::Reference < c const OUString& rEleName, StreamMode nMode ) { sal_Int32 nEleMode = embed::ElementModes::SEEKABLEREAD; - if ( nMode & STREAM_WRITE ) + if ( nMode & StreamMode::WRITE ) nEleMode |= embed::ElementModes::WRITE; - if ( nMode & STREAM_TRUNC ) + if ( nMode & StreamMode::TRUNC ) nEleMode |= embed::ElementModes::TRUNCATE; - if ( nMode & STREAM_NOCREATE ) + if ( nMode & StreamMode::NOCREATE ) nEleMode |= embed::ElementModes::NOCREATE; SvStream* pStream = NULL; @@ -927,7 +927,7 @@ SotStorage* SotStorage::OpenOLEStorage( const com::sun::star::uno::Reference < c uno::Reference < io::XStream > xStream = xStorage->openStreamElement( rEleName, nEleMode ); // TODO/LATER: should it be done this way? - if ( nMode & STREAM_WRITE ) + if ( nMode & StreamMode::WRITE ) { uno::Reference < beans::XPropertySet > xStreamProps( xStream, uno::UNO_QUERY_THROW ); xStreamProps->setPropertyValue( diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx index 441a7b7e8873..6e9243e40b3d 100644 --- a/sot/source/sdstor/ucbstorage.cxx +++ b/sot/source/sdstor/ucbstorage.cxx @@ -523,7 +523,7 @@ public: { long nError = m_nError; ReadContent(); - if ( m_nMode & STREAM_WRITE ) + if ( m_nMode & StreamMode::WRITE ) { m_nError = nError; if ( m_pAntiImpl ) @@ -643,7 +643,7 @@ UCBStorageStream_Impl::UCBStorageStream_Impl( const OUString& rName, StreamMode , m_nRepresentMode( nonset ) , m_nError( 0 ) , m_nMode( nMode ) - , m_bSourceRead( !( nMode & STREAM_TRUNC ) ) + , m_bSourceRead( !( nMode & StreamMode::TRUNC ) ) , m_bModified( false ) , m_bCommited( false ) , m_bDirect( bDirect ) @@ -925,7 +925,7 @@ sal_uLong UCBStorageStream_Impl::GetData( void* pData, sal_uLong nSize ) sal_uLong UCBStorageStream_Impl::PutData( const void* pData, sal_uLong nSize ) { - if ( !(m_nMode & STREAM_WRITE) ) + if ( !(m_nMode & StreamMode::WRITE) ) { SetError( ERRCODE_IO_ACCESSDENIED ); return 0; // ?mav? @@ -986,7 +986,7 @@ sal_uInt64 UCBStorageStream_Impl::SeekPos(sal_uInt64 const nPos) DBG_ASSERT( aResult == m_pStream->Tell(), "Error in stream arithmetic!\n" ); } - if( (m_nMode & STREAM_WRITE) && !m_bSourceRead && aResult < nPos ) + if( (m_nMode & StreamMode::WRITE) && !m_bSourceRead && aResult < nPos ) { // it means that all the Source stream was copied already // but the required position still was not reached @@ -1004,7 +1004,7 @@ sal_uInt64 UCBStorageStream_Impl::SeekPos(sal_uInt64 const nPos) void UCBStorageStream_Impl::SetSize(sal_uInt64 const nSize) { - if ( !(m_nMode & STREAM_WRITE) ) + if ( !(m_nMode & StreamMode::WRITE) ) { SetError( ERRCODE_IO_ACCESSDENIED ); return; @@ -1105,8 +1105,8 @@ sal_Int16 UCBStorageStream_Impl::Commit() Free(); // the temporary file does not exist only for truncated streams - DBG_ASSERT( !m_aTempURL.isEmpty() || ( m_nMode & STREAM_TRUNC ), "No temporary file to read from!"); - if ( m_aTempURL.isEmpty() && !( m_nMode & STREAM_TRUNC ) ) + DBG_ASSERT( !m_aTempURL.isEmpty() || ( m_nMode & StreamMode::TRUNC ), "No temporary file to read from!"); + if ( m_aTempURL.isEmpty() && !( m_nMode & StreamMode::TRUNC ) ) throw RuntimeException(); // create wrapper to stream that is only used while reading inside package component @@ -1177,12 +1177,12 @@ bool UCBStorageStream_Impl::Revert() m_rSource = m_pContent->openStream(); if( m_rSource.is() ) { - if ( m_pAntiImpl && ( m_nMode & STREAM_TRUNC ) ) + if ( m_pAntiImpl && ( m_nMode & StreamMode::TRUNC ) ) // stream is in use and should be truncated m_bSourceRead = false; else { - m_nMode &= ~STREAM_TRUNC; + m_nMode &= ~StreamMode::TRUNC; m_bSourceRead = true; } } @@ -1238,17 +1238,17 @@ void UCBStorageStream_Impl::Free() void UCBStorageStream_Impl::PrepareCachedForReopen( StreamMode nMode ) { - bool isWritable = (( m_nMode & STREAM_WRITE ) != 0 ); + bool isWritable = bool( m_nMode & StreamMode::WRITE ); if ( isWritable ) { // once stream was writable, never reset to readonly - nMode |= STREAM_WRITE; + nMode |= StreamMode::WRITE; } m_nMode = nMode; Free(); - if ( nMode & STREAM_TRUNC ) + if ( nMode & StreamMode::TRUNC ) { m_bSourceRead = false; // usually it should be 0 already but just in case... @@ -1280,7 +1280,7 @@ UCBStorageStream::UCBStorageStream( UCBStorageStream_Impl *pImpl ) UCBStorageStream::~UCBStorageStream() { - if ( pImp->m_nMode & STREAM_WRITE ) + if ( pImp->m_nMode & StreamMode::WRITE ) pImp->Flush(); pImp->m_pAntiImpl = NULL; pImp->Free(); @@ -1325,22 +1325,19 @@ bool UCBStorageStream::SetSize( sal_uLong nNewSize ) bool UCBStorageStream::Validate( bool bWrite ) const { - return ( !bWrite || ( pImp->m_nMode & STREAM_WRITE ) ); + return ( !bWrite || ( pImp->m_nMode & StreamMode::WRITE ) ); } bool UCBStorageStream::ValidateMode( StreamMode m ) const { // ??? - if( m == ( STREAM_READ | STREAM_TRUNC ) ) // from stg.cxx + if( m == ( StreamMode::READ | StreamMode::TRUNC ) ) // from stg.cxx return true; - sal_uInt16 nCurMode = 0xFFFF; - if( ( m & 3 ) == STREAM_READ ) + if( ( m & STREAM_READWRITE) == StreamMode::READ ) { // only SHARE_DENYWRITE or SHARE_DENYALL allowed - if( ( ( m & STREAM_SHARE_DENYWRITE ) - && ( nCurMode & STREAM_SHARE_DENYWRITE ) ) - || ( ( m & STREAM_SHARE_DENYALL ) - && ( nCurMode & STREAM_SHARE_DENYALL ) ) ) + if( ( m & StreamMode::SHARE_DENYWRITE ) + || ( m & StreamMode::SHARE_DENYALL ) ) return true; } else @@ -1348,8 +1345,7 @@ bool UCBStorageStream::ValidateMode( StreamMode m ) const // only SHARE_DENYALL allowed // storages open in r/o mode are OK, since only // the commit may fail - if( ( m & STREAM_SHARE_DENYALL ) - && ( nCurMode & STREAM_SHARE_DENYALL ) ) + if( m & StreamMode::SHARE_DENYALL ) return true; } @@ -1461,9 +1457,9 @@ UCBStorage::UCBStorage( SvStream& rStrm, bool bDirect ) OUString aURL = GetLinkedFile( rStrm ); if ( !aURL.isEmpty() ) { - StreamMode nMode = STREAM_READ; + StreamMode nMode = StreamMode::READ; if( rStrm.IsWritable() ) - nMode = STREAM_READ | STREAM_WRITE; + nMode = StreamMode::READ | StreamMode::WRITE; ::ucbhelper::Content aContent( aURL, Reference < XCommandEnvironment >(), comphelper::getProcessComponentContext() ); pImp = new UCBStorage_Impl( aContent, aURL, nMode, this, bDirect, true ); @@ -1599,7 +1595,7 @@ UCBStorage_Impl::UCBStorage_Impl( const OUString& rName, StreamMode nMode, UCBSt aTemp += INetURLObject::encode( aName, INetURLObject::PART_AUTHORITY, '%', INetURLObject::ENCODE_ALL ); m_aURL = aTemp; - if ( m_nMode & STREAM_WRITE ) + if ( m_nMode & StreamMode::WRITE ) { // the root storage opens the package, so make sure that there is any SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aName, STREAM_STD_READWRITE, m_pTempFile != 0 /* bFileExists */ ); @@ -1658,9 +1654,9 @@ UCBStorage_Impl::UCBStorage_Impl( SvStream& rStream, UCBStorage* pStorage, bool m_pSource->Seek(0); // check opening mode - m_nMode = STREAM_READ; + m_nMode = StreamMode::READ; if( rStream.IsWritable() ) - m_nMode = STREAM_READ | STREAM_WRITE; + m_nMode = StreamMode::READ | StreamMode::WRITE; } void UCBStorage_Impl::Init() @@ -1671,17 +1667,10 @@ void UCBStorage_Impl::Init() // if the name was not already set to a temp name m_aName = m_aOriginalName = aObj.GetLastName(); - // don't create the content for disk spanned files, avoid too early access to directory and/or manifest - if ( !m_pContent && !( m_nMode & STORAGE_DISKSPANNED_MODE ) ) + if ( !m_pContent ) CreateContent(); - if ( m_nMode & STORAGE_DISKSPANNED_MODE ) - { - // Hack! Avoid access to the manifest file until mediatype is not available in the first segment of a - // disk spanned file - m_aContentType = m_aOriginalContentType = "application/vnd.sun.xml.impress"; - } - else if ( m_pContent ) + if ( m_pContent ) { if ( m_bIsLinked ) { @@ -1882,7 +1871,7 @@ void UCBStorage_Impl::ReadContent() catch (const CommandAbortedException&) { // any command wasn't executed successfully - not specified - if ( !( m_nMode & STREAM_WRITE ) ) + if ( !( m_nMode & StreamMode::WRITE ) ) // if the folder was just inserted and not already committed, this is not an error! SetError( ERRCODE_IO_GENERAL ); } @@ -2130,7 +2119,7 @@ sal_Int16 UCBStorage_Impl::Commit() // there is nothing to do if the storage has been opened readonly or if it was opened in transacted mode and no // commit command has been sent - if ( ( m_nMode & STREAM_WRITE ) && ( m_bCommited || m_bDirect ) ) + if ( ( m_nMode & StreamMode::WRITE ) && ( m_bCommited || m_bDirect ) ) { try { @@ -2533,7 +2522,7 @@ bool UCBStorage::CopyStorageElement_Impl( UCBStorageElement_Impl& rElement, Base { // copy the streams data // the destination stream must not be open - boost::scoped_ptr<BaseStorageStream> pOtherStream(pDest->OpenStream( rNew, STREAM_WRITE | STREAM_SHARE_DENYALL, pImp->m_bDirect )); + boost::scoped_ptr<BaseStorageStream> pOtherStream(pDest->OpenStream( rNew, StreamMode::WRITE | StreamMode::SHARE_DENYALL, pImp->m_bDirect )); BaseStorageStream* pStream = NULL; bool bDeleteStream = false; @@ -2577,8 +2566,8 @@ bool UCBStorage::CopyStorageElement_Impl( UCBStorageElement_Impl& rElement, Base bool bOpenUCBStorage = pUCBDest && pUCBCopy; boost::scoped_ptr<BaseStorage> pOtherStorage(bOpenUCBStorage ? - pDest->OpenUCBStorage( rNew, STREAM_WRITE | STREAM_SHARE_DENYALL, pImp->m_bDirect ) : - pDest->OpenOLEStorage( rNew, STREAM_WRITE | STREAM_SHARE_DENYALL, pImp->m_bDirect )); + pDest->OpenUCBStorage( rNew, StreamMode::WRITE | StreamMode::SHARE_DENYALL, pImp->m_bDirect ) : + pDest->OpenOLEStorage( rNew, StreamMode::WRITE | StreamMode::SHARE_DENYALL, pImp->m_bDirect )); // For UCB storages, the class id and the format id may differ, // do passing the class id is not sufficient. @@ -2695,9 +2684,9 @@ BaseStorageStream* UCBStorage::OpenStream( const OUString& rEleName, StreamMode if ( !pElement ) { // element does not exist, check if creation is allowed - if( ( nMode & STREAM_NOCREATE ) ) + if( ( nMode & StreamMode::NOCREATE ) ) { - SetError( ( nMode & STREAM_WRITE ) ? SVSTREAM_CANNOT_MAKE : SVSTREAM_FILE_NOT_FOUND ); + SetError( ( nMode & StreamMode::WRITE ) ? SVSTREAM_CANNOT_MAKE : SVSTREAM_FILE_NOT_FOUND ); OUString aName( pImp->m_aURL ); aName += "/"; aName += rEleName; @@ -2794,9 +2783,9 @@ BaseStorage* UCBStorage::OpenStorage_Impl( const OUString& rEleName, StreamMode if ( !pElement ) { // element does not exist, check if creation is allowed - if( ( nMode & STREAM_NOCREATE ) ) + if( ( nMode & StreamMode::NOCREATE ) ) { - SetError( ( nMode & STREAM_WRITE ) ? SVSTREAM_CANNOT_MAKE : SVSTREAM_FILE_NOT_FOUND ); + SetError( ( nMode & StreamMode::WRITE ) ? SVSTREAM_CANNOT_MAKE : SVSTREAM_FILE_NOT_FOUND ); OUString aName( pImp->m_aURL ); aName += "/"; aName += rEleName; // ??? @@ -2827,7 +2816,7 @@ BaseStorage* UCBStorage::OpenStorage_Impl( const OUString& rEleName, StreamMode UCBStorageStream* pStream = PTR_CAST( UCBStorageStream, pStr ); if ( !pStream ) { - SetError( ( nMode & STREAM_WRITE ) ? SVSTREAM_CANNOT_MAKE : SVSTREAM_FILE_NOT_FOUND ); + SetError( ( nMode & StreamMode::WRITE ) ? SVSTREAM_CANNOT_MAKE : SVSTREAM_FILE_NOT_FOUND ); return NULL; } @@ -2839,7 +2828,7 @@ BaseStorage* UCBStorage::OpenStorage_Impl( const OUString& rEleName, StreamMode bool bInited = pElement->m_xStream->Init(); if (!bInited) { - SetError( ( nMode & STREAM_WRITE ) ? SVSTREAM_CANNOT_MAKE : SVSTREAM_FILE_NOT_FOUND ); + SetError( ( nMode & StreamMode::WRITE ) ? SVSTREAM_CANNOT_MAKE : SVSTREAM_FILE_NOT_FOUND ); return NULL; } @@ -2856,8 +2845,8 @@ BaseStorage* UCBStorage::OpenStorage_Impl( const OUString& rEleName, StreamMode } else { - bool bIsWritable = (( pElement->m_xStorage->m_nMode & STREAM_WRITE ) != 0); - if ( !bIsWritable && (( nMode & STREAM_WRITE ) != 0 )) + bool bIsWritable = bool( pElement->m_xStorage->m_nMode & StreamMode::WRITE ); + if ( !bIsWritable && ( nMode & StreamMode::WRITE ) ) { OUString aName( pImp->m_aURL ); aName += "/"; @@ -2875,7 +2864,7 @@ BaseStorage* UCBStorage::OpenStorage_Impl( const OUString& rEleName, StreamMode else if ( !pElement->m_xStream.Is() ) { // storage is opened the first time - bool bIsWritable = (( pImp->m_nMode & STREAM_WRITE ) != 0 ); + bool bIsWritable = bool(pImp->m_nMode & StreamMode::WRITE); if ( pImp->m_bIsLinked && pImp->m_bIsRoot && bIsWritable ) { // make sure that the root storage object has been created before substorages will be created @@ -3050,33 +3039,19 @@ bool UCBStorage::ValidateFAT() bool UCBStorage::Validate( bool bWrite ) const { // ??? - return ( !bWrite || ( pImp->m_nMode & STREAM_WRITE ) ); + return ( !bWrite || ( pImp->m_nMode & StreamMode::WRITE ) ); } bool UCBStorage::ValidateMode( StreamMode m ) const { // ??? - if( m == ( STREAM_READ | STREAM_TRUNC ) ) // from stg.cxx + if( m == ( StreamMode::READ | StreamMode::TRUNC ) ) // from stg.cxx + return true; + // only SHARE_DENYALL allowed + // storages open in r/o mode are OK, since only + // the commit may fail + if( m & StreamMode::SHARE_DENYALL ) return true; - sal_uInt16 nCurMode = 0xFFFF; - if( ( m & 3 ) == STREAM_READ ) - { - // only SHARE_DENYWRITE or SHARE_DENYALL allowed - if( ( ( m & STREAM_SHARE_DENYWRITE ) - && ( nCurMode & STREAM_SHARE_DENYWRITE ) ) - || ( ( m & STREAM_SHARE_DENYALL ) - && ( nCurMode & STREAM_SHARE_DENYALL ) ) ) - return true; - } - else - { - // only SHARE_DENYALL allowed - // storages open in r/o mode are OK, since only - // the commit may fail - if( ( m & STREAM_SHARE_DENYALL ) - && ( nCurMode & STREAM_SHARE_DENYALL ) ) - return true; - } return true; } @@ -3186,7 +3161,7 @@ OUString UCBStorage::CreateLinkFile( const OUString& rName ) boost::scoped_ptr< ::utl::TempFile> pTempFile(new ::utl::TempFile( &aFolderURL )); // get the stream from the temp file - SvStream* pStream = pTempFile->GetStream( STREAM_STD_READWRITE | STREAM_TRUNC ); + SvStream* pStream = pTempFile->GetStream( STREAM_STD_READWRITE | StreamMode::TRUNC ); // write header pStream->WriteUInt32( 0x04034b50 ); diff --git a/sot/source/unoolestorage/xolesimplestorage.cxx b/sot/source/unoolestorage/xolesimplestorage.cxx index 368da14a3639..fd4b822e9643 100644 --- a/sot/source/unoolestorage/xolesimplestorage.cxx +++ b/sot/source/unoolestorage/xolesimplestorage.cxx @@ -489,7 +489,7 @@ uno::Any SAL_CALL OLESimpleStorage::getByName( const OUString& aName ) } else { - BaseStorageStream* pStream = m_pStorage->OpenStream( aName, STREAM_READ | STREAM_SHARE_DENYALL | STREAM_NOCREATE ); + BaseStorageStream* pStream = m_pStorage->OpenStream( aName, StreamMode::READ | StreamMode::SHARE_DENYALL | StreamMode::NOCREATE ); try { if ( !pStream || pStream->GetError() || m_pStorage->GetError() ) |