You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by or...@apache.org on 2012/08/14 15:40:36 UTC
svn commit: r1372879 - in /incubator/ooo/trunk/main/sot/source/sdstor:
stgelem.cxx stgelem.hxx
Author: orw
Date: Tue Aug 14 13:40:36 2012
New Revision: 1372879
URL: http://svn.apache.org/viewvc?rev=1372879&view=rev
Log:
some refactoring on <StgHeader>
Modified:
incubator/ooo/trunk/main/sot/source/sdstor/stgelem.cxx
incubator/ooo/trunk/main/sot/source/sdstor/stgelem.hxx
Modified: incubator/ooo/trunk/main/sot/source/sdstor/stgelem.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sot/source/sdstor/stgelem.cxx?rev=1372879&r1=1372878&r2=1372879&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sot/source/sdstor/stgelem.cxx (original)
+++ incubator/ooo/trunk/main/sot/source/sdstor/stgelem.cxx Tue Aug 14 13:40:36 2012
@@ -114,7 +114,7 @@ void StgHeader::Init()
SetTOCStart( STG_EOF );
SetDataFATStart( STG_EOF );
- for( short i = 0; i < 109; i++ )
+ for( short i = 0; i < cFATPagesInHeader; i++ )
SetFATPage( i, STG_FREE );
}
@@ -149,7 +149,7 @@ sal_Bool StgHeader::Load( SvStream& r )
>> nDataFATSize // 40 # of data FATpages
>> nMasterChain // 44 chain to the next master block
>> nMaster; // 48 # of additional master blocks
- for( short i = 0; i < 109; i++ )
+ for( short i = 0; i < cFATPagesInHeader; i++ )
r >> nMasterFAT[ i ];
return ( r.GetErrorCode() == ERRCODE_NONE && Check() );
@@ -175,7 +175,7 @@ sal_Bool StgHeader::Store( StgIo& rIo )
<< nDataFATSize // 40 # of data FAT pages
<< nMasterChain // 44 chain to the next master block
<< nMaster; // 48 # of additional master blocks
- for( short i = 0; i < 109; i++ )
+ for( short i = 0; i < cFATPagesInHeader; i++ )
r << nMasterFAT[ i ];
bDirty = !rIo.Good();
return sal_Bool( !bDirty );
@@ -197,14 +197,14 @@ sal_Bool StgHeader::Check()
&& nFATSize > 0
&& nTOCstrm >= 0
&& nThreshold > 0
- && ( nDataFAT == -2 || ( nDataFAT >= 0 && nDataFATSize > 0 ) )
- && ( nMasterChain == -2 || ( nMasterChain >=0 && nMaster > 109 ) )
+ && ( nDataFAT == STG_EOF || ( nDataFAT >= 0 && nDataFATSize > 0 ) )
+ && ( nMasterChain == STG_EOF || ( nMasterChain >=0 && nMaster > 0 ) )
&& nMaster >= 0;
}
sal_Int32 StgHeader::GetFATPage( short n ) const
{
- if( n >= 0 && n < 109 )
+ if( n >= 0 && n < cFATPagesInHeader )
return nMasterFAT[ n ];
else
return STG_EOF;
@@ -212,7 +212,7 @@ sal_Int32 StgHeader::GetFATPage( short n
void StgHeader::SetFATPage( short n, sal_Int32 nb )
{
- if( n >= 0 && n < 109 )
+ if( n >= 0 && n < cFATPagesInHeader )
{
if( nMasterFAT[ n ] != nb )
bDirty = sal_True, nMasterFAT[ n ] = nb;
@@ -436,7 +436,9 @@ sal_Bool StgEntry::Load( const void* pFr
sal_uInt16 n = nNameLen;
if( n )
n = ( n >> 1 ) - 1;
- if( n > 31 || (nSize < 0 && cType != STG_STORAGE) || ( nPage1 < 0 && nPage1 != -2 ) )
+ if ( n > 31 ||
+ (nSize < 0 && cType != STG_STORAGE) ||
+ ( nPage1 < 0 && nPage1 != STG_EOF ) )
{
// the size makes no sence for the substorage
// TODO/LATER: actually the size should be an unsigned value, but in this case it would mean a stream of more than 2Gb
Modified: incubator/ooo/trunk/main/sot/source/sdstor/stgelem.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sot/source/sdstor/stgelem.hxx?rev=1372879&r1=1372878&r2=1372879&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sot/source/sdstor/stgelem.hxx (original)
+++ incubator/ooo/trunk/main/sot/source/sdstor/stgelem.hxx Tue Aug 14 13:40:36 2012
@@ -42,23 +42,25 @@ SvStream& operator<<( SvStream&, const C
class StgHeader
{
- sal_uInt8 cSignature[ 8 ]; // 00 signature (see below)
- ClsId aClsId; // 08 Class ID
- sal_Int32 nVersion; // 18 version number
- sal_uInt16 nByteOrder; // 1C Unicode byte order indicator
- sal_Int16 nPageSize; // 1E 1 << nPageSize = block size
- sal_Int16 nDataPageSize; // 20 1 << this size == data block size
- sal_uInt8 bDirty; // 22 internal dirty flag
- sal_uInt8 cReserved[ 9 ]; // 23
- sal_Int32 nFATSize; // 2C total number of FAT pages
- sal_Int32 nTOCstrm; // 30 starting page for the TOC stream
- sal_Int32 nReserved; // 34
- sal_Int32 nThreshold; // 38 minimum file size for big data
- sal_Int32 nDataFAT; // 3C page # of 1st data FAT block
- sal_Int32 nDataFATSize; // 40 # of data fat blocks
- sal_Int32 nMasterChain; // 44 chain to the next master block
- sal_Int32 nMaster; // 48 # of additional master blocks
- sal_Int32 nMasterFAT[ 109 ]; // 4C first 109 master FAT pages
+ static const sal_uInt8 cFATPagesInHeader = 109;
+
+ sal_uInt8 cSignature[ 8 ]; // 00 signature (see below)
+ ClsId aClsId; // 08 Class ID
+ sal_Int32 nVersion; // 18 version number
+ sal_uInt16 nByteOrder; // 1C Unicode byte order indicator
+ sal_Int16 nPageSize; // 1E 1 << nPageSize = block size
+ sal_Int16 nDataPageSize; // 20 1 << this size == data block size
+ sal_uInt8 bDirty; // 22 internal dirty flag
+ sal_uInt8 cReserved[ 9 ]; // 23
+ sal_Int32 nFATSize; // 2C total number of FAT pages
+ sal_Int32 nTOCstrm; // 30 starting page for the TOC stream
+ sal_Int32 nReserved; // 34
+ sal_Int32 nThreshold; // 38 minimum file size for big data
+ sal_Int32 nDataFAT; // 3C page # of 1st data FAT block
+ sal_Int32 nDataFATSize; // 40 # of data fat blocks
+ sal_Int32 nMasterChain; // 44 chain to the next master block
+ sal_Int32 nMaster; // 48 # of additional master blocks
+ sal_Int32 nMasterFAT[ cFATPagesInHeader ]; // 4C first [cFATPagesInHeader] master FAT pages
public:
StgHeader();
@@ -67,23 +69,23 @@ public:
sal_Bool Load( SvStream& );
sal_Bool Store( StgIo& );
sal_Bool Check(); // check the signature and version
- short GetByteOrder() const { return nByteOrder; }
- sal_Int32 GetTOCStart() const { return nTOCstrm; }
+ short GetByteOrder() const { return nByteOrder; }
+ sal_Int32 GetTOCStart() const { return nTOCstrm; }
void SetTOCStart( sal_Int32 n );
- sal_Int32 GetDataFATStart() const { return nDataFAT; }
+ sal_Int32 GetDataFATStart() const { return nDataFAT; }
void SetDataFATStart( sal_Int32 n );
- sal_Int32 GetDataFATSize() const { return nDataFATSize; }
+ sal_Int32 GetDataFATSize() const { return nDataFATSize; }
void SetDataFATSize( sal_Int32 n );
- sal_Int32 GetThreshold() const { return nThreshold; }
- short GetPageSize() const { return nPageSize; }
- short GetDataPageSize() const { return nDataPageSize; }
- sal_Int32 GetFATSize() const { return nFATSize; }
+ sal_Int32 GetThreshold() const { return nThreshold; }
+ short GetPageSize() const { return nPageSize; }
+ short GetDataPageSize() const { return nDataPageSize; }
+ sal_Int32 GetFATSize() const { return nFATSize; }
void SetFATSize( sal_Int32 n );
- sal_Int32 GetFATChain() const { return nMasterChain; }
+ sal_Int32 GetFATChain() const { return nMasterChain; }
void SetFATChain( sal_Int32 n );
- sal_Int32 GetMasters() const { return nMaster; }
+ sal_Int32 GetMasters() const { return nMaster; }
void SetMasters( sal_Int32 n );
- short GetFAT1Size() const { return 109; }
+ short GetFAT1Size() const { return cFATPagesInHeader; }
const ClsId& GetClassId() const { return aClsId; }
void SetClassId( const ClsId& );
sal_Int32 GetFATPage( short ) const;