Kaydet (Commit) e89964eb authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz: Pos2Page returns true on same value that returned false previously

a failed position returns false, but stays at the failed position, so
next time its called without moving it then it returns true

store what we return for a given position for reuse if the position
doesn't change

Change-Id: I404c65ac89eb6f5c867f62a62028b87effdbcbf8
Reviewed-on: https://gerrit.libreoffice.org/49308Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 469430a7
......@@ -86,6 +86,11 @@ public:
m_vector.clear();
}
void reserve(size_type amount)
{
m_vector.reserve(amount);
}
// ACCESSORS
size_type size() const
......
......@@ -63,7 +63,6 @@ namespace
// Read as much as we can, a corrupted FAT chain can cause real grief here
nReadableSize = xStream->ReadBytes(static_cast<void *>(pData), nSize);
// fprintf(stderr, "readable size %d vs size %d remaining %d\n", nReadableSize, nSize, nReadableSize);
}
{ // Read the data backwards as well
tools::SvRef<SotStorageStream> xStream( xObjStor->OpenSotStream( rStreamName ) );
......
......@@ -839,7 +839,8 @@ bool StgDirStrm::Store()
sal_Int32 nOldStart = m_nStart; // save for later deletion
sal_Int32 nOldSize = m_nSize;
m_nStart = m_nPage = STG_EOF;
m_nSize = m_nPos = 0;
m_nSize = 0;
SetPos(0, true);
m_nOffset = 0;
// Delete all temporary entries
m_pRoot->DelTemp( false );
......
This diff is collapsed.
......@@ -21,8 +21,8 @@
#define INCLUDED_SOT_SOURCE_SDSTOR_STGSTRMS_HXX
#include <tools/stream.hxx>
#include <o3tl/sorted_vector.hxx>
#include <rtl/ref.hxx>
#include <vector>
#include <memory>
......@@ -61,25 +61,29 @@ public:
// and accessing the data on a physical basis. It uses the built-in
// FAT class for the page allocations.
class StgStrm { // base class for all streams
class StgStrm { // base class for all streams
private:
sal_Int32 m_nPos; // current byte position
bool m_bBytePosValid; // what Pos2Page returns for m_nPos
protected:
StgIo& m_rIo; // I/O system
std::unique_ptr<StgFAT> m_pFat; // FAT stream for allocations
StgDirEntry* m_pEntry; // dir entry (for ownership)
sal_Int32 m_nStart; // 1st data page
sal_Int32 m_nSize; // stream size in bytes
sal_Int32 m_nPos; // current byte position
sal_Int32 m_nPage; // current logical page
short m_nOffset; // offset into current page
short m_nPageSize; // logical page size
std::vector<sal_Int32> m_aPagesCache;
o3tl::sorted_vector<sal_Int32> m_aUsedPageNumbers;
sal_Int32 scanBuildPageChainCache();
bool Copy( sal_Int32 nFrom, sal_Int32 nBytes );
void SetPos(sal_Int32 nPos, bool bValid) { m_nPos = nPos; m_bBytePosValid = bValid; }
explicit StgStrm( StgIo& );
public:
virtual ~StgStrm();
StgIo& GetIo() { return m_rIo; }
sal_Int32 GetPos() const { return m_nPos; }
sal_Int32 GetPos() const { return m_nPos; }
sal_Int32 GetStart() const { return m_nStart; }
sal_Int32 GetSize() const { return m_nSize; }
sal_Int32 GetPage() const { return m_nPage; }
......
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