summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sot/storage.hxx2
-rw-r--r--include/tools/stream.hxx6
-rw-r--r--sot/source/sdstor/storage.cxx10
-rw-r--r--tools/source/stream/stream.cxx16
4 files changed, 21 insertions, 13 deletions
diff --git a/include/sot/storage.hxx b/include/sot/storage.hxx
index 6a7e25af9dfb..cb1c0baa3938 100644
--- a/include/sot/storage.hxx
+++ b/include/sot/storage.hxx
@@ -56,7 +56,7 @@ public:
void CopyTo( SotStorageStream * pDestStm );
bool Commit();
bool SetProperty( const OUString& rName, const css::uno::Any& rValue );
- virtual sal_uInt64 remainingSize() override;
+ virtual sal_uInt64 TellEnd() override;
};
class BaseStorage;
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index 4da1d2e0adb7..c627ed494998 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -272,9 +272,9 @@ public:
sal_uInt64 Seek( sal_uInt64 nPos );
sal_uInt64 SeekRel( sal_Int64 nPos );
sal_uInt64 Tell() const { return m_nBufFilePos + m_nBufActualPos; }
- sal_uInt64 TellEnd();
+ virtual sal_uInt64 TellEnd();
// length between current (Tell()) pos and end of stream
- virtual sal_uInt64 remainingSize();
+ sal_uInt64 remainingSize();
void Flush();
// next Tell() <= nSize
bool SetStreamSize( sal_uInt64 nSize );
@@ -669,7 +669,7 @@ public:
void ObjectOwnsMemory( bool bOwn ) { bOwnsData = bOwn; }
void SetResizeOffset( std::size_t nNewResize ) { nResize = nNewResize; }
- virtual sal_uInt64 remainingSize() override { FlushBuffer(true); return GetEndOfData() - Tell(); }
+ virtual sal_uInt64 TellEnd() override { FlushBuffer(true); return nEndOfData; }
};
#endif
diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx
index cff3520264ba..bc78bddbbe04 100644
--- a/sot/source/sdstor/storage.cxx
+++ b/sot/source/sdstor/storage.cxx
@@ -181,12 +181,16 @@ sal_uInt32 SotStorageStream::GetSize() const
return nSize;
}
-sal_uInt64 SotStorageStream::remainingSize()
+sal_uInt64 SotStorageStream::TellEnd()
{
+ // Need to flush the buffer so we materialise the stream and return the correct answer
+ // otherwise we return a 0 value from StgEntry::GetSize
+ FlushBuffer(true);
+
if (pOwnStm)
- return pOwnStm->GetSize() - Tell();
+ return pOwnStm->GetSize();
- return SvStream::remainingSize();
+ return SvStream::TellEnd();
}
void SotStorageStream::CopyTo( SotStorageStream * pDestStm )
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 818726b2a619..a0160348dff7 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1425,12 +1425,21 @@ bool checkSeek(SvStream &rSt, sal_uInt64 nOffset)
sal_uInt64 SvStream::remainingSize()
{
sal_uInt64 const nCurr = Tell();
- sal_uInt64 const nEnd = Seek(STREAM_SEEK_TO_END);
+ sal_uInt64 const nEnd = TellEnd();
sal_uInt64 nMaxAvailable = nEnd > nCurr ? (nEnd-nCurr) : 0;
Seek(nCurr);
return nMaxAvailable;
}
+sal_uInt64 SvStream::TellEnd()
+{
+ FlushBuffer(true);
+ sal_uInt64 const nCurr = Tell();
+ sal_uInt64 const nEnd = Seek(STREAM_SEEK_TO_END);
+ Seek(nCurr);
+ return nEnd;
+}
+
void SvStream::Flush()
{
FlushBuffer(m_isConsistent);
@@ -1903,11 +1912,6 @@ void SvMemoryStream::SetSize(sal_uInt64 const nNewSize)
ReAllocateMemory( nDiff );
}
-sal_uInt64 SvStream::TellEnd()
-{
- return Tell() + remainingSize();
-}
-
//Create a OString of nLen bytes from rStream
OString read_uInt8s_ToOString(SvStream& rStrm, std::size_t nLen)
{