Convert SV_DECL_PTRARR_SORT(ScAddInDocs) to std::set

Change-Id: If9faa49b3d3fc36f36db4a7cc6ab82f8af54935a
This commit is contained in:
Noel Grandin
2012-07-09 16:02:05 +02:00
committed by Michael Stahl
parent fc01739951
commit aa3a9f917f
4 changed files with 23 additions and 29 deletions

View File

@@ -67,10 +67,10 @@ public:
static void RemoveDocument( ScDocument* pDocument ); static void RemoveDocument( ScDocument* pDocument );
bool HasDocument( ScDocument* pDoc ) const bool HasDocument( ScDocument* pDoc ) const
{ return pDocs->Seek_Entry( pDoc ); } { return pDocs->find( pDoc ) != pDocs->end(); }
void AddDocument( ScDocument* pDoc ) void AddDocument( ScDocument* pDoc )
{ pDocs->Insert( pDoc ); } { pDocs->insert( pDoc ); }
const com::sun::star::uno::Any& GetResult() const const com::sun::star::uno::Any& GetResult() const
{ return aResult; } { return aResult; }

View File

@@ -31,6 +31,7 @@
#include <svl/broadcast.hxx> #include <svl/broadcast.hxx>
#include <svl/svarray.hxx> #include <svl/svarray.hxx>
#include <set>
#include "callform.hxx" #include "callform.hxx"
@@ -45,8 +46,7 @@ SV_DECL_PTRARR_SORT( ScAddInAsyncs, ScAddInAsyncPtr, 4 )
extern ScAddInAsyncs theAddInAsyncTbl; // in adiasync.cxx extern ScAddInAsyncs theAddInAsyncTbl; // in adiasync.cxx
class ScDocument; class ScDocument;
typedef ScDocument* ScAddInDocPtr; class ScAddInDocs : public std::set<ScDocument*> {};
SV_DECL_PTRARR_SORT( ScAddInDocs, ScAddInDocPtr, 1 )
class String; class String;
@@ -78,9 +78,9 @@ public:
ParamType GetType() const { return meType; } ParamType GetType() const { return meType; }
double GetValue() const { return nVal; } double GetValue() const { return nVal; }
const String& GetString() const { return *pStr; } const String& GetString() const { return *pStr; }
sal_Bool HasDocument( ScDocument* pDoc ) const bool HasDocument( ScDocument* pDoc ) const
{ return pDocs->Seek_Entry( pDoc ); } { return pDocs->find( pDoc ) != pDocs->end(); }
void AddDocument( ScDocument* pDoc ) { pDocs->Insert( pDoc ); } void AddDocument( ScDocument* pDoc ) { pDocs->insert( pDoc ); }
// Vergleichsoperatoren fuer PtrArrSort // Vergleichsoperatoren fuer PtrArrSort
sal_Bool operator < ( const ScAddInAsync& r ) { return nHandle < r.nHandle; } sal_Bool operator < ( const ScAddInAsync& r ) { return nHandle < r.nHandle; }

View File

@@ -59,8 +59,8 @@ ScAddInListener* ScAddInListener::CreateListener(
ScAddInListener::ScAddInListener( uno::Reference<sheet::XVolatileResult> xVR, ScDocument* pDoc ) : ScAddInListener::ScAddInListener( uno::Reference<sheet::XVolatileResult> xVR, ScDocument* pDoc ) :
xVolRes( xVR ) xVolRes( xVR )
{ {
pDocs = new ScAddInDocs( 1 ); pDocs = new ScAddInDocs();
pDocs->Insert( pDoc ); pDocs->insert( pDoc );
} }
ScAddInListener::~ScAddInListener() ScAddInListener::~ScAddInListener()
@@ -91,11 +91,11 @@ void ScAddInListener::RemoveDocument( ScDocument* pDocumentP )
while(iter != aAllListeners.end()) while(iter != aAllListeners.end())
{ {
ScAddInDocs* p = (*iter)->pDocs; ScAddInDocs* p = (*iter)->pDocs;
sal_uInt16 nFoundPos; ScAddInDocs::iterator iter2 = p->find( pDocumentP );
if ( p->Seek_Entry( pDocumentP, &nFoundPos ) ) if( iter2 != p->end() )
{ {
p->Remove( nFoundPos ); p->erase( iter2 );
if ( p->Count() == 0 ) if ( p->empty() )
{ {
if ( (*iter)->xVolRes.is() ) if ( (*iter)->xVolRes.is() )
(*iter)->xVolRes->removeResultListener( *iter ); (*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 ) ); Broadcast( ScHint( SC_HINT_DATACHANGED, ScAddress(), NULL ) );
const ScDocument** ppDoc = (const ScDocument**) pDocs->GetData(); for ( ScAddInDocs::iterator it = pDocs->begin(); it != pDocs->end(); ++it )
sal_uInt16 nCount = pDocs->Count();
for ( sal_uInt16 j=0; j<nCount; j++, ppDoc++ )
{ {
ScDocument* pDoc = (ScDocument*)*ppDoc; ScDocument* pDoc = *it;
pDoc->TrackFormulas(); pDoc->TrackFormulas();
pDoc->GetDocumentShell()->Broadcast( SfxSimpleHint( FID_DATACHANGED ) ); pDoc->GetDocumentShell()->Broadcast( SfxSimpleHint( FID_DATACHANGED ) );
} }

View File

@@ -44,8 +44,6 @@ static ScAddInAsync aSeekObj;
SV_IMPL_OP_PTRARR_SORT( ScAddInAsyncs, ScAddInAsyncPtr ); SV_IMPL_OP_PTRARR_SORT( ScAddInAsyncs, ScAddInAsyncPtr );
SV_IMPL_PTRARR_SORT( ScAddInDocs, ScAddInDocPtr );
extern "C" { extern "C" {
void CALLTYPE ScAddInAsyncCallBack( double& nHandle, void* pData ) void CALLTYPE ScAddInAsyncCallBack( double& nHandle, void* pData )
{ {
@@ -71,8 +69,8 @@ ScAddInAsync::ScAddInAsync(sal_uLong nHandleP, FuncData* pFuncData, ScDocument*
meType(pFuncData->GetAsyncType()), meType(pFuncData->GetAsyncType()),
bValid( false ) bValid( false )
{ {
pDocs = new ScAddInDocs( 1 ); pDocs = new ScAddInDocs();
pDocs->Insert( pDoc ); pDocs->insert( pDoc );
theAddInAsyncTbl.Insert( this ); theAddInAsyncTbl.Insert( this );
} }
@@ -137,11 +135,9 @@ void ScAddInAsync::CallBack( sal_uLong nHandleP, void* pData )
p->bValid = sal_True; p->bValid = sal_True;
p->Broadcast( ScHint( SC_HINT_DATACHANGED, ScAddress(), NULL ) ); p->Broadcast( ScHint( SC_HINT_DATACHANGED, ScAddress(), NULL ) );
const ScDocument** ppDoc = (const ScDocument**) p->pDocs->GetData(); for ( ScAddInDocs::iterator it = p->pDocs->begin(); it != p->pDocs->end(); ++it )
sal_uInt16 nCount = p->pDocs->Count();
for ( sal_uInt16 j=0; j<nCount; j++, ppDoc++ )
{ {
ScDocument* pDoc = (ScDocument*)*ppDoc; ScDocument* pDoc = *it;
pDoc->TrackFormulas(); pDoc->TrackFormulas();
pDoc->GetDocumentShell()->Broadcast( SfxSimpleHint( FID_DATACHANGED ) ); pDoc->GetDocumentShell()->Broadcast( SfxSimpleHint( FID_DATACHANGED ) );
} }
@@ -159,11 +155,11 @@ void ScAddInAsync::RemoveDocument( ScDocument* pDocumentP )
for ( ; nPos-- >0; ppAsync-- ) for ( ; nPos-- >0; ppAsync-- )
{ // rueckwaerts wg. Pointer-Aufrueckerei im Array { // rueckwaerts wg. Pointer-Aufrueckerei im Array
ScAddInDocs* p = ((ScAddInAsync*)*ppAsync)->pDocs; ScAddInDocs* p = ((ScAddInAsync*)*ppAsync)->pDocs;
sal_uInt16 nFoundPos; ScAddInDocs::iterator iter2 = p->find( pDocumentP );
if ( p->Seek_Entry( pDocumentP, &nFoundPos ) ) if( iter2 != p->end() )
{ {
p->Remove( nFoundPos ); p->erase( iter2 );
if ( p->Count() == 0 ) if ( p->empty() )
{ // dieses AddIn wird nicht mehr benutzt { // dieses AddIn wird nicht mehr benutzt
ScAddInAsync* pAsync = (ScAddInAsync*)*ppAsync; ScAddInAsync* pAsync = (ScAddInAsync*)*ppAsync;
theAddInAsyncTbl.Remove( nPos ); theAddInAsyncTbl.Remove( nPos );