diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-07-27 00:43:34 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-07-27 00:45:21 +0200 |
commit | 3a46d91f8de420f38dd763028e91229c846dff52 (patch) | |
tree | f34ae4072fdd9ff6f06dbd4bac49072ff81f5c60 | |
parent | 197010643e7e1b8c973013efa9034ffc9bdb56c0 (diff) |
SfxStyleSheetBasePool: remove internal iterator
The clients always start with First() anyway so they might as well use
external iterators, which makes calling First() in certain situations
just so the internal iterator is invalidated unnecessary.
Change-Id: I0948576c20410136448e8b85311c21a257469bc7
24 files changed, 130 insertions, 168 deletions
diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx index f9ab85f59ba9..c336b52be3f2 100644 --- a/cui/source/tabpages/paragrph.cxx +++ b/cui/source/tabpages/paragrph.cxx @@ -1942,8 +1942,9 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage( Window* pParent, const SfxItemSe if ( pSh ) { SfxStyleSheetBasePool* pPool = pSh->GetStyleSheetPool(); - pPool->SetSearchMask( SFX_STYLE_FAMILY_PAGE ); - SfxStyleSheetBase* pStyle = pPool->First(); + SfxStyleSheetIterator iter(pPool, + SFX_STYLE_FAMILY_PAGE, SFXSTYLEBIT_ALL); + SfxStyleSheetBase* pStyle = iter.First(); String aStdName; while( pStyle ) @@ -1952,7 +1953,7 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage( Window* pParent, const SfxItemSe // first style == standard style aStdName = pStyle->GetName(); m_pApplyCollBox->InsertEntry( pStyle->GetName() ); - pStyle = pPool->Next(); + pStyle = iter.Next(); } nStdPos = m_pApplyCollBox->GetEntryPos( aStdName ); } diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx index 4006918917f7..785dedad0936 100644 --- a/editeng/source/editeng/editdbg.cxx +++ b/editeng/source/editeng/editdbg.cxx @@ -419,12 +419,12 @@ void EditDbg::ShowEditEngineData( EditEngine* pEE, sal_Bool bInfoBox ) if ( pEE->pImpEditEngine->GetStyleSheetPool() ) { - sal_uLong nStyles = pEE->pImpEditEngine->GetStyleSheetPool() ? pEE->pImpEditEngine->GetStyleSheetPool()->Count() : 0; + SfxStyleSheetIterator aIter( pEE->pImpEditEngine->GetStyleSheetPool(), SFX_STYLE_FAMILY_ALL ); + sal_uLong nStyles = pEE->pImpEditEngine->GetStyleSheetPool() ? aIter.Count() : 0; fprintf( fp, "\n\n================================================================================" ); fprintf( fp, "\n================== Stylesheets =============================================" ); fprintf( fp, "\n================================================================================" ); - fprintf( fp, "\n#Template: %lu\n", nStyles ); - SfxStyleSheetIterator aIter( pEE->pImpEditEngine->GetStyleSheetPool(), SFX_STYLE_FAMILY_ALL ); + fprintf( fp, "\n#Styles: %lu\n", nStyles ); SfxStyleSheetBase* pStyle = aIter.First(); while ( pStyle ) { diff --git a/include/svl/style.hxx b/include/svl/style.hxx index 9d4b3be2596e..464a9c86f673 100644 --- a/include/svl/style.hxx +++ b/include/svl/style.hxx @@ -204,8 +204,6 @@ friend class SfxStyleSheetBase; SfxStyleSheetBasePool_Impl *pImp; protected: - SfxStyleSheetIterator& GetIterator_Impl(); - OUString aAppName; SfxItemPool& rPool; SfxStyles aStyles; @@ -229,8 +227,6 @@ public: const SfxItemPool& GetPool() const; virtual SfxStyleSheetIteratorPtr CreateIterator(SfxStyleFamily, sal_uInt16 nMask); - virtual sal_uInt16 Count(); - virtual SfxStyleSheetBase* operator[](sal_uInt16 nIdx); virtual SfxStyleSheetBase& Make(const OUString&, SfxStyleFamily eFam, @@ -248,8 +244,6 @@ public: SfxStyleSheetBasePool& operator+=( const SfxStyleSheetBasePool& ); const SfxStyles& GetStyles(); - virtual SfxStyleSheetBase* First(); - virtual SfxStyleSheetBase* Next(); virtual SfxStyleSheetBase* Find( const OUString&, SfxStyleFamily eFam, sal_uInt16 n=SFXSTYLEBIT_ALL ); virtual bool SetParent(SfxStyleFamily eFam, diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx index 5cbf833ca3b3..05c3e9d4053c 100644 --- a/sc/source/filter/html/htmlexp.cxx +++ b/sc/source/filter/html/htmlexp.cxx @@ -447,13 +447,16 @@ const SfxItemSet& ScHTMLExport::PageDefaults( SCTAB nTab ) // remember defaults for compare in WriteCell if ( !aHTMLStyle.bInitialized ) { - pStylePool->SetSearchMask( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL ); pStyleSheet = pStylePool->Find( ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA ); OSL_ENSURE( pStyleSheet, "ParaStyle not found! :-(" ); if (!pStyleSheet) - pStyleSheet = pStylePool->First(); + { + SfxStyleSheetIterator iter(pStylePool, + SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL); + pStyleSheet = iter.First(); + } const SfxItemSet& rSetPara = pStyleSheet->GetItemSet(); aHTMLStyle.nDefaultScriptType = ScGlobal::GetDefaultScriptType(); @@ -470,11 +473,14 @@ const SfxItemSet& ScHTMLExport::PageDefaults( SCTAB nTab ) // Page style sheet printer settings, e.g. for background graphics. // There's only one background graphic in HTML! - pStylePool->SetSearchMask( SFX_STYLE_FAMILY_PAGE, SFXSTYLEBIT_ALL ); pStyleSheet = pStylePool->Find( pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE ); OSL_ENSURE( pStyleSheet, "PageStyle not found! :-(" ); if (!pStyleSheet) - pStyleSheet = pStylePool->First(); + { + SfxStyleSheetIterator iter(pStylePool, + SFX_STYLE_FAMILY_PAGE, SFXSTYLEBIT_ALL); + pStyleSheet = iter.First(); + } const SfxItemSet& rSet = pStyleSheet->GetItemSet(); if ( !aHTMLStyle.bInitialized ) { diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx index 3256980caf29..a1b29853eefc 100644 --- a/sc/source/ui/docshell/docsh6.cxx +++ b/sc/source/ui/docshell/docsh6.cxx @@ -231,8 +231,9 @@ SfxStyleSheetBasePool* ScDocShell::GetStyleSheetPool() static void lcl_AdjustPool( SfxStyleSheetBasePool* pStylePool ) { - pStylePool->SetSearchMask(SFX_STYLE_FAMILY_PAGE, SFXSTYLEBIT_ALL); - SfxStyleSheetBase *pStyle = pStylePool->First(); + SfxStyleSheetIterator iter(pStylePool, + SFX_STYLE_FAMILY_PAGE, SFXSTYLEBIT_ALL); + SfxStyleSheetBase *pStyle = iter.First(); while ( pStyle ) { SfxItemSet& rStyleSet = pStyle->GetItemSet(); @@ -253,7 +254,7 @@ static void lcl_AdjustPool( SfxStyleSheetBasePool* pStylePool ) rStyleSet.Put(SvxSetItem(ATTR_PAGE_FOOTERSET,pDestSet)); } - pStyle = pStylePool->Next(); + pStyle = iter.Next(); } } diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx index 3881a9ff04f6..35ef3199ee8f 100644 --- a/sd/source/core/drawdoc3.cxx +++ b/sd/source/core/drawdoc3.cxx @@ -1494,11 +1494,12 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum, // only worry about presentation templates String aName; SdStyleSheetPool* pSourceStyleSheetPool = (SdStyleSheetPool*) pSourceDoc->GetStyleSheetPool(); - pSourceStyleSheetPool->SetSearchMask(SD_STYLE_FAMILY_MASTERPAGE); + SfxStyleSheetIterator iter(pSourceStyleSheetPool, + SD_STYLE_FAMILY_MASTERPAGE, SFXSTYLEBIT_ALL); static_cast<SdStyleSheetPool*>( mxStyleSheetPool.get())->SetSearchMask(SD_STYLE_FAMILY_MASTERPAGE); SdStyleSheetVector aCreatedStyles; // List of created stylesheets - SfxStyleSheetBase* pHisSheet = pSourceStyleSheetPool->First(); + SfxStyleSheetBase* pHisSheet = iter.First(); while (pHisSheet) { @@ -1561,7 +1562,7 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum, aReplList.push_back(aReplData); } - pHisSheet = (SfxStyleSheet*) pSourceStyleSheetPool->Next(); + pHisSheet = iter.Next(); } // If new styles were created: re-create parent chaining of the item diff --git a/sd/source/ui/func/fuhhconv.cxx b/sd/source/ui/func/fuhhconv.cxx index bc73ef62ad0a..acc59294e815 100644 --- a/sd/source/ui/func/fuhhconv.cxx +++ b/sd/source/ui/func/fuhhconv.cxx @@ -163,7 +163,9 @@ void FuHangulHanjaConversion::ConvertStyles( sal_Int16 nTargetLanguage, const Fo if( !pStyleSheetPool ) return; - SfxStyleSheetBase* pStyle = pStyleSheetPool->First(); + SfxStyleSheetIterator iter(pStyleSheetPool, + pStyleSheetPool->GetSearchFamily(), pStyleSheetPool->GetSearchMask()); + SfxStyleSheetBase* pStyle = iter.First(); while( pStyle ) { SfxItemSet& rSet = pStyle->GetItemSet(); @@ -186,7 +188,7 @@ void FuHangulHanjaConversion::ConvertStyles( sal_Int16 nTargetLanguage, const Fo rSet.Put( aFontItem ); } - pStyle = pStyleSheetPool->Next(); + pStyle = iter.Next(); } mpDoc->SetLanguage( EE_CHAR_LANGUAGE_CJK, nTargetLanguage ); diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx index 698baafabb32..b26c08cd5f53 100644 --- a/sfx2/source/dialog/mgetempl.cxx +++ b/sfx2/source/dialog/mgetempl.cxx @@ -83,7 +83,6 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemS if ( pPool ) { pPool->SetSearchMask( pStyle->GetFamily() ); - pPool->First(); // for SW - update internal list } if ( pStyle->GetName().isEmpty() && pPool ) @@ -119,12 +118,14 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemS if ( pStyle->HasFollowSupport() && pPool ) { - SfxStyleSheetBase* pPoolStyle = pPool->First(); + SfxStyleSheetIterator iter(pPool, pStyle->GetFamily(), SFXSTYLEBIT_ALL); + + SfxStyleSheetBase* pPoolStyle = iter.First(); while ( pPoolStyle ) { m_pFollowLb->InsertEntry( pPoolStyle->GetName() ); - pPoolStyle = pPool->Next(); + pPoolStyle = iter.Next(); } // A new Template is not yet in the Pool @@ -143,7 +144,9 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemS // the base template can be set to NULL m_pBaseLb->InsertEntry( SfxResId(STR_NONE).toString() ); - SfxStyleSheetBase* pPoolStyle = pPool->First(); + SfxStyleSheetIterator iter(pPool, pStyle->GetFamily(), SFXSTYLEBIT_ALL); + + SfxStyleSheetBase* pPoolStyle = iter.First(); while ( pPoolStyle ) { @@ -151,7 +154,7 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemS // own name as base template if ( aStr != aName ) m_pBaseLb->InsertEntry( aStr ); - pPoolStyle = pPool->Next(); + pPoolStyle = iter.Next(); } } else diff --git a/sfx2/source/dialog/newstyle.cxx b/sfx2/source/dialog/newstyle.cxx index a81cd6d2a38e..18780f20c3b3 100644 --- a/sfx2/source/dialog/newstyle.cxx +++ b/sfx2/source/dialog/newstyle.cxx @@ -81,11 +81,13 @@ SfxNewStyleDlg::SfxNewStyleDlg( Window* pParent, SfxStyleSheetBasePool& rInPool aColBox.SetDoubleClickHdl(LINK(this, SfxNewStyleDlg, OKHdl)); // aColBox.SetAccessibleName(SfxResId(FL_COL).toString()); - SfxStyleSheetBase *pStyle = rPool.First(); + SfxStyleSheetIterator iter(&rPool, + rPool.GetSearchFamily(), rPool.GetSearchMask()); + SfxStyleSheetBase *pStyle = iter.First(); while ( pStyle ) { aColBox.InsertEntry(pStyle->GetName()); - pStyle = rPool.Next(); + pStyle = iter.Next(); } } diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index 73c9f8705b5e..9bf8063c4568 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -1227,7 +1227,10 @@ void SfxCommonTemplateDialog_Impl::EnableTreeDrag( sal_Bool bEnable ) { if ( pStyleSheetPool ) { - SfxStyleSheetBase* pStyle = pStyleSheetPool->First(); + SfxStyleSheetIterator iter(pStyleSheetPool, + pStyleSheetPool->GetSearchFamily(), + pStyleSheetPool->GetSearchMask()); + SfxStyleSheetBase* pStyle = iter.First(); if ( pTreeBox ) { if ( pStyle && pStyle->HasParentSupport() && bEnable ) @@ -1248,8 +1251,10 @@ void SfxCommonTemplateDialog_Impl::FillTreeBox() { const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl(); pStyleSheetPool->SetSearchMask(pItem->GetFamily(), SFXSTYLEBIT_ALL_VISIBLE); + SfxStyleSheetIterator iter(pStyleSheetPool, + pItem->GetFamily(), SFXSTYLEBIT_ALL_VISIBLE); StyleTreeArr_Impl aArr; - SfxStyleSheetBase *pStyle = pStyleSheetPool->First(); + SfxStyleSheetBase *pStyle = iter.First(); if(pStyle && pStyle->HasParentSupport() && bTreeDrag ) pTreeBox->SetDragDropMode(SV_DRAGDROP_CTRL_MOVE); else @@ -1259,7 +1264,7 @@ void SfxCommonTemplateDialog_Impl::FillTreeBox() StyleTree_Impl* pNew = new StyleTree_Impl(pStyle->GetName(), pStyle->GetParent()); aArr.push_back(pNew); - pStyle = pStyleSheetPool->Next(); + pStyle = iter.Next(); } MakeTree_Impl(aArr); ExpandedEntries_t aEntries; @@ -1392,7 +1397,10 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags) { EnableItem(SID_STYLE_WATERCAN,sal_False); - SfxStyleSheetBase *pStyle = pStyleSheetPool->First(); + SfxStyleSheetIterator iter(pStyleSheetPool, + pStyleSheetPool->GetSearchFamily(), + pStyleSheetPool->GetSearchMask()); + SfxStyleSheetBase *pStyle = iter.First(); SvTreeListEntry* pEntry = aFmtLb.First(); std::vector<OUString> aStrings; @@ -1407,7 +1415,7 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags) for(nPos = aStrings.size(); nPos && aSorter.compare(aStrings[nPos-1], pStyle->GetName()) > 0; --nPos) {}; aStrings.insert(aStrings.begin() + nPos, pStyle->GetName()); - pStyle = pStyleSheetPool->Next(); + pStyle = iter.Next(); } size_t nCount = aStrings.size(); diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 49f9745f4f96..da71fafe3133 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -319,21 +319,15 @@ void SfxObjectShell::LoadStyles */ { - struct Styles_Impl - { - SfxStyleSheetBase *pSource; - SfxStyleSheetBase *pDest; - }; - SfxStyleSheetBasePool *pSourcePool = rSource.GetStyleSheetPool(); DBG_ASSERT(pSourcePool, "Source-DocumentShell ohne StyleSheetPool"); SfxStyleSheetBasePool *pMyPool = GetStyleSheetPool(); DBG_ASSERT(pMyPool, "Dest-DocumentShell ohne StyleSheetPool"); - pSourcePool->SetSearchMask(SFX_STYLE_FAMILY_ALL, SFXSTYLEBIT_ALL); - Styles_Impl *pFound = new Styles_Impl[pSourcePool->Count()]; - sal_uInt16 nFound = 0; + SfxStyleSheetIterator iter(pSourcePool, + SFX_STYLE_FAMILY_ALL, SFXSTYLEBIT_ALL); + std::vector<std::pair<SfxStyleSheetBase*, SfxStyleSheetBase*> > found; - SfxStyleSheetBase *pSource = pSourcePool->First(); + SfxStyleSheetBase *pSource = iter.First(); while ( pSource ) { SfxStyleSheetBase *pDest = @@ -344,21 +338,19 @@ void SfxObjectShell::LoadStyles pSource->GetFamily(), pSource->GetMask()); // Setting of Parents, the next style } - pFound[nFound].pSource = pSource; - pFound[nFound].pDest = pDest; - ++nFound; - pSource = pSourcePool->Next(); + found.push_back(std::make_pair(pSource, pDest)); + pSource = iter.Next(); } - for ( sal_uInt16 i = 0; i < nFound; ++i ) + for (size_t i = 0; i < found.size(); ++i) { - pFound[i].pDest->GetItemSet().PutExtended(pFound[i].pSource->GetItemSet(), SFX_ITEM_DONTCARE, SFX_ITEM_DEFAULT); - if(pFound[i].pSource->HasParentSupport()) - pFound[i].pDest->SetParent(pFound[i].pSource->GetParent()); - if(pFound[i].pSource->HasFollowSupport()) - pFound[i].pDest->SetFollow(pFound[i].pSource->GetParent()); + found[i].second->GetItemSet().PutExtended(found[i].first->GetItemSet(), + SFX_ITEM_DONTCARE, SFX_ITEM_DEFAULT); + if (found[i].first->HasParentSupport()) + found[i].second->SetParent(found[i].first->GetParent()); + if (found[i].first->HasFollowSupport()) + found[i].second->SetFollow(found[i].first->GetParent()); } - delete [] pFound; } //-------------------------------------------------------------------- diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx index 1c0465581b5a..57f202466bc1 100644 --- a/svl/source/items/style.cxx +++ b/svl/source/items/style.cxx @@ -83,8 +83,7 @@ SfxStyleSheetHint::SfxStyleSheetHint class SfxStyleSheetBasePool_Impl { -public: - SfxStyleSheetIteratorPtr pIter; + // TODO: move members here }; @@ -531,16 +530,6 @@ void SfxStyleSheetBasePool::Replace( SfxStyleSheetBase& rSource, SfxStyleSheetBa rTargetSet.Put( rSourceSet ); } -SfxStyleSheetIterator& SfxStyleSheetBasePool::GetIterator_Impl() -{ - if( !pImp->pIter || (pImp->pIter->GetSearchMask() != nMask) || (pImp->pIter->GetSearchFamily() != nSearchFamily) ) - { - pImp->pIter = CreateIterator( nSearchFamily, nMask ); - } - - return *pImp->pIter; -} - SfxStyleSheetBasePool::SfxStyleSheetBasePool( SfxItemPool& r ) : aAppName(r.GetName()) , rPool(r) @@ -682,16 +671,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, sal_uInt16 mask) @@ -705,16 +684,6 @@ const SfxStyles& SfxStyleSheetBasePool::GetStyles() return aStyles; } -SfxStyleSheetBase* SfxStyleSheetBasePool::First() -{ - return GetIterator_Impl().First(); -} - -SfxStyleSheetBase* SfxStyleSheetBasePool::Next() -{ - return GetIterator_Impl().Next(); -} - void SfxStyleSheetBasePool::Remove( SfxStyleSheetBase* p ) { if( p ) @@ -791,9 +760,8 @@ void SfxStyleSheetBasePool::ChangeParent(const OUString& rOld, const OUString& rNew, bool bVirtual) { - const sal_uInt16 nTmpMask = GetSearchMask(); - SetSearchMask(GetSearchFamily(), SFXSTYLEBIT_ALL); - for( SfxStyleSheetBase* p = First(); p; p = Next() ) + SfxStyleSheetIterator iter(this, GetSearchFamily(), SFXSTYLEBIT_ALL); + for (SfxStyleSheetBase* p = iter.First(); p; p = iter.Next()) { if( p->GetParent() == rOld ) { @@ -803,7 +771,6 @@ void SfxStyleSheetBasePool::ChangeParent(const OUString& rOld, p->aParent = rNew; } } - SetSearchMask(GetSearchFamily(), nTmpMask); } void SfxStyleSheetBase::Load( SvStream&, sal_uInt16 ) diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index 11d235e57870..63b3a9b45f31 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -894,16 +894,16 @@ void SvxSearchDialog::Init_Impl( int bSearchPattern ) m_pSearchTmplLB->Clear(); m_pReplaceTmplLB->Clear(); SfxStyleSheetBasePool* pStylePool = pShell->GetStyleSheetPool(); - pStylePool->SetSearchMask( pSearchItem->GetFamily(), + SfxStyleSheetIterator iter(pStylePool, pSearchItem->GetFamily(), SFXSTYLEBIT_ALL ); - SfxStyleSheetBase* pBase = pStylePool->First(); + SfxStyleSheetBase* pBase = iter.First(); while ( pBase ) { if ( pBase->IsUsed() ) m_pSearchTmplLB->InsertEntry( pBase->GetName() ); m_pReplaceTmplLB->InsertEntry( pBase->GetName() ); - pBase = pStylePool->Next(); + pBase = iter.Next(); } m_pSearchTmplLB->SelectEntry( pSearchItem->GetSearchString() ); m_pReplaceTmplLB->SelectEntry( pSearchItem->GetReplaceString() ); @@ -1564,17 +1564,18 @@ void SvxSearchDialog::TemplatesChanged_Impl( SfxStyleSheetBasePool& rPool ) String aOldRepl( m_pReplaceTmplLB->GetSelectEntry() ); m_pSearchTmplLB->Clear(); m_pReplaceTmplLB->Clear(); - rPool.SetSearchMask( pSearchItem->GetFamily(), SFXSTYLEBIT_ALL ); m_pSearchTmplLB->SetUpdateMode( sal_False ); m_pReplaceTmplLB->SetUpdateMode( sal_False ); - SfxStyleSheetBase* pBase = rPool.First(); + SfxStyleSheetIterator iter(&rPool, + pSearchItem->GetFamily(), SFXSTYLEBIT_ALL); + SfxStyleSheetBase* pBase = iter.First(); while ( pBase ) { if ( pBase->IsUsed() ) m_pSearchTmplLB->InsertEntry( pBase->GetName() ); m_pReplaceTmplLB->InsertEntry( pBase->GetName() ); - pBase = rPool.Next(); + pBase = iter.Next(); } m_pSearchTmplLB->SetUpdateMode( sal_True ); m_pReplaceTmplLB->SetUpdateMode( sal_True ); diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 779753c45b5f..aa5a5910c39f 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -420,11 +420,11 @@ void SvxStyleBox_Impl::Select() if ( pPool ) { - pPool->SetSearchMask( eStyleFamily, SFXSTYLEBIT_ALL ); + SfxStyleSheetIterator iter(pPool, eStyleFamily, SFXSTYLEBIT_ALL); - pStyle = pPool->First(); + pStyle = iter.First(); while ( pStyle && OUString( pStyle->GetName() ) != aSearchEntry ) - pStyle = pPool->Next(); + pStyle = iter.Next(); } if ( !pStyle ) @@ -569,11 +569,11 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt ) if ( pPool ) { - pPool->SetSearchMask( eStyleFamily, SFXSTYLEBIT_ALL ); + SfxStyleSheetIterator iter(pPool, eStyleFamily, SFXSTYLEBIT_ALL); - pStyle = pPool->First(); + pStyle = iter.First(); while ( pStyle && OUString( pStyle->GetName() ) != aStyleName ) - pStyle = pPool->Next(); + pStyle = iter.Next(); } if ( !pStyle ) @@ -1942,17 +1942,16 @@ void SvxStyleToolBoxControl::FillStyleBox() if ( pStyleSheetPool && pBox && nActFamily!=0xffff ) { const SfxStyleFamily eFamily = GetActFamily(); - sal_uInt16 nCount = pStyleSheetPool->Count(); SfxStyleSheetBase* pStyle = NULL; bool bDoFill = false; - pStyleSheetPool->SetSearchMask( eFamily, SFXSTYLEBIT_USED ); + SfxStyleSheetIterator iter(pStyleSheetPool, eFamily, SFXSTYLEBIT_USED); // Check whether fill is necessary - pStyle = pStyleSheetPool->First(); + pStyle = iter.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->GetEntryCount() ) + if (iter.Count() != pBox->GetEntryCount()) { bDoFill = true; } @@ -1962,7 +1961,7 @@ void SvxStyleToolBoxControl::FillStyleBox() while ( pStyle && !bDoFill ) { bDoFill = ( pBox->GetEntry(i) != pStyle->GetName() ); - pStyle = pStyleSheetPool->Next(); + pStyle = iter.Next(); i++; } } @@ -1976,7 +1975,7 @@ void SvxStyleToolBoxControl::FillStyleBox() sal_uInt16 _i; sal_uInt32 nCnt = pImpl->aDefaultStyles.size(); - pStyle = pStyleSheetPool->First(); + pStyle = iter.First(); if( pImpl->bSpecModeWriter || pImpl->bSpecModeCalc ) { @@ -1997,7 +1996,7 @@ void SvxStyleToolBoxControl::FillStyleBox() if( bInsert ) pBox->InsertEntry( aName ); - pStyle = pStyleSheetPool->Next(); + pStyle = iter.Next(); } } else @@ -2005,7 +2004,7 @@ void SvxStyleToolBoxControl::FillStyleBox() while ( pStyle ) { pBox->InsertEntry( pStyle->GetName() ); - pStyle = pStyleSheetPool->Next(); + pStyle = iter.Next(); } } } diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx index 900bbbc596ec..f422d97baabd 100644 --- a/sw/inc/docstyle.hxx +++ b/sw/inc/docstyle.hxx @@ -175,8 +175,6 @@ public: virtual SfxStyleSheetBase* Find(const OUString& rStr); virtual void Notify( SfxBroadcaster&, const SfxHint& ); - - void InvalidateIterator(); }; @@ -220,8 +218,6 @@ public: virtual void SAL_CALL acquire( ) throw (); virtual void SAL_CALL release( ) throw (); - void InvalidateIterator(); - protected: virtual ~SwDocStyleSheetPool(); diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 1eaa460e8597..152e3e3e7a13 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -1900,14 +1900,15 @@ static void lcl_SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry, // sal_Int16 nIdx = GetCommandContextIndex( pSeq[i].Name ); - pBasePool->SetSearchMask( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL ); + SfxStyleSheetIterator iter(pBasePool, + SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL); sal_Bool bStyleFound = sal_False; - const SfxStyleSheetBase* pBase = pBasePool->First(); + const SfxStyleSheetBase* pBase = iter.First(); while (pBase && !bStyleFound) { if(pBase->GetName() == aStyleName) bStyleFound = sal_True; - pBase = pBasePool->Next(); + pBase = iter.Next(); } if (nIdx == -1 || !bStyleFound) diff --git a/sw/source/ui/app/docstyle.cxx b/sw/source/ui/app/docstyle.cxx index dc78296ca79e..4f10b1cdb354 100644 --- a/sw/source/ui/app/docstyle.cxx +++ b/sw/source/ui/app/docstyle.cxx @@ -476,8 +476,6 @@ void SwDocStyleSheet::SetHidden( sal_Bool bValue ) if( bChg ) { - // calling pPool->First() here would be quite slow... - dynamic_cast<SwDocStyleSheetPool*>(pPool)->InvalidateIterator(); // internal list has to be updated pPool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) ); SwEditShell* pSh = rDoc.GetEditShell(); if( pSh ) @@ -913,7 +911,6 @@ bool SwDocStyleSheet::SetName( const OUString& rStr) if( bChg ) { - pPool->First(); // internal list has to be updated pPool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) ); SwEditShell* pSh = rDoc.GetEditShell(); if( pSh ) @@ -2867,21 +2864,6 @@ void SwStyleSheetIterator::AppendStyleList(const boost::ptr_vector<String>& rLis } } -void SwDocStyleSheetPool::InvalidateIterator() -{ - dynamic_cast<SwStyleSheetIterator&>(GetIterator_Impl()).InvalidateIterator(); -} - -void SwStyleSheetIterator::InvalidateIterator() -{ - // potentially we could send an SfxHint to Notify but currently it's - // iterating over the vector anyway so would still be slow - why does - // this iterator not use a map? - bFirstCalled = false; - nLastPos = 0; - aLst.Erase(); -} - void SwStyleSheetIterator::Notify( SfxBroadcaster&, const SfxHint& rHint ) { // search and remove from View-List!! diff --git a/sw/source/ui/chrdlg/pardlg.cxx b/sw/source/ui/chrdlg/pardlg.cxx index 20b4f957de30..17e39a58a313 100644 --- a/sw/source/ui/chrdlg/pardlg.cxx +++ b/sw/source/ui/chrdlg/pardlg.cxx @@ -240,13 +240,14 @@ void SwParaDlg::PageCreated(sal_uInt16 nId, SfxTabPage& rPage) ((SwParagraphNumTabPage&)rPage).EnableNewStart(); ListBox & rBox = ((SwParagraphNumTabPage&)rPage).GetStyleBox(); SfxStyleSheetBasePool* pPool = rView.GetDocShell()->GetStyleSheetPool(); - pPool->SetSearchMask(SFX_STYLE_FAMILY_PSEUDO, SFXSTYLEBIT_ALL); - const SfxStyleSheetBase* pBase = pPool->First(); + SfxStyleSheetIterator iter(pPool, + SFX_STYLE_FAMILY_PSEUDO, SFXSTYLEBIT_ALL); + SfxStyleSheetBase const* pBase = iter.First(); std::set<String> aNames; while(pBase) { aNames.insert(pBase->GetName()); - pBase = pPool->Next(); + pBase = iter.Next(); } for(std::set<String>::const_iterator it = aNames.begin(); it != aNames.end(); ++it) rBox.InsertEntry(*it); diff --git a/sw/source/ui/chrdlg/swuiccoll.cxx b/sw/source/ui/chrdlg/swuiccoll.cxx index beb916efbc8a..c46eceb7eb20 100644 --- a/sw/source/ui/chrdlg/swuiccoll.cxx +++ b/sw/source/ui/chrdlg/swuiccoll.cxx @@ -184,14 +184,14 @@ void SwCondCollPage::Reset(const SfxItemSet &/*rSet*/) aTbLinks.Clear(); SfxStyleSheetBasePool* pPool = rSh.GetView().GetDocShell()->GetStyleSheetPool(); - pPool->SetSearchMask(SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL); aStyleLB.Clear(); - const SfxStyleSheetBase* pBase = pPool->First(); + SfxStyleSheetIterator iter(pPool, SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL); + const SfxStyleSheetBase* pBase = iter.First(); while( pBase ) { if(!pFmt || pBase->GetName() != pFmt->GetName()) aStyleLB.InsertEntry(pBase->GetName()); - pBase = pPool->Next(); + pBase = iter.Next(); } aStyleLB.SelectEntryPos(0); @@ -274,14 +274,14 @@ IMPL_LINK( SwCondCollPage, SelectHdl, ListBox*, pBox) sal_uInt16 nSearchFlags = pBox->GetSelectEntryPos(); nSearchFlags = *(sal_uInt16*)aFilterLB.GetEntryData(nSearchFlags); SfxStyleSheetBasePool* pPool = rSh.GetView().GetDocShell()->GetStyleSheetPool(); - pPool->SetSearchMask(SFX_STYLE_FAMILY_PARA, nSearchFlags); - const SfxStyleSheetBase* pBase = pPool->First(); + SfxStyleSheetIterator iter(pPool, SFX_STYLE_FAMILY_PARA, nSearchFlags); + const SfxStyleSheetBase* pBase = iter.First(); while( pBase ) { if(!pFmt || pBase->GetName() != pFmt->GetName()) aStyleLB.InsertEntry(pBase->GetName()); - pBase = pPool->Next(); + pBase = iter.Next(); } aStyleLB.SelectEntryPos(0); SelectHdl(&aStyleLB); diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index 8fc1c6ce6d4e..da49467b451d 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -348,14 +348,15 @@ SwInsertDBColAutoPilot::SwInsertDBColAutoPilot( SwView& rView, // fill paragraph templates-ListBox { SfxStyleSheetBasePool* pPool = pView->GetDocShell()->GetStyleSheetPool(); - pPool->SetSearchMask( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL ); + SfxStyleSheetIterator iter(pPool, + SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL); aLbDbParaColl.InsertEntry( sNoTmpl ); - const SfxStyleSheetBase* pBase = pPool->First(); + const SfxStyleSheetBase* pBase = iter.First(); while( pBase ) { aLbDbParaColl.InsertEntry( pBase->GetName() ); - pBase = pPool->Next(); + pBase = iter.Next(); } aLbDbParaColl.SelectEntryPos( 0 ); } diff --git a/sw/source/ui/fmtui/tmpdlg.cxx b/sw/source/ui/fmtui/tmpdlg.cxx index af1c631843e9..ca6da1fae5dc 100644 --- a/sw/source/ui/fmtui/tmpdlg.cxx +++ b/sw/source/ui/fmtui/tmpdlg.cxx @@ -420,13 +420,14 @@ void SwTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) }//<-end ListBox & rBox = ((SwParagraphNumTabPage&)rPage).GetStyleBox(); SfxStyleSheetBasePool* pPool = pWrtShell->GetView().GetDocShell()->GetStyleSheetPool(); - pPool->SetSearchMask(SFX_STYLE_FAMILY_PSEUDO, SFXSTYLEBIT_ALL); - const SfxStyleSheetBase* pBase = pPool->First(); + SfxStyleSheetIterator iter(pPool, + SFX_STYLE_FAMILY_PSEUDO, SFXSTYLEBIT_ALL); + const SfxStyleSheetBase* pBase = iter.First(); std::set<String> aNames; while(pBase) { aNames.insert(pBase->GetName()); - pBase = pPool->Next(); + pBase = iter.Next(); } for(std::set<String>::const_iterator it = aNames.begin(); it != aNames.end(); ++it) rBox.InsertEntry(*it); @@ -488,12 +489,13 @@ void SwTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) { SfxStyleSheetBasePool* pStyleSheetPool = pWrtShell-> GetView().GetDocShell()->GetStyleSheetPool(); - pStyleSheetPool->SetSearchMask(SFX_STYLE_FAMILY_PARA); - SfxStyleSheetBase *pFirstStyle = pStyleSheetPool->First(); + SfxStyleSheetIterator iter(pStyleSheetPool, + SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL); + SfxStyleSheetBase *pFirstStyle = iter.First(); while(pFirstStyle) { aList.push_back( pFirstStyle->GetName() ); - pFirstStyle = pStyleSheetPool->Next(); + pFirstStyle = iter.Next(); } } aSet.Put (SfxStringListItem(SID_COLLECT_LIST, &aList)); diff --git a/sw/source/ui/misc/docfnote.cxx b/sw/source/ui/misc/docfnote.cxx index e515491ad19b..767906823570 100644 --- a/sw/source/ui/misc/docfnote.cxx +++ b/sw/source/ui/misc/docfnote.cxx @@ -171,13 +171,14 @@ void SwEndNoteOptionPage::Reset( const SfxItemSet& ) // styles special regions // paragraph - SfxStyleSheetBasePool* pStyleSheetPool = pSh->GetView().GetDocShell()->GetStyleSheetPool(); - pStyleSheetPool->SetSearchMask(SFX_STYLE_FAMILY_PARA, SWSTYLEBIT_EXTRA); - SfxStyleSheetBase *pStyle = pStyleSheetPool->First(); + SfxStyleSheetBasePool *const pSPool = + pSh->GetView().GetDocShell()->GetStyleSheetPool(); + SfxStyleSheetIterator iter(pSPool, SFX_STYLE_FAMILY_PARA, SWSTYLEBIT_EXTRA); + SfxStyleSheetBase *pStyle = iter.First(); while(pStyle) { m_pParaTemplBox->InsertEntry(pStyle->GetName()); - pStyle = pStyleSheetPool->Next(); + pStyle = iter.Next(); } String sStr; diff --git a/sw/source/ui/utlui/tmplctrl.cxx b/sw/source/ui/utlui/tmplctrl.cxx index 456faf6e7d8b..bb3ec4fb5a94 100644 --- a/sw/source/ui/utlui/tmplctrl.cxx +++ b/sw/source/ui/utlui/tmplctrl.cxx @@ -104,16 +104,17 @@ void SwTemplateControl::Command( const CommandEvent& rCEvt ) { SfxStyleSheetBasePool* pPool = pView->GetDocShell()-> GetStyleSheetPool(); - pPool->SetSearchMask(SFX_STYLE_FAMILY_PAGE, SFXSTYLEBIT_ALL); - if( pPool->Count() > 1 ) + SfxStyleSheetIterator iter(pPool, + SFX_STYLE_FAMILY_PAGE, SFXSTYLEBIT_ALL); + if (iter.Count() > 1) { sal_uInt16 nCount = 0; - SfxStyleSheetBase* pStyle = pPool->First(); + SfxStyleSheetBase* pStyle = iter.First(); while( pStyle ) { nCount++; aPop.InsertItem( nCount, pStyle->GetName() ); - pStyle = pPool->Next(); + pStyle = iter.Next(); } aPop.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel()); @@ -121,7 +122,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 = iter.operator[]( nCurrId - 1 ); SfxStringItem aStyle( FN_SET_PAGE_STYLE, pStyle->GetName() ); pWrtShell->GetView().GetViewFrame()->GetDispatcher()->Execute( FN_SET_PAGE_STYLE, diff --git a/sw/source/ui/utlui/uitool.cxx b/sw/source/ui/utlui/uitool.cxx index 70e5e2234b36..8251b326f985 100644 --- a/sw/source/ui/utlui/uitool.cxx +++ b/sw/source/ui/utlui/uitool.cxx @@ -598,9 +598,9 @@ void FillCharStyleListBox(ListBox& rToFill, SwDocShell* pDocSh, bool bSorted, bo { sal_Bool bHasOffset = rToFill.GetEntryCount() > 0; SfxStyleSheetBasePool* pPool = pDocSh->GetStyleSheetPool(); - pPool->SetSearchMask(SFX_STYLE_FAMILY_CHAR, SFXSTYLEBIT_ALL); SwDoc* pDoc = pDocSh->GetDoc(); - const SfxStyleSheetBase* pBase = pPool->First(); + SfxStyleSheetIterator iter(pPool, SFX_STYLE_FAMILY_CHAR, SFXSTYLEBIT_ALL); + const SfxStyleSheetBase* pBase = iter.First(); String sStandard; SwStyleNameMapper::FillUIName( RES_POOLCOLL_STANDARD, sStandard ); while(pBase) @@ -615,7 +615,7 @@ void FillCharStyleListBox(ListBox& rToFill, SwDocShell* pDocSh, bool bSorted, bo sal_IntPtr nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( pBase->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); rToFill.SetEntryData( nPos, (void*) (nPoolId)); } - pBase = pPool->Next(); + pBase = iter.Next(); } // non-pool styles const SwCharFmts* pFmts = pDoc->GetCharFmts(); |