[Libreoffice-commits] .: 3 commits - basic/source sfx2/source
Fridrich Strba
fridrich at kemper.freedesktop.org
Fri May 6 02:01:09 PDT 2011
basic/source/runtime/ddectrl.cxx | 86 ++++++++++++++++++++++-----------------
basic/source/runtime/ddectrl.hxx | 11 ++--
sfx2/source/appl/lnkbase2.cxx | 10 ++--
3 files changed, 60 insertions(+), 47 deletions(-)
New commits:
commit 823773af7dd8e24db1e441ba8c6bcc33d1a47a96
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date: Fri May 6 10:56:43 2011 +0200
Clear a leftover instance of DdeTopics
diff --git a/sfx2/source/appl/lnkbase2.cxx b/sfx2/source/appl/lnkbase2.cxx
index 2755b8b..b2a58c0 100644
--- a/sfx2/source/appl/lnkbase2.cxx
+++ b/sfx2/source/appl/lnkbase2.cxx
@@ -625,14 +625,14 @@ static DdeTopic* FindTopic( const String & rLinkName, sal_uInt16* pItemStt )
if( pItemStt )
*pItemStt = nTokenPos;
- DdeTopics& rTopics = pService->GetTopics();
+ std::vector<DdeTopic*>& rTopics = pService->GetTopics();
for( int i = 0; i < 2; ++i )
{
- for( DdeTopic* pTopic = rTopics.First(); pTopic;
- pTopic = rTopics.Next() )
- if( pTopic->GetName() == sTopic )
- return pTopic;
+ for( std::vector<DdeTopic*>::iterator iterTopic = rTopics.begin();
+ iterTopic != rTopics.end(); iterTopic++ )
+ if( (*iterTopic)->GetName() == sTopic )
+ return *iterTopic;
// Topic not found?
// then we try once to create it
commit 5a328a98fe3a74bb78c79ba41b9439e56b20a6c7
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date: Fri May 6 10:41:50 2011 +0200
Fix to build
diff --git a/basic/source/runtime/ddectrl.cxx b/basic/source/runtime/ddectrl.cxx
index 3535f75..c482b19 100644
--- a/basic/source/runtime/ddectrl.cxx
+++ b/basic/source/runtime/ddectrl.cxx
@@ -123,18 +123,18 @@ SbError SbiDdeControl::Initiate( const String& rService, const String& rTopic,
return 0;
}
-SbError SbiDdeControl::Terminate( sal_Int16 nChannel )
+SbError SbiDdeControl::Terminate( sal_uInt16 nChannel )
{
if (!nChannel || nChannel > aConvList.size())
return SbERR_DDE_NO_CHANNEL;
- std::vector<DdeConnection*> iterConv = aConvList.begin()+nChannel-1;
+ DdeConnection* pConv = aConvList[nChannel-1];
- if( *iterConv == DDE_FREECHANNEL )
+ if( pConv == DDE_FREECHANNEL )
return SbERR_DDE_NO_CHANNEL;
- delete *iterConv;
- *iterConv = DDE_FREECHANNEL;
+ delete pConv;
+ pConv = DDE_FREECHANNEL;
return 0L;
}
@@ -142,7 +142,7 @@ SbError SbiDdeControl::Terminate( sal_Int16 nChannel )
SbError SbiDdeControl::TerminateAll()
{
DdeConnection *conv;
- for (sal_Int16 nChannel = 0; nChannel < aConvList.size(); ++nChannel)
+ for (sal_uInt16 nChannel = 0; nChannel < aConvList.size(); ++nChannel)
{
conv = aConvList[nChannel];
@@ -155,7 +155,7 @@ SbError SbiDdeControl::TerminateAll()
return 0;
}
-SbError SbiDdeControl::Request( sal_Int16 nChannel, const String& rItem, String& rResult )
+SbError SbiDdeControl::Request( sal_uInt16 nChannel, const String& rItem, String& rResult )
{
if (!nChannel || nChannel > aConvList.size())
return SbERR_DDE_NO_CHANNEL;
@@ -172,14 +172,14 @@ SbError SbiDdeControl::Request( sal_Int16 nChannel, const String& rItem, String&
return GetLastErr( pConv );
}
-SbError SbiDdeControl::Execute( sal_Int16 nChannel, const String& rCommand )
+SbError SbiDdeControl::Execute( sal_uInt16 nChannel, const String& rCommand )
{
if (!nChannel || nChannel > aConvList.size())
return SbERR_DDE_NO_CHANNEL;
DdeConnection* pConv = aConvList[nChannel-1];
- if( conv == DDE_FREECHANNEL )
+ if( pConv == DDE_FREECHANNEL )
return SbERR_DDE_NO_CHANNEL;
DdeExecute aRequest( *pConv, rCommand, 30000 );
@@ -187,7 +187,7 @@ SbError SbiDdeControl::Execute( sal_Int16 nChannel, const String& rCommand )
return GetLastErr( pConv );
}
-SbError SbiDdeControl::Poke( sal_Int16 nChannel, const String& rItem, const String& rData )
+SbError SbiDdeControl::Poke( sal_uInt16 nChannel, const String& rItem, const String& rData )
{
if (!nChannel || nChannel > aConvList.size())
return SbERR_DDE_NO_CHANNEL;
diff --git a/basic/source/runtime/ddectrl.hxx b/basic/source/runtime/ddectrl.hxx
index 3b05549..d6ba9ed 100644
--- a/basic/source/runtime/ddectrl.hxx
+++ b/basic/source/runtime/ddectrl.hxx
@@ -52,11 +52,11 @@ public:
SbError Initiate( const String& rService, const String& rTopic,
sal_Int16& rnHandle );
- SbError Terminate( sal_Int16 nChannel );
+ SbError Terminate( sal_uInt16 nChannel );
SbError TerminateAll();
- SbError Request( sal_Int16 nChannel, const String& rItem, String& rResult );
- SbError Execute( sal_Int16 nChannel, const String& rCommand );
- SbError Poke( sal_Int16 nChannel, const String& rItem, const String& rData );
+ SbError Request( sal_uInt16 nChannel, const String& rItem, String& rResult );
+ SbError Execute( sal_uInt16 nChannel, const String& rCommand );
+ SbError Poke( sal_uInt16 nChannel, const String& rItem, const String& rData );
};
#endif
commit 03632f0f8a84c3dc121b6ac864065266c6a1241e
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Wed Apr 27 11:27:37 2011 -0430
Remove usage of List for DdeConnection in SbiDdeControl.
diff --git a/basic/source/runtime/ddectrl.cxx b/basic/source/runtime/ddectrl.cxx
index 9c048c1..3535f75 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 4212479..3b05549 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:
More information about the Libreoffice-commits
mailing list