From 26c0c9d404a65d5ab7a5a9c227132594e467cef4 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Mon, 12 Dec 2011 16:02:22 +0000 Subject: [PATCH] Related: fdo#38832 Replace ImplAccesTable with std::map --- vcl/source/window/accel.cxx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/vcl/source/window/accel.cxx b/vcl/source/window/accel.cxx index f45b1459d738..e755d486eefb 100644 --- a/vcl/source/window/accel.cxx +++ b/vcl/source/window/accel.cxx @@ -27,18 +27,18 @@ ************************************************************************/ -#include #include #include #include #include #include +#include #include // ======================================================================= -DECLARE_TABLE( ImplAccelTable, ImplAccelEntry* ) +typedef ::std::map< sal_uLong, ImplAccelEntry* > ImplAccelMap; typedef ::std::vector< ImplAccelEntry* > ImplAccelList; #define ACCELENTRY_NOTFOUND ((sal_uInt16)0xFFFF) @@ -48,8 +48,8 @@ typedef ::std::vector< ImplAccelEntry* > ImplAccelList; class ImplAccelData { public: - ImplAccelTable maKeyTable; // for keycodes, generated with a code - ImplAccelList maIdList; // Id-List + ImplAccelMap maKeyMap; // for keycodes, generated with a code + ImplAccelList maIdList; // Id-List }; // ======================================================================= @@ -179,7 +179,11 @@ void Accelerator::ImplInit() ImplAccelEntry* Accelerator::ImplGetAccelData( const KeyCode& rKeyCode ) const { - return mpData->maKeyTable.Get( rKeyCode.GetFullKeyCode() ); + ImplAccelMap::iterator it = mpData->maKeyMap.find( rKeyCode.GetFullKeyCode() ); + if( it != mpData->maKeyMap.end() ) + return it->second; + else + return NULL; } // ----------------------------------------------------------------------- @@ -200,7 +204,7 @@ void Accelerator::ImplCopyData( ImplAccelData& rAccelData ) else pEntry->mpAutoAccel = NULL; - mpData->maKeyTable.Insert( (sal_uLong)pEntry->maKeyCode.GetFullKeyCode(), pEntry ); + mpData->maKeyMap.insert( std::make_pair( pEntry->maKeyCode.GetFullKeyCode(), pEntry ) ); mpData->maIdList.push_back( pEntry ); } } @@ -267,7 +271,7 @@ void Accelerator::ImplInsertAccel( sal_uInt16 nItemId, const KeyCode& rKeyCode, OSL_FAIL( "Accelerator::InsertItem(): KeyCode with KeyCode 0 not allowed" ); delete pEntry; } - else if ( !mpData->maKeyTable.Insert( nCode, pEntry ) ) + else if ( mpData->maKeyMap.insert( std::make_pair( nCode, pEntry ) ).second ) { OSL_TRACE( "Accelerator::InsertItem(): KeyCode (Key: %lx) already exists", nCode ); delete pEntry; @@ -470,7 +474,7 @@ Accelerator& Accelerator::operator=( const Accelerator& rAccel ) // delete and copy tables ImplDeleteData(); - mpData->maKeyTable.Clear(); + mpData->maKeyMap.clear(); ImplCopyData( *((ImplAccelData*)(rAccel.mpData)) ); return *this;