[Libreoffice-commits] .: vcl/inc vcl/source
Joseph Powers
jpowers at kemper.freedesktop.org
Thu Feb 17 10:21:54 PST 2011
vcl/inc/vcl/accmgr.hxx | 6 ++-
vcl/source/window/accmgr.cxx | 80 ++++++++++++++++++++-----------------------
2 files changed, 42 insertions(+), 44 deletions(-)
New commits:
commit 71a79cf252f39a2f3a0514c6f6baa078e3cb6734
Author: Joseph Powers <jpowers27 at cox.net>
Date: Thu Feb 17 10:20:19 2011 -0800
Remove DECLARE_LIST( ImplAccelList, Accelerator* )
diff --git a/vcl/inc/vcl/accmgr.hxx b/vcl/inc/vcl/accmgr.hxx
index e362014..5b98805 100644
--- a/vcl/inc/vcl/accmgr.hxx
+++ b/vcl/inc/vcl/accmgr.hxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -30,11 +30,13 @@
#define _SV_ACCMGR_HXX
#include <vcl/sv.h>
+#include <vector>
-class ImplAccelList;
class Accelerator;
class KeyCode;
+typedef ::std::vector< Accelerator* > ImplAccelList;
+
// --------------------
// - ImplAccelManager -
// --------------------
diff --git a/vcl/source/window/accmgr.cxx b/vcl/source/window/accmgr.cxx
index 0983834..b450204 100644
--- a/vcl/source/window/accmgr.cxx
+++ b/vcl/source/window/accmgr.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -28,18 +28,12 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_vcl.hxx"
-#include <tools/list.hxx>
+
#include <tools/debug.hxx>
#include <vcl/accel.h>
#include <vcl/accel.hxx>
#include <vcl/accmgr.hxx>
-
-
-// =======================================================================
-
-DECLARE_LIST( ImplAccelList, Accelerator* )
-
// =======================================================================
DBG_NAMEEX( Accelerator )
@@ -58,18 +52,17 @@ ImplAccelManager::~ImplAccelManager()
BOOL ImplAccelManager::InsertAccel( Accelerator* pAccel )
{
- if ( !mpAccelList )
+ if ( !mpAccelList ) {
mpAccelList = new ImplAccelList;
- else
- {
- // Gibts den schon ?
- if ( mpAccelList->GetPos( pAccel ) != LIST_ENTRY_NOTFOUND )
- return FALSE;
+ } else {
+ for ( size_t i = 0, n = mpAccelList->size(); i < n; ++i ) {
+ if ( (*mpAccelList)[ i ] == pAccel ) {
+ return FALSE;
+ }
+ }
}
- // Am Anfang der Liste einfuegen
- mpAccelList->Insert( pAccel, (ULONG)0 );
-
+ mpAccelList->insert( mpAccelList->begin(), pAccel );
return TRUE;
}
@@ -84,22 +77,30 @@ void ImplAccelManager::RemoveAccel( Accelerator* pAccel )
//e.g. #i90599#. Someone starts typing a sequence in a dialog, but doesn't
//end it, and then closes the dialog, deleting the accelerators. So if
//we're removing an accelerator that a sub-accelerator which is in the
- //sequence list, throw away the entire sequence
- if ( mpSequenceList )
- {
- for (USHORT i = 0; i < pAccel->GetItemCount(); ++i)
- {
- Accelerator* pSubAccel = pAccel->GetAccel(pAccel->GetItemId(i));
- if ( mpSequenceList->GetPos( pSubAccel ) != LIST_ENTRY_NOTFOUND )
- {
- EndSequence( true );
- break;
+ //sequence list, throw away the entire sequence
+ if ( mpSequenceList ) {
+ for (USHORT i = 0; i < pAccel->GetItemCount(); ++i) {
+ Accelerator* pSubAccel = pAccel->GetAccel( pAccel->GetItemId(i) );
+ for ( size_t j = 0, n = mpSequenceList->size(); j < n; ++j ) {
+ if ( (*mpSequenceList)[ j ] == pSubAccel ) {
+ EndSequence( true );
+ i = pAccel->GetItemCount();
+ break;
+ }
}
}
}
// Raus damit
- mpAccelList->Remove( pAccel );
+ for ( ImplAccelList::iterator it = mpAccelList->begin();
+ it < mpAccelList->end();
+ ++it
+ ) {
+ if ( *it == pAccel ) {
+ mpAccelList->erase( it );
+ break;
+ }
+ }
}
// -----------------------------------------------------------------------
@@ -111,9 +112,9 @@ void ImplAccelManager::EndSequence( BOOL bCancel )
return;
// Alle Deactivate-Handler der Acceleratoren in der Sequenz rufen
- Accelerator* pTempAccel = mpSequenceList->First();
- while( pTempAccel )
+ for ( size_t i = 0, n = mpSequenceList->size(); i < n; ++i )
{
+ Accelerator* pTempAccel = (*mpSequenceList)[ i ];
BOOL bDel = FALSE;
pTempAccel->mbIsCancel = bCancel;
pTempAccel->mpDel = &bDel;
@@ -123,8 +124,6 @@ void ImplAccelManager::EndSequence( BOOL bCancel )
pTempAccel->mbIsCancel = FALSE;
pTempAccel->mpDel = NULL;
}
-
- pTempAccel = mpSequenceList->Next();
}
// Sequenz-Liste loeschen
@@ -141,13 +140,13 @@ BOOL ImplAccelManager::IsAccelKey( const KeyCode& rKeyCode, USHORT nRepeat )
// Haben wir ueberhaupt Acceleratoren ??
if ( !mpAccelList )
return FALSE;
- if ( !mpAccelList->Count() )
+ if ( mpAccelList->empty() )
return FALSE;
// Sind wir in einer Sequenz ?
if ( mpSequenceList )
{
- pAccel = mpSequenceList->GetObject( 0 );
+ pAccel = mpSequenceList->empty() ? NULL : (*mpSequenceList)[ 0 ];
DBG_CHKOBJ( pAccel, Accelerator, NULL );
// Nicht Gefunden ?
@@ -169,7 +168,7 @@ BOOL ImplAccelManager::IsAccelKey( const KeyCode& rKeyCode, USHORT nRepeat )
{
DBG_CHKOBJ( pNextAccel, Accelerator, NULL );
- mpSequenceList->Insert( pNextAccel, (ULONG)0 );
+ mpSequenceList->insert( mpSequenceList->begin(), pNextAccel );
// Activate-Handler vom Neuen rufen
pNextAccel->Activate();
@@ -222,9 +221,9 @@ BOOL ImplAccelManager::IsAccelKey( const KeyCode& rKeyCode, USHORT nRepeat )
}
// Durch die Liste der Acceleratoren wuehlen
- pAccel = mpAccelList->First();
- while ( pAccel )
+ for ( size_t i = 0, n = mpAccelList->size(); i < n; ++i )
{
+ pAccel = (*mpAccelList)[ i ];
DBG_CHKOBJ( pAccel, Accelerator, NULL );
// Ist der Eintrag da drin ?
@@ -240,8 +239,8 @@ BOOL ImplAccelManager::IsAccelKey( const KeyCode& rKeyCode, USHORT nRepeat )
// Sequenz-Liste erzeugen
mpSequenceList = new ImplAccelList;
- mpSequenceList->Insert( pAccel, (ULONG)0 );
- mpSequenceList->Insert( pNextAccel, (ULONG)0 );
+ mpSequenceList->insert( mpSequenceList->begin(), pAccel );
+ mpSequenceList->insert( mpSequenceList->begin(), pNextAccel );
// Activate-Handler vom Neuen rufen
pNextAccel->Activate();
@@ -282,9 +281,6 @@ BOOL ImplAccelManager::IsAccelKey( const KeyCode& rKeyCode, USHORT nRepeat )
return FALSE;
}
}
-
- // Nicht gefunden, vielleicht im naechsten Accelerator
- pAccel = mpAccelList->Next();
}
return FALSE;
More information about the Libreoffice-commits
mailing list