summaryrefslogtreecommitdiff
path: root/vcl/unx/generic/fontmanager
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2018-01-31 11:49:59 +0100
committerJulien Nabet <serval2412@yahoo.fr>2018-01-31 15:56:25 +0100
commit8b700053cf1b91fbc728cb0b69b6efe21ab61248 (patch)
treea4e4ac2c830bc826469453d97705f44f80bfe678 /vcl/unx/generic/fontmanager
parentb843f01c5d3fbdb179cb208083938f26f28a8ed4 (diff)
Modernize a bit vcl (part5)
by using for range loops Change-Id: I52d6e6c9e1c2c321dc81d8258943a1a9a611441c Reviewed-on: https://gerrit.libreoffice.org/48987 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'vcl/unx/generic/fontmanager')
-rw-r--r--vcl/unx/generic/fontmanager/fontconfig.cxx22
-rw-r--r--vcl/unx/generic/fontmanager/fontmanager.cxx34
2 files changed, 29 insertions, 27 deletions
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx
index 59acfa5841b0..639dc37591ae 100644
--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
+++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
@@ -269,16 +269,15 @@ namespace
sFullMatch += OString('-');
sFullMatch += OUStringToOString(rLangTag.getCountry().toAsciiLowerCase(), RTL_TEXTENCODING_UTF8);
- std::vector<lang_and_element>::const_iterator aEnd = elements.end();
bool alreadyclosematch = false;
bool found_fallback_englishname = false;
- for( std::vector<lang_and_element>::const_iterator aIter = elements.begin(); aIter != aEnd; ++aIter )
+ for (auto const& element : elements)
{
- const char *pLang = reinterpret_cast<const char*>(aIter->first);
+ const char *pLang = reinterpret_cast<const char*>(element.first);
if( sFullMatch == pLang)
{
// both language and country match
- candidate = aIter->second;
+ candidate = element.second;
break;
}
else if( alreadyclosematch )
@@ -290,7 +289,7 @@ namespace
else if( sLangMatch == pLang)
{
// just the language matches
- candidate = aIter->second;
+ candidate = element.second;
alreadyclosematch = true;
}
else if( found_fallback_englishname )
@@ -303,7 +302,7 @@ namespace
{
// select a fallback candidate of the first english element
// name
- candidate = aIter->second;
+ candidate = element.second;
found_fallback_englishname = true;
}
}
@@ -315,10 +314,9 @@ namespace
void FontCfgWrapper::cacheLocalizedFontNames(const FcChar8 *origfontname, const FcChar8 *bestfontname,
const std::vector< lang_and_element > &lang_and_elements)
{
- std::vector<lang_and_element>::const_iterator aEnd = lang_and_elements.end();
- for (std::vector<lang_and_element>::const_iterator aIter = lang_and_elements.begin(); aIter != aEnd; ++aIter)
+ for (auto const& element : lang_and_elements)
{
- const char *candidate = reinterpret_cast<const char*>(aIter->second);
+ const char *candidate = reinterpret_cast<const char*>(element.second);
if (rtl_str_compare(candidate, reinterpret_cast<const char*>(bestfontname)) != 0)
m_aFontNameToLocalized[OString(candidate)] = OString(reinterpret_cast<const char*>(bestfontname));
}
@@ -585,11 +583,11 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o
// a collection entry, get the correct index
if( eIndexRes == FcResultMatch && nCollectionEntry != -1 )
{
- for (auto it = aFonts.begin(); it != aFonts.end(); ++it)
+ for (auto & font : aFonts)
{
- if( (*it)->m_nCollectionEntry == nCollectionEntry )
+ if( font->m_nCollectionEntry == nCollectionEntry )
{
- xUpdate = std::move(*it);
+ xUpdate = std::move(font);
break;
}
}
diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx
index 0f14242a5150..5288fead1298 100644
--- a/vcl/unx/generic/fontmanager/fontmanager.cxx
+++ b/vcl/unx/generic/fontmanager/fontmanager.cxx
@@ -154,8 +154,8 @@ PrintFontManager::~PrintFontManager()
{
m_aFontInstallerTimer.Stop();
deinitFontconfig();
- for( std::unordered_map< fontID, PrintFont* >::const_iterator it = m_aFonts.begin(); it != m_aFonts.end(); ++it )
- delete (*it).second;
+ for (auto const& font : m_aFonts)
+ delete font.second;
}
OString PrintFontManager::getDirectory( int nAtom ) const
@@ -195,10 +195,10 @@ std::vector<fontID> PrintFontManager::addFontFile( const OString& rFileName )
std::vector<std::unique_ptr<PrintFont>> aNewFonts = analyzeFontFile(nDirID, aName);
if (!aNewFonts.empty())
{
- for (auto it = aNewFonts.begin(); it != aNewFonts.end(); ++it)
+ for (auto & font : aNewFonts)
{
fontID nFontId = m_nNextFontID++;
- m_aFonts[nFontId] = it->release();
+ m_aFonts[nFontId] = font.release();
m_aFontFileToFontID[ aName ].insert( nFontId );
aFontIds.push_back(nFontId);
}
@@ -314,15 +314,19 @@ fontID PrintFontManager::findFontFileID( int nDirID, const OString& rFontFile, i
if( set_it == m_aFontFileToFontID.end() )
return nID;
- for( ::std::set< fontID >::const_iterator font_it = set_it->second.begin(); font_it != set_it->second.end() && ! nID; ++font_it )
+ for (auto const& elem : set_it->second)
{
- std::unordered_map< fontID, PrintFont* >::const_iterator it = m_aFonts.find( *font_it );
+ std::unordered_map< fontID, PrintFont* >::const_iterator it = m_aFonts.find(elem);
if( it == m_aFonts.end() )
continue;
PrintFont* const pFont = (*it).second;
if (pFont->m_nDirectory == nDirID &&
pFont->m_aFontFile == rFontFile && pFont->m_nCollectionEntry == nFaceIndex)
- nID = it->first;
+ {
+ nID = it->first;
+ if (nID)
+ break;
+ }
}
return nID;
@@ -336,15 +340,15 @@ std::vector<fontID> PrintFontManager::findFontFileIDs( int nDirID, const OString
if( set_it == m_aFontFileToFontID.end() )
return aIds;
- for( ::std::set< fontID >::const_iterator font_it = set_it->second.begin(); font_it != set_it->second.end(); ++font_it )
+ for (auto const& elem : set_it->second)
{
- std::unordered_map< fontID, PrintFont* >::const_iterator it = m_aFonts.find( *font_it );
+ std::unordered_map< fontID, PrintFont* >::const_iterator it = m_aFonts.find(elem);
if( it == m_aFonts.end() )
continue;
- PrintFont* const pFont = (*it).second;
- if (pFont->m_nDirectory == nDirID &&
- pFont->m_aFontFile == rFontFile)
- aIds.push_back(it->first);
+ PrintFont* const pFont = (*it).second;
+ if (pFont->m_nDirectory == nDirID &&
+ pFont->m_aFontFile == rFontFile)
+ aIds.push_back(it->first);
}
return aIds;
@@ -713,8 +717,8 @@ void PrintFontManager::initialize()
// gtk-fontconfig-timestamp changes to reflect new font installed and
// PrintFontManager::initialize called again
{
- for( std::unordered_map< fontID, PrintFont* >::const_iterator it = m_aFonts.begin(); it != m_aFonts.end(); ++it )
- delete (*it).second;
+ for (auto const& font : m_aFonts)
+ delete font.second;
m_nNextFontID = 1;
m_aFonts.clear();
}