[Libreoffice-commits] core.git: include/svl sfx2/source svl/source svx/source sw/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue May 5 07:42:33 UTC 2020


 include/svl/style.hxx               |    2 --
 sfx2/source/doc/objcont.cxx         |    7 ++++---
 svl/source/items/style.cxx          |   10 ----------
 svx/source/tbxctrls/tbcontrl.cxx    |   13 +++++++------
 sw/source/uibase/utlui/tmplctrl.cxx |    9 +++++----
 5 files changed, 16 insertions(+), 25 deletions(-)

New commits:
commit d6acdb786c25619ed02d20dde7fe082b11d4a8dc
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon May 4 20:55:51 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue May 5 09:41:58 2020 +0200

    drop SfxStyleSheetBasePool::Count
    
    and use CreateIterator to make it explicit what is being counted
    
    Change-Id: I8d76aef601533960a23c056b83a48c4f130bbe75
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93446
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svl/style.hxx b/include/svl/style.hxx
index 9b8c06d3f782..8ae7c68e000d 100644
--- a/include/svl/style.hxx
+++ b/include/svl/style.hxx
@@ -259,8 +259,6 @@ public:
     const SfxItemPool&          GetPool() const { return rPool;}
 
     virtual std::unique_ptr<SfxStyleSheetIterator> CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask = SfxStyleSearchBits::All);
-    sal_uInt16              Count();
-    SfxStyleSheetBase*  operator[](sal_uInt16 nIdx);
 
     virtual SfxStyleSheetBase&  Make(const OUString&,
                                      SfxStyleFamily eFam,
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index 5edc31456c61..b1ee8eca0bf7 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -314,10 +314,11 @@ void SfxObjectShell::LoadStyles
     SfxStyleSheetBasePool *pMyPool = GetStyleSheetPool();
     DBG_ASSERT(pMyPool, "Dest-DocumentShell without StyleSheetPool");
     pSourcePool->SetSearchMask(SfxStyleFamily::All);
-    std::unique_ptr<Styles_Impl[]> pFound(new Styles_Impl[pSourcePool->Count()]);
+    auto xIter = pSourcePool->CreateIterator(SfxStyleFamily::All);
+    std::unique_ptr<Styles_Impl[]> pFound(new Styles_Impl[xIter->Count()]);
     sal_uInt16 nFound = 0;
 
-    SfxStyleSheetBase *pSource = pSourcePool->First();
+    SfxStyleSheetBase *pSource = xIter->First();
     while ( pSource )
     {
         SfxStyleSheetBase *pDest =
@@ -331,7 +332,7 @@ void SfxObjectShell::LoadStyles
         pFound[nFound].pSource = pSource;
         pFound[nFound].pDest = pDest;
         ++nFound;
-        pSource = pSourcePool->Next();
+        pSource = xIter->Next();
     }
 
     for ( sal_uInt16 i = 0; i < nFound; ++i )
diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx
index f8bbd6c25936..e0a722e42edb 100644
--- a/svl/source/items/style.cxx
+++ b/svl/source/items/style.cxx
@@ -705,16 +705,6 @@ SfxStyleSheetBasePool& SfxStyleSheetBasePool::operator+=( const SfxStyleSheetBas
     return *this;
 }
 
-sal_uInt16 SfxStyleSheetBasePool::Count()
-{
-    return GetIterator_Impl().Count();
-}
-
-SfxStyleSheetBase *SfxStyleSheetBasePool::operator[](sal_uInt16 nIdx)
-{
-    return GetIterator_Impl()[nIdx];
-}
-
 SfxStyleSheetBase* SfxStyleSheetBasePool::Find(const OUString& rName,
                                                SfxStyleFamily eFam,
                                                SfxStyleSearchBits mask)
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 5effd2609eaf..89fce7fea547 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -2753,14 +2753,15 @@ void SvxStyleToolBoxControl::FillStyleBox()
     if ( pStyleSheetPool && pBox && nActFamily!=0xffff )
     {
         const SfxStyleFamily    eFamily     = GetActFamily();
-        sal_uInt16              nCount      = pStyleSheetPool->Count();
         SfxStyleSheetBase*      pStyle      = nullptr;
         bool                    bDoFill     = false;
 
         pStyleSheetPool->SetSearchMask( eFamily, SfxStyleSearchBits::Used );
+        auto xIter = pStyleSheetPool->CreateIterator(eFamily, SfxStyleSearchBits::Used);
+        sal_uInt16 nCount = xIter->Count();
 
         // Check whether fill is necessary
-        pStyle = pStyleSheetPool->First();
+        pStyle = xIter->First();
         //!!! TODO: This condition isn't right any longer, because we always show some default entries
         //!!! so the list doesn't show the count
         if ( nCount != pBox->get_count() )
@@ -2773,7 +2774,7 @@ void SvxStyleToolBoxControl::FillStyleBox()
             while ( pStyle && !bDoFill )
             {
                 bDoFill = ( pBox->get_text(i) != pStyle->GetName() );
-                pStyle = pStyleSheetPool->Next();
+                pStyle = xIter->Next();
                 i++;
             }
         }
@@ -2787,7 +2788,7 @@ void SvxStyleToolBoxControl::FillStyleBox()
             std::vector<OUString> aStyles;
 
             {
-                pStyle = pStyleSheetPool->Next();
+                pStyle = xIter->Next();
 
                 if( pImpl->bSpecModeWriter || pImpl->bSpecModeCalc )
                 {
@@ -2807,7 +2808,7 @@ void SvxStyleToolBoxControl::FillStyleBox()
 
                         if( bInsert )
                             aStyles.push_back(aName);
-                        pStyle = pStyleSheetPool->Next();
+                        pStyle = xIter->Next();
                     }
                 }
                 else
@@ -2815,7 +2816,7 @@ void SvxStyleToolBoxControl::FillStyleBox()
                     while ( pStyle )
                     {
                         aStyles.push_back(pStyle->GetName());
-                        pStyle = pStyleSheetPool->Next();
+                        pStyle = xIter->Next();
                     }
                 }
             }
diff --git a/sw/source/uibase/utlui/tmplctrl.cxx b/sw/source/uibase/utlui/tmplctrl.cxx
index c944f01c2602..eb3fb95c989b 100644
--- a/sw/source/uibase/utlui/tmplctrl.cxx
+++ b/sw/source/uibase/utlui/tmplctrl.cxx
@@ -111,14 +111,15 @@ void SwTemplateControl::Command( const CommandEvent& rCEvt )
                 SfxStyleSheetBasePool* pPool = pView->GetDocShell()->
                                                             GetStyleSheetPool();
                 pPool->SetSearchMask(SfxStyleFamily::Page);
-                if( pPool->Count() > 1 )
+                auto xIter = pPool->CreateIterator(SfxStyleFamily::Page);
+                if (xIter->Count() > 1)
                 {
                     sal_uInt16 nCount = 0;
-                    SfxStyleSheetBase* pStyle = pPool->First();
+                    SfxStyleSheetBase* pStyle = xIter->First();
                     while( pStyle )
                     {
                         aPop->InsertItem( ++nCount, pStyle->GetName() );
-                        pStyle = pPool->Next();
+                        pStyle = xIter->Next();
                     }
 
                     aPop->Execute( &GetStatusBar(), rCEvt.GetMousePosPixel());
@@ -126,7 +127,7 @@ void SwTemplateControl::Command( const CommandEvent& rCEvt )
                     if( nCurrId != USHRT_MAX)
                     {
                         // looks a bit awkward, but another way is not possible
-                        pStyle = pPool->operator[]( nCurrId - 1 );
+                        pStyle = xIter->operator[]( nCurrId - 1 );
                         SfxStringItem aStyle( FN_SET_PAGE_STYLE, pStyle->GetName() );
                         pWrtShell->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(
                                     FN_SET_PAGE_STYLE,


More information about the Libreoffice-commits mailing list