sal_Int32 StgHeader::GetFATPage( short n ) const
{ if( n >= 0 && n < cFATPagesInHeader ) return m_nMasterFAT[ n ]; else return STG_EOF;
}
void StgHeader::SetFATPage( short n, sal_Int32 nb )
{ if( n >= 0 && n < cFATPagesInHeader )
{ if( m_nMasterFAT[ n ] != nb )
{
m_bDirty = sal_uInt8(true);
m_nMasterFAT[ n ] = nb;
}
}
}
void StgHeader::SetTOCStart( sal_Int32 n )
{ if( n != m_nTOCstrm )
{
m_bDirty = sal_uInt8(true);
m_nTOCstrm = n;
}
}
void StgHeader::SetDataFATStart( sal_Int32 n )
{ if( n != m_nDataFAT )
{
m_bDirty = sal_uInt8(true);
m_nDataFAT = n;
}
}
void StgHeader::SetDataFATSize( sal_Int32 n )
{ if( n != m_nDataFATSize )
{
m_bDirty = sal_uInt8(true);
m_nDataFATSize = n;
}
}
void StgHeader::SetFATSize( sal_Int32 n )
{ if( n != m_nFATSize )
{
m_bDirty = sal_uInt8(true);
m_nFATSize = n;
}
}
void StgHeader::SetFATChain( sal_Int32 n )
{ if( n != m_nMasterChain )
{
m_bDirty = sal_uInt8(true);
m_nMasterChain = n;
}
}
void StgHeader::SetMasters( sal_Int32 n )
{ if( n != m_nMaster )
{
m_bDirty = sal_uInt8(true);
m_nMaster = n;
}
}
static OUString ToUpperUnicode( const OUString & rStr )
{ // I don't know the locale, so en_US is hopefully fine static CharClass aCC( LanguageTag( css::lang::Locale( u"en"_ustr, u"US"_ustr, u""_ustr )) ); return aCC.uppercase( rStr );
}
void StgEntry::SetName( const OUString& rName )
{ // I don't know the locale, so en_US is hopefully fine
m_aName = ToUpperUnicode( rName ); if(m_aName.getLength() > nMaxLegalStr)
{
m_aName = m_aName.copy(0, nMaxLegalStr);
}
sal_Int32 i; for( i = 0; i < rName.getLength() && i <= nMaxLegalStr; i++ )
{
m_nName[ i ] = rName[ i ];
} while (i <= nMaxLegalStr)
{
m_nName[ i++ ] = 0;
}
m_nNameLen = ( rName.getLength() + 1 ) << 1;
}
sal_Int32 StgEntry::GetLeaf( StgEntryRef eRef ) const
{
sal_Int32 n = -1; switch( eRef )
{ case STG_LEFT: n = m_nLeft; break; case STG_RIGHT: n = m_nRight; break; case STG_CHILD: n = m_nChild; break; case STG_DATA: n = m_nPage1; break;
} return n;
}
void StgEntry::SetLeaf( StgEntryRef eRef, sal_Int32 nPage )
{ switch( eRef )
{ case STG_LEFT: m_nLeft = nPage; break; case STG_RIGHT: m_nRight = nPage; break; case STG_CHILD: m_nChild = nPage; break; case STG_DATA: m_nPage1 = nPage; break;
}
}
SvMemoryStream r( const_cast<void *>(pFrom), nBufSize, StreamMode::READ ); for(sal_Unicode & i : m_nName)
r.ReadUtf16( i ); // 00 name as WCHAR
r.ReadUInt16( m_nNameLen ) // 40 size of name in bytes including 00H
.ReadUChar( m_cType ) // 42 entry type
.ReadUChar( m_cFlags ) // 43 0 or 1 (tree balance?)
.ReadInt32( m_nLeft ) // 44 left node entry
.ReadInt32( m_nRight ) // 48 right node entry
.ReadInt32( m_nChild ); // 4C 1st child entry if storage
ReadClsId( r, m_aClsId ); // 50 class ID (optional)
r.ReadInt32( m_nFlags ) // 60 state flags(?)
.ReadInt32( m_nMtime[ 0 ] ) // 64 modification time
.ReadInt32( m_nMtime[ 1 ] ) // 64 modification time
.ReadInt32( m_nAtime[ 0 ] ) // 6C creation and access time
.ReadInt32( m_nAtime[ 1 ] ) // 6C creation and access time
.ReadInt32( m_nPage1 ) // 74 starting block (either direct or translated)
.ReadInt32( m_nSize ) // 78 file size
.ReadInt32( m_nUnknown ); // 7C unknown
sal_uInt16 n = m_nNameLen; if( n )
n = ( n >> 1 ) - 1;
if (n > nMaxLegalStr) returnfalse;
if (m_cType != STG_STORAGE)
{ if (m_nPage1 < 0 && !isKnownSpecial(m_nPage1))
{ //bad pageid returnfalse;
} if (m_cType == STG_EMPTY)
{ /* tdf#112399opensfineinMSOffice2013despiteamassivem_nSizefield
Free(unused)directoryentriesaremarkedwithObjectType0x0 (unknownorunallocated).Theentiredirectoryentrymustconsistof allzeroesexceptforthechild,rightsibling,andleftsibling pointers,whichmustbeinitializedtoNOSTREAM(0xFFFFFFFF).
*/
m_nSize = 0;
} if (m_nSize < 0)
{ // the size makes no sense 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 returnfalse;
} if (o3tl::make_unsigned(m_nSize) > nUnderlyingStreamSize)
{ // surely an entry cannot be larger than the underlying file returnfalse;
}
}
m_aName = OUString(m_nName , n); // I don't know the locale, so en_US is hopefully fine
m_aName = ToUpperUnicode( m_aName ); if(m_aName.getLength() > nMaxLegalStr)
{
m_aName = m_aName.copy(0, nMaxLegalStr);
}
returntrue;
}
void StgEntry::Store( void* pTo )
{
SvMemoryStream r( pTo, 128, StreamMode::WRITE ); for(sal_Unicode i : m_nName)
r.WriteUInt16( i ); // 00 name as WCHAR
r.WriteUInt16( m_nNameLen ) // 40 size of name in bytes including 00H
.WriteUChar( m_cType ) // 42 entry type
.WriteUChar( m_cFlags ) // 43 0 or 1 (tree balance?)
.WriteInt32( m_nLeft ) // 44 left node entry
.WriteInt32( m_nRight ) // 48 right node entry
.WriteInt32( m_nChild ); // 4C 1st child entry if storage;
WriteClsId( r, m_aClsId ); // 50 class ID (optional)
r.WriteInt32( m_nFlags ) // 60 state flags(?)
.WriteInt32( m_nMtime[ 0 ] ) // 64 modification time
.WriteInt32( m_nMtime[ 1 ] ) // 64 modification time
.WriteInt32( m_nAtime[ 0 ] ) // 6C creation and access time
.WriteInt32( m_nAtime[ 1 ] ) // 6C creation and access time
.WriteInt32( m_nPage1 ) // 74 starting block (either direct or translated)
.WriteInt32( m_nSize ) // 78 file size
.WriteInt32( m_nUnknown ); // 7C unknown
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.