ooo-build r12626 - in trunk: . patches/test



Author: kyoshida
Date: Thu May 22 00:11:42 2008
New Revision: 12626
URL: http://svn.gnome.org/viewvc/ooo-build?rev=12626&view=rev

Log:
2008-05-21  Kohei Yoshida  <kyoshida novell com>

	* patches/test/sfx-broadcaster-hashset-sd.diff: fixed ambiguity in the
	names of two data members as it caused a build breakage.
	
	* patches/test/sfx-broadcaster-hashset-svtools.diff: added back the old
	implementation and used USE_NEW_IMPL to switch between the old and the 
	new implementations.


Modified:
   trunk/ChangeLog
   trunk/patches/test/sfx-broadcaster-hashset-sd.diff
   trunk/patches/test/sfx-broadcaster-hashset-svtools.diff

Modified: trunk/patches/test/sfx-broadcaster-hashset-sd.diff
==============================================================================
--- trunk/patches/test/sfx-broadcaster-hashset-sd.diff	(original)
+++ trunk/patches/test/sfx-broadcaster-hashset-sd.diff	Thu May 22 00:11:42 2008
@@ -248,3 +248,47 @@
  }
  
  /*************************************************************************
+diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx
+index 5062b73..ca32063 100644
+--- sd/source/ui/view/drviews1.cxx
++++ sd/source/ui/view/drviews1.cxx
+@@ -384,7 +384,7 @@ void DrawViewShell::ChangeEditMode(EditMode eEMode, bool bIsLayerModeActive)
+ 
+         // If the master view toolbar is not shown we hide it before
+         // switching the edit mode.
+-        if (mpImpl->mbIsInitialized
++        if (::sd::ViewShell::mpImpl->mbIsInitialized
+             && IsMainViewShell()
+             && ! bShowMasterViewToolbar)
+         {
+@@ -457,7 +457,7 @@ void DrawViewShell::ChangeEditMode(EditMode eEMode, bool bIsLayerModeActive)
+ 
+         // If the master view toolbar is to be shown we turn it on after the
+         // edit mode has been changed.
+-        if (mpImpl->mbIsInitialized
++        if (::sd::ViewShell::mpImpl->mbIsInitialized
+             && IsMainViewShell()
+             && bShowMasterViewToolbar)
+         {
+diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
+index 22d2fbd..5bd51ea 100644
+--- sd/source/ui/view/drviews2.cxx
++++ sd/source/ui/view/drviews2.cxx
+@@ -409,7 +409,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
+ 				}
+ 				USHORT nPage = maTabControl.GetCurPageId() - 1;
+ 				mpActualPage = GetDoc()->GetSdPage(nPage, mePageKind);
+-                mpImpl->ProcessModifyPageSlot (
++                ::sd::ViewShell::mpImpl->ProcessModifyPageSlot (
+                     rReq,
+                     mpActualPage,
+                     mePageKind);
+@@ -431,7 +431,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
+ 
+                 SFX_REQUEST_ARG (rReq, pWhatPage, SfxUInt32Item, ID_VAL_WHATPAGE, FALSE);
+                 SFX_REQUEST_ARG (rReq, pWhatLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, FALSE);
+-                mpImpl->AssignLayout (
++                ::sd::ViewShell::mpImpl->AssignLayout (
+                     GetDoc()->GetSdPage((USHORT)pWhatPage->GetValue(), mePageKind),
+                     (AutoLayout)pWhatLayout->GetValue());
+             }

Modified: trunk/patches/test/sfx-broadcaster-hashset-svtools.diff
==============================================================================
--- trunk/patches/test/sfx-broadcaster-hashset-svtools.diff	(original)
+++ trunk/patches/test/sfx-broadcaster-hashset-svtools.diff	Thu May 22 00:11:42 2008
@@ -125,10 +125,10 @@
  
  //////////////////////// SfxStyleSheetPool ///////////////////////////////
 diff --git a/svtools/source/notify/brdcst.cxx b/svtools/source/notify/brdcst.cxx
-index 4e7f5c5..c0f3291 100644
+index 4e7f5c5..ad8019e 100644
 --- svtools/source/notify/brdcst.cxx
 +++ svtools/source/notify/brdcst.cxx
-@@ -39,17 +39,111 @@
+@@ -39,17 +39,122 @@
  #include <svtools/smplhint.hxx>
  #include <svtools/lstner.hxx>
  
@@ -140,6 +140,8 @@
 +#include <algorithm>
 +#include <hash_set>
 +
++#define USE_NEW_IMPL 0
++
 +using ::std::find;
 +using ::std::unary_function;
 +
@@ -157,18 +159,27 @@
 +    }
 +};
 +
++#if USE_NEW_IMPL
 +typedef ::std::hash_set<SfxListener*, SfxListenerHash> ListenerArray;
++#else
++
++//#ifndef _SFX_BRDCST_CXX
++//typedef SvPtrarr ListenerArray;
++//#endif
++
++SV_DECL_PTRARR( ListenerArray, SfxListener*, 0, 2 )
++
++#endif
 +
 +struct SfxBroadcasterImpl
 +{
 +	ListenerArray   maListeners;
 +
-+    SfxBroadcasterImpl() {}
++//  SfxBroadcasterImpl() {}
 +
-+    explicit SfxBroadcasterImpl(const SfxBroadcasterImpl& r) :
-+        maListeners(r.maListeners)
-+    {
-+    }
++//  explicit SfxBroadcasterImpl(const SfxBroadcasterImpl& r)
++//  {
++//  }
 +};
 +
 +// ----------------------------------------------------------------------------
@@ -243,38 +254,22 @@
  //====================================================================
  // broadcast immediately
  
-@@ -59,25 +153,28 @@ void SfxBroadcaster::Broadcast( const SfxHint &rHint )
+@@ -58,27 +163,42 @@ void SfxBroadcaster::Broadcast( const SfxHint &rHint )
+ {
  	DBG_CHKTHIS(SfxBroadcaster, 0);
  
++#if USE_NEW_IMPL
  	// is anybody to notify?
 -	if ( aListeners.Count() /*! || aGlobListeners.Count() */ )
 +	if ( !mpImpl->maListeners.empty() /*! || aGlobListeners.Count() */ )
- 	{
--        #if 0
--		// determine the type only once, because of its expensiveness
--		const TypeId& rBCType = Type();
--		const TypeId& rHintType = rHint.Type();
--        #endif
--
- 		// notify all registered listeners exactly once
--		for ( USHORT n = 0; n < aListeners.Count(); ++n )
--		{
--			SfxListener* pListener = aListeners[n];
--			if ( pListener )
--                #if 0
--				pListener->SFX_NOTIFY( *this, rBCType, rHint, rHintType );
--                #else
--				pListener->Notify( *this, rHint );
--                #endif
--		}
++	{
++		// notify all registered listeners exactly once
 +#if 1
 +        ListenerArray::iterator itrEnd = mpImpl->maListeners.end();
 +        for (ListenerArray::iterator itr = mpImpl->maListeners.begin(); itr != itrEnd; ++itr)
 +        {
 +            SfxListener* pLis = *itr;
-+            unsigned int nFoo = reinterpret_cast<unsigned int>(pLis);
-+            fprintf(stdout, "SfxBroadcaster::Broadcast:   notifying listener = %p (%d)\n", pLis, nFoo);fflush(stdout);
-+            if (pLis && nFoo > 20)
++            if (pLis)
 +            {
 +                fprintf(stdout, "SfxBroadcaster::Broadcast:   notifying\n");
 +                pLis->Notify(*this, rHint);
@@ -286,21 +281,62 @@
 +        NotifyListenerFunc f(rHint, *this);
 +        for_each(mpImpl->maListeners.begin(), mpImpl->maListeners.end(), f);
 +#endif
++	}
++#else
++	// is anybody to notify?
++	if ( mpImpl->maListeners.Count() /*! || aGlobListeners.Count() */ )
+ 	{
+-        #if 0
+-		// determine the type only once, because of its expensiveness
+-		const TypeId& rBCType = Type();
+-		const TypeId& rHintType = rHint.Type();
+-        #endif
+-
+ 		// notify all registered listeners exactly once
+-		for ( USHORT n = 0; n < aListeners.Count(); ++n )
++		for ( USHORT n = 0; n < mpImpl->maListeners.Count(); ++n )
+ 		{
+-			SfxListener* pListener = aListeners[n];
++			SfxListener* pListener = (SfxListener*)mpImpl->maListeners[n];
+ 			if ( pListener )
+-                #if 0
+-				pListener->SFX_NOTIFY( *this, rBCType, rHint, rHintType );
+-                #else
+ 				pListener->Notify( *this, rHint );
+-                #endif
+ 		}
  	}
++#endif
  }
  
-@@ -111,19 +208,16 @@ SfxBroadcaster::~SfxBroadcaster()
+ //--------------------------------------------------------------------
+@@ -111,19 +231,35 @@ SfxBroadcaster::~SfxBroadcaster()
  	Broadcast( SfxSimpleHint(SFX_HINT_DYING) );
  
  	// remove all still registered listeners
 -	for ( USHORT nPos = 0; nPos < aListeners.Count(); ++nPos )
--	{
--		SfxListener *pListener = aListeners[nPos];
--		if ( pListener )
--			pListener->RemoveBroadcaster_Impl(*this);
--	}
++#if USE_NEW_IMPL
++#if 1
++    ListenerArray::iterator itrEnd = mpImpl->maListeners.end();
++    for (ListenerArray::iterator itr = mpImpl->maListeners.begin(); itr != itrEnd; ++itr)
++    {
++        SfxListener* pLis = *itr;
++        if (pLis)
++            pLis->RemoveBroadcaster_Impl(*this);
++    }
++#else    
 +    UnregisterListenerFunc f(*this);
 +    for_each(mpImpl->maListeners.begin(), mpImpl->maListeners.end(), f);
++#endif
++#else
++	for ( USHORT nPos = 0; nPos < mpImpl->maListeners.Count(); ++nPos )
+ 	{
+-		SfxListener *pListener = aListeners[nPos];
++		SfxListener *pListener = static_cast<SfxListener*>(mpImpl->maListeners[nPos]);
+ 		if ( pListener )
+ 			pListener->RemoveBroadcaster_Impl(*this);
+ 	}
++#endif
  }
  
  //--------------------------------------------------------------------
@@ -313,53 +349,76 @@
  {
  	DBG_CTOR(SfxBroadcaster, 0);
  }
-@@ -133,16 +227,13 @@ SfxBroadcaster::SfxBroadcaster()
+@@ -133,16 +269,32 @@ SfxBroadcaster::SfxBroadcaster()
  // copy ctor of class SfxBroadcaster
  
  
 -SfxBroadcaster::SfxBroadcaster( const SfxBroadcaster &rBC )
 +SfxBroadcaster::SfxBroadcaster( const SfxBroadcaster &rBC ) :
-+    mpImpl(new SfxBroadcasterImpl(*rBC.mpImpl))
++    mpImpl(new SfxBroadcasterImpl)
  {
  	DBG_CTOR(SfxBroadcaster, 0);
  
 -	for ( USHORT n = 0; n < rBC.aListeners.Count(); ++n )
--	{
--		SfxListener *pListener = rBC.aListeners[n];
--		if ( pListener )
--			pListener->StartListening( *this );
--	}
++#if USE_NEW_IMPL
++#if 1
++    ListenerArray::iterator itrEnd = mpImpl->maListeners.end();
++    for (ListenerArray::iterator itr = mpImpl->maListeners.begin(); itr != itrEnd; ++itr)
++    {
++        SfxListener* pLis = *itr;
++        if (pLis)
++            pLis->StartListening(*this);
++    }
++#else
 +    RegisterListenerFunc f(*this);
 +    for_each(rBC.mpImpl->maListeners.begin(), rBC.mpImpl->maListeners.end(), f);
++#endif
++#else
++	for ( USHORT n = 0; n < rBC.mpImpl->maListeners.Count(); ++n )
+ 	{
+-		SfxListener *pListener = rBC.aListeners[n];
++		SfxListener *pListener = static_cast<SfxListener*>(rBC.mpImpl->maListeners[n]);
+ 		if ( pListener )
+ 			pListener->StartListening( *this );
+ 	}
++#endif
  }
  
  //--------------------------------------------------------------------
-@@ -152,21 +243,9 @@ SfxBroadcaster::SfxBroadcaster( const SfxBroadcaster &rBC )
+@@ -152,21 +304,26 @@ SfxBroadcaster::SfxBroadcaster( const SfxBroadcaster &rBC )
  BOOL SfxBroadcaster::AddListener( SfxListener& rListener )
  {
  	DBG_CHKTHIS(SfxBroadcaster, 0);
--	const SfxListener *pListener = &rListener;
--	const SfxListener *pNull = 0;
++#if USE_NEW_IMPL
++	SfxListener *pListener = &rListener;
++    mpImpl->maListeners.insert(pListener);
++#else
+ 	const SfxListener *pListener = &rListener;
+ 	const SfxListener *pNull = 0;
 -	USHORT nFreePos = aListeners.GetPos( pNull );
 -	if ( nFreePos < aListeners.Count() )
 -		aListeners.GetData()[nFreePos] = pListener;
 -	else if ( aListeners.Count() < (USHRT_MAX-1) )
 -		aListeners.Insert( pListener, aListeners.Count() );
--	else
--	{
--		DBG_ERROR( "array overflow" );
--		return FALSE;
--	}
--
++	USHORT nFreePos = mpImpl->maListeners.GetPos( pNull );
++	if ( nFreePos < mpImpl->maListeners.Count() )
++		mpImpl->maListeners.GetData()[nFreePos] = pListener;
++	else if ( mpImpl->maListeners.Count() < (USHRT_MAX-1) )
++		mpImpl->maListeners.Insert( pListener, mpImpl->maListeners.Count() );
+ 	else
+ 	{
+ 		DBG_ERROR( "array overflow" );
+ 		return FALSE;
+ 	}
+ 
 -	DBG_ASSERT( USHRT_MAX != aListeners.GetPos(pListener),
--				"AddListener failed" );
-+	SfxListener *pListener = &rListener;
-+    fprintf(stdout, "SfxBroadcaster::AddListener:   adding listener %p\n", pListener);
-+    mpImpl->maListeners.insert(pListener);
++	DBG_ASSERT( USHRT_MAX != mpImpl->maListeners.GetPos(pListener),
+ 				"AddListener failed" );
++#endif
  	return TRUE;
  }
  
-@@ -182,17 +261,10 @@ void SfxBroadcaster::ListenersGone()
+@@ -182,17 +339,30 @@ void SfxBroadcaster::ListenersGone()
  //--------------------------------------------------------------------
  
  // forward a notification to all registered listeners
@@ -369,25 +428,38 @@
 +void SfxBroadcaster::Forward(SfxBroadcaster& rBC, const SfxHint& rHint)
  {
 -	const USHORT nCount = aListeners.Count();
--	for ( USHORT i = 0; i < nCount; ++i )
--	{
--		SfxListener *pListener = aListeners[i];
--		if ( pListener )
--			pListener->SFX_NOTIFY( rBC, rBCType, rHint, rHintType);
--	}
++#if USE_NEW_IMPL
++#if 1
++    ListenerArray::iterator itrEnd = mpImpl->maListeners.end();
++    for (ListenerArray::iterator itr = mpImpl->maListeners.begin(); itr != itrEnd; ++itr)
++    {
++        SfxListener* pLis = *itr;
++        if (pLis)
++            pLis->Notify(rBC, rHint);
++    }
++#else
 +    NotifyListenerFunc f(rHint, rBC);
 +    for_each(mpImpl->maListeners.begin(), mpImpl->maListeners.end(), f);
++#endif
++#else
++	const USHORT nCount = mpImpl->maListeners.Count();
+ 	for ( USHORT i = 0; i < nCount; ++i )
+ 	{
+-		SfxListener *pListener = aListeners[i];
++		SfxListener *pListener = mpImpl->maListeners[i];
+ 		if ( pListener )
+-			pListener->SFX_NOTIFY( rBC, rBCType, rHint, rHintType);
++			pListener->Notify( rBC, rHint );
+ 	}
++#endif
  }
  
  //--------------------------------------------------------------------
-@@ -202,10 +274,23 @@ void SfxBroadcaster::SFX_FORWARD(SfxBroadcaster& rBC, const TypeId& rBCType,
+@@ -202,22 +372,71 @@ void SfxBroadcaster::SFX_FORWARD(SfxBroadcaster& rBC, const TypeId& rBCType,
  void SfxBroadcaster::RemoveListener( SfxListener& rListener )
  {
  	{DBG_CHKTHIS(SfxBroadcaster, 0);}
--	const SfxListener *pListener = &rListener;
--	USHORT nPos = aListeners.GetPos(pListener);
--	DBG_ASSERT( nPos != USHRT_MAX, "RemoveListener: Listener unknown" );
--	aListeners.GetData()[nPos] = 0;
++#if USE_NEW_IMPL
 +	SfxListener *pListener = &rListener;
 +    fprintf(stdout, "SfxBroadcaster::RemoveListener:   removing listener %p\n", pListener);
 +    ListenerArray::iterator itr = find(mpImpl->maListeners.begin(), mpImpl->maListeners.end(), pListener);
@@ -405,18 +477,34 @@
 +    for (itr = mpImpl->maListeners.begin(); itr != mpImpl->maListeners.end(); ++itr)
 +        fprintf(stdout, "SfxBroadcaster::RemoveListener:   - listener %p\n", *itr);
 +
++	if ( !HasListeners() )
++		ListenersGone();
++#else
+ 	const SfxListener *pListener = &rListener;
+-	USHORT nPos = aListeners.GetPos(pListener);
++	USHORT nPos = mpImpl->maListeners.GetPos(pListener);
+ 	DBG_ASSERT( nPos != USHRT_MAX, "RemoveListener: Listener unknown" );
+-	aListeners.GetData()[nPos] = 0;
++	mpImpl->maListeners.GetData()[nPos] = 0;
  	if ( !HasListeners() )
  		ListenersGone();
++#endif
  }
-@@ -214,10 +299,22 @@ void SfxBroadcaster::RemoveListener( SfxListener& rListener )
+ 
+ //--------------------------------------------------------------------
  
  BOOL SfxBroadcaster::HasListeners() const
  {
 -	for ( USHORT n = 0; n < aListeners.Count(); ++n )
 -		if ( aListeners.GetObject(n) != 0 )
--			return TRUE;
--	return FALSE;
++#if USE_NEW_IMPL
 +    return !mpImpl->maListeners.empty();
++#else
++	for ( USHORT n = 0; n < mpImpl->maListeners.Count(); ++n )
++		if ( mpImpl->maListeners.GetObject(n) != 0 )
+ 			return TRUE;
+ 	return FALSE;
++#endif
  }
  
 -//--------------------------------------------------------------------
@@ -424,23 +512,31 @@
 +
 +size_t SfxBroadcaster::GetListenerCount() const
 +{
++#if USE_NEW_IMPL
 +    return mpImpl->maListeners.size();
++#else
++    return mpImpl->maListeners.Count();
++#endif
 +}
 +
 +SfxListener* SfxBroadcaster::GetListener( size_t nNo ) const
 +{
++#if USE_NEW_IMPL
 +    if (nNo >= mpImpl->maListeners.size())
 +        return NULL;
 +
 +    ListenerArray::const_iterator itr = mpImpl->maListeners.begin();
 +    ::std::advance(itr, nNo);
 +    return *itr;
++#else
++    return (SfxListener*) mpImpl->maListeners[nNo];
++#endif
 +}
 diff --git a/svtools/source/notify/lstner.cxx b/svtools/source/notify/lstner.cxx
-index 25246c0..660dcb1 100644
+index 25246c0..3f31a3f 100644
 --- svtools/source/notify/lstner.cxx
 +++ svtools/source/notify/lstner.cxx
-@@ -39,20 +39,88 @@
+@@ -39,20 +39,87 @@
  
  #include <svtools/hint.hxx>
  #include <svtools/brdcst.hxx>
@@ -452,6 +548,8 @@
  
 -#define _SFX_LSTNER_CXX
 -#include <svtools/lstner.hxx>
++#define USE_NEW_IMPL 0
++
 +using ::std::find;
 +using ::std::unary_function;
 +using ::std::advance;
@@ -470,18 +568,15 @@
 +    }
 +};
 +
++#if USE_NEW_IMPL
 +typedef ::std::hash_multiset<SfxBroadcaster*, SfxBroadcasterHash> BroadcasterArray;
++#else
++SV_DECL_PTRARR( BroadcasterArray, SfxBroadcaster*, 0, 2 )
++#endif
 +
 +struct SfxListenerImpl
 +{
 +	BroadcasterArray maBCs;
-+
-+    SfxListenerImpl() {}
-+
-+    SfxListenerImpl(const SfxListenerImpl& r) :
-+        maBCs(r.maBCs)
-+    {
-+    }
 +};
 +
 +// ----------------------------------------------------------------------------
@@ -533,78 +628,134 @@
  {
  	DBG_CTOR(SfxListener, 0);
  }
-@@ -60,13 +128,14 @@ SfxListener::SfxListener()
+@@ -60,13 +127,28 @@ SfxListener::SfxListener()
  
  // copy ctor of class SfxListener
  
 -SfxListener::SfxListener( const SfxListener &rListener )
 +SfxListener::SfxListener( const SfxListener &rListener ) :
-+    mpImpl(new SfxListenerImpl(*rListener.mpImpl))
++    mpImpl(new SfxListenerImpl)
  {
  	DBG_CTOR(SfxListener, 0);
 -
 -	for ( USHORT n = 0; n < rListener.aBCs.Count(); ++n )
 -		StartListening( *rListener.aBCs[n] );
++#if USE_NEW_IMPL
++#if 1
++    BroadcasterArray::iterator itrEnd = rListener.mpImpl->maBCs.end();
++    for (BroadcasterArray::iterator itr = rListener.mpImpl->maBCs.begin(); itr != itrEnd; ++itr)
++    {
++        SfxBroadcaster* pBC = *itr;
++        StartListening(*pBC);
++    }
++#else
 +    StartListeningToBC f(*this);
 +    for_each(rListener.mpImpl->maBCs.begin(), rListener.mpImpl->maBCs.end(), f);
++#endif
++#else
++	for ( USHORT n = 0; n < rListener.mpImpl->maBCs.Count(); ++n )
++		StartListening( *rListener.mpImpl->maBCs[n] );
++#endif
  }
 +
  //--------------------------------------------------------------------
  
  // unregisteres the SfxListener from its SfxBroadcasters
-@@ -76,11 +145,8 @@ SfxListener::~SfxListener()
+@@ -76,11 +158,25 @@ SfxListener::~SfxListener()
  	DBG_DTOR(SfxListener, 0);
  
  	// unregister at all remainding broadcasters
 -	for ( USHORT nPos = 0; nPos < aBCs.Count(); ++nPos )
--	{
--		SfxBroadcaster *pBC = aBCs[nPos];
--		pBC->RemoveListener(*this);
--	}
++#if USE_NEW_IMPL
++#if 1
++    BroadcasterArray::iterator itrEnd = mpImpl->maBCs.end();
++    for (BroadcasterArray::iterator itr = mpImpl->maBCs.begin(); itr != itrEnd; ++itr)
++    {
++        SfxBroadcaster* pBC = *itr;
++        pBC->RemoveListener(*this);
++    }
++#else
 +    RemoveListenerFromBC f(*this);
 +    for_each(mpImpl->maBCs.begin(), mpImpl->maBCs.end(), f);
++#endif
++#else
++	for ( USHORT nPos = 0; nPos < mpImpl->maBCs.Count(); ++nPos )
+ 	{
+-		SfxBroadcaster *pBC = aBCs[nPos];
++		SfxBroadcaster *pBC = mpImpl->maBCs[nPos];
+ 		pBC->RemoveListener(*this);
+ 	}
++#endif
  }
  
  //--------------------------------------------------------------------
-@@ -91,8 +157,10 @@ void SfxListener::RemoveBroadcaster_Impl( SfxBroadcaster& rBC )
+@@ -91,8 +187,20 @@ void SfxListener::RemoveBroadcaster_Impl( SfxBroadcaster& rBC )
  {
  	DBG_CHKTHIS(SfxListener, 0);
  
--	const SfxBroadcaster *pBC = &rBC;
--	aBCs.Remove( aBCs.GetPos(pBC), 1 );
++#if USE_NEW_IMPL
 +	SfxBroadcaster *pBC = &rBC;
 +    BroadcasterArray::iterator itr = ::std::find(mpImpl->maBCs.begin(), mpImpl->maBCs.end(), pBC);
-+    if (itr != mpImpl->maBCs.end())
-+        mpImpl->maBCs.erase(itr);
++    if (itr == mpImpl->maBCs.end())
++    {
++        fprintf(stdout, "SfxListener::RemoveBroadcaster_Impl:   broadcaster not found!!!\n");
++        return;
++    }
++
++    mpImpl->maBCs.erase(itr);
++#else
+ 	const SfxBroadcaster *pBC = &rBC;
+-	aBCs.Remove( aBCs.GetPos(pBC), 1 );
++	mpImpl->maBCs.Remove( mpImpl->maBCs.GetPos(pBC), 1 );
++#endif
  }
  
  //--------------------------------------------------------------------
-@@ -107,8 +175,9 @@ BOOL SfxListener::StartListening( SfxBroadcaster& rBroadcaster, BOOL bPreventDup
+@@ -107,8 +215,13 @@ BOOL SfxListener::StartListening( SfxBroadcaster& rBroadcaster, BOOL bPreventDup
  	{
  		if ( rBroadcaster.AddListener(*this) )
  		{
 -			const SfxBroadcaster *pBC = &rBroadcaster;
 -			aBCs.Insert( pBC, aBCs.Count() );
++#if USE_NEW_IMPL
 +			SfxBroadcaster *pBC = &rBroadcaster;
 +            mpImpl->maBCs.insert(pBC);
-+//          maBCs.push_back(pBC);
++#else
++            const SfxBroadcaster *pBC = &rBroadcaster;
++			mpImpl->maBCs.Insert( pBC, mpImpl->maBCs.Count() );
++#endif
  
  			DBG_ASSERT( IsListening(rBroadcaster), "StartListening failed" );
  			return TRUE;
-@@ -132,8 +201,10 @@ BOOL SfxListener::EndListening( SfxBroadcaster& rBroadcaster, BOOL bAllDups )
- 	do
- 	{
- 		rBroadcaster.RemoveListener(*this);
--		const SfxBroadcaster *pBC = &rBroadcaster;
--		aBCs.Remove( aBCs.GetPos(pBC), 1 );
+@@ -129,27 +242,50 @@ BOOL SfxListener::EndListening( SfxBroadcaster& rBroadcaster, BOOL bAllDups )
+ 	if ( !IsListening( rBroadcaster ) )
+ 		return FALSE;
+ 
++#if USE_NEW_IMPL
++	do
++	{
++		rBroadcaster.RemoveListener(*this);
 +		SfxBroadcaster *pBC = &rBroadcaster;
 +        BroadcasterArray::iterator itr = ::std::find(mpImpl->maBCs.begin(), mpImpl->maBCs.end(), pBC);
 +        if (itr != mpImpl->maBCs.end())
 +            mpImpl->maBCs.erase(itr);
++	}
++	while ( bAllDups && IsListening( rBroadcaster ) );
++	return TRUE;
++#else
+ 	do
+ 	{
+ 		rBroadcaster.RemoveListener(*this);
+ 		const SfxBroadcaster *pBC = &rBroadcaster;
+-		aBCs.Remove( aBCs.GetPos(pBC), 1 );
++        mpImpl->maBCs.Remove( mpImpl->maBCs.GetPos(pBC), 1 );
  	}
  	while ( bAllDups && IsListening( rBroadcaster ) );
  	return TRUE;
-@@ -143,13 +214,18 @@ BOOL SfxListener::EndListening( SfxBroadcaster& rBroadcaster, BOOL bAllDups )
++#endif
+ }
+ 
+ //--------------------------------------------------------------------
  
  // unregisteres at a specific SfxBroadcaster by index
  
@@ -612,10 +763,9 @@
 +void SfxListener::EndListening( size_t nNo )
  {
  	DBG_CHKTHIS(SfxListener, 0);
- 
+-
 -	SfxBroadcaster *pBC = aBCs.GetObject(nNo);
--	pBC->RemoveListener(*this);
--	aBCs.Remove( nNo, 1 );
++#if USE_NEW_IMPL
 +    if (nNo >= mpImpl->maBCs.size())
 +        return;
 +
@@ -624,53 +774,87 @@
 +    SfxBroadcaster* pBC = *itr;
 +    pBC->RemoveListener(*this);
 +    mpImpl->maBCs.erase(itr);
++#else
++	SfxBroadcaster *pBC = mpImpl->maBCs.GetObject(nNo);
+ 	pBC->RemoveListener(*this);
+-	aBCs.Remove( nNo, 1 );
++	mpImpl->maBCs.Remove( nNo, 1 );
++#endif
  }
  
  //--------------------------------------------------------------------
-@@ -160,21 +236,33 @@ void SfxListener::EndListeningAll()
+@@ -159,22 +295,64 @@ void SfxListener::EndListening( USHORT nNo )
+ void SfxListener::EndListeningAll()
  {
  	DBG_CHKTHIS(SfxListener, 0);
- 
+-
 -	// MI: bei Optimierung beachten: Seiteneffekte von RemoveListener beachten!
 -	while ( aBCs.Count() )
--	{
--		SfxBroadcaster *pBC = aBCs.GetObject(0);
--		pBC->RemoveListener(*this);
--		aBCs.Remove( 0, 1 );
--	}
++#if USE_NEW_IMPL
++#if 1
++    BroadcasterArray::iterator itrEnd = mpImpl->maBCs.end();
++    for (BroadcasterArray::iterator itr = mpImpl->maBCs.begin(); itr != itrEnd; ++itr)
++    {
++        SfxBroadcaster* pBC = *itr;
++        pBC->RemoveListener(*this);
++    }
++#else    
 +    RemoveListenerFromBC f(*this);
 +    for_each(mpImpl->maBCs.begin(), mpImpl->maBCs.end(), f);
++#endif    
 +    mpImpl->maBCs.clear();
++#else
++	while ( mpImpl->maBCs.Count() )
+ 	{
+-		SfxBroadcaster *pBC = aBCs.GetObject(0);
++		SfxBroadcaster *pBC = mpImpl->maBCs.GetObject(0);
+ 		pBC->RemoveListener(*this);
+-		aBCs.Remove( 0, 1 );
++		mpImpl->maBCs.Remove( 0, 1 );
+ 	}
++#endif
  }
  
  //--------------------------------------------------------------------
  
  BOOL SfxListener::IsListening( SfxBroadcaster& rBroadcaster ) const
  {
--	const SfxBroadcaster *pBC = &rBroadcaster;
--	return USHRT_MAX != aBCs.GetPos( pBC );
++#if USE_NEW_IMPL
 +	SfxBroadcaster *pBC = &rBroadcaster;
 +    BroadcasterArray::const_iterator itr = find(mpImpl->maBCs.begin(), mpImpl->maBCs.end(), pBC);
 +    return itr != mpImpl->maBCs.end();
++#else
+ 	const SfxBroadcaster *pBC = &rBroadcaster;
+-	return USHRT_MAX != aBCs.GetPos( pBC );
++	return USHRT_MAX != mpImpl->maBCs.GetPos( pBC );
++#endif
 +}
 +
 +size_t SfxListener::GetBroadcasterCount() const
 +{
++#if USE_NEW_IMPL
 +    return mpImpl->maBCs.size();
++#else
++    return mpImpl->maBCs.Count();
++#endif
 +}
 +
 +SfxBroadcaster* SfxListener::GetBroadcasterJOE( size_t nNo ) const
 +{
++#if USE_NEW_IMPL
 +    if (nNo >= mpImpl->maBCs.size())
 +        return NULL;
 +
 +    BroadcasterArray::const_iterator itr = mpImpl->maBCs.begin();
 +    advance(itr, nNo);
 +    return *itr;
++#else
++    return (SfxBroadcaster*) mpImpl->maBCs.GetObject(nNo);
++#endif
  }
  
  //--------------------------------------------------------------------
-@@ -182,17 +270,16 @@ BOOL SfxListener::IsListening( SfxBroadcaster& rBroadcaster ) const
+@@ -182,17 +360,22 @@ BOOL SfxListener::IsListening( SfxBroadcaster& rBroadcaster ) const
  // base implementation of notification handler
  
  #ifdef DBG_UTIL
@@ -684,14 +868,19 @@
  #endif
  {
 -    #ifdef DBG_UTIL
--	const SfxBroadcaster *pBC = &rBC;
--	DBG_ASSERT( USHRT_MAX != aBCs.GetPos(pBC),
 +#ifdef DBG_UTIL
++#if USE_NEW_IMPL
 +	SfxBroadcaster *pBC = &rBC;
 +    BroadcasterArray::const_iterator itr = find(mpImpl->maBCs.begin(), mpImpl->maBCs.end(), pBC);
 +	DBG_ASSERT( itr != mpImpl->maBCs.end(),
++				"notification from unregistered broadcaster" );
++#else
+ 	const SfxBroadcaster *pBC = &rBC;
+-	DBG_ASSERT( USHRT_MAX != aBCs.GetPos(pBC),
++	DBG_ASSERT( USHRT_MAX != mpImpl->maBCs.GetPos(pBC),
  				"notification from unregistered broadcaster" );
 -    #endif
 +#endif
++#endif
  }
  



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]