[Libreoffice-commits] core.git: include/vcl svtools/source vcl/inc vcl/source
Julien Nabet
serval2412 at yahoo.fr
Thu Oct 26 06:55:46 UTC 2017
include/vcl/outdev.hxx | 3 --
svtools/source/config/fontsubstconfig.cxx | 5 ----
vcl/inc/outdev.h | 5 +---
vcl/source/outdev/font.cxx | 36 +++++++++---------------------
4 files changed, 15 insertions(+), 34 deletions(-)
New commits:
commit aded98ce3d7a4189a4fa30989505da9427abc83b
Author: Julien Nabet <serval2412 at yahoo.fr>
Date: Wed Oct 25 22:58:59 2017 +0200
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 at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 2bb258f95213..dab8630eab47 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1253,8 +1253,7 @@ public:
static void AddFontSubstitute( const OUString& rFontName,
const OUString& rReplaceFontName,
AddFontSubstituteFlags nFlags );
- static void RemoveFontSubstitute( sal_uInt16 n );
- static sal_uInt16 GetFontSubstituteCount();
+ static void RemoveFontsSubstitute();
static vcl::Font GetDefaultFont( DefaultFontType nType,
LanguageType eLang,
diff --git a/svtools/source/config/fontsubstconfig.cxx b/svtools/source/config/fontsubstconfig.cxx
index a9b42a6ffc52..7db21e021ba2 100644
--- a/svtools/source/config/fontsubstconfig.cxx
+++ b/svtools/source/config/fontsubstconfig.cxx
@@ -161,10 +161,7 @@ void SvtFontSubstConfig::Apply()
OutputDevice::BeginFontSubstitution();
// remove old substitutions
- sal_uInt16 nOldCount = OutputDevice::GetFontSubstituteCount();
-
- while (nOldCount)
- OutputDevice::RemoveFontSubstitute(--nOldCount);
+ OutputDevice::RemoveFontsSubstitute();
// read new substitutions
sal_Int32 nCount = IsEnabled() ? SubstitutionCount() : 0;
diff --git a/vcl/inc/outdev.h b/vcl/inc/outdev.h
index 33fa41255f66..a7921a933876 100644
--- a/vcl/inc/outdev.h
+++ b/vcl/inc/outdev.h
@@ -20,7 +20,6 @@
#ifndef INCLUDED_VCL_INC_OUTDEV_H
#define INCLUDED_VCL_INC_OUTDEV_H
-#include <list>
#include <set>
#include <vector>
@@ -96,10 +95,10 @@ class ImplDirectFontSubstitution
: public ImplFontSubstitution
{
private:
- std::list<ImplFontSubstEntry> maFontSubstList;
+ std::vector<ImplFontSubstEntry> maFontSubstList;
public:
void AddFontSubstitute( const OUString& rFontName, const OUString& rSubstName, AddFontSubstituteFlags nFlags );
- void RemoveFontSubstitute( int nIndex );
+ void RemoveFontsSubstitute();
int GetFontSubstituteCount() const { return maFontSubstList.size(); };
bool FindFontSubstitute( OUString& rSubstName, const OUString& rFontName ) const;
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;
}
More information about the Libreoffice-commits
mailing list