diff options
-rw-r--r-- | sot/source/sdstor/stgstrms.cxx | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx index 88bc41630f4b..3ee485e66432 100644 --- a/sot/source/sdstor/stgstrms.cxx +++ b/sot/source/sdstor/stgstrms.cxx @@ -455,17 +455,14 @@ sal_Bool StgStrm::Pos2Page( sal_Int32 nBytePos ) } else { - size_t nBgnDistance = std::distance(m_aPagesCache.begin(), aI); + size_t nBgnIndex = std::distance(m_aPagesCache.begin(), aI); + size_t nIndex = nBgnIndex + nRel; - size_t nIndex = nBgnDistance + nRel; - - if (nIndex > m_aPagesCache.size()) - { - nRel = m_aPagesCache.size() - nBgnDistance; + if (nIndex >= m_aPagesCache.size()) nIndex = m_aPagesCache.size() - 1; - } - else - nRel = 0; + + size_t nSuccessfulStepsTaken = nIndex - nBgnIndex; + nRel -= nSuccessfulStepsTaken; nLast = nIndex ? m_aPagesCache[nIndex - 1] : STG_EOF; nBgn = m_aPagesCache[nIndex]; |