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 );
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; }

View File

@@ -31,6 +31,7 @@
#include <svl/broadcast.hxx>
#include <svl/svarray.hxx>
#include <set>
#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<ScDocument*> {};
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; }

View File

@@ -59,8 +59,8 @@ ScAddInListener* ScAddInListener::CreateListener(
ScAddInListener::ScAddInListener( uno::Reference<sheet::XVolatileResult> 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; j<nCount; j++, ppDoc++ )
for ( ScAddInDocs::iterator it = pDocs->begin(); it != pDocs->end(); ++it )
{
ScDocument* pDoc = (ScDocument*)*ppDoc;
ScDocument* pDoc = *it;
pDoc->TrackFormulas();
pDoc->GetDocumentShell()->Broadcast( SfxSimpleHint( FID_DATACHANGED ) );
}

View File

@@ -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; j<nCount; j++, ppDoc++ )
for ( ScAddInDocs::iterator it = p->pDocs->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 );