27#include <osl/diagnose.h>
50 *pbOk =
m_aEntry.
Load( pBuffer, nBufferLen, nUnderlyingStreamSize );
94 sal_Int32 nResult = -1;
304 !(
m_nMode & StreamMode::WRITE ) ||
321 OSL_ENSURE(
m_pStgStrm,
"The pointer may not be NULL!" );
330 sal_uInt16 nOldSize = 0;
334 nOldSize =
static_cast<sal_uInt16
>(pOld->
GetSize());
337 else if( nNewSize < nThreshold && !m_pStgStrm->IsSmallStrm() )
340 nOldSize =
static_cast<sal_uInt16
>(nNewSize);
352 std::unique_ptr<sal_uInt8[]> pBuf(
new sal_uInt8[ nOldSize ]);
355 if( pOld->
Read( pBuf.get(), nOldSize )
403 OSL_ENSURE(
m_pStgStrm,
"The pointer may not be NULL!" );
442 OSL_ENSURE(
m_pStgStrm,
"The pointer may not be NULL!" );
457 if( nLen <= 0 || !(
m_nMode & StreamMode::WRITE ) )
467 OSL_ENSURE(
m_pStgStrm,
"The pointer may not be NULL!" );
478 sal_Int32 nNew =
m_nPos + nLen;
499 void*
p =
static_cast<void*
>( aTempBytes );
507 if(
Read(
p, nn ) != nn )
509 if( sal::static_int_cast<sal_Int32>(rDest.
Write(
p, nn )) != nn )
569 OSL_ENSURE(
m_pStgStrm,
"The pointer may not be NULL!" );
574 void*
p =
static_cast<void*
>( aTempBytes );
597 OSL_ENSURE(
m_pStgStrm,
"The pointer may not be NULL!" );
621 OSL_ENSURE(
m_pStgStrm,
"The pointer may not be NULL!" );
625 std::unique_ptr<StgStrm> pNewStrm;
632 if( pNewStrm->SetSize(
n ) )
643 if(
static_cast<sal_uInt64
>(pNewStrm->Write(
p, nn )) != nn )
686 p->Invalidate( bDel );
708 static constexpr OUStringLiteral sRootEntry =
u"Root Entry";
738 sal_uInt64 nUnderlyingStreamSize = pUnderlyingStream->
TellEnd();
754 sal_Int32 nLeft = pCur->m_aEntry.GetLeaf(
STG_LEFT );
755 sal_Int32 nRight = pCur->m_aEntry.GetLeaf(
STG_RIGHT );
760 nLeaf = pCur->m_aEntry.GetLeaf(
STG_CHILD );
768 if( !(nLeaf != 0 && nLeft != 0 && nRight != 0) )
777 SAL_WARN(
"sot",
"Leaf node of upper StgDirEntry is same as current StgDirEntry's leaf node. Circular entry chain, discarding link");
786 pCur->
m_pUp = pUpper;
869 m_pFat->FreePages( nOldStart,
true );
923 std::unique_ptr<StgDirEntry> pNewRes(
new StgDirEntry( std::move(aEntry) ));
926 pNewRes->m_pUp = &rStg;
934 return pNewRes.release();
virtual sal_uInt64 Tell()=0
virtual sal_uInt64 Seek(sal_uInt64 nPos)=0
virtual sal_Int32 Write(const void *pData, sal_Int32 nSize)=0
virtual bool SetSize(sal_uInt64 nNewSize)=0
static bool Remove(StgAvlNode **, StgAvlNode *, bool bDel)
StgAvlNode * Find(StgAvlNode const *)
static bool Insert(StgAvlNode **, StgAvlNode *)
ErrCode const & GetError() const
void * GetPtr(sal_Int32 nPos, bool bDirty)
bool StoreStream(StgIo &)
void Copy(BaseStorageStream &)
sal_Int32 Write(const void *, sal_Int32)
virtual ~StgDirEntry() override
sal_Int32 Read(void *, sal_Int32)
virtual sal_Int32 Compare(const StgAvlNode *) const override
StgDirEntry(const void *pBuffer, sal_uInt32 nBufferLen, sal_uInt64 nUnderlyingStreamSize, bool *pbOk)
sal_Int32 GetSize() const
bool StoreStreams(StgIo &)
sal_Int32 Seek(sal_Int32)
StgDirEntry * Create(StgDirEntry &, const OUString &, StgEntryType)
void * GetEntry(sal_Int32 n, bool)
void SetupEntry(sal_Int32, StgDirEntry *)
virtual bool SetSize(sal_Int32) override
virtual ~StgDirStrm() override
static StgDirEntry * Find(StgDirEntry &, const OUString &)
sal_Int32 Compare(const StgEntry &) const
sal_Int32 GetSize() const
void SetLeaf(StgEntryRef, sal_Int32)
sal_Int32 GetLeaf(StgEntryRef) const
void SetName(const OUString &)
StgEntryType GetType() const
bool Load(const void *pBuffer, sal_uInt32 nBufSize, sal_uInt64 nUnderlyingStreamSize)
void SetType(StgEntryType t)
void SetEntry(StgDirEntry &)
virtual sal_Int32 Read(void *, sal_Int32)
virtual sal_Int32 Write(const void *, sal_Int32)
void SetPos(sal_Int32 nPos, bool bValid)
virtual bool SetSize(sal_Int32)
sal_Int32 GetSize() const
virtual bool IsSmallStrm() const
std::unique_ptr< StgFAT > m_pFat
bool Copy(sal_Int32 nFrom, sal_Int32 nBytes)
virtual bool Pos2Page(sal_Int32 nBytePos)
virtual void SetSize(sal_uInt64) override
sal_uInt64 GetSize() const
virtual sal_uInt64 TellEnd()
std::size_t WriteBytes(const void *pData, std::size_t nSize)
sal_uInt64 Seek(sal_uInt64 nPos)
std::size_t ReadBytes(void *pData, std::size_t nSize)
#define SVSTREAM_GENERALERROR
#define SVSTREAM_CANNOT_MAKE
#define SAL_WARN(area, stream)