include/svl/style.hxx      |    2 +-
 svl/source/items/style.cxx |   24 ++++++++++++------------
 2 files changed, 13 insertions(+), 13 deletions(-)

New commits:
commit bb555a73cfa54e048dbedfbab227271d73e37a9d
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Jan 28 16:32:35 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Jan 29 12:53:43 2022 +0100

    fix loading file with very large number of styles
    
    where nCurrentPosition was wrapping around
    
    Change-Id: I839215f3138d58884f03509b6341147ef28edb4c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129108
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    (cherry picked from commit 7f3682ecb8a40fe85b6525be9e73d49d76bb308b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129074
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/include/svl/style.hxx b/include/svl/style.hxx
index 85f3934db783..5f1c83290946 100644
--- a/include/svl/style.hxx
+++ b/include/svl/style.hxx
@@ -215,7 +215,7 @@ private:
     SVL_DLLPRIVATE bool         IsTrivialSearch() const;
 
     SfxStyleSheetBase*      pCurrentStyle;
-    sal_uInt16              nCurrentPosition;
+    sal_Int32               mnCurrentPosition;
     bool                    bSearchUsed;
 
 friend class SfxStyleSheetBasePool;
diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx
index 8ef014755874..332dde00712e 100644
--- a/svl/source/items/style.cxx
+++ b/svl/source/items/style.cxx
@@ -390,7 +390,7 @@ struct DoesStyleMatchStyleSheetPredicate final : public 
svl::StyleSheetPredicate
 SfxStyleSheetIterator::SfxStyleSheetIterator(SfxStyleSheetBasePool *pBase,
                                              SfxStyleFamily eFam, 
SfxStyleSearchBits n)
     : pCurrentStyle(nullptr)
-    , nCurrentPosition(0)
+    , mnCurrentPosition(0)
 {
     pBasePool=pBase;
     nSearchFamily=eFam;
@@ -433,7 +433,7 @@ SfxStyleSheetBase* 
SfxStyleSheetIterator::operator[](sal_Int32 nIdx)
     if( IsTrivialSearch())
     {
         retval = 
pBasePool->pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(nIdx);
-        nCurrentPosition = nIdx;
+        mnCurrentPosition = nIdx;
     }
     else if(nMask == SfxStyleSearchBits::All)
     {
@@ -442,7 +442,7 @@ SfxStyleSheetBase* 
SfxStyleSheetIterator::operator[](sal_Int32 nIdx)
                 
pBasePool->pImpl->mxIndexedStyleSheets->GetStyleSheetPositionsByFamily(nSearchFamily).at(nIdx))
                 ;
         retval = ref.get();
-        nCurrentPosition = nIdx;
+        mnCurrentPosition = nIdx;
     }
     else
     {
@@ -451,7 +451,7 @@ SfxStyleSheetBase* 
SfxStyleSheetIterator::operator[](sal_Int32 nIdx)
                 
pBasePool->pImpl->mxIndexedStyleSheets->GetNthStyleSheetThatMatchesPredicate(nIdx,
 predicate);
         if (ref)
         {
-            nCurrentPosition = 
pBasePool->pImpl->mxIndexedStyleSheets->FindStyleSheetPosition(*ref);
+            mnCurrentPosition = 
pBasePool->pImpl->mxIndexedStyleSheets->FindStyleSheetPosition(*ref);
             retval = ref.get();
         }
     }
@@ -481,22 +481,22 @@ SfxStyleSheetBase* SfxStyleSheetIterator::Next()
     if ( IsTrivialSearch() )
     {
         sal_Int32 nStyleSheets = 
pBasePool->pImpl->mxIndexedStyleSheets->GetNumberOfStyleSheets();
-        sal_Int32 newPosition = nCurrentPosition + 1;
+        sal_Int32 newPosition = mnCurrentPosition + 1;
         if (nStyleSheets > newPosition)
         {
-            nCurrentPosition = newPosition;
-            retval = 
pBasePool->pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(nCurrentPosition);
+            mnCurrentPosition = newPosition;
+            retval = 
pBasePool->pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(mnCurrentPosition);
         }
     }
     else if(nMask == SfxStyleSearchBits::All)
     {
-        sal_Int32 newPosition = nCurrentPosition + 1;
+        sal_Int32 newPosition = mnCurrentPosition + 1;
         const std::vector<sal_Int32>& familyVector
             =
             
pBasePool->pImpl->mxIndexedStyleSheets->GetStyleSheetPositionsByFamily(nSearchFamily);
         if (static_cast<sal_Int32>(familyVector.size()) > newPosition)
         {
-            nCurrentPosition = newPosition;
+            mnCurrentPosition = newPosition;
             sal_Int32 stylePosition = familyVector[newPosition];
             retval = 
pBasePool->pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(stylePosition);
         }
@@ -506,10 +506,10 @@ SfxStyleSheetBase* SfxStyleSheetIterator::Next()
         DoesStyleMatchStyleSheetPredicate predicate(this);
         rtl::Reference< SfxStyleSheetBase > ref =
                 
pBasePool->pImpl->mxIndexedStyleSheets->GetNthStyleSheetThatMatchesPredicate(
-                        0, predicate, nCurrentPosition+1);
+                        0, predicate, mnCurrentPosition+1);
         retval = ref.get();
         if (retval != nullptr) {
-            nCurrentPosition = 
pBasePool->pImpl->mxIndexedStyleSheets->FindStyleSheetPosition(*ref);
+            mnCurrentPosition = 
pBasePool->pImpl->mxIndexedStyleSheets->FindStyleSheetPosition(*ref);
         }
     }
     pCurrentStyle = retval;
@@ -529,7 +529,7 @@ SfxStyleSheetBase* SfxStyleSheetIterator::Find(const 
OUString& rStr)
 
     sal_Int32 pos = positions.front();
     SfxStyleSheetBase* pStyle = 
pBasePool->pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(pos);
-    nCurrentPosition = pos;
+    mnCurrentPosition = pos;
     pCurrentStyle = pStyle;
     return pCurrentStyle;
 }

Reply via email to