From aa3a9f917f97ee87bfa5c6269bca1bff15542dbb Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 9 Jul 2012 16:02:05 +0200 Subject: [PATCH] Convert SV_DECL_PTRARR_SORT(ScAddInDocs) to std::set Change-Id: If9faa49b3d3fc36f36db4a7cc6ab82f8af54935a --- sc/source/core/inc/addinlis.hxx | 4 ++-- sc/source/core/inc/adiasync.hxx | 10 +++++----- sc/source/core/tool/addinlis.cxx | 18 ++++++++---------- sc/source/core/tool/adiasync.cxx | 20 ++++++++------------ 4 files changed, 23 insertions(+), 29 deletions(-) diff --git a/sc/source/core/inc/addinlis.hxx b/sc/source/core/inc/addinlis.hxx index 401a1ee1f8a0..a8ac4dc0acd6 100644 --- a/sc/source/core/inc/addinlis.hxx +++ b/sc/source/core/inc/addinlis.hxx @@ -67,10 +67,10 @@ public: static void RemoveDocument( ScDocument* pDocument ); bool HasDocument( ScDocument* pDoc ) const - { return pDocs->Seek_Entry( pDoc ); } + { return pDocs->find( pDoc ) != pDocs->end(); } void AddDocument( ScDocument* pDoc ) - { pDocs->Insert( pDoc ); } + { pDocs->insert( pDoc ); } const com::sun::star::uno::Any& GetResult() const { return aResult; } diff --git a/sc/source/core/inc/adiasync.hxx b/sc/source/core/inc/adiasync.hxx index cfb3c214266b..62cc2e7e89be 100644 --- a/sc/source/core/inc/adiasync.hxx +++ b/sc/source/core/inc/adiasync.hxx @@ -31,6 +31,7 @@ #include #include +#include #include "callform.hxx" @@ -45,8 +46,7 @@ SV_DECL_PTRARR_SORT( ScAddInAsyncs, ScAddInAsyncPtr, 4 ) extern ScAddInAsyncs theAddInAsyncTbl; // in adiasync.cxx class ScDocument; -typedef ScDocument* ScAddInDocPtr; -SV_DECL_PTRARR_SORT( ScAddInDocs, ScAddInDocPtr, 1 ) +class ScAddInDocs : public std::set {}; class String; @@ -78,9 +78,9 @@ public: ParamType GetType() const { return meType; } double GetValue() const { return nVal; } const String& GetString() const { return *pStr; } - sal_Bool HasDocument( ScDocument* pDoc ) const - { return pDocs->Seek_Entry( pDoc ); } - void AddDocument( ScDocument* pDoc ) { pDocs->Insert( pDoc ); } + bool HasDocument( ScDocument* pDoc ) const + { return pDocs->find( pDoc ) != pDocs->end(); } + void AddDocument( ScDocument* pDoc ) { pDocs->insert( pDoc ); } // Vergleichsoperatoren fuer PtrArrSort sal_Bool operator < ( const ScAddInAsync& r ) { return nHandle < r.nHandle; } diff --git a/sc/source/core/tool/addinlis.cxx b/sc/source/core/tool/addinlis.cxx index 42b74070df1d..ea8348042912 100644 --- a/sc/source/core/tool/addinlis.cxx +++ b/sc/source/core/tool/addinlis.cxx @@ -59,8 +59,8 @@ ScAddInListener* ScAddInListener::CreateListener( ScAddInListener::ScAddInListener( uno::Reference xVR, ScDocument* pDoc ) : xVolRes( xVR ) { - pDocs = new ScAddInDocs( 1 ); - pDocs->Insert( pDoc ); + pDocs = new ScAddInDocs(); + pDocs->insert( pDoc ); } ScAddInListener::~ScAddInListener() @@ -91,11 +91,11 @@ void ScAddInListener::RemoveDocument( ScDocument* pDocumentP ) while(iter != aAllListeners.end()) { ScAddInDocs* p = (*iter)->pDocs; - sal_uInt16 nFoundPos; - if ( p->Seek_Entry( pDocumentP, &nFoundPos ) ) + ScAddInDocs::iterator iter2 = p->find( pDocumentP ); + if( iter2 != p->end() ) { - p->Remove( nFoundPos ); - if ( p->Count() == 0 ) + p->erase( iter2 ); + if ( p->empty() ) { if ( (*iter)->xVolRes.is() ) (*iter)->xVolRes->removeResultListener( *iter ); @@ -126,11 +126,9 @@ void SAL_CALL ScAddInListener::modified( const ::com::sun::star::sheet::ResultEv Broadcast( ScHint( SC_HINT_DATACHANGED, ScAddress(), NULL ) ); - const ScDocument** ppDoc = (const ScDocument**) pDocs->GetData(); - sal_uInt16 nCount = pDocs->Count(); - for ( sal_uInt16 j=0; jbegin(); it != pDocs->end(); ++it ) { - ScDocument* pDoc = (ScDocument*)*ppDoc; + ScDocument* pDoc = *it; pDoc->TrackFormulas(); pDoc->GetDocumentShell()->Broadcast( SfxSimpleHint( FID_DATACHANGED ) ); } diff --git a/sc/source/core/tool/adiasync.cxx b/sc/source/core/tool/adiasync.cxx index e30bca92cf36..b48488506f12 100644 --- a/sc/source/core/tool/adiasync.cxx +++ b/sc/source/core/tool/adiasync.cxx @@ -44,8 +44,6 @@ static ScAddInAsync aSeekObj; SV_IMPL_OP_PTRARR_SORT( ScAddInAsyncs, ScAddInAsyncPtr ); -SV_IMPL_PTRARR_SORT( ScAddInDocs, ScAddInDocPtr ); - extern "C" { void CALLTYPE ScAddInAsyncCallBack( double& nHandle, void* pData ) { @@ -71,8 +69,8 @@ ScAddInAsync::ScAddInAsync(sal_uLong nHandleP, FuncData* pFuncData, ScDocument* meType(pFuncData->GetAsyncType()), bValid( false ) { - pDocs = new ScAddInDocs( 1 ); - pDocs->Insert( pDoc ); + pDocs = new ScAddInDocs(); + pDocs->insert( pDoc ); theAddInAsyncTbl.Insert( this ); } @@ -137,11 +135,9 @@ void ScAddInAsync::CallBack( sal_uLong nHandleP, void* pData ) p->bValid = sal_True; p->Broadcast( ScHint( SC_HINT_DATACHANGED, ScAddress(), NULL ) ); - const ScDocument** ppDoc = (const ScDocument**) p->pDocs->GetData(); - sal_uInt16 nCount = p->pDocs->Count(); - for ( sal_uInt16 j=0; jpDocs->begin(); it != p->pDocs->end(); ++it ) { - ScDocument* pDoc = (ScDocument*)*ppDoc; + ScDocument* pDoc = *it; pDoc->TrackFormulas(); pDoc->GetDocumentShell()->Broadcast( SfxSimpleHint( FID_DATACHANGED ) ); } @@ -159,11 +155,11 @@ void ScAddInAsync::RemoveDocument( ScDocument* pDocumentP ) for ( ; nPos-- >0; ppAsync-- ) { // rueckwaerts wg. Pointer-Aufrueckerei im Array ScAddInDocs* p = ((ScAddInAsync*)*ppAsync)->pDocs; - sal_uInt16 nFoundPos; - if ( p->Seek_Entry( pDocumentP, &nFoundPos ) ) + ScAddInDocs::iterator iter2 = p->find( pDocumentP ); + if( iter2 != p->end() ) { - p->Remove( nFoundPos ); - if ( p->Count() == 0 ) + p->erase( iter2 ); + if ( p->empty() ) { // dieses AddIn wird nicht mehr benutzt ScAddInAsync* pAsync = (ScAddInAsync*)*ppAsync; theAddInAsyncTbl.Remove( nPos );