[Libreoffice-commits] .: vcl/inc vcl/source
David Tardon
dtardon at kemper.freedesktop.org
Tue Feb 8 04:01:47 PST 2011
vcl/inc/vcl/vclevent.hxx | 6 +++++-
vcl/source/app/svapp.cxx | 17 +++++++----------
vcl/source/app/vclevent.cxx | 20 ++++++++++++++++++--
vcl/source/window/menu.cxx | 9 ++++-----
vcl/source/window/window.cxx | 14 ++++++--------
5 files changed, 40 insertions(+), 26 deletions(-)
New commits:
commit 0ec0893ce8b8d9a023da1479739dfba9117f5239
Author: David Tardon <dtardon at redhat.com>
Date: Tue Feb 8 13:01:00 2011 +0100
do not derive from std::list
diff --git a/vcl/inc/vcl/vclevent.hxx b/vcl/inc/vcl/vclevent.hxx
index f4cc2f5..636420d 100644
--- a/vcl/inc/vcl/vclevent.hxx
+++ b/vcl/inc/vcl/vclevent.hxx
@@ -260,7 +260,7 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxAccessible;
};
-class VCL_DLLPUBLIC VclEventListeners : public std::list<Link>
+class VCL_DLLPUBLIC VclEventListeners
{
public:
void Call( VclSimpleEvent* pEvent ) const;
@@ -269,6 +269,10 @@ public:
// and returns TRUE in that case
// a handler must return TRUE to signal that it has processed the event
BOOL Process( VclSimpleEvent* pEvent ) const;
+ void addListener( const Link& rListener );
+ void removeListener( const Link& rListener );
+private:
+ std::list<Link> m_aListeners;
};
class VCL_DLLPUBLIC VclEventListeners2 : public vcl::DeletionNotifier
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 8b16d63..a00cde5 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -833,8 +833,7 @@ void Application::ImplCallEventListeners( ULONG nEvent, Window *pWin, void* pDat
VclWindowEvent aEvent( pWin, nEvent, pData );
if ( pSVData->maAppData.mpEventListeners )
- if ( !pSVData->maAppData.mpEventListeners->empty() )
- pSVData->maAppData.mpEventListeners->Call( &aEvent );
+ pSVData->maAppData.mpEventListeners->Call( &aEvent );
}
// -----------------------------------------------------------------------
@@ -844,8 +843,7 @@ void Application::ImplCallEventListeners( VclSimpleEvent* pEvent )
ImplSVData* pSVData = ImplGetSVData();
if ( pSVData->maAppData.mpEventListeners )
- if ( !pSVData->maAppData.mpEventListeners->empty() )
- pSVData->maAppData.mpEventListeners->Call( pEvent );
+ pSVData->maAppData.mpEventListeners->Call( pEvent );
}
// -----------------------------------------------------------------------
@@ -855,7 +853,7 @@ void Application::AddEventListener( const Link& rEventListener )
ImplSVData* pSVData = ImplGetSVData();
if( !pSVData->maAppData.mpEventListeners )
pSVData->maAppData.mpEventListeners = new VclEventListeners;
- pSVData->maAppData.mpEventListeners->push_back( rEventListener );
+ pSVData->maAppData.mpEventListeners->addListener( rEventListener );
}
// -----------------------------------------------------------------------
@@ -864,7 +862,7 @@ void Application::RemoveEventListener( const Link& rEventListener )
{
ImplSVData* pSVData = ImplGetSVData();
if( pSVData->maAppData.mpEventListeners )
- pSVData->maAppData.mpEventListeners->remove( rEventListener );
+ pSVData->maAppData.mpEventListeners->removeListener( rEventListener );
}
// -----------------------------------------------------------------------
@@ -873,7 +871,7 @@ void Application::AddKeyListener( const Link& rKeyListener )
ImplSVData* pSVData = ImplGetSVData();
if( !pSVData->maAppData.mpKeyListeners )
pSVData->maAppData.mpKeyListeners = new VclEventListeners;
- pSVData->maAppData.mpKeyListeners->push_back( rKeyListener );
+ pSVData->maAppData.mpKeyListeners->addListener( rKeyListener );
}
// -----------------------------------------------------------------------
@@ -882,7 +880,7 @@ void Application::RemoveKeyListener( const Link& rKeyListener )
{
ImplSVData* pSVData = ImplGetSVData();
if( pSVData->maAppData.mpKeyListeners )
- pSVData->maAppData.mpKeyListeners->remove( rKeyListener );
+ pSVData->maAppData.mpKeyListeners->removeListener( rKeyListener );
}
// -----------------------------------------------------------------------
@@ -896,8 +894,7 @@ BOOL Application::HandleKey( ULONG nEvent, Window *pWin, KeyEvent* pKeyEvent )
BOOL bProcessed = FALSE;
if ( pSVData->maAppData.mpKeyListeners )
- if ( !pSVData->maAppData.mpKeyListeners->empty() )
- bProcessed = pSVData->maAppData.mpKeyListeners->Process( &aEvent );
+ bProcessed = pSVData->maAppData.mpKeyListeners->Process( &aEvent );
return bProcessed;
}
diff --git a/vcl/source/app/vclevent.cxx b/vcl/source/app/vclevent.cxx
index 65a490b..2e538ae 100644
--- a/vcl/source/app/vclevent.cxx
+++ b/vcl/source/app/vclevent.cxx
@@ -58,8 +58,11 @@ Reference<XAccessible> VclAccessibleEvent::GetAccessible() const
void VclEventListeners::Call( VclSimpleEvent* pEvent ) const
{
+ if ( m_aListeners.empty() )
+ return;
+
// Copy the list, because this can be destroyed when calling a Link...
- std::list<Link> aCopy( *this );
+ std::list<Link> aCopy( m_aListeners );
std::list<Link>::iterator aIter( aCopy.begin() );
if( pEvent->IsA( VclWindowEvent::StaticType() ) )
{
@@ -83,9 +86,12 @@ void VclEventListeners::Call( VclSimpleEvent* pEvent ) const
BOOL VclEventListeners::Process( VclSimpleEvent* pEvent ) const
{
+ if ( m_aListeners.empty() )
+ return FALSE;
+
BOOL bProcessed = FALSE;
// Copy the list, because this can be destroyed when calling a Link...
- std::list<Link> aCopy( *this );
+ std::list<Link> aCopy( m_aListeners );
std::list<Link>::iterator aIter( aCopy.begin() );
while ( aIter != aCopy.end() )
{
@@ -99,6 +105,16 @@ BOOL VclEventListeners::Process( VclSimpleEvent* pEvent ) const
return bProcessed;
}
+void VclEventListeners::addListener( const Link& rListener )
+{
+ m_aListeners.push_back( rListener );
+}
+
+void VclEventListeners::removeListener( const Link& rListener )
+{
+ m_aListeners.remove( rListener );
+}
+
VclEventListeners2::VclEventListeners2()
{
}
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index b1fc14e..892d175 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -1183,7 +1183,7 @@ void Menu::ImplCallEventListeners( ULONG nEvent, USHORT nPos )
ImplGetSVData()->mpApp->ImplCallEventListeners( &aEvent );
}
- if ( !aDelData.isDeleted() && !maEventListeners.empty() )
+ if ( !aDelData.isDeleted() )
maEventListeners.Call( &aEvent );
if( !aDelData.isDeleted() )
@@ -1191,8 +1191,7 @@ void Menu::ImplCallEventListeners( ULONG nEvent, USHORT nPos )
Menu* pMenu = this;
while ( pMenu )
{
- if ( !maChildEventListeners.empty() )
- maChildEventListeners.Call( &aEvent );
+ maChildEventListeners.Call( &aEvent );
if( aDelData.isDeleted() )
break;
@@ -1204,12 +1203,12 @@ void Menu::ImplCallEventListeners( ULONG nEvent, USHORT nPos )
void Menu::AddEventListener( const Link& rEventListener )
{
- maEventListeners.push_back( rEventListener );
+ maEventListeners.addListener( rEventListener );
}
void Menu::RemoveEventListener( const Link& rEventListener )
{
- maEventListeners.remove( rEventListener );
+ maEventListeners.removeListener( rEventListener );
}
// -----------------------------------------------------------------------
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index a019cdc..0469c99 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -5245,8 +5245,7 @@ void Window::CallEventListeners( ULONG nEvent, void* pData )
if ( aDelData.IsDelete() )
return;
- if ( !mpWindowImpl->maEventListeners.empty() )
- mpWindowImpl->maEventListeners.Call( &aEvent );
+ mpWindowImpl->maEventListeners.Call( &aEvent );
if ( aDelData.IsDelete() )
return;
@@ -5258,8 +5257,7 @@ void Window::CallEventListeners( ULONG nEvent, void* pData )
{
pWindow->ImplAddDel( &aDelData );
- if ( !pWindow->mpWindowImpl->maChildEventListeners.empty() )
- pWindow->mpWindowImpl->maChildEventListeners.Call( &aEvent );
+ pWindow->mpWindowImpl->maChildEventListeners.Call( &aEvent );
if ( aDelData.IsDelete() )
return;
@@ -5279,28 +5277,28 @@ void Window::FireVclEvent( VclSimpleEvent* pEvent )
void Window::AddEventListener( const Link& rEventListener )
{
- mpWindowImpl->maEventListeners.push_back( rEventListener );
+ mpWindowImpl->maEventListeners.addListener( rEventListener );
}
// -----------------------------------------------------------------------
void Window::RemoveEventListener( const Link& rEventListener )
{
- mpWindowImpl->maEventListeners.remove( rEventListener );
+ mpWindowImpl->maEventListeners.removeListener( rEventListener );
}
// -----------------------------------------------------------------------
void Window::AddChildEventListener( const Link& rEventListener )
{
- mpWindowImpl->maChildEventListeners.push_back( rEventListener );
+ mpWindowImpl->maChildEventListeners.addListener( rEventListener );
}
// -----------------------------------------------------------------------
void Window::RemoveChildEventListener( const Link& rEventListener )
{
- mpWindowImpl->maChildEventListeners.remove( rEventListener );
+ mpWindowImpl->maChildEventListeners.removeListener( rEventListener );
}
// -----------------------------------------------------------------------
More information about the Libreoffice-commits
mailing list