Kaydet (Commit) 47fbe385 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Avoid pointless class derivation for the CoreText SystemFontList

Change-Id: Ib3e6705d166dec9d7db8787496947faf73e3cfb3
üst 0379f8b6
...@@ -36,29 +36,6 @@ ...@@ -36,29 +36,6 @@
// ======================================================================= // =======================================================================
class CTFontList
: public SystemFontList
{
public:
explicit CTFontList( void );
virtual ~CTFontList( void );
bool Init( void );
void AddFont( CoreTextFontData* );
virtual void AnnounceFonts( ImplDevFontList& ) const;
virtual CoreTextFontData* GetFontDataFromId( sal_IntPtr ) const;
private:
CTFontCollectionRef mpCTFontCollection;
CFArrayRef mpCTFontArray;
typedef boost::unordered_map<sal_IntPtr,CoreTextFontData*> CTFontContainer;
CTFontContainer maFontContainer;
};
// =======================================================================
inline double toRadian(int nDegree) inline double toRadian(int nDegree)
{ {
return nDegree * (M_PI / 1800.0); return nDegree * (M_PI / 1800.0);
...@@ -411,21 +388,21 @@ static void CTFontEnumCallBack( const void* pValue, void* pContext ) ...@@ -411,21 +388,21 @@ static void CTFontEnumCallBack( const void* pValue, void* pContext )
{ {
const sal_IntPtr nFontId = (sal_IntPtr)pValue; const sal_IntPtr nFontId = (sal_IntPtr)pValue;
CoreTextFontData* pFontData = new CoreTextFontData( rDFA, nFontId ); CoreTextFontData* pFontData = new CoreTextFontData( rDFA, nFontId );
CTFontList* pFontList = (CTFontList*)pContext; SystemFontList* pFontList = (SystemFontList*)pContext;
pFontList->AddFont( pFontData ); pFontList->AddFont( pFontData );
} }
} }
// ======================================================================= // =======================================================================
CTFontList::CTFontList() SystemFontList::SystemFontList()
: mpCTFontCollection( NULL ) : mpCTFontCollection( NULL )
, mpCTFontArray( NULL ) , mpCTFontArray( NULL )
{} {}
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
CTFontList::~CTFontList() SystemFontList::~SystemFontList()
{ {
CTFontContainer::const_iterator it = maFontContainer.begin(); CTFontContainer::const_iterator it = maFontContainer.begin();
for(; it != maFontContainer.end(); ++it ) for(; it != maFontContainer.end(); ++it )
...@@ -440,7 +417,7 @@ CTFontList::~CTFontList() ...@@ -440,7 +417,7 @@ CTFontList::~CTFontList()
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void CTFontList::AddFont( CoreTextFontData* pFontData ) void SystemFontList::AddFont( CoreTextFontData* pFontData )
{ {
sal_IntPtr nFontId = pFontData->GetFontId(); sal_IntPtr nFontId = pFontData->GetFontId();
maFontContainer[ nFontId ] = pFontData; maFontContainer[ nFontId ] = pFontData;
...@@ -448,7 +425,7 @@ void CTFontList::AddFont( CoreTextFontData* pFontData ) ...@@ -448,7 +425,7 @@ void CTFontList::AddFont( CoreTextFontData* pFontData )
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void CTFontList::AnnounceFonts( ImplDevFontList& rFontList ) const void SystemFontList::AnnounceFonts( ImplDevFontList& rFontList ) const
{ {
CTFontContainer::const_iterator it = maFontContainer.begin(); CTFontContainer::const_iterator it = maFontContainer.begin();
for(; it != maFontContainer.end(); ++it ) for(; it != maFontContainer.end(); ++it )
...@@ -457,7 +434,7 @@ void CTFontList::AnnounceFonts( ImplDevFontList& rFontList ) const ...@@ -457,7 +434,7 @@ void CTFontList::AnnounceFonts( ImplDevFontList& rFontList ) const
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
CoreTextFontData* CTFontList::GetFontDataFromId( sal_IntPtr nFontId ) const CoreTextFontData* SystemFontList::GetFontDataFromId( sal_IntPtr nFontId ) const
{ {
CTFontContainer::const_iterator it = maFontContainer.find( nFontId ); CTFontContainer::const_iterator it = maFontContainer.find( nFontId );
if( it == maFontContainer.end() ) if( it == maFontContainer.end() )
...@@ -467,7 +444,7 @@ CoreTextFontData* CTFontList::GetFontDataFromId( sal_IntPtr nFontId ) const ...@@ -467,7 +444,7 @@ CoreTextFontData* CTFontList::GetFontDataFromId( sal_IntPtr nFontId ) const
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
bool CTFontList::Init( void ) bool SystemFontList::Init( void )
{ {
// enumerate available system fonts // enumerate available system fonts
static const int nMaxDictEntries = 8; static const int nMaxDictEntries = 8;
...@@ -489,7 +466,7 @@ bool CTFontList::Init( void ) ...@@ -489,7 +466,7 @@ bool CTFontList::Init( void )
SystemFontList* GetCoretextFontList( void ) SystemFontList* GetCoretextFontList( void )
{ {
CTFontList* pList = new CTFontList(); SystemFontList* pList = new SystemFontList();
if( !pList->Init() ) { if( !pList->Init() ) {
delete pList; delete pList;
return NULL; return NULL;
......
...@@ -59,12 +59,6 @@ ...@@ -59,12 +59,6 @@
using namespace vcl; using namespace vcl;
// =======================================================================
SystemFontList::~SystemFontList( void )
{}
// ======================================================================= // =======================================================================
CoreTextFontData::CoreTextFontData( const CoreTextFontData& rSrc ) CoreTextFontData::CoreTextFontData( const CoreTextFontData& rSrc )
......
...@@ -119,10 +119,21 @@ private: ...@@ -119,10 +119,21 @@ private:
class SystemFontList class SystemFontList
{ {
public: public:
virtual ~SystemFontList( void ); SystemFontList( void );
~SystemFontList( void );
virtual void AnnounceFonts( ImplDevFontList& ) const = 0; bool Init( void );
virtual CoreTextFontData* GetFontDataFromId( sal_IntPtr nFontId ) const = 0; void AddFont( CoreTextFontData* );
void AnnounceFonts( ImplDevFontList& ) const;
CoreTextFontData* GetFontDataFromId( sal_IntPtr nFontId ) const;
private:
CTFontCollectionRef mpCTFontCollection;
CFArrayRef mpCTFontArray;
typedef boost::unordered_map<sal_IntPtr,CoreTextFontData*> CTFontContainer;
CTFontContainer maFontContainer;
}; };
#ifdef MACOSX #ifdef MACOSX
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment