impldde.cxx (d119d52d) impldde.cxx (d2c21ab4)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 35 unchanged lines hidden (view full) ---

44#include "sfx2/sfxresid.hxx"
45
46#include <com/sun/star/uno/Any.hxx>
47#include <com/sun/star/uno/Sequence.hxx>
48
49#include <svl/svdde.hxx>
50#include <sot/formats.hxx>
51
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 35 unchanged lines hidden (view full) ---

44#include "sfx2/sfxresid.hxx"
45
46#include <com/sun/star/uno/Any.hxx>
47#include <com/sun/star/uno/Sequence.hxx>
48
49#include <svl/svdde.hxx>
50#include <sot/formats.hxx>
51
52#include <unotools/securityoptions.hxx>
53
52#define DDELINK_COLD 0
53#define DDELINK_HOT 1
54
55#define DDELINK_ERROR_APP 1
56#define DDELINK_ERROR_DATA 2
57#define DDELINK_ERROR_LINK 3
58
59using namespace ::com::sun::star::uno;

--- 142 unchanged lines hidden (view full) ---

202 rData <<= aEmptyStr;
203 }
204 return 0 == pConnection->GetError();
205}
206
207
208sal_Bool SvDDEObject::Connect( SvBaseLink * pSvLink )
209{
54#define DDELINK_COLD 0
55#define DDELINK_HOT 1
56
57#define DDELINK_ERROR_APP 1
58#define DDELINK_ERROR_DATA 2
59#define DDELINK_ERROR_LINK 3
60
61using namespace ::com::sun::star::uno;

--- 142 unchanged lines hidden (view full) ---

204 rData <<= aEmptyStr;
205 }
206 return 0 == pConnection->GetError();
207}
208
209
210sal_Bool SvDDEObject::Connect( SvBaseLink * pSvLink )
211{
210#if defined(WNT)
211 static sal_Bool bInWinExec = sal_False;
212#endif
213 sal_uInt16 nLinkType = pSvLink->GetUpdateMode();
214 if( pConnection ) // Verbindung steht ja schon
215 {
216 // tja, dann nur noch als Abhaengig eintragen
217 AddDataAdvise( pSvLink,
218 SotExchange::GetFormatMimeType( pSvLink->GetContentType()),
219 LINKUPDATE_ONCALL == nLinkType
220 ? ADVISEMODE_ONLYONCE

--- 10 unchanged lines hidden (view full) ---

231 pSvLink->GetLinkManager()->GetDisplayNames( pSvLink, &sServer, &sTopic, &sItem );
232
233 if( !sServer.Len() || !sTopic.Len() || !sItem.Len() )
234 return sal_False;
235
236 pConnection = new DdeConnection( sServer, sTopic );
237 if( pConnection->GetError() )
238 {
212 sal_uInt16 nLinkType = pSvLink->GetUpdateMode();
213 if( pConnection ) // Verbindung steht ja schon
214 {
215 // tja, dann nur noch als Abhaengig eintragen
216 AddDataAdvise( pSvLink,
217 SotExchange::GetFormatMimeType( pSvLink->GetContentType()),
218 LINKUPDATE_ONCALL == nLinkType
219 ? ADVISEMODE_ONLYONCE

--- 10 unchanged lines hidden (view full) ---

230 pSvLink->GetLinkManager()->GetDisplayNames( pSvLink, &sServer, &sTopic, &sItem );
231
232 if( !sServer.Len() || !sTopic.Len() || !sItem.Len() )
233 return sal_False;
234
235 pConnection = new DdeConnection( sServer, sTopic );
236 if( pConnection->GetError() )
237 {
239 // kann man denn das System-Topic ansprechen ?
240 // dann ist der Server oben, kennt nur nicht das Topic!
241 if( sTopic.EqualsIgnoreCaseAscii( "SYSTEM" ) )
238 // check if the DDE server knows the "SYSTEM" topic
239 bool bSysTopic = false;
240 if( !sTopic.EqualsIgnoreCaseAscii( "SYSTEM" ))
242 {
241 {
243 sal_Bool bSysTopic;
244 {
245 DdeConnection aTmp( sServer, String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "SYSTEM" ) ) );
246 bSysTopic = !aTmp.GetError();
247 }
248
249 if( bSysTopic )
250 {
251 nError = DDELINK_ERROR_DATA;
252 return sal_False;
253 }
254 // ansonsten unter Win/WinNT die Applikation direkt starten
242 DdeConnection aTmp( sServer, String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "SYSTEM" ) ) );
243 bSysTopic = !aTmp.GetError();
255 }
256
244 }
245
257#if defined(WNT)
258
259 // Server nicht da, starten und nochmal versuchen
260 if( !bInWinExec )
246 if( bSysTopic )
261 {
247 {
262 ByteString aCmdLine( sServer, RTL_TEXTENCODING_ASCII_US );
263 aCmdLine.Append( ".exe " );
264 aCmdLine.Append( ByteString( sTopic, RTL_TEXTENCODING_ASCII_US ) );
265
266 if( WinExec( aCmdLine.GetBuffer(), SW_SHOWMINIMIZED ) < 32 )
267 nError = DDELINK_ERROR_APP;
268 else
269 {
270 sal_uInt16 i;
271 for( i=0; i<5; i++ )
272 {
273 bInWinExec = sal_True;
274 Application::Reschedule();
275 bInWinExec = sal_False;
276
277 delete pConnection;
278 pConnection = new DdeConnection( sServer, sTopic );
279 if( !pConnection->GetError() )
280 break;
281 }
282
283 if( i == 5 )
284 {
285 nError = DDELINK_ERROR_APP;
286 }
287 }
248 // if the system topic works then the server is up but just doesn't know the original topic
249 nError = DDELINK_ERROR_DATA;
250 return sal_False;
288 }
251 }
289 else
290#endif // WNT
291 {
292 nError = DDELINK_ERROR_APP;
293 }
252
253 nError = DDELINK_ERROR_APP;
294 }
295
296 if( LINKUPDATE_ALWAYS == nLinkType && !pLink && !pConnection->GetError() )
297 {
298 // Hot Link einrichten, Daten kommen irgendwann spaeter
299 pLink = new DdeHotLink( *pConnection, sItem );
300 pLink->SetDataHdl( LINK( this, SvDDEObject, ImplGetDDEData ) );
301 pLink->SetDoneHdl( LINK( this, SvDDEObject, ImplDoneDDEData ) );

--- 143 unchanged lines hidden ---
254 }
255
256 if( LINKUPDATE_ALWAYS == nLinkType && !pLink && !pConnection->GetError() )
257 {
258 // Hot Link einrichten, Daten kommen irgendwann spaeter
259 pLink = new DdeHotLink( *pConnection, sItem );
260 pLink->SetDataHdl( LINK( this, SvDDEObject, ImplGetDDEData ) );
261 pLink->SetDoneHdl( LINK( this, SvDDEObject, ImplDoneDDEData ) );

--- 143 unchanged lines hidden ---