callcatcher: cleanup Accelerator

This commit is contained in:
Thomas Arnhold 2011-07-19 17:23:58 +02:00
parent d8a09482fb
commit ded34422f2
2 changed files with 5 additions and 273 deletions

View file

@ -83,9 +83,6 @@ public:
void InsertItem( sal_uInt16 nItemId, const KeyCode& rKeyCode );
void InsertItem( const ResId& rResId );
void RemoveItem( sal_uInt16 nItemId );
void RemoveItem( const KeyCode rKeyCode );
void Clear();
sal_uInt16 GetCurItemId() const { return mnCurId; }
const KeyCode& GetCurKeyCode() const { return maCurKeyCode; }
@ -94,21 +91,9 @@ public:
sal_uInt16 GetItemCount() const;
sal_uInt16 GetItemId( sal_uInt16 nPos ) const;
KeyCode GetItemKeyCode( sal_uInt16 nPos ) const;
sal_uInt16 GetItemId( const KeyCode& rKeyCode ) const;
KeyCode GetKeyCode( sal_uInt16 nItemId ) const;
sal_Bool IsIdValid( sal_uInt16 nItemId ) const;
sal_Bool Call( const KeyCode& rKeyCode, sal_uInt16 nRepeat = 0 );
void SetAccel( sal_uInt16 nItemId, Accelerator* pAccel );
Accelerator* GetAccel( sal_uInt16 nItemId ) const;
void SetAccel( const KeyCode rKeyCode, Accelerator* pAccel );
Accelerator* GetAccel( const KeyCode rKeyCode ) const;
void EnableItem( sal_uInt16 nItemId, sal_Bool bEnable = sal_True );
sal_Bool IsItemEnabled( sal_uInt16 nItemId ) const;
void EnableItem( const KeyCode rKeyCode, sal_Bool bEnable = sal_True );
sal_Bool IsItemEnabled( const KeyCode rKeyCode ) const;
void SetHelpText( const XubString& rHelpText ) { maHelpStr = rHelpText; }
const XubString& GetHelpText() const { return maHelpStr; }

View file

@ -410,85 +410,6 @@ void Accelerator::InsertItem( const ResId& rResId )
// -----------------------------------------------------------------------
void Accelerator::RemoveItem( sal_uInt16 nItemId )
{
DBG_CHKTHIS( Accelerator, NULL );
// Aus der Id-Liste entfernen
sal_uInt16 nIndex = ImplAccelEntryGetFirstPos( &(mpData->maIdList), nItemId );
if ( nIndex != ACCELENTRY_NOTFOUND )
{
sal_uInt16 nItemCount = GetItemCount();
do
{
ImplAccelEntry* pEntry = ( nIndex < mpData->maIdList.size() ) ? mpData->maIdList[ nIndex ] : NULL;
if ( pEntry && pEntry->mnId == nItemId )
{
mpData->maKeyTable.Remove( pEntry->maKeyCode.GetFullKeyCode() );
ImplAccelList::iterator it = mpData->maIdList.begin();
::std::advance( it, nIndex );
mpData->maIdList.erase( it );
// AutoResAccel zerstoeren
if ( pEntry->mpAutoAccel )
delete pEntry->mpAutoAccel;
delete pEntry;
}
else
break;
}
while ( nIndex < nItemCount );
}
}
// -----------------------------------------------------------------------
void Accelerator::RemoveItem( const KeyCode rKeyCode )
{
DBG_CHKTHIS( Accelerator, NULL );
ImplAccelEntry* pEntry = ImplGetAccelData( rKeyCode );
if ( pEntry )
{
// Aus der Id-Liste entfernen
sal_uInt16 nIndex = ImplAccelEntryGetFirstPos( &(mpData->maIdList), pEntry->mnId );
sal_uInt16 nItemCount = GetItemCount();
do
{
if ( mpData->maIdList[ nIndex ] == pEntry )
break;
nIndex++;
}
while ( nIndex < nItemCount );
mpData->maKeyTable.Remove( rKeyCode.GetFullKeyCode() );
ImplAccelList::iterator it = mpData->maIdList.begin();
::std::advance( it, nIndex );
mpData->maIdList.erase( it );
// AutoResAccel zerstoeren
if ( pEntry->mpAutoAccel )
delete pEntry->mpAutoAccel;
delete pEntry;
}
}
// -----------------------------------------------------------------------
void Accelerator::Clear()
{
DBG_CHKTHIS( Accelerator, NULL );
ImplDeleteData();
mpData->maKeyTable.Clear();
}
// -----------------------------------------------------------------------
sal_uInt16 Accelerator::GetItemCount() const
{
DBG_CHKTHIS( Accelerator, NULL );
@ -498,45 +419,6 @@ sal_uInt16 Accelerator::GetItemCount() const
// -----------------------------------------------------------------------
sal_uInt16 Accelerator::GetItemId( sal_uInt16 nPos ) const
{
DBG_CHKTHIS( Accelerator, NULL );
ImplAccelEntry* pEntry = ( nPos < mpData->maIdList.size() ) ? mpData->maIdList[ nPos ] : NULL;
if ( pEntry )
return pEntry->mnId;
else
return 0;
}
// -----------------------------------------------------------------------
KeyCode Accelerator::GetItemKeyCode( sal_uInt16 nPos ) const
{
DBG_CHKTHIS( Accelerator, NULL );
ImplAccelEntry* pEntry = ( nPos < mpData->maIdList.size() ) ? mpData->maIdList[ nPos ] : NULL;
if ( pEntry )
return pEntry->maKeyCode;
else
return KeyCode();
}
// -----------------------------------------------------------------------
sal_uInt16 Accelerator::GetItemId( const KeyCode& rKeyCode ) const
{
DBG_CHKTHIS( Accelerator, NULL );
ImplAccelEntry* pEntry = ImplGetAccelData( rKeyCode );
if ( pEntry )
return pEntry->mnId;
else
return 0;
}
// -----------------------------------------------------------------------
KeyCode Accelerator::GetKeyCode( sal_uInt16 nItemId ) const
{
DBG_CHKTHIS( Accelerator, NULL );
@ -550,66 +432,15 @@ KeyCode Accelerator::GetKeyCode( sal_uInt16 nItemId ) const
// -----------------------------------------------------------------------
sal_Bool Accelerator::IsIdValid( sal_uInt16 nItemId ) const
sal_uInt16 Accelerator::GetItemId( sal_uInt16 nPos ) const
{
DBG_CHKTHIS( Accelerator, NULL );
sal_uInt16 nIndex = ImplAccelEntryGetIndex( &(mpData->maIdList), nItemId );
return (nIndex != ACCELENTRY_NOTFOUND);
}
// -----------------------------------------------------------------------
sal_Bool Accelerator::Call( const KeyCode& rKeyCode, sal_uInt16 nRepeat )
{
DBG_CHKTHIS( Accelerator, NULL );
ImplAccelEntry* pEntry = ImplGetAccelData( rKeyCode );
ImplAccelEntry* pEntry = ( nPos < mpData->maIdList.size() ) ? mpData->maIdList[ nPos ] : NULL;
if ( pEntry )
{
if ( pEntry->mbEnabled )
{
sal_Bool bDel = sal_False;
mnCurId = pEntry->mnId;
maCurKeyCode = rKeyCode;
mnCurRepeat = nRepeat;
mpDel = &bDel;
Select();
if ( !bDel )
{
mnCurId = 0;
maCurKeyCode = KeyCode();
mnCurRepeat = 0;
}
return sal_True;
}
}
return sal_False;
}
// -----------------------------------------------------------------------
void Accelerator::SetAccel( sal_uInt16 nItemId, Accelerator* pAccel )
{
DBG_CHKTHIS( Accelerator, NULL );
sal_uInt16 nIndex = ImplAccelEntryGetFirstPos( &(mpData->maIdList), nItemId );
if ( nIndex != ACCELENTRY_NOTFOUND )
{
sal_uInt16 nItemCount = GetItemCount();
do
{
ImplAccelEntry* pEntry = mpData->maIdList[ nIndex ];
if ( pEntry->mnId != nItemId )
break;
pEntry->mpAccel = pAccel;
nIndex++;
}
while ( nIndex < nItemCount );
}
return pEntry->mnId;
else
return 0;
}
// -----------------------------------------------------------------------
@ -627,90 +458,6 @@ Accelerator* Accelerator::GetAccel( sal_uInt16 nItemId ) const
// -----------------------------------------------------------------------
void Accelerator::SetAccel( const KeyCode rKeyCode, Accelerator* pAccel )
{
DBG_CHKTHIS( Accelerator, NULL );
ImplAccelEntry* pEntry = ImplGetAccelData( rKeyCode );
if ( pEntry )
pEntry->mpAccel = pAccel;
}
// -----------------------------------------------------------------------
Accelerator* Accelerator::GetAccel( const KeyCode rKeyCode ) const
{
DBG_CHKTHIS( Accelerator, NULL );
ImplAccelEntry* pEntry = ImplGetAccelData( rKeyCode );
if ( pEntry )
return pEntry->mpAccel;
else
return sal_False;
}
// -----------------------------------------------------------------------
void Accelerator::EnableItem( sal_uInt16 nItemId, sal_Bool bEnable )
{
DBG_CHKTHIS( Accelerator, NULL );
sal_uInt16 nIndex = ImplAccelEntryGetFirstPos( &(mpData->maIdList), nItemId );
if ( nIndex != ACCELENTRY_NOTFOUND )
{
sal_uInt16 nItemCount = GetItemCount();
do
{
ImplAccelEntry* pEntry = mpData->maIdList[ nIndex ];
if ( pEntry->mnId != nItemId )
break;
pEntry->mbEnabled = bEnable;
nIndex++;
}
while ( nIndex < nItemCount );
}
}
// -----------------------------------------------------------------------
sal_Bool Accelerator::IsItemEnabled( sal_uInt16 nItemId ) const
{
DBG_CHKTHIS( Accelerator, NULL );
sal_uInt16 nIndex = ImplAccelEntryGetIndex( &(mpData->maIdList), nItemId );
if ( nIndex != ACCELENTRY_NOTFOUND )
return mpData->maIdList[ nIndex ]->mbEnabled;
else
return sal_False;
}
// -----------------------------------------------------------------------
void Accelerator::EnableItem( const KeyCode rKeyCode, sal_Bool bEnable )
{
DBG_CHKTHIS( Accelerator, NULL );
ImplAccelEntry* pEntry = ImplGetAccelData( rKeyCode );
if ( pEntry )
pEntry->mbEnabled = bEnable;
}
// -----------------------------------------------------------------------
sal_Bool Accelerator::IsItemEnabled( const KeyCode rKeyCode ) const
{
DBG_CHKTHIS( Accelerator, NULL );
ImplAccelEntry* pEntry = ImplGetAccelData( rKeyCode );
if ( pEntry )
return pEntry->mbEnabled;
else
return sal_False;
}
// -----------------------------------------------------------------------
Accelerator& Accelerator::operator=( const Accelerator& rAccel )
{
DBG_CHKTHIS( Accelerator, NULL );