summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Dominguez <venccsralph@gmail.com>2011-05-02 13:42:19 -0430
committerJoseph Powers <jpowers27@cox.net>2011-05-04 07:06:18 -0700
commitbd28739f58c1de217237b469560b29c89beb1893 (patch)
tree20d54290032cf6557ec92ec2731c106368ac8251
parente85f223e82a8beafd1fe090b575f6bb0a779d018 (diff)
Remove deprecated List from ImplEntryList
-rw-r--r--vcl/inc/vcl/ilstbox.hxx18
-rw-r--r--vcl/source/control/ilstbox.cxx83
2 files changed, 61 insertions, 40 deletions
diff --git a/vcl/inc/vcl/ilstbox.hxx b/vcl/inc/vcl/ilstbox.hxx
index 850531c64d9d..69d127a68d15 100644
--- a/vcl/inc/vcl/ilstbox.hxx
+++ b/vcl/inc/vcl/ilstbox.hxx
@@ -29,6 +29,8 @@
#ifndef _SV_ILSTBOX_HXX
#define _SV_ILSTBOX_HXX
+#include <boost/ptr_container/ptr_vector.hpp>
+
#include <vcl/sv.h>
#include <vcl/image.hxx>
#include <vcl/ctrl.hxx>
@@ -104,7 +106,7 @@ struct ImplEntryType
// - ImplEntryList -
// -----------------
-class ImplEntryList : private List
+class ImplEntryList
{
private:
Window* mpWindow; // For getting the current locale when matching strings
@@ -117,8 +119,14 @@ private:
Link maSelectionChangedHdl;
sal_Bool mbCallSelectionChangedHdl;
+ boost::ptr_vector<ImplEntryType> maEntries;
- ImplEntryType* GetEntry( sal_uInt16 nPos ) const { return (ImplEntryType*)List::GetObject( nPos ); }
+ ImplEntryType* GetEntry( sal_uInt16 nPos ) const
+ {
+ if (nPos >= maEntries.size())
+ return NULL;
+ return const_cast<ImplEntryType*>(&maEntries[nPos]);
+ }
public:
ImplEntryList( Window* pWindow );
@@ -126,8 +134,8 @@ public:
sal_uInt16 InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry, sal_Bool bSort );
void RemoveEntry( sal_uInt16 nPos );
- const ImplEntryType* GetEntryPtr( sal_uInt16 nPos ) const { return (const ImplEntryType*) GetObject( nPos ); }
- ImplEntryType* GetMutableEntryPtr( sal_uInt16 nPos ) const { return (ImplEntryType*) GetObject( nPos ); }
+ const ImplEntryType* GetEntryPtr( sal_uInt16 nPos ) const { return (const ImplEntryType*) GetEntry( nPos ); }
+ ImplEntryType* GetMutableEntryPtr( sal_uInt16 nPos ) const { return GetEntry( nPos ); }
void Clear();
sal_uInt16 FindMatchingEntry( const XubString& rStr, sal_uInt16 nStart = 0, sal_Bool bForward = sal_True, sal_Bool bLazy = sal_True ) const;
@@ -141,7 +149,7 @@ public:
long GetAddedHeight( sal_uInt16 nEndIndex, sal_uInt16 nBeginIndex = 0, long nBeginHeight = 0 ) const;
long GetEntryHeight( sal_uInt16 nPos ) const;
- sal_uInt16 GetEntryCount() const { return (sal_uInt16)List::Count(); }
+ sal_uInt16 GetEntryCount() const { return (sal_uInt16)maEntries.size(); }
sal_Bool HasImages() const { return mnImages ? sal_True : sal_False; }
XubString GetEntryText( sal_uInt16 nPos ) const;
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx
index 55e2d0ae0a3a..50481c31dec0 100644
--- a/vcl/source/control/ilstbox.cxx
+++ b/vcl/source/control/ilstbox.cxx
@@ -124,26 +124,24 @@ ImplEntryList::~ImplEntryList()
void ImplEntryList::Clear()
{
mnImages = 0;
- for ( sal_uInt16 n = GetEntryCount(); n; )
- {
- ImplEntryType* pImplEntry = GetEntry( --n );
- delete pImplEntry;
- }
- List::Clear();
+ maEntries.clear();
}
// -----------------------------------------------------------------------
void ImplEntryList::SelectEntry( sal_uInt16 nPos, sal_Bool bSelect )
{
- ImplEntryType* pImplEntry = GetEntry( nPos );
- if ( pImplEntry &&
- ( pImplEntry->mbIsSelected != bSelect ) &&
- ( (pImplEntry->mnFlags & LISTBOX_ENTRY_FLAG_DISABLE_SELECTION) == 0 ) )
+ if (nPos < maEntries.size())
{
- pImplEntry->mbIsSelected = bSelect;
- if ( mbCallSelectionChangedHdl )
- maSelectionChangedHdl.Call( (void*)sal_IntPtr(nPos) );
+ boost::ptr_vector<ImplEntryType>::iterator iter = maEntries.begin()+nPos;
+
+ if ( ( iter->mbIsSelected != bSelect ) &&
+ ( (iter->mnFlags & LISTBOX_ENTRY_FLAG_DISABLE_SELECTION) == 0 ) )
+ {
+ iter->mbIsSelected = bSelect;
+ if ( mbCallSelectionChangedHdl )
+ maSelectionChangedHdl.Call( (void*)sal_IntPtr(nPos) );
+ }
}
}
@@ -177,9 +175,20 @@ sal_uInt16 ImplEntryList::InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry
if ( !!pNewEntry->maImage )
mnImages++;
- if ( !bSort || !Count() )
+ sal_uInt16 insPos = 0;
+
+ if ( !bSort || maEntries.empty())
{
- Insert( pNewEntry, nPos );
+ if (nPos < maEntries.size())
+ {
+ insPos = nPos;
+ maEntries.insert( maEntries.begin() + nPos, pNewEntry );
+ }
+ else
+ {
+ maEntries.push_back(pNewEntry);
+ insPos = maEntries.size();
+ }
}
else
{
@@ -188,7 +197,7 @@ sal_uInt16 ImplEntryList::InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry
const XubString& rStr = pNewEntry->maStr;
sal_uLong nLow, nHigh, nMid;
- nHigh = Count();
+ nHigh = maEntries.size();
ImplEntryType* pTemp = GetEntry( (sal_uInt16)(nHigh-1) );
@@ -201,7 +210,8 @@ sal_uInt16 ImplEntryList::InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry
// Schnelles Einfuegen bei sortierten Daten
if ( eComp != COMPARE_LESS )
{
- Insert( pNewEntry, LIST_APPEND );
+ insPos = maEntries.size();
+ maEntries.push_back(pNewEntry);
}
else
{
@@ -211,7 +221,8 @@ sal_uInt16 ImplEntryList::InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry
eComp = (StringCompare)rSorter.compare(rStr, pTemp->maStr);
if ( eComp != COMPARE_GREATER )
{
- Insert( pNewEntry, (sal_uLong)0 );
+ insPos = 0;
+ maEntries.insert(maEntries.begin(),pNewEntry);
}
else
{
@@ -220,7 +231,7 @@ sal_uInt16 ImplEntryList::InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry
do
{
nMid = (nLow + nHigh) / 2;
- pTemp = (ImplEntryType*)GetObject( nMid );
+ pTemp = (ImplEntryType*)GetEntry( nMid );
eComp = (StringCompare)rSorter.compare(rStr, pTemp->maStr);
@@ -239,7 +250,8 @@ sal_uInt16 ImplEntryList::InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry
if ( eComp != COMPARE_LESS )
nMid++;
- Insert( pNewEntry, nMid );
+ insPos = nMid;
+ maEntries.insert(maEntries.begin()+nMid,pNewEntry);
}
}
}
@@ -249,25 +261,27 @@ sal_uInt16 ImplEntryList::InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry
// garbage you wouldn't insert it. If the exception occurred because the
// Collator implementation is garbage then give the user a chance to see
// his stuff
- Insert( pNewEntry, (sal_uLong)0 );
+ insPos = 0;
+ maEntries.insert(maEntries.begin(),pNewEntry);
}
}
- return (sal_uInt16)GetPos( pNewEntry );
+ return insPos;
}
// -----------------------------------------------------------------------
void ImplEntryList::RemoveEntry( sal_uInt16 nPos )
{
- ImplEntryType* pImplEntry = (ImplEntryType*)List::Remove( nPos );
- if ( pImplEntry )
+ boost::ptr_vector<ImplEntryType>::iterator iter = maEntries.begin()+ nPos;
+
+ if (iter != maEntries.end())
{
- if ( !!pImplEntry->maImage )
+ if ( !!iter->maImage )
mnImages--;
- delete pImplEntry;
+ maEntries.erase(iter);
}
}
@@ -275,11 +289,10 @@ void ImplEntryList::RemoveEntry( sal_uInt16 nPos )
sal_uInt16 ImplEntryList::FindEntry( const XubString& rString, sal_Bool bSearchMRUArea ) const
{
- sal_uInt16 nEntries = GetEntryCount();
+ sal_uInt16 nEntries = maEntries.size();
for ( sal_uInt16 n = bSearchMRUArea ? 0 : GetMRUCount(); n < nEntries; n++ )
{
- ImplEntryType* pImplEntry = GetEntry( n );
- String aComp( vcl::I18nHelper::filterFormattingChars( pImplEntry->maStr ) );
+ String aComp( vcl::I18nHelper::filterFormattingChars( maEntries[n].maStr ) );
if ( aComp == rString )
return n;
}
@@ -385,7 +398,7 @@ XubString ImplEntryList::GetEntryText( sal_uInt16 nPos ) const
sal_Bool ImplEntryList::HasEntryImage( sal_uInt16 nPos ) const
{
sal_Bool bImage = sal_False;
- ImplEntryType* pImplEntry = (ImplEntryType*)List::GetObject( nPos );
+ ImplEntryType* pImplEntry = GetEntry( nPos );
if ( pImplEntry )
bImage = !!pImplEntry->maImage;
return bImage;
@@ -396,7 +409,7 @@ sal_Bool ImplEntryList::HasEntryImage( sal_uInt16 nPos ) const
Image ImplEntryList::GetEntryImage( sal_uInt16 nPos ) const
{
Image aImage;
- ImplEntryType* pImplEntry = (ImplEntryType*)List::GetObject( nPos );
+ ImplEntryType* pImplEntry = GetEntry( nPos );
if ( pImplEntry )
aImage = pImplEntry->maImage;
return aImage;
@@ -406,7 +419,7 @@ Image ImplEntryList::GetEntryImage( sal_uInt16 nPos ) const
void ImplEntryList::SetEntryData( sal_uInt16 nPos, void* pNewData )
{
- ImplEntryType* pImplEntry = (ImplEntryType*)List::GetObject( nPos );
+ ImplEntryType* pImplEntry = GetEntry( nPos );
if ( pImplEntry )
pImplEntry->mpUserData = pNewData;
}
@@ -415,7 +428,7 @@ void ImplEntryList::SetEntryData( sal_uInt16 nPos, void* pNewData )
void* ImplEntryList::GetEntryData( sal_uInt16 nPos ) const
{
- ImplEntryType* pImplEntry = (ImplEntryType*)List::GetObject( nPos );
+ ImplEntryType* pImplEntry = GetEntry( nPos );
return pImplEntry ? pImplEntry->mpUserData : NULL;
}
@@ -423,7 +436,7 @@ void* ImplEntryList::GetEntryData( sal_uInt16 nPos ) const
void ImplEntryList::SetEntryFlags( sal_uInt16 nPos, long nFlags )
{
- ImplEntryType* pImplEntry = (ImplEntryType*)List::GetObject( nPos );
+ ImplEntryType* pImplEntry = GetEntry( nPos );
if ( pImplEntry )
pImplEntry->mnFlags = nFlags;
}
@@ -432,7 +445,7 @@ void ImplEntryList::SetEntryFlags( sal_uInt16 nPos, long nFlags )
long ImplEntryList::GetEntryFlags( sal_uInt16 nPos ) const
{
- ImplEntryType* pImplEntry = (ImplEntryType*)List::GetObject( nPos );
+ ImplEntryType* pImplEntry = GetEntry( nPos );
return pImplEntry ? pImplEntry->mnFlags : 0;
}