summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sot/source/sdstor/stgstrms.cxx15
1 files changed, 11 insertions, 4 deletions
diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx
index b2c94ef3b0e2..dae953f25bcb 100644
--- a/sot/source/sdstor/stgstrms.cxx
+++ b/sot/source/sdstor/stgstrms.cxx
@@ -23,6 +23,7 @@
#include <sal/log.hxx>
#include <osl/file.hxx>
#include <tools/tempfile.hxx>
+#include <set>
#include "sot/stg.hxx"
#include "stgelem.hxx"
@@ -341,16 +342,22 @@ void StgStrm::scanBuildPageChainCache(sal_Int32 *pOptionalCalcSize)
bool bError = false;
sal_Int32 nBgn = nStart;
- sal_Int32 nOldBgn = -1;
sal_Int32 nOptSize = 0;
- while( nBgn >= 0 && nBgn != nOldBgn )
+
+ // Track already scanned PageNumbers here and use them to
+ // see if an already counted page is re-visited
+ std::set< sal_Int32 > nUsedPageNumbers;
+
+ while( nBgn >= 0 && !bError )
{
if( nBgn >= 0 )
m_aPagesCache.push_back(nBgn);
- nOldBgn = nBgn;
nBgn = pFat->GetNextPage( nBgn );
- if( nBgn == nOldBgn )
+
+ //returned second is false if it already exists
+ if (!nUsedPageNumbers.insert(nBgn).second)
bError = true;
+
nOptSize += nPageSize;
}
if (bError)