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);
|
SubsetMap aAll(nullptr);
|
||||||
rListBox.Clear();
|
rListBox.Clear();
|
||||||
bool bFirst = true;
|
for (auto & subset : aAll.GetSubsetMap())
|
||||||
while (const Subset *s = aAll.GetNextSubset(bFirst))
|
rListBox.InsertEntry( subset.GetName() );
|
||||||
{
|
|
||||||
rListBox.InsertEntry( s->GetName() );
|
|
||||||
bFirst = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -675,13 +671,11 @@ IMPL_LINK_NOARG(SvxCharacterMap, FontSelectHdl, ListBox&, void)
|
|||||||
pSubsetMap = new SubsetMap( xFontCharMap );
|
pSubsetMap = new SubsetMap( xFontCharMap );
|
||||||
|
|
||||||
// update subset listbox for new font's unicode subsets
|
// update subset listbox for new font's unicode subsets
|
||||||
// TODO: is it worth to improve the stupid linear search?
|
|
||||||
bool bFirst = true;
|
bool bFirst = true;
|
||||||
const Subset* s;
|
for (auto const& subset : pSubsetMap->GetSubsetMap())
|
||||||
while( nullptr != (s = pSubsetMap->GetNextSubset( bFirst )) )
|
|
||||||
{
|
{
|
||||||
const sal_Int32 nPos_ = m_pSubsetLB->InsertEntry( s->GetName() );
|
const sal_Int32 nPos_ = m_pSubsetLB->InsertEntry( subset.GetName() );
|
||||||
m_pSubsetLB->SetEntryData( nPos_, const_cast<Subset *>(s) );
|
m_pSubsetLB->SetEntryData( nPos_, const_cast<Subset *>(&subset) );
|
||||||
// NOTE: subset must live at least as long as the selected font
|
// NOTE: subset must live at least as long as the selected font
|
||||||
if( bFirst )
|
if( bFirst )
|
||||||
m_pSubsetLB->SelectEntryPos( nPos_ );
|
m_pSubsetLB->SelectEntryPos( nPos_ );
|
||||||
|
@@ -2525,10 +2525,10 @@ static char* getFontSubset (const OString& aFontName)
|
|||||||
aDevice->GetFontCharMap(xFontCharMap);
|
aDevice->GetFontCharMap(xFontCharMap);
|
||||||
SubsetMap aSubMap(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;
|
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));
|
aValues.push_back(std::make_pair("", aChild));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -60,11 +60,10 @@ public:
|
|||||||
SubsetMap( const FontCharMapRef& );
|
SubsetMap( const FontCharMapRef& );
|
||||||
|
|
||||||
const Subset* GetSubsetByUnicode( sal_UCS4 ) const;
|
const Subset* GetSubsetByUnicode( sal_UCS4 ) const;
|
||||||
const Subset* GetNextSubset( bool bFirst ) const;
|
const SubsetList& GetSubsetMap() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SubsetList maSubsets;
|
SubsetList maSubsets;
|
||||||
mutable SubsetList::const_iterator maSubsetIterator;
|
|
||||||
|
|
||||||
SVX_DLLPRIVATE void InitList();
|
SVX_DLLPRIVATE void InitList();
|
||||||
SVX_DLLPRIVATE void ApplyCharMap( const FontCharMapRef& );
|
SVX_DLLPRIVATE void ApplyCharMap( const FontCharMapRef& );
|
||||||
|
@@ -2257,11 +2257,10 @@ void SmSymDefineDialog::SetFont(const OUString &rFontName, const OUString &rStyl
|
|||||||
|
|
||||||
pFontsSubsetLB->Clear();
|
pFontsSubsetLB->Clear();
|
||||||
bool bFirst = true;
|
bool bFirst = true;
|
||||||
const Subset* pSubset;
|
for (auto & subset : pSubsetMap->GetSubsetMap())
|
||||||
while( nullptr != (pSubset = pSubsetMap->GetNextSubset( bFirst )) )
|
|
||||||
{
|
{
|
||||||
const sal_Int32 nPos = pFontsSubsetLB->InsertEntry( pSubset->GetName());
|
const sal_Int32 nPos = pFontsSubsetLB->InsertEntry( subset.GetName());
|
||||||
pFontsSubsetLB->SetEntryData( nPos, const_cast<Subset *>(pSubset) );
|
pFontsSubsetLB->SetEntryData( nPos, const_cast<Subset *>(&subset) );
|
||||||
// subset must live at least as long as the selected font !!!
|
// subset must live at least as long as the selected font !!!
|
||||||
if( bFirst )
|
if( bFirst )
|
||||||
pFontsSubsetLB->SelectEntryPos( nPos );
|
pFontsSubsetLB->SelectEntryPos( nPos );
|
||||||
|
@@ -960,18 +960,9 @@ SubsetMap::SubsetMap( const FontCharMapRef& rxFontCharMap )
|
|||||||
ApplyCharMap(rxFontCharMap);
|
ApplyCharMap(rxFontCharMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Subset* SubsetMap::GetNextSubset( bool bFirst ) const
|
const SubsetList& SubsetMap::GetSubsetMap() const
|
||||||
{
|
{
|
||||||
if( bFirst )
|
return maSubsets;
|
||||||
{
|
|
||||||
maSubsetIterator = maSubsets.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( maSubsetIterator == maSubsets.end() )
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
const Subset* s = &*(maSubsetIterator++);
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Subset* SubsetMap::GetSubsetByUnicode( sal_UCS4 cChar ) const
|
const Subset* SubsetMap::GetSubsetByUnicode( sal_UCS4 cChar ) const
|
||||||
|
Reference in New Issue
Block a user