Kaydet (Commit) e85f223e authored tarafından Rafael Dominguez's avatar Rafael Dominguez Kaydeden (comit) Joseph Powers

Remove List usage in FontList

üst 57ad48b8
...@@ -29,8 +29,9 @@ ...@@ -29,8 +29,9 @@
#ifndef _CTRLTOOL_HXX #ifndef _CTRLTOOL_HXX
#define _CTRLTOOL_HXX #define _CTRLTOOL_HXX
#include <boost/ptr_container/ptr_vector.hpp>
#include "svtools/svtdllapi.h" #include "svtools/svtdllapi.h"
#include <tools/list.hxx>
#include <sal/types.h> #include <sal/types.h>
#include <vcl/metric.hxx> #include <vcl/metric.hxx>
...@@ -150,7 +151,7 @@ von der FontList, sollte deshalb das Array nicht mehr referenziert werden. ...@@ -150,7 +151,7 @@ von der FontList, sollte deshalb das Array nicht mehr referenziert werden.
#define FONTLIST_FONTNAMETYPE_SCREEN ((sal_uInt16)0x0002) #define FONTLIST_FONTNAMETYPE_SCREEN ((sal_uInt16)0x0002)
#define FONTLIST_FONTNAMETYPE_SCALABLE ((sal_uInt16)0x0004) #define FONTLIST_FONTNAMETYPE_SCALABLE ((sal_uInt16)0x0004)
class SVT_DLLPUBLIC FontList : private List class SVT_DLLPUBLIC FontList
{ {
private: private:
XubString maMapBoth; XubString maMapBoth;
...@@ -170,7 +171,7 @@ private: ...@@ -170,7 +171,7 @@ private:
long* mpSizeAry; long* mpSizeAry;
OutputDevice* mpDev; OutputDevice* mpDev;
OutputDevice* mpDev2; OutputDevice* mpDev2;
boost::ptr_vector<ImplFontListNameInfo> maEntries;
#ifdef CTRLTOOL_CXX #ifdef CTRLTOOL_CXX
SVT_DLLPRIVATE ImplFontListNameInfo* ImplFind( const XubString& rSearchName, sal_uLong* pIndex ) const; SVT_DLLPRIVATE ImplFontListNameInfo* ImplFind( const XubString& rSearchName, sal_uLong* pIndex ) const;
SVT_DLLPRIVATE ImplFontListNameInfo* ImplFindByName( const XubString& rStr ) const; SVT_DLLPRIVATE ImplFontListNameInfo* ImplFindByName( const XubString& rStr ) const;
...@@ -206,7 +207,7 @@ public: ...@@ -206,7 +207,7 @@ public:
sal_Bool IsAvailable( const XubString& rName ) const; sal_Bool IsAvailable( const XubString& rName ) const;
sal_uInt16 GetFontNameCount() const sal_uInt16 GetFontNameCount() const
{ return (sal_uInt16)List::Count(); } { return (sal_uInt16)maEntries.size(); }
const FontInfo& GetFontName( sal_uInt16 nFont ) const; const FontInfo& GetFontName( sal_uInt16 nFont ) const;
sal_uInt16 GetFontNameType( sal_uInt16 nFont ) const; sal_uInt16 GetFontNameType( sal_uInt16 nFont ) const;
sal_Handle GetFirstFontInfo( const XubString& rName ) const; sal_Handle GetFirstFontInfo( const XubString& rName ) const;
......
...@@ -171,30 +171,30 @@ ImplFontListNameInfo* FontList::ImplFind( const XubString& rSearchName, sal_uLon ...@@ -171,30 +171,30 @@ ImplFontListNameInfo* FontList::ImplFind( const XubString& rSearchName, sal_uLon
// und somit die Wahrscheinlichkeit das hinten angehaengt werden muss // und somit die Wahrscheinlichkeit das hinten angehaengt werden muss
// sehr gross ist. // sehr gross ist.
StringCompare eComp; StringCompare eComp;
sal_uLong nCnt = Count(); sal_uLong nCnt = maEntries.size();
if ( !nCnt ) if ( !nCnt )
{ {
if ( pIndex ) if ( pIndex )
*pIndex = LIST_APPEND; *pIndex = ULONG_MAX;
return NULL; return NULL;
} }
else else
{ {
ImplFontListNameInfo* pCmpData = (ImplFontListNameInfo*)List::GetObject( nCnt-1 ); const ImplFontListNameInfo* pCmpData = &maEntries[nCnt-1];
eComp = rSearchName.CompareTo( pCmpData->maSearchName ); eComp = rSearchName.CompareTo( pCmpData->maSearchName );
if ( eComp == COMPARE_GREATER ) if ( eComp == COMPARE_GREATER )
{ {
if ( pIndex ) if ( pIndex )
*pIndex = LIST_APPEND; *pIndex = ULONG_MAX;
return NULL; return NULL;
} }
else if ( eComp == COMPARE_EQUAL ) else if ( eComp == COMPARE_EQUAL )
return pCmpData; return const_cast<ImplFontListNameInfo*>(pCmpData);
} }
// Fonts in der Liste suchen // Fonts in der Liste suchen
ImplFontListNameInfo* pCompareData; const ImplFontListNameInfo* pCompareData;
ImplFontListNameInfo* pFoundData = NULL; const ImplFontListNameInfo* pFoundData = NULL;
sal_uLong nLow = 0; sal_uLong nLow = 0;
sal_uLong nHigh = nCnt-1; sal_uLong nHigh = nCnt-1;
sal_uLong nMid; sal_uLong nMid;
...@@ -202,7 +202,7 @@ ImplFontListNameInfo* FontList::ImplFind( const XubString& rSearchName, sal_uLon ...@@ -202,7 +202,7 @@ ImplFontListNameInfo* FontList::ImplFind( const XubString& rSearchName, sal_uLon
do do
{ {
nMid = (nLow + nHigh) / 2; nMid = (nLow + nHigh) / 2;
pCompareData = (ImplFontListNameInfo*)List::GetObject( nMid ); pCompareData = &maEntries[nMid];
eComp = rSearchName.CompareTo( pCompareData->maSearchName ); eComp = rSearchName.CompareTo( pCompareData->maSearchName );
if ( eComp == COMPARE_LESS ) if ( eComp == COMPARE_LESS )
{ {
...@@ -232,7 +232,7 @@ ImplFontListNameInfo* FontList::ImplFind( const XubString& rSearchName, sal_uLon ...@@ -232,7 +232,7 @@ ImplFontListNameInfo* FontList::ImplFind( const XubString& rSearchName, sal_uLon
*pIndex = nMid; *pIndex = nMid;
} }
return pFoundData; return const_cast<ImplFontListNameInfo*>(pFoundData);
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -284,7 +284,11 @@ void FontList::ImplInsertFonts( OutputDevice* pDevice, sal_Bool bAll, ...@@ -284,7 +284,11 @@ void FontList::ImplInsertFonts( OutputDevice* pDevice, sal_Bool bAll,
pData->mpFirst = pNewInfo; pData->mpFirst = pNewInfo;
pNewInfo->mpNext = NULL; pNewInfo->mpNext = NULL;
pData->mnType = 0; pData->mnType = 0;
Insert( (void*)pData, nIndex );
if (nIndex < maEntries.size())
maEntries.insert(maEntries.begin()+nIndex,pData);
else
maEntries.push_back(pData);
} }
} }
else else
...@@ -344,8 +348,7 @@ void FontList::ImplInsertFonts( OutputDevice* pDevice, sal_Bool bAll, ...@@ -344,8 +348,7 @@ void FontList::ImplInsertFonts( OutputDevice* pDevice, sal_Bool bAll,
// ======================================================================= // =======================================================================
FontList::FontList( OutputDevice* pDevice, OutputDevice* pDevice2, sal_Bool bAll ) : FontList::FontList( OutputDevice* pDevice, OutputDevice* pDevice2, sal_Bool bAll )
List( 4096, sal::static_int_cast< sal_uInt16 >(pDevice->GetDevFontCount()), 32 )
{ {
// Variablen initialisieren // Variablen initialisieren
mpDev = pDevice; mpDev = pDevice;
...@@ -387,20 +390,17 @@ FontList::~FontList() ...@@ -387,20 +390,17 @@ FontList::~FontList()
delete[] mpSizeAry; delete[] mpSizeAry;
// FontInfos loeschen // FontInfos loeschen
ImplFontListNameInfo* pData = (ImplFontListNameInfo*)First(); ImplFontListFontInfo *pTemp, *pInfo;
while ( pData ) boost::ptr_vector<ImplFontListNameInfo>::iterator it;
for (it = maEntries.begin(); it != maEntries.end(); ++it)
{ {
ImplFontListFontInfo* pTemp; pInfo = it->mpFirst;
ImplFontListFontInfo* pInfo = pData->mpFirst;
while ( pInfo ) while ( pInfo )
{ {
pTemp = pInfo->mpNext; pTemp = pInfo->mpNext;
delete pInfo; delete pInfo;
pInfo = pTemp; pInfo = pTemp;
} }
ImplFontListNameInfo* pNext = (ImplFontListNameInfo*)Next();
delete pData;
pData = pNext;
} }
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -757,8 +757,7 @@ const FontInfo& FontList::GetFontName( sal_uInt16 nFont ) const ...@@ -757,8 +757,7 @@ const FontInfo& FontList::GetFontName( sal_uInt16 nFont ) const
{ {
DBG_ASSERT( nFont < GetFontNameCount(), "FontList::GetFontName(): nFont >= Count" ); DBG_ASSERT( nFont < GetFontNameCount(), "FontList::GetFontName(): nFont >= Count" );
ImplFontListNameInfo* pData = (ImplFontListNameInfo*)List::GetObject( nFont ); return *(maEntries[nFont].mpFirst);
return *(pData->mpFirst);
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -767,8 +766,7 @@ sal_uInt16 FontList::GetFontNameType( sal_uInt16 nFont ) const ...@@ -767,8 +766,7 @@ sal_uInt16 FontList::GetFontNameType( sal_uInt16 nFont ) const
{ {
DBG_ASSERT( nFont < GetFontNameCount(), "FontList::GetFontNameType(): nFont >= Count" ); DBG_ASSERT( nFont < GetFontNameCount(), "FontList::GetFontNameType(): nFont >= Count" );
ImplFontListNameInfo* pData = (ImplFontListNameInfo*)List::GetObject( nFont ); return maEntries[nFont].mnType;
return pData->mnType;
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
......
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