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>
This commit is contained in:
@@ -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_ );
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
|
@@ -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& );
|
||||
|
@@ -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 );
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user