diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2017-10-25 22:58:59 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-10-26 08:55:23 +0200 |
commit | aded98ce3d7a4189a4fa30989505da9427abc83b (patch) | |
tree | 494514c970c1d70b6373ceb9b22b0b11b595e8d7 /vcl/source | |
parent | 4130a5c4b07b5d440d05ab7df0d593373cd76044 (diff) |
Refactor font substitute removing (vcl/svtools)
+ replace list by vector for maFontSubstList
Change-Id: I4d5668611212358c759fa5cf26f5341311551298
Reviewed-on: https://gerrit.libreoffice.org/43855
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/outdev/font.cxx | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 4156ed7677a2..e0d81ccf231b 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -708,45 +708,31 @@ ImplFontSubstEntry::ImplFontSubstEntry( const OUString& rFontName, maSearchReplaceName = GetEnglishSearchFontName( rSubstFontName ); } -void OutputDevice::RemoveFontSubstitute( sal_uInt16 n ) +void OutputDevice::RemoveFontsSubstitute() { ImplDirectFontSubstitution* pSubst = ImplGetSVData()->maGDIData.mpDirectFontSubst; if( pSubst ) - pSubst->RemoveFontSubstitute( n ); + pSubst->RemoveFontsSubstitute(); } -void ImplDirectFontSubstitution::RemoveFontSubstitute( int nIndex ) +void ImplDirectFontSubstitution::RemoveFontsSubstitute() { - std::list<ImplFontSubstEntry>::iterator it = maFontSubstList.begin(); - for( int nCount = 0; (it != maFontSubstList.end()) && (nCount++ != nIndex); ++it ) ; - if( it != maFontSubstList.end() ) - maFontSubstList.erase( it ); -} - -sal_uInt16 OutputDevice::GetFontSubstituteCount() -{ - const ImplDirectFontSubstitution* pSubst = ImplGetSVData()->maGDIData.mpDirectFontSubst; - if( !pSubst ) - return 0; - int nCount = pSubst->GetFontSubstituteCount(); - return (sal_uInt16)nCount; + maFontSubstList.clear(); } bool ImplDirectFontSubstitution::FindFontSubstitute( OUString& rSubstName, const OUString& rSearchName ) const { // TODO: get rid of O(N) searches - std::list<ImplFontSubstEntry>::const_iterator it = maFontSubstList.begin(); - for(; it != maFontSubstList.end(); ++it ) + std::vector<ImplFontSubstEntry>::const_iterator it = std::find_if ( + maFontSubstList.begin(), maFontSubstList.end(), + [&] (const ImplFontSubstEntry& s) { return (s.mnFlags & AddFontSubstituteFlags::ALWAYS) + && (s.maSearchName == rSearchName); } ); + if (it != maFontSubstList.end()) { - const ImplFontSubstEntry& rEntry = *it; - if( (rEntry.mnFlags & AddFontSubstituteFlags::ALWAYS) && rEntry.maSearchName == rSearchName ) - { - rSubstName = rEntry.maSearchReplaceName; - return true; - } + rSubstName = it->maSearchReplaceName; + return true; } - return false; } |