summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorRafael Dominguez <venccsralph@gmail.com>2011-04-27 11:27:37 -0430
committerFridrich Štrba <fridrich.strba@bluewin.ch>2011-05-06 10:26:00 +0200
commit0105e425bac83783ce5631b51d2d635a438881b6 (patch)
tree2cf1466f409cd1dbdae0ef5538a5676ce5e34591 /basic
parent747d3154e34ad0267674516f03d67265e0e923c0 (diff)
Remove usage of List for DdeConnection in SbiDdeControl.
Diffstat (limited to 'basic')
-rw-r--r--basic/source/runtime/ddectrl.cxx80
-rw-r--r--basic/source/runtime/ddectrl.hxx3
2 files changed, 48 insertions, 35 deletions
diff --git a/basic/source/runtime/ddectrl.cxx b/basic/source/runtime/ddectrl.cxx
index 83ce5b05adb5..3ec4c74f1a29 100644
--- a/basic/source/runtime/ddectrl.cxx
+++ b/basic/source/runtime/ddectrl.cxx
@@ -81,32 +81,26 @@ IMPL_LINK_INLINE( SbiDdeControl,Data , DdeData*, pData,
SbiDdeControl::SbiDdeControl()
{
- pConvList = new DdeConnections;
- DdeConnection* pPtr = DDE_FREECHANNEL;
- pConvList->Insert( pPtr );
}
SbiDdeControl::~SbiDdeControl()
{
TerminateAll();
- delete pConvList;
}
sal_Int16 SbiDdeControl::GetFreeChannel()
{
- sal_Int16 nListSize = (sal_Int16)pConvList->Count();
- DdeConnection* pPtr = pConvList->First();
- pPtr = pConvList->Next(); // nullten eintrag ueberspringen
- sal_Int16 nChannel;
- for( nChannel = 1; nChannel < nListSize; nChannel++ )
+ sal_Int16 nChannel = 0;
+ sal_Int16 nListSize = static_cast<sal_Int16>(aConvList.size());
+
+ for (; nChannel < nListSize; ++nChannel)
{
- if( pPtr == DDE_FREECHANNEL )
- return nChannel;
- pPtr = pConvList->Next();
+ if (aConvList[nChannel] == DDE_FREECHANNEL)
+ return nChannel+1;
}
- pPtr = DDE_FREECHANNEL;
- pConvList->Insert( pPtr, LIST_APPEND );
- return nChannel;
+
+ aConvList.push_back(DDE_FREECHANNEL);
+ return nChannel+1;
}
SbError SbiDdeControl::Initiate( const String& rService, const String& rTopic,
@@ -123,7 +117,7 @@ SbError SbiDdeControl::Initiate( const String& rService, const String& rTopic,
else
{
sal_Int16 nChannel = GetFreeChannel();
- pConvList->Replace( pConv, (sal_uIntPtr)nChannel );
+ aConvList[nChannel-1] = pConv;
rnHandle = nChannel;
}
return 0;
@@ -131,34 +125,44 @@ SbError SbiDdeControl::Initiate( const String& rService, const String& rTopic,
SbError SbiDdeControl::Terminate( sal_Int16 nChannel )
{
- DdeConnection* pConv = pConvList->GetObject( (sal_uIntPtr)nChannel );
- if( !nChannel || !pConv || pConv == DDE_FREECHANNEL )
+ if (!nChannel || nChannel > aConvList.size())
+ return SbERR_DDE_NO_CHANNEL;
+
+ std::vector<DdeConnection*> iterConv = aConvList.begin()+nChannel-1;
+
+ if( *iterConv == DDE_FREECHANNEL )
return SbERR_DDE_NO_CHANNEL;
- pConvList->Replace( DDE_FREECHANNEL, (sal_uIntPtr)nChannel );
- delete pConv;
+
+ delete *iterConv;
+ *iterConv = DDE_FREECHANNEL;
+
return 0L;
}
SbError SbiDdeControl::TerminateAll()
{
- sal_Int16 nChannel = (sal_Int16)pConvList->Count();
- while( nChannel )
+ DdeConnection *conv;
+ for (sal_Int16 nChannel = 0; nChannel < aConvList.size(); ++nChannel)
{
- nChannel--;
- Terminate( nChannel );
+ conv = aConvList[nChannel];
+
+ if (conv != DDE_FREECHANNEL)
+ delete conv;
}
- pConvList->Clear();
- DdeConnection* pPtr = DDE_FREECHANNEL;
- pConvList->Insert( pPtr );
+ aConvList.clear();
return 0;
}
SbError SbiDdeControl::Request( sal_Int16 nChannel, const String& rItem, String& rResult )
{
- DdeConnection* pConv = pConvList->GetObject( (sal_uIntPtr)nChannel );
- if( !nChannel || !pConv || pConv == DDE_FREECHANNEL )
+ if (!nChannel || nChannel > aConvList.size())
+ return SbERR_DDE_NO_CHANNEL;
+
+ DdeConnection* pConv = aConvList[nChannel-1];
+
+ if( pConv == DDE_FREECHANNEL )
return SbERR_DDE_NO_CHANNEL;
DdeRequest aRequest( *pConv, rItem, 30000 );
@@ -170,9 +174,14 @@ SbError SbiDdeControl::Request( sal_Int16 nChannel, const String& rItem, String&
SbError SbiDdeControl::Execute( sal_Int16 nChannel, const String& rCommand )
{
- DdeConnection* pConv = pConvList->GetObject( (sal_uIntPtr)nChannel );
- if( !nChannel || !pConv || pConv == DDE_FREECHANNEL )
+ if (!nChannel || nChannel > aConvList.size())
return SbERR_DDE_NO_CHANNEL;
+
+ DdeConnection* pConv = aConvList[nChannel-1];
+
+ if( conv == DDE_FREECHANNEL )
+ return SbERR_DDE_NO_CHANNEL;
+
DdeExecute aRequest( *pConv, rCommand, 30000 );
aRequest.Execute();
return GetLastErr( pConv );
@@ -180,9 +189,14 @@ SbError SbiDdeControl::Execute( sal_Int16 nChannel, const String& rCommand )
SbError SbiDdeControl::Poke( sal_Int16 nChannel, const String& rItem, const String& rData )
{
- DdeConnection* pConv = pConvList->GetObject( (sal_uIntPtr)nChannel );
- if( !nChannel || !pConv || pConv == DDE_FREECHANNEL )
+ if (!nChannel || nChannel > aConvList.size())
return SbERR_DDE_NO_CHANNEL;
+
+ DdeConnection* pConv = aConvList[nChannel-1];
+
+ if( pConv == DDE_FREECHANNEL )
+ return SbERR_DDE_NO_CHANNEL;
+
DdePoke aRequest( *pConv, rItem, DdeData(rData), 30000 );
aRequest.Execute();
return GetLastErr( pConv );
diff --git a/basic/source/runtime/ddectrl.hxx b/basic/source/runtime/ddectrl.hxx
index 2f12e8128791..e10109b64177 100644
--- a/basic/source/runtime/ddectrl.hxx
+++ b/basic/source/runtime/ddectrl.hxx
@@ -34,7 +34,6 @@
#include <tools/string.hxx>
class DdeConnection;
-class DdeConnections;
class DdeData;
class SbiDdeControl
@@ -43,7 +42,7 @@ private:
DECL_LINK( Data, DdeData* );
SbError GetLastErr( DdeConnection* );
sal_Int16 GetFreeChannel();
- DdeConnections* pConvList;
+ std::vector<DdeConnection*> aConvList;
String aData;
public: