From 439672d171ab3278fe7b14100eea145d641b8bc2 Mon Sep 17 00:00:00 2001
From: Rafael Dominguez <venccsralph@gmail.com>
Date: Wed, 27 Apr 2011 12:04:23 -0430
Subject: [PATCH] Remove DECLARE_LIST(DdeConnections,DdeConnection*)

---
 svl/inc/svl/svdde.hxx       |    4 +---
 svl/source/svdde/ddecli.cxx |   28 ++++++++++++----------------
 svl/source/svdde/ddeimp.hxx |    2 +-
 3 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/svl/inc/svl/svdde.hxx b/svl/inc/svl/svdde.hxx
index 5cd1b97..033f211 100644
--- a/svl/inc/svl/svdde.hxx
+++ b/svl/inc/svl/svdde.hxx
@@ -55,12 +55,10 @@ class DdeItemImp;
 struct Conversation;
 
 #ifndef _SVDDE_NOLISTS
-DECLARE_LIST( DdeConnections, DdeConnection* )
 DECLARE_LIST( DdeServices, DdeService* )
 DECLARE_LIST( DdeTopics, DdeTopic* )
 DECLARE_LIST( DdeItems, DdeItem* )
 #else
-typedef List DdeConnections;
 typedef List DdeServices;
 typedef List DdeTopics;
 typedef List DdeItems;
@@ -244,7 +242,7 @@ public:
     long            GetError();
     long            GetConvId();
 
-    static const DdeConnections& GetConnections();
+    static const std::vector<DdeConnection*>& GetConnections();
 
     sal_Bool            IsConnected();
 
diff --git a/svl/source/svdde/ddecli.cxx b/svl/source/svdde/ddecli.cxx
index 3c2948f..920a0cf 100644
--- a/svl/source/svdde/ddecli.cxx
+++ b/svl/source/svdde/ddecli.cxx
@@ -39,11 +39,6 @@
 #include <tools/solarmutex.hxx>
 #include <osl/mutex.hxx>
 
-// static DWORD        hDdeInst  = NULL;
-// static short        nInstance = 0;
-
-// DdeConnections*     DdeConnection::pConnections = NULL;
-
 DdeInstData* ImpInitInstData()
 {
     DdeInstData* pData = new DdeInstData;
@@ -74,15 +69,19 @@ HDDEDATA CALLBACK DdeInternal::CliCallback(
             HDDEDATA hData, DWORD nInfo1, DWORD )
 {
     HDDEDATA nRet = DDE_FNOTPROCESSED;
-    DdeConnections&     rAll = (DdeConnections&)DdeConnection::GetConnections();
+    const std::vector<DdeConnection*> &rAll = DdeConnection::GetConnections();
     DdeConnection*      self = 0;
 
     DdeInstData* pInst = ImpGetInstData();
     DBG_ASSERT(pInst,"SVDDE:No instance data");
 
-    for ( self = rAll.First(); self; self = rAll.Next() )
+    for ( size_t i = 0; i < rAll.size(); ++i)
+    {
+        self = rAll[i];
+
         if ( self->pImp->hConv == hConv )
             break;
+    }
 
     if( self )
     {
@@ -173,7 +172,6 @@ DdeConnection::DdeConnection( const String& rService, const String& rTopic )
                                        CBF_FAIL_ALLSVRXACTIONS |
                                        CBF_SKIP_REGISTRATIONS  |
                                        CBF_SKIP_UNREGISTRATIONS, 0L );
-        pInst->pConnections = new DdeConnections;
     }
 
     pService = new DdeString( pInst->hDdeInstCli, rService );
@@ -186,8 +184,7 @@ DdeConnection::DdeConnection( const String& rService, const String& rTopic )
             pImp->nStatus = DdeGetLastError( pInst->hDdeInstCli );
     }
 
-    if ( pInst->pConnections )
-        pInst->pConnections->Insert( this );
+    pInst->aConnections.push_back( this );
 }
 
 // --- DdeConnection::~DdeConnection() -----------------------------
@@ -202,8 +199,9 @@ DdeConnection::~DdeConnection()
 
     DdeInstData* pInst = ImpGetInstData();
     DBG_ASSERT(pInst,"SVDDE:No instance data");
-    if ( pInst->pConnections )
-        pInst->pConnections->Remove( this );
+
+    pInst->aConnections.erase(std::remove(pInst->aConnections.begin(),
+                                          pInst->aConnections.end(),this));
 
     pInst->nInstanceCli--;
     pInst->nRefCount--;
@@ -212,8 +210,6 @@ DdeConnection::~DdeConnection()
         if( DdeUninitialize( pInst->hDdeInstCli ) )
         {
             pInst->hDdeInstCli = NULL;
-            delete pInst->pConnections;
-            pInst->pConnections = NULL;
             if( pInst->nRefCount == 0 )
                 ImpDeinitInstData();
         }
@@ -263,11 +259,11 @@ long DdeConnection::GetConvId()
     return (long)pImp->hConv;
 }
 
-const DdeConnections& DdeConnection::GetConnections()
+const std::vector<DdeConnection*>& DdeConnection::GetConnections()
 {
     DdeInstData* pInst = ImpGetInstData();
     DBG_ASSERT(pInst,"SVDDE:No instance data");
-    return *(pInst->pConnections);
+    return pInst->aConnections;
 }
 
 // --- DdeTransaction::DdeTransaction() ----------------------------
diff --git a/svl/source/svdde/ddeimp.hxx b/svl/source/svdde/ddeimp.hxx
index fea2322..0227453 100644
--- a/svl/source/svdde/ddeimp.hxx
+++ b/svl/source/svdde/ddeimp.hxx
@@ -143,7 +143,7 @@ class DdeServices;
 struct DdeInstData
 {
     sal_uInt16			nRefCount;
-    DdeConnections*	pConnections;
+    std::vector<DdeConnection*>	aConnections;
     // Server
     long 			hCurConvSvr;
     DWORD			hDdeInstSvr;
-- 
1.7.3.4

