Kaydet (Commit) a884fe58 authored tarafından Norbert Thiebaud's avatar Norbert Thiebaud

basic: OUStringification of ddectrl

Change-Id: I2af40d7c8117aff8ce62a8ea0eec579664f8bdeb
üst c5b7d8f9
...@@ -52,7 +52,9 @@ void BasicDLL::EnableBreak( bool bEnable ) ...@@ -52,7 +52,9 @@ void BasicDLL::EnableBreak( bool bEnable )
BasicDLL* pThis = BASIC_DLL(); BasicDLL* pThis = BASIC_DLL();
DBG_ASSERT( pThis, "BasicDLL::EnableBreak: Noch keine Instanz!" ); DBG_ASSERT( pThis, "BasicDLL::EnableBreak: Noch keine Instanz!" );
if ( pThis ) if ( pThis )
{
pThis->bBreakEnabled = bEnable; pThis->bBreakEnabled = bEnable;
}
} }
void BasicDLL::SetDebugMode( bool bDebugMode ) void BasicDLL::SetDebugMode( bool bDebugMode )
...@@ -60,7 +62,9 @@ void BasicDLL::SetDebugMode( bool bDebugMode ) ...@@ -60,7 +62,9 @@ void BasicDLL::SetDebugMode( bool bDebugMode )
BasicDLL* pThis = BASIC_DLL(); BasicDLL* pThis = BASIC_DLL();
DBG_ASSERT( pThis, "BasicDLL::EnableBreak: Noch keine Instanz!" ); DBG_ASSERT( pThis, "BasicDLL::EnableBreak: Noch keine Instanz!" );
if ( pThis ) if ( pThis )
{
pThis->bDebugMode = bDebugMode; pThis->bDebugMode = bDebugMode;
}
} }
......
...@@ -31,9 +31,7 @@ using namespace ::com::sun::star; ...@@ -31,9 +31,7 @@ using namespace ::com::sun::star;
if ( m_xInvocation.is() ) if ( m_xInvocation.is() )
{ {
sal_Int32 nLength = 0; sal_Int32 nLength = 0;
bResult = bResult = ( ( m_xInvocation->getValue( OUString("length" ) ) >>= nLength ) && nLength > m_nCurInd );
( ( m_xInvocation->getValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "length" ) ) ) >>= nLength )
&& nLength > m_nCurInd );
} }
} }
catch(const uno::Exception& ) catch(const uno::Exception& )
...@@ -57,7 +55,7 @@ uno::Any SAL_CALL ComEnumerationWrapper::nextElement() ...@@ -57,7 +55,7 @@ uno::Any SAL_CALL ComEnumerationWrapper::nextElement()
aArgs[0] <<= m_nCurInd++; aArgs[0] <<= m_nCurInd++;
return m_xInvocation->invoke( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "item" ) ), return m_xInvocation->invoke( OUString("item"),
aArgs, aArgs,
aNamedParamIndex, aNamedParamIndex,
aNamedParam ); aNamedParam );
......
...@@ -52,13 +52,19 @@ static const SbError nDdeErrMap[] = ...@@ -52,13 +52,19 @@ static const SbError nDdeErrMap[] =
SbError SbiDdeControl::GetLastErr( DdeConnection* pConv ) SbError SbiDdeControl::GetLastErr( DdeConnection* pConv )
{ {
if( !pConv ) if( !pConv )
{
return 0; return 0;
}
long nErr = pConv->GetError(); long nErr = pConv->GetError();
if( !nErr ) if( !nErr )
{
return 0; return 0;
}
if( nErr < DDE_FIRSTERR || nErr > DDE_LASTERR ) if( nErr < DDE_FIRSTERR || nErr > DDE_LASTERR )
{
return SbERR_DDE_ERROR; return SbERR_DDE_ERROR;
return nDdeErrMap[ 2*(nErr - DDE_FIRSTERR) + 1 ]; }
return nDdeErrMap[ 2 * (nErr - DDE_FIRSTERR) + 1 ];
} }
IMPL_LINK_INLINE( SbiDdeControl,Data , DdeData*, pData, IMPL_LINK_INLINE( SbiDdeControl,Data , DdeData*, pData,
...@@ -77,23 +83,25 @@ SbiDdeControl::~SbiDdeControl() ...@@ -77,23 +83,25 @@ SbiDdeControl::~SbiDdeControl()
TerminateAll(); TerminateAll();
} }
sal_Int16 SbiDdeControl::GetFreeChannel() size_t SbiDdeControl::GetFreeChannel()
{ {
sal_Int16 nChannel = 0; size_t nChannel = 0;
sal_Int16 nListSize = static_cast<sal_Int16>(aConvList.size()); size_t nListSize = aConvList.size();
for (; nChannel < nListSize; ++nChannel) for (; nChannel < nListSize; ++nChannel)
{ {
if (aConvList[nChannel] == DDE_FREECHANNEL) if (aConvList[nChannel] == DDE_FREECHANNEL)
{
return nChannel+1; return nChannel+1;
}
} }
aConvList.push_back(DDE_FREECHANNEL); aConvList.push_back(DDE_FREECHANNEL);
return nChannel+1; return nChannel+1;
} }
SbError SbiDdeControl::Initiate( const String& rService, const String& rTopic, SbError SbiDdeControl::Initiate( const OUString& rService, const OUString& rTopic,
sal_Int16& rnHandle ) size_t& rnHandle )
{ {
SbError nErr; SbError nErr;
DdeConnection* pConv = new DdeConnection( rService, rTopic ); DdeConnection* pConv = new DdeConnection( rService, rTopic );
...@@ -105,23 +113,25 @@ SbError SbiDdeControl::Initiate( const String& rService, const String& rTopic, ...@@ -105,23 +113,25 @@ SbError SbiDdeControl::Initiate( const String& rService, const String& rTopic,
} }
else else
{ {
sal_Int16 nChannel = GetFreeChannel(); size_t nChannel = GetFreeChannel();
aConvList[nChannel-1] = pConv; aConvList[nChannel-1] = pConv;
rnHandle = nChannel; rnHandle = nChannel;
} }
return 0; return 0;
} }
SbError SbiDdeControl::Terminate( sal_uInt16 nChannel ) SbError SbiDdeControl::Terminate( size_t nChannel )
{ {
if (!nChannel || nChannel > aConvList.size()) if (!nChannel || nChannel > aConvList.size())
{
return SbERR_DDE_NO_CHANNEL; return SbERR_DDE_NO_CHANNEL;
}
DdeConnection* pConv = aConvList[nChannel-1]; DdeConnection* pConv = aConvList[nChannel-1];
if( pConv == DDE_FREECHANNEL ) if( pConv == DDE_FREECHANNEL )
{
return SbERR_DDE_NO_CHANNEL; return SbERR_DDE_NO_CHANNEL;
}
delete pConv; delete pConv;
pConv = DDE_FREECHANNEL; pConv = DDE_FREECHANNEL;
...@@ -131,12 +141,14 @@ SbError SbiDdeControl::Terminate( sal_uInt16 nChannel ) ...@@ -131,12 +141,14 @@ SbError SbiDdeControl::Terminate( sal_uInt16 nChannel )
SbError SbiDdeControl::TerminateAll() SbError SbiDdeControl::TerminateAll()
{ {
DdeConnection *conv; DdeConnection *conv;
for (sal_uInt16 nChannel = 0; nChannel < aConvList.size(); ++nChannel) for (size_t nChannel = 0; nChannel < aConvList.size(); ++nChannel)
{ {
conv = aConvList[nChannel]; conv = aConvList[nChannel];
if (conv != DDE_FREECHANNEL) if (conv != DDE_FREECHANNEL)
{
delete conv; delete conv;
}
} }
aConvList.clear(); aConvList.clear();
...@@ -144,15 +156,19 @@ SbError SbiDdeControl::TerminateAll() ...@@ -144,15 +156,19 @@ SbError SbiDdeControl::TerminateAll()
return 0; return 0;
} }
SbError SbiDdeControl::Request( sal_uInt16 nChannel, const String& rItem, String& rResult ) SbError SbiDdeControl::Request( size_t nChannel, const OUString& rItem, OUString& rResult )
{ {
if (!nChannel || nChannel > aConvList.size()) if (!nChannel || nChannel > aConvList.size())
{
return SbERR_DDE_NO_CHANNEL; return SbERR_DDE_NO_CHANNEL;
}
DdeConnection* pConv = aConvList[nChannel-1]; DdeConnection* pConv = aConvList[nChannel-1];
if( pConv == DDE_FREECHANNEL ) if( pConv == DDE_FREECHANNEL )
{
return SbERR_DDE_NO_CHANNEL; return SbERR_DDE_NO_CHANNEL;
}
DdeRequest aRequest( *pConv, rItem, 30000 ); DdeRequest aRequest( *pConv, rItem, 30000 );
aRequest.SetDataHdl( LINK( this, SbiDdeControl, Data ) ); aRequest.SetDataHdl( LINK( this, SbiDdeControl, Data ) );
...@@ -161,31 +177,36 @@ SbError SbiDdeControl::Request( sal_uInt16 nChannel, const String& rItem, String ...@@ -161,31 +177,36 @@ SbError SbiDdeControl::Request( sal_uInt16 nChannel, const String& rItem, String
return GetLastErr( pConv ); return GetLastErr( pConv );
} }
SbError SbiDdeControl::Execute( sal_uInt16 nChannel, const String& rCommand ) SbError SbiDdeControl::Execute( size_t nChannel, const OUString& rCommand )
{ {
if (!nChannel || nChannel > aConvList.size()) if (!nChannel || nChannel > aConvList.size())
{
return SbERR_DDE_NO_CHANNEL; return SbERR_DDE_NO_CHANNEL;
}
DdeConnection* pConv = aConvList[nChannel-1]; DdeConnection* pConv = aConvList[nChannel-1];
if( pConv == DDE_FREECHANNEL ) if( pConv == DDE_FREECHANNEL )
{
return SbERR_DDE_NO_CHANNEL; return SbERR_DDE_NO_CHANNEL;
}
DdeExecute aRequest( *pConv, rCommand, 30000 ); DdeExecute aRequest( *pConv, rCommand, 30000 );
aRequest.Execute(); aRequest.Execute();
return GetLastErr( pConv ); return GetLastErr( pConv );
} }
SbError SbiDdeControl::Poke( sal_uInt16 nChannel, const String& rItem, const String& rData ) SbError SbiDdeControl::Poke( size_t nChannel, const OUString& rItem, const OUString& rData )
{ {
if (!nChannel || nChannel > aConvList.size()) if (!nChannel || nChannel > aConvList.size())
{
return SbERR_DDE_NO_CHANNEL; return SbERR_DDE_NO_CHANNEL;
}
DdeConnection* pConv = aConvList[nChannel-1]; DdeConnection* pConv = aConvList[nChannel-1];
if( pConv == DDE_FREECHANNEL ) if( pConv == DDE_FREECHANNEL )
{
return SbERR_DDE_NO_CHANNEL; return SbERR_DDE_NO_CHANNEL;
}
DdePoke aRequest( *pConv, rItem, DdeData(rData), 30000 ); DdePoke aRequest( *pConv, rItem, DdeData(rData), 30000 );
aRequest.Execute(); aRequest.Execute();
return GetLastErr( pConv ); return GetLastErr( pConv );
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <tools/link.hxx> #include <tools/link.hxx>
#include <basic/sberrors.hxx> #include <basic/sberrors.hxx>
#include <tools/string.hxx>
class DdeConnection; class DdeConnection;
class DdeData; class DdeData;
...@@ -32,22 +31,22 @@ class SbiDdeControl ...@@ -32,22 +31,22 @@ class SbiDdeControl
private: private:
DECL_LINK( Data, DdeData* ); DECL_LINK( Data, DdeData* );
SbError GetLastErr( DdeConnection* ); SbError GetLastErr( DdeConnection* );
sal_Int16 GetFreeChannel(); size_t GetFreeChannel();
std::vector<DdeConnection*> aConvList; std::vector<DdeConnection*> aConvList;
String aData; OUString aData;
public: public:
SbiDdeControl(); SbiDdeControl();
~SbiDdeControl(); ~SbiDdeControl();
SbError Initiate( const String& rService, const String& rTopic, SbError Initiate( const OUString& rService, const OUString& rTopic,
sal_Int16& rnHandle ); size_t& rnHandle );
SbError Terminate( sal_uInt16 nChannel ); SbError Terminate( size_t nChannel );
SbError TerminateAll(); SbError TerminateAll();
SbError Request( sal_uInt16 nChannel, const String& rItem, String& rResult ); SbError Request( size_t nChannel, const OUString& rItem, OUString& rResult );
SbError Execute( sal_uInt16 nChannel, const String& rCommand ); SbError Execute( size_t nChannel, const OUString& rCommand );
SbError Poke( sal_uInt16 nChannel, const String& rItem, const String& rData ); SbError Poke( size_t nChannel, const OUString& rItem, const OUString& rData );
}; };
#endif #endif
......
...@@ -3427,16 +3427,20 @@ RTLFUNC(DDEInitiate) ...@@ -3427,16 +3427,20 @@ RTLFUNC(DDEInitiate)
StarBASIC::Error( SbERR_BAD_ARGUMENT ); StarBASIC::Error( SbERR_BAD_ARGUMENT );
return; return;
} }
const String& rApp = rPar.Get(1)->GetString(); const OUString& rApp = rPar.Get(1)->GetString();
const String& rTopic = rPar.Get(2)->GetString(); const OUString& rTopic = rPar.Get(2)->GetString();
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl(); SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
sal_Int16 nChannel; size_t nChannel;
SbError nDdeErr = pDDE->Initiate( rApp, rTopic, nChannel ); SbError nDdeErr = pDDE->Initiate( rApp, rTopic, nChannel );
if( nDdeErr ) if( nDdeErr )
{
StarBASIC::Error( nDdeErr ); StarBASIC::Error( nDdeErr );
}
else else
rPar.Get(0)->PutInteger( nChannel ); {
rPar.Get(0)->PutInteger( (int)nChannel );
}
} }
RTLFUNC(DDETerminate) RTLFUNC(DDETerminate)
...@@ -3458,11 +3462,13 @@ RTLFUNC(DDETerminate) ...@@ -3458,11 +3462,13 @@ RTLFUNC(DDETerminate)
StarBASIC::Error( SbERR_BAD_ARGUMENT ); StarBASIC::Error( SbERR_BAD_ARGUMENT );
return; return;
} }
sal_Int16 nChannel = rPar.Get(1)->GetInteger(); size_t nChannel = rPar.Get(1)->GetInteger();
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl(); SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
SbError nDdeErr = pDDE->Terminate( nChannel ); SbError nDdeErr = pDDE->Terminate( nChannel );
if( nDdeErr ) if( nDdeErr )
{
StarBASIC::Error( nDdeErr ); StarBASIC::Error( nDdeErr );
}
} }
RTLFUNC(DDETerminateAll) RTLFUNC(DDETerminateAll)
...@@ -3488,8 +3494,9 @@ RTLFUNC(DDETerminateAll) ...@@ -3488,8 +3494,9 @@ RTLFUNC(DDETerminateAll)
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl(); SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
SbError nDdeErr = pDDE->TerminateAll(); SbError nDdeErr = pDDE->TerminateAll();
if( nDdeErr ) if( nDdeErr )
{
StarBASIC::Error( nDdeErr ); StarBASIC::Error( nDdeErr );
}
} }
RTLFUNC(DDERequest) RTLFUNC(DDERequest)
...@@ -3510,15 +3517,19 @@ RTLFUNC(DDERequest) ...@@ -3510,15 +3517,19 @@ RTLFUNC(DDERequest)
StarBASIC::Error( SbERR_BAD_ARGUMENT ); StarBASIC::Error( SbERR_BAD_ARGUMENT );
return; return;
} }
sal_Int16 nChannel = rPar.Get(1)->GetInteger(); size_t nChannel = rPar.Get(1)->GetInteger();
const String& rItem = rPar.Get(2)->GetString(); const OUString& rItem = rPar.Get(2)->GetString();
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl(); SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
String aResult; OUString aResult;
SbError nDdeErr = pDDE->Request( nChannel, rItem, aResult ); SbError nDdeErr = pDDE->Request( nChannel, rItem, aResult );
if( nDdeErr ) if( nDdeErr )
{
StarBASIC::Error( nDdeErr ); StarBASIC::Error( nDdeErr );
}
else else
{
rPar.Get(0)->PutString( aResult ); rPar.Get(0)->PutString( aResult );
}
} }
RTLFUNC(DDEExecute) RTLFUNC(DDEExecute)
...@@ -3540,12 +3551,14 @@ RTLFUNC(DDEExecute) ...@@ -3540,12 +3551,14 @@ RTLFUNC(DDEExecute)
StarBASIC::Error( SbERR_BAD_ARGUMENT ); StarBASIC::Error( SbERR_BAD_ARGUMENT );
return; return;
} }
sal_Int16 nChannel = rPar.Get(1)->GetInteger(); size_t nChannel = rPar.Get(1)->GetInteger();
const String& rCommand = rPar.Get(2)->GetString(); const OUString& rCommand = rPar.Get(2)->GetString();
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl(); SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
SbError nDdeErr = pDDE->Execute( nChannel, rCommand ); SbError nDdeErr = pDDE->Execute( nChannel, rCommand );
if( nDdeErr ) if( nDdeErr )
{
StarBASIC::Error( nDdeErr ); StarBASIC::Error( nDdeErr );
}
} }
RTLFUNC(DDEPoke) RTLFUNC(DDEPoke)
...@@ -3567,13 +3580,15 @@ RTLFUNC(DDEPoke) ...@@ -3567,13 +3580,15 @@ RTLFUNC(DDEPoke)
StarBASIC::Error( SbERR_BAD_ARGUMENT ); StarBASIC::Error( SbERR_BAD_ARGUMENT );
return; return;
} }
sal_Int16 nChannel = rPar.Get(1)->GetInteger(); size_t nChannel = rPar.Get(1)->GetInteger();
const String& rItem = rPar.Get(2)->GetString(); const OUString& rItem = rPar.Get(2)->GetString();
const String& rData = rPar.Get(3)->GetString(); const OUString& rData = rPar.Get(3)->GetString();
SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl(); SbiDdeControl* pDDE = GetSbData()->pInst->GetDdeControl();
SbError nDdeErr = pDDE->Poke( nChannel, rItem, rData ); SbError nDdeErr = pDDE->Poke( nChannel, rItem, rData );
if( nDdeErr ) if( nDdeErr )
{
StarBASIC::Error( nDdeErr ); StarBASIC::Error( nDdeErr );
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment