diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2017-11-05 08:39:47 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2017-11-05 11:40:33 +0100 |
commit | e567694246d99a2a99c4079b04ed2ad8cd5ed785 (patch) | |
tree | 006797c2b3e74e1a3e37c4739b0b5e513041dd2f | |
parent | ca2aaa2b9f4ce69d05d415e13451ae6a6030f032 (diff) |
Remove GetNextSubset and create GetSubsetMap
To avoid to store an iterator and simplify loops
Change-Id: I9b160714125176841961a56905d81dcb876c68b6
Reviewed-on: https://gerrit.libreoffice.org/44326
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r-- | cui/source/dialogs/cuicharmap.cxx | 16 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 4 | ||||
-rw-r--r-- | include/svx/ucsubset.hxx | 3 | ||||
-rw-r--r-- | starmath/source/dialog.cxx | 7 | ||||
-rw-r--r-- | svx/source/dialog/charmap.cxx | 13 |
5 files changed, 13 insertions, 30 deletions
diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx index 1f039be57e85..1058b70a795d 100644 --- a/cui/source/dialogs/cuicharmap.cxx +++ b/cui/source/dialogs/cuicharmap.cxx @@ -609,12 +609,8 @@ void SvxCharacterMap::fillAllSubsets(ListBox &rListBox) { SubsetMap aAll(nullptr); rListBox.Clear(); - bool bFirst = true; - while (const Subset *s = aAll.GetNextSubset(bFirst)) - { - rListBox.InsertEntry( s->GetName() ); - bFirst = false; - } + for (auto & subset : aAll.GetSubsetMap()) + rListBox.InsertEntry( subset.GetName() ); } @@ -675,13 +671,11 @@ IMPL_LINK_NOARG(SvxCharacterMap, FontSelectHdl, ListBox&, void) pSubsetMap = new SubsetMap( xFontCharMap ); // update subset listbox for new font's unicode subsets - // TODO: is it worth to improve the stupid linear search? bool bFirst = true; - const Subset* s; - while( nullptr != (s = pSubsetMap->GetNextSubset( bFirst )) ) + for (auto const& subset : pSubsetMap->GetSubsetMap()) { - const sal_Int32 nPos_ = m_pSubsetLB->InsertEntry( s->GetName() ); - m_pSubsetLB->SetEntryData( nPos_, const_cast<Subset *>(s) ); + const sal_Int32 nPos_ = m_pSubsetLB->InsertEntry( subset.GetName() ); + m_pSubsetLB->SetEntryData( nPos_, const_cast<Subset *>(&subset) ); // NOTE: subset must live at least as long as the selected font if( bFirst ) m_pSubsetLB->SelectEntryPos( nPos_ ); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 906e271f5c30..96b6ab2e2399 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2525,10 +2525,10 @@ static char* getFontSubset (const OString& aFontName) aDevice->GetFontCharMap(xFontCharMap); SubsetMap aSubMap(xFontCharMap); - for(const Subset* pItSub = aSubMap.GetNextSubset(true); pItSub; pItSub = aSubMap.GetNextSubset(false)) + for (auto const& subset : aSubMap.GetSubsetMap()) { boost::property_tree::ptree aChild; - aChild.put("", static_cast<int>(ublock_getCode(pItSub->GetRangeMin()))); + aChild.put("", static_cast<int>(ublock_getCode(subset.GetRangeMin()))); aValues.push_back(std::make_pair("", aChild)); } } diff --git a/include/svx/ucsubset.hxx b/include/svx/ucsubset.hxx index 570913f3bd18..ae5286ec3863 100644 --- a/include/svx/ucsubset.hxx +++ b/include/svx/ucsubset.hxx @@ -60,11 +60,10 @@ public: SubsetMap( const FontCharMapRef& ); const Subset* GetSubsetByUnicode( sal_UCS4 ) const; - const Subset* GetNextSubset( bool bFirst ) const; + const SubsetList& GetSubsetMap() const; private: SubsetList maSubsets; - mutable SubsetList::const_iterator maSubsetIterator; SVX_DLLPRIVATE void InitList(); SVX_DLLPRIVATE void ApplyCharMap( const FontCharMapRef& ); diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index ffde4194dbbd..f710aa1988f0 100644 --- a/starmath/source/dialog.cxx +++ b/starmath/source/dialog.cxx @@ -2257,11 +2257,10 @@ void SmSymDefineDialog::SetFont(const OUString &rFontName, const OUString &rStyl pFontsSubsetLB->Clear(); bool bFirst = true; - const Subset* pSubset; - while( nullptr != (pSubset = pSubsetMap->GetNextSubset( bFirst )) ) + for (auto & subset : pSubsetMap->GetSubsetMap()) { - const sal_Int32 nPos = pFontsSubsetLB->InsertEntry( pSubset->GetName()); - pFontsSubsetLB->SetEntryData( nPos, const_cast<Subset *>(pSubset) ); + const sal_Int32 nPos = pFontsSubsetLB->InsertEntry( subset.GetName()); + pFontsSubsetLB->SetEntryData( nPos, const_cast<Subset *>(&subset) ); // subset must live at least as long as the selected font !!! if( bFirst ) pFontsSubsetLB->SelectEntryPos( nPos ); diff --git a/svx/source/dialog/charmap.cxx b/svx/source/dialog/charmap.cxx index b529e3a9ebfa..510ca605711a 100644 --- a/svx/source/dialog/charmap.cxx +++ b/svx/source/dialog/charmap.cxx @@ -960,18 +960,9 @@ SubsetMap::SubsetMap( const FontCharMapRef& rxFontCharMap ) ApplyCharMap(rxFontCharMap); } -const Subset* SubsetMap::GetNextSubset( bool bFirst ) const +const SubsetList& SubsetMap::GetSubsetMap() const { - if( bFirst ) - { - maSubsetIterator = maSubsets.begin(); - } - - if( maSubsetIterator == maSubsets.end() ) - return nullptr; - - const Subset* s = &*(maSubsetIterator++); - return s; + return maSubsets; } const Subset* SubsetMap::GetSubsetByUnicode( sal_UCS4 cChar ) const |