Kaydet (Commit) b5475c7a authored tarafından Miklos Vajna's avatar Miklos Vajna

sot: prefix members of StgCache

Change-Id: If406303ec1685c9d7eebefaf172db0bbf0cd723b
üst 0147e744
...@@ -87,16 +87,16 @@ static sal_Int32 lcl_GetPageCount( sal_uLong nFileSize, short nPageSize ) ...@@ -87,16 +87,16 @@ static sal_Int32 lcl_GetPageCount( sal_uLong nFileSize, short nPageSize )
} }
StgCache::StgCache() StgCache::StgCache()
: nError( SVSTREAM_OK ) : m_nError( SVSTREAM_OK )
, nPages( 0 ) , m_nPages( 0 )
, nRef( 0 ) , m_nRef( 0 )
, nReplaceIdx( 0 ) , m_nReplaceIdx( 0 )
, maLRUPages( 8 ) // entries in the LRU lookup , maLRUPages( 8 ) // entries in the LRU lookup
, nPageSize( 512 ) , m_nPageSize( 512 )
, pStorageStream( NULL ) , m_pStorageStream( NULL )
, pStrm( NULL ) , m_pStrm( NULL )
, bMyStream( false ) , m_bMyStream( false )
, bFile( false ) , m_bFile( false )
{ {
} }
...@@ -111,11 +111,11 @@ void StgCache::SetPhysPageSize( short n ) ...@@ -111,11 +111,11 @@ void StgCache::SetPhysPageSize( short n )
OSL_ENSURE( n >= 512, "Unexpecte page size is provided!" ); OSL_ENSURE( n >= 512, "Unexpecte page size is provided!" );
if ( n >= 512 ) if ( n >= 512 )
{ {
nPageSize = n; m_nPageSize = n;
sal_uLong nPos = pStrm->Tell(); sal_uLong nPos = m_pStrm->Tell();
sal_uLong nFileSize = pStrm->Seek( STREAM_SEEK_TO_END ); sal_uLong nFileSize = m_pStrm->Seek( STREAM_SEEK_TO_END );
nPages = lcl_GetPageCount( nFileSize, nPageSize ); m_nPages = lcl_GetPageCount( nFileSize, m_nPageSize );
pStrm->Seek( nPos ); m_pStrm->Seek( nPos );
} }
} }
...@@ -123,8 +123,8 @@ void StgCache::SetPhysPageSize( short n ) ...@@ -123,8 +123,8 @@ void StgCache::SetPhysPageSize( short n )
rtl::Reference< StgPage > StgCache::Create( sal_Int32 nPg ) rtl::Reference< StgPage > StgCache::Create( sal_Int32 nPg )
{ {
rtl::Reference< StgPage > xElem( StgPage::Create( nPageSize, nPg ) ); rtl::Reference< StgPage > xElem( StgPage::Create( m_nPageSize, nPg ) );
maLRUPages[ nReplaceIdx++ % maLRUPages.size() ] = xElem; maLRUPages[ m_nReplaceIdx++ % maLRUPages.size() ] = xElem;
return xElem; return xElem;
} }
...@@ -230,8 +230,8 @@ bool StgCache::Commit() ...@@ -230,8 +230,8 @@ bool StgCache::Commit()
maDirtyPages.clear(); maDirtyPages.clear();
pStrm->Flush(); m_pStrm->Flush();
SetError( pStrm->GetError() ); SetError( m_pStrm->GetError() );
return true; return true;
} }
...@@ -240,36 +240,36 @@ bool StgCache::Commit() ...@@ -240,36 +240,36 @@ bool StgCache::Commit()
void StgCache::SetStrm( SvStream* p, bool bMy ) void StgCache::SetStrm( SvStream* p, bool bMy )
{ {
if( pStorageStream ) if( m_pStorageStream )
{ {
pStorageStream->ReleaseRef(); m_pStorageStream->ReleaseRef();
pStorageStream = NULL; m_pStorageStream = NULL;
} }
if( bMyStream ) if( m_bMyStream )
delete pStrm; delete m_pStrm;
pStrm = p; m_pStrm = p;
bMyStream = bMy; m_bMyStream = bMy;
} }
void StgCache::SetStrm( UCBStorageStream* pStgStream ) void StgCache::SetStrm( UCBStorageStream* pStgStream )
{ {
if( pStorageStream ) if( m_pStorageStream )
pStorageStream->ReleaseRef(); m_pStorageStream->ReleaseRef();
pStorageStream = pStgStream; m_pStorageStream = pStgStream;
if( bMyStream ) if( m_bMyStream )
delete pStrm; delete m_pStrm;
pStrm = NULL; m_pStrm = NULL;
if ( pStorageStream ) if ( m_pStorageStream )
{ {
pStorageStream->AddFirstRef(); m_pStorageStream->AddFirstRef();
pStrm = pStorageStream->GetModifySvStream(); m_pStrm = m_pStorageStream->GetModifySvStream();
} }
bMyStream = false; m_bMyStream = false;
} }
void StgCache::SetDirty( const rtl::Reference< StgPage > &rPage ) void StgCache::SetDirty( const rtl::Reference< StgPage > &rPage )
...@@ -296,23 +296,23 @@ bool StgCache::Open( const OUString& rName, StreamMode nMode ) ...@@ -296,23 +296,23 @@ bool StgCache::Open( const OUString& rName, StreamMode nMode )
SetStrm( pFileStrm, true ); SetStrm( pFileStrm, true );
if( pFileStrm->IsOpen() ) if( pFileStrm->IsOpen() )
{ {
sal_uLong nFileSize = pStrm->Seek( STREAM_SEEK_TO_END ); sal_uLong nFileSize = m_pStrm->Seek( STREAM_SEEK_TO_END );
nPages = lcl_GetPageCount( nFileSize, nPageSize ); m_nPages = lcl_GetPageCount( nFileSize, m_nPageSize );
pStrm->Seek( 0L ); m_pStrm->Seek( 0L );
} }
else else
nPages = 0; m_nPages = 0;
bFile = true; m_bFile = true;
SetError( bAccessDenied ? ERRCODE_IO_ACCESSDENIED : pStrm->GetError() ); SetError( bAccessDenied ? ERRCODE_IO_ACCESSDENIED : m_pStrm->GetError() );
return Good(); return Good();
} }
void StgCache::Close() void StgCache::Close()
{ {
if( bFile ) if( m_bFile )
{ {
static_cast<SvFileStream*>(pStrm)->Close(); static_cast<SvFileStream*>(m_pStrm)->Close();
SetError( pStrm->GetError() ); SetError( m_pStrm->GetError() );
} }
} }
...@@ -326,28 +326,28 @@ bool StgCache::Read( sal_Int32 nPage, void* pBuf, sal_Int32 nPg ) ...@@ -326,28 +326,28 @@ bool StgCache::Read( sal_Int32 nPage, void* pBuf, sal_Int32 nPg )
last valid page (see document attached to the issue). In that case last valid page (see document attached to the issue). In that case
(if nPage==nPages), just do nothing here and let the caller work on (if nPage==nPages), just do nothing here and let the caller work on
the empty zero-filled buffer. */ the empty zero-filled buffer. */
if ( nPage > nPages ) if ( nPage > m_nPages )
SetError( SVSTREAM_READ_ERROR ); SetError( SVSTREAM_READ_ERROR );
else if ( nPage < nPages ) else if ( nPage < m_nPages )
{ {
sal_uInt32 nPos = Page2Pos( nPage ); sal_uInt32 nPos = Page2Pos( nPage );
sal_Int32 nPg2 = ( ( nPage + nPg ) > nPages ) ? nPages - nPage : nPg; sal_Int32 nPg2 = ( ( nPage + nPg ) > m_nPages ) ? m_nPages - nPage : nPg;
sal_uInt32 nBytes = nPg2 * nPageSize; sal_uInt32 nBytes = nPg2 * m_nPageSize;
// fixed address and size for the header // fixed address and size for the header
if( nPage == -1 ) if( nPage == -1 )
{ {
nPos = 0L, nBytes = 512; nPos = 0L, nBytes = 512;
nPg2 = nPg; nPg2 = nPg;
} }
if( pStrm->Tell() != nPos ) if( m_pStrm->Tell() != nPos )
{ {
pStrm->Seek(nPos); m_pStrm->Seek(nPos);
} }
pStrm->Read( pBuf, nBytes ); m_pStrm->Read( pBuf, nBytes );
if ( nPg != nPg2 ) if ( nPg != nPg2 )
SetError( SVSTREAM_READ_ERROR ); SetError( SVSTREAM_READ_ERROR );
else else
SetError( pStrm->GetError() ); SetError( m_pStrm->GetError() );
} }
} }
return Good(); return Good();
...@@ -359,22 +359,22 @@ bool StgCache::Write( sal_Int32 nPage, void* pBuf, sal_Int32 nPg ) ...@@ -359,22 +359,22 @@ bool StgCache::Write( sal_Int32 nPage, void* pBuf, sal_Int32 nPg )
{ {
sal_uInt32 nPos = Page2Pos( nPage ); sal_uInt32 nPos = Page2Pos( nPage );
sal_uInt32 nBytes = 0; sal_uInt32 nBytes = 0;
if ( SAL_MAX_INT32 / nPg > nPageSize ) if ( SAL_MAX_INT32 / nPg > m_nPageSize )
nBytes = nPg * nPageSize; nBytes = nPg * m_nPageSize;
// fixed address and size for the header // fixed address and size for the header
// nPageSize must be >= 512, otherwise the header can not be written here, we check it on import // nPageSize must be >= 512, otherwise the header can not be written here, we check it on import
if( nPage == -1 ) if( nPage == -1 )
nPos = 0L, nBytes = 512; nPos = 0L, nBytes = 512;
if( pStrm->Tell() != nPos ) if( m_pStrm->Tell() != nPos )
{ {
pStrm->Seek(nPos); m_pStrm->Seek(nPos);
} }
sal_uLong nRes = pStrm->Write( pBuf, nBytes ); sal_uLong nRes = m_pStrm->Write( pBuf, nBytes );
if( nRes != nBytes ) if( nRes != nBytes )
SetError( SVSTREAM_WRITE_ERROR ); SetError( SVSTREAM_WRITE_ERROR );
else else
SetError( pStrm->GetError() ); SetError( m_pStrm->GetError() );
} }
return Good(); return Good();
} }
...@@ -384,31 +384,31 @@ bool StgCache::Write( sal_Int32 nPage, void* pBuf, sal_Int32 nPg ) ...@@ -384,31 +384,31 @@ bool StgCache::Write( sal_Int32 nPage, void* pBuf, sal_Int32 nPg )
bool StgCache::SetSize( sal_Int32 n ) bool StgCache::SetSize( sal_Int32 n )
{ {
// Add the file header // Add the file header
sal_Int32 nSize = n * nPageSize + 512; sal_Int32 nSize = n * m_nPageSize + 512;
pStrm->SetStreamSize( nSize ); m_pStrm->SetStreamSize( nSize );
SetError( pStrm->GetError() ); SetError( m_pStrm->GetError() );
if( !nError ) if( !m_nError )
nPages = n; m_nPages = n;
return Good(); return Good();
} }
void StgCache::SetError( sal_uLong n ) void StgCache::SetError( sal_uLong n )
{ {
if( n && !nError ) if( n && !m_nError )
nError = n; m_nError = n;
} }
void StgCache::ResetError() void StgCache::ResetError()
{ {
nError = SVSTREAM_OK; m_nError = SVSTREAM_OK;
pStrm->ResetError(); m_pStrm->ResetError();
} }
void StgCache::MoveError( StorageBase& r ) void StgCache::MoveError( StorageBase& r )
{ {
if( nError != SVSTREAM_OK ) if( m_nError != SVSTREAM_OK )
{ {
r.SetError( nError ); r.SetError( m_nError );
ResetError(); ResetError();
} }
} }
...@@ -418,7 +418,7 @@ void StgCache::MoveError( StorageBase& r ) ...@@ -418,7 +418,7 @@ void StgCache::MoveError( StorageBase& r )
sal_Int32 StgCache::Page2Pos( sal_Int32 nPage ) sal_Int32 StgCache::Page2Pos( sal_Int32 nPage )
{ {
if( nPage < 0 ) nPage = 0; if( nPage < 0 ) nPage = 0;
return( nPage * nPageSize ) + nPageSize; return( nPage * m_nPageSize ) + m_nPageSize;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -45,36 +45,36 @@ class StgCache ...@@ -45,36 +45,36 @@ class StgCache
typedef std::vector< rtl::Reference< StgPage > > LRUList; typedef std::vector< rtl::Reference< StgPage > > LRUList;
sal_uLong nError; // error code sal_uLong m_nError; // error code
sal_Int32 nPages; // size of data area in pages sal_Int32 m_nPages; // size of data area in pages
sal_uInt16 nRef; // reference count sal_uInt16 m_nRef; // reference count
IndexToStgPage maDirtyPages; // hash of all dirty pages IndexToStgPage maDirtyPages; // hash of all dirty pages
int nReplaceIdx; // index into maLRUPages to replace next int m_nReplaceIdx; // index into maLRUPages to replace next
LRUList maLRUPages; // list of last few non-dirty pages. LRUList maLRUPages; // list of last few non-dirty pages.
short nPageSize; // page size of the file short m_nPageSize; // page size of the file
UCBStorageStream* pStorageStream; // holds reference to UCB storage stream UCBStorageStream* m_pStorageStream; // holds reference to UCB storage stream
void Erase( const rtl::Reference< StgPage >& ); // delete a cache element void Erase( const rtl::Reference< StgPage >& ); // delete a cache element
rtl::Reference< StgPage > Create( sal_Int32 ); // create a cached page rtl::Reference< StgPage > Create( sal_Int32 ); // create a cached page
protected: protected:
SvStream* pStrm; // physical stream SvStream* m_pStrm; // physical stream
bool bMyStream; // true: delete stream in dtor bool m_bMyStream; // true: delete stream in dtor
bool bFile; // true: file stream bool m_bFile; // true: file stream
sal_Int32 Page2Pos( sal_Int32 ); // page address --> file position sal_Int32 Page2Pos( sal_Int32 ); // page address --> file position
public: public:
StgCache(); StgCache();
~StgCache(); ~StgCache();
void IncRef() { nRef++; } void IncRef() { m_nRef++; }
sal_uInt16 DecRef() { return --nRef; } sal_uInt16 DecRef() { return --m_nRef; }
void SetPhysPageSize( short ); void SetPhysPageSize( short );
sal_Int32 GetPhysPages() { return nPages; } sal_Int32 GetPhysPages() { return m_nPages; }
short GetPhysPageSize() { return nPageSize; } short GetPhysPageSize() { return m_nPageSize; }
SvStream* GetStrm() { return pStrm; } SvStream* GetStrm() { return m_pStrm; }
void SetStrm( SvStream*, bool ); void SetStrm( SvStream*, bool );
void SetStrm( UCBStorageStream* ); void SetStrm( UCBStorageStream* );
bool IsWritable() { return ( pStrm && pStrm->IsWritable() ); } bool IsWritable() { return ( m_pStrm && m_pStrm->IsWritable() ); }
bool Good() { return nError == SVSTREAM_OK; } bool Good() { return m_nError == SVSTREAM_OK; }
sal_uLong GetError() { return nError; } sal_uLong GetError() { return m_nError; }
void MoveError( StorageBase& ); void MoveError( StorageBase& );
void SetError( sal_uLong ); void SetError( sal_uLong );
void ResetError(); void ResetError();
......
...@@ -51,7 +51,7 @@ StgIo::~StgIo() ...@@ -51,7 +51,7 @@ StgIo::~StgIo()
bool StgIo::Load() bool StgIo::Load()
{ {
if( pStrm ) if( m_pStrm )
{ {
if( aHdr.Load( *this ) ) if( aHdr.Load( *this ) )
{ {
...@@ -126,8 +126,8 @@ bool StgIo::CommitAll() ...@@ -126,8 +126,8 @@ bool StgIo::CommitAll()
aHdr.SetTOCStart( pTOC->GetStart() ); aHdr.SetTOCStart( pTOC->GetStart() );
if( aHdr.Store( *this ) ) if( aHdr.Store( *this ) )
{ {
pStrm->Flush(); m_pStrm->Flush();
sal_uLong n = pStrm->GetError(); sal_uLong n = m_pStrm->GetError();
SetError( n ); SetError( n );
#ifdef DBG_UTIL #ifdef DBG_UTIL
if( n==0 ) ValidateFATs(); if( n==0 ) ValidateFATs();
...@@ -350,7 +350,7 @@ const Link<StgLinkArg&,void>& StgIo::GetErrorLink() ...@@ -350,7 +350,7 @@ const Link<StgLinkArg&,void>& StgIo::GetErrorLink()
sal_uLong StgIo::ValidateFATs() sal_uLong StgIo::ValidateFATs()
{ {
if( bFile ) if( m_bFile )
{ {
Validator *pV = new Validator( *this ); Validator *pV = new Validator( *this );
bool bRet1 = !pV->IsError(), bRet2 = true ; bool bRet1 = !pV->IsError(), bRet2 = true ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment