summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2012-06-03 18:58:57 +0200
committerMichael Stahl <mstahl@redhat.com>2012-06-08 22:52:32 +0200
commit905fe5993ec3a3a22f01ea31fce6c884359d48ab (patch)
treec036a615469066207a72f5a6e1f63f78a460c668 /svl
parentbe369facf912da2e0da27194738027fc5a07d779 (diff)
Convert SV_PTRARR_DECL(SfxBroadcasterArr_Impl) to std::deque
Change-Id: I24cdc05c559536e83101e4d811080746f92c74af
Diffstat (limited to 'svl')
-rw-r--r--svl/inc/svl/lstner.hxx9
-rw-r--r--svl/source/notify/lstner.cxx45
2 files changed, 23 insertions, 31 deletions
diff --git a/svl/inc/svl/lstner.hxx b/svl/inc/svl/lstner.hxx
index a2b590939804..3a4513aa0274 100644
--- a/svl/inc/svl/lstner.hxx
+++ b/svl/inc/svl/lstner.hxx
@@ -31,13 +31,12 @@
#include "svl/svldllapi.h"
#include <tools/rtti.hxx>
#include <svl/svarray.hxx>
+#include <deque>
class SfxBroadcaster;
class SfxHint;
-#ifndef _SFX_LSTNER_CXX
-typedef SvPtrarr SfxBroadcasterArr_Impl;
-#endif
+typedef std::deque<SfxBroadcaster*> SfxBroadcasterArr_Impl;
#define SFX_NOTIFY( rBC, rBCT, rHint, rHintT ) \
Notify( rBC, rHint )
@@ -64,9 +63,9 @@ public:
sal_Bool IsListening( SfxBroadcaster& rBroadcaster ) const;
sal_uInt16 GetBroadcasterCount() const
- { return aBCs.Count(); }
+ { return aBCs.size(); }
SfxBroadcaster* GetBroadcasterJOE( sal_uInt16 nNo ) const
- { return (SfxBroadcaster*) aBCs.GetObject(nNo); }
+ { return aBCs[nNo]; }
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
diff --git a/svl/source/notify/lstner.cxx b/svl/source/notify/lstner.cxx
index 8973273b0c69..55da270f5a13 100644
--- a/svl/source/notify/lstner.cxx
+++ b/svl/source/notify/lstner.cxx
@@ -32,10 +32,8 @@
#include <svl/hint.hxx>
#include <svl/brdcst.hxx>
-SV_DECL_PTRARR( SfxBroadcasterArr_Impl, SfxBroadcaster*, 0 )
-
-#define _SFX_LSTNER_CXX
#include <svl/lstner.hxx>
+#include <algorithm>
//====================================================================
DBG_NAME(SfxListener)
@@ -56,19 +54,19 @@ SfxListener::SfxListener( const SfxListener &rListener )
{
DBG_CTOR(SfxListener, 0);
- for ( sal_uInt16 n = 0; n < rListener.aBCs.Count(); ++n )
+ for ( sal_uInt16 n = 0; n < rListener.aBCs.size(); ++n )
StartListening( *rListener.aBCs[n] );
}
//--------------------------------------------------------------------
-// unregisteres the SfxListener from its SfxBroadcasters
+// unregisters the SfxListener from its SfxBroadcasters
SfxListener::~SfxListener()
{
DBG_DTOR(SfxListener, 0);
- // unregister at all remainding broadcasters
- for ( sal_uInt16 nPos = 0; nPos < aBCs.Count(); ++nPos )
+ // unregister at all remaining broadcasters
+ for ( sal_uInt16 nPos = 0; nPos < aBCs.size(); ++nPos )
{
SfxBroadcaster *pBC = aBCs[nPos];
pBC->RemoveListener(*this);
@@ -77,19 +75,18 @@ SfxListener::~SfxListener()
//--------------------------------------------------------------------
-// unregisteres at a specific SfxBroadcaster
+// unregisters a specific SfxBroadcaster
-void SfxListener::RemoveBroadcaster_Impl( SfxBroadcaster& rBC )
+void SfxListener::RemoveBroadcaster_Impl( SfxBroadcaster& rBroadcaster )
{
DBG_CHKTHIS(SfxListener, 0);
- const SfxBroadcaster *pBC = &rBC;
- aBCs.Remove( aBCs.GetPos(pBC), 1 );
+ aBCs.erase( std::find( aBCs.begin(), aBCs.end(), &rBroadcaster ) );
}
//--------------------------------------------------------------------
-// registeres at a specific SfxBroadcaster
+// registers a specific SfxBroadcaster
sal_Bool SfxListener::StartListening( SfxBroadcaster& rBroadcaster, sal_Bool bPreventDups )
{
@@ -99,8 +96,7 @@ sal_Bool SfxListener::StartListening( SfxBroadcaster& rBroadcaster, sal_Bool bPr
{
if ( rBroadcaster.AddListener(*this) )
{
- const SfxBroadcaster *pBC = &rBroadcaster;
- aBCs.Insert( pBC, aBCs.Count() );
+ aBCs.push_back( &rBroadcaster );
DBG_ASSERT( IsListening(rBroadcaster), "StartListening failed" );
return sal_True;
@@ -112,7 +108,7 @@ sal_Bool SfxListener::StartListening( SfxBroadcaster& rBroadcaster, sal_Bool bPr
//--------------------------------------------------------------------
-// unregisteres at a specific SfxBroadcaster
+// unregisters a specific SfxBroadcaster
sal_Bool SfxListener::EndListening( SfxBroadcaster& rBroadcaster, sal_Bool bAllDups )
{
@@ -124,8 +120,7 @@ sal_Bool SfxListener::EndListening( SfxBroadcaster& rBroadcaster, sal_Bool bAllD
do
{
rBroadcaster.RemoveListener(*this);
- const SfxBroadcaster *pBC = &rBroadcaster;
- aBCs.Remove( aBCs.GetPos(pBC), 1 );
+ aBCs.erase( std::find( aBCs.begin(), aBCs.end(), &rBroadcaster ) );
}
while ( bAllDups && IsListening( rBroadcaster ) );
return sal_True;
@@ -133,18 +128,18 @@ sal_Bool SfxListener::EndListening( SfxBroadcaster& rBroadcaster, sal_Bool bAllD
//--------------------------------------------------------------------
-// unregisteres all Broadcasters
+// unregisters all Broadcasters
void SfxListener::EndListeningAll()
{
DBG_CHKTHIS(SfxListener, 0);
// MI: bei Optimierung beachten: Seiteneffekte von RemoveListener beachten!
- while ( aBCs.Count() )
+ while ( !aBCs.empty() )
{
- SfxBroadcaster *pBC = aBCs.GetObject(0);
+ SfxBroadcaster *pBC = aBCs.front();
pBC->RemoveListener(*this);
- aBCs.Remove( 0, 1 );
+ aBCs.pop_front();
}
}
@@ -152,8 +147,7 @@ void SfxListener::EndListeningAll()
sal_Bool SfxListener::IsListening( SfxBroadcaster& rBroadcaster ) const
{
- const SfxBroadcaster *pBC = &rBroadcaster;
- return USHRT_MAX != aBCs.GetPos( pBC );
+ return aBCs.end() != std::find( aBCs.begin(), aBCs.end(), &rBroadcaster );
}
//--------------------------------------------------------------------
@@ -161,14 +155,13 @@ sal_Bool SfxListener::IsListening( SfxBroadcaster& rBroadcaster ) const
// base implementation of notification handler
#ifdef DBG_UTIL
-void SfxListener::Notify( SfxBroadcaster& rBC, const SfxHint& )
+void SfxListener::Notify( SfxBroadcaster& rBroadcaster, const SfxHint& )
#else
void SfxListener::Notify( SfxBroadcaster&, const SfxHint& )
#endif
{
#ifdef DBG_UTIL
- const SfxBroadcaster *pBC = &rBC;
- DBG_ASSERT( USHRT_MAX != aBCs.GetPos(pBC),
+ DBG_ASSERT(aBCs.end() != std::find(aBCs.begin(), aBCs.end(), &rBroadcaster),
"notification from unregistered broadcaster" );
#endif
}