xref: /AOO41X/main/sfx2/source/appl/impldde.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #if defined(WNT)
32*cdf0e10cSrcweir #include <tools/svwin.h>
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include "impldde.hxx"
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <vcl/svapp.hxx>
38*cdf0e10cSrcweir #include <vcl/fixed.hxx>
39*cdf0e10cSrcweir #include <vcl/edit.hxx>
40*cdf0e10cSrcweir #include <vcl/button.hxx>
41*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
42*cdf0e10cSrcweir #include <sot/exchange.hxx>
43*cdf0e10cSrcweir #include <rtl/ustring.hxx>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #include "dde.hrc"
46*cdf0e10cSrcweir #include <sfx2/lnkbase.hxx>
47*cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
48*cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
51*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir #include <svl/svdde.hxx>
54*cdf0e10cSrcweir #include <sot/formats.hxx>
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir #define DDELINK_COLD		0
57*cdf0e10cSrcweir #define DDELINK_HOT 		1
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir #define DDELINK_ERROR_APP	1
60*cdf0e10cSrcweir #define DDELINK_ERROR_DATA	2
61*cdf0e10cSrcweir #define DDELINK_ERROR_LINK	3
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir namespace sfx2
66*cdf0e10cSrcweir {
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir class SvDDELinkEditDialog : public ModalDialog
69*cdf0e10cSrcweir {
70*cdf0e10cSrcweir     FixedText aFtDdeApp;
71*cdf0e10cSrcweir     Edit aEdDdeApp;
72*cdf0e10cSrcweir     FixedText aFtDdeTopic;
73*cdf0e10cSrcweir     Edit aEdDdeTopic;
74*cdf0e10cSrcweir     FixedText aFtDdeItem;
75*cdf0e10cSrcweir     Edit aEdDdeItem;
76*cdf0e10cSrcweir     FixedLine aGroupDdeChg;
77*cdf0e10cSrcweir     OKButton aOKButton1;
78*cdf0e10cSrcweir     CancelButton aCancelButton1;
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     DECL_STATIC_LINK( SvDDELinkEditDialog, EditHdl_Impl, Edit* );
81*cdf0e10cSrcweir public:
82*cdf0e10cSrcweir 	SvDDELinkEditDialog( Window* pParent, SvBaseLink* );
83*cdf0e10cSrcweir 	String GetCmd() const;
84*cdf0e10cSrcweir };
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir SvDDELinkEditDialog::SvDDELinkEditDialog( Window* pParent, SvBaseLink* pLink )
87*cdf0e10cSrcweir     : ModalDialog( pParent, SfxResId( MD_DDE_LINKEDIT ) ),
88*cdf0e10cSrcweir     aFtDdeApp( this, SfxResId( FT_DDE_APP ) ),
89*cdf0e10cSrcweir     aEdDdeApp( this, SfxResId( ED_DDE_APP ) ),
90*cdf0e10cSrcweir     aFtDdeTopic( this, SfxResId( FT_DDE_TOPIC ) ),
91*cdf0e10cSrcweir     aEdDdeTopic( this, SfxResId( ED_DDE_TOPIC ) ),
92*cdf0e10cSrcweir     aFtDdeItem( this, SfxResId( FT_DDE_ITEM ) ),
93*cdf0e10cSrcweir     aEdDdeItem( this, SfxResId( ED_DDE_ITEM ) ),
94*cdf0e10cSrcweir     aGroupDdeChg( this, SfxResId( GROUP_DDE_CHG ) ),
95*cdf0e10cSrcweir     aOKButton1( this, SfxResId( 1 ) ),
96*cdf0e10cSrcweir     aCancelButton1( this, SfxResId( 1 ) )
97*cdf0e10cSrcweir {
98*cdf0e10cSrcweir     FreeResource();
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	String sServer, sTopic, sItem;
101*cdf0e10cSrcweir 	pLink->GetLinkManager()->GetDisplayNames( pLink, &sServer, &sTopic, &sItem );
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 	aEdDdeApp.SetText( sServer );
104*cdf0e10cSrcweir 	aEdDdeTopic.SetText( sTopic );
105*cdf0e10cSrcweir 	aEdDdeItem.SetText( sItem );
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 	aEdDdeApp.SetModifyHdl( STATIC_LINK( this, SvDDELinkEditDialog, EditHdl_Impl));
108*cdf0e10cSrcweir 	aEdDdeTopic.SetModifyHdl( STATIC_LINK( this, SvDDELinkEditDialog, EditHdl_Impl));
109*cdf0e10cSrcweir 	aEdDdeItem.SetModifyHdl( STATIC_LINK( this, SvDDELinkEditDialog, EditHdl_Impl));
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	aOKButton1.Enable( sServer.Len() && sTopic.Len() && sItem.Len() );
112*cdf0e10cSrcweir }
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir String SvDDELinkEditDialog::GetCmd() const
115*cdf0e10cSrcweir {
116*cdf0e10cSrcweir 	String sCmd( aEdDdeApp.GetText() ), sRet;
117*cdf0e10cSrcweir     ::sfx2::MakeLnkName( sRet, &sCmd, aEdDdeTopic.GetText(), aEdDdeItem.GetText() );
118*cdf0e10cSrcweir 	return sRet;
119*cdf0e10cSrcweir }
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir IMPL_STATIC_LINK( SvDDELinkEditDialog, EditHdl_Impl, Edit *, pEdit )
122*cdf0e10cSrcweir {
123*cdf0e10cSrcweir     (void)pEdit; // unused variable
124*cdf0e10cSrcweir     pThis->aOKButton1.Enable( pThis->aEdDdeApp.GetText().Len() &&
125*cdf0e10cSrcweir 							  pThis->aEdDdeTopic.GetText().Len() &&
126*cdf0e10cSrcweir 							  pThis->aEdDdeItem.GetText().Len() );
127*cdf0e10cSrcweir 	return 0;
128*cdf0e10cSrcweir }
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir /*  */
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir SvDDEObject::SvDDEObject()
134*cdf0e10cSrcweir 	: pConnection( 0 ), pLink( 0 ), pRequest( 0 ), pGetData( 0 ), nError( 0 )
135*cdf0e10cSrcweir {
136*cdf0e10cSrcweir 	SetUpdateTimeout( 100 );
137*cdf0e10cSrcweir 	bWaitForData = sal_False;
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir SvDDEObject::~SvDDEObject()
141*cdf0e10cSrcweir {
142*cdf0e10cSrcweir 	delete pLink;
143*cdf0e10cSrcweir 	delete pRequest;
144*cdf0e10cSrcweir 	delete pConnection;
145*cdf0e10cSrcweir }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir sal_Bool SvDDEObject::GetData( ::com::sun::star::uno::Any & rData /*out param*/,
148*cdf0e10cSrcweir 							const String & rMimeType,
149*cdf0e10cSrcweir 							sal_Bool bSynchron )
150*cdf0e10cSrcweir {
151*cdf0e10cSrcweir 	if( !pConnection )
152*cdf0e10cSrcweir 		return sal_False;
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 	if( pConnection->GetError() )		// dann versuchen wir es nochmal
155*cdf0e10cSrcweir 	{
156*cdf0e10cSrcweir 		String sServer( pConnection->GetServiceName() );
157*cdf0e10cSrcweir 		String sTopic( pConnection->GetTopicName() );
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 		delete pConnection;
160*cdf0e10cSrcweir 		pConnection = new DdeConnection( sServer, sTopic );
161*cdf0e10cSrcweir 		if( pConnection->GetError() )
162*cdf0e10cSrcweir 			nError = DDELINK_ERROR_APP;
163*cdf0e10cSrcweir 	}
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 	if( bWaitForData )		// wir sind rekursiv drin, wieder raus
166*cdf0e10cSrcweir 		return sal_False;
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir 	// Verriegeln gegen Reentrance
169*cdf0e10cSrcweir 	bWaitForData = sal_True;
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 	// falls gedruckt werden soll, warten wir bis die Daten vorhanden sind
172*cdf0e10cSrcweir 	if( bSynchron )
173*cdf0e10cSrcweir 	{
174*cdf0e10cSrcweir 		DdeRequest aReq( *pConnection, sItem, 5000 );
175*cdf0e10cSrcweir 		aReq.SetDataHdl( LINK( this, SvDDEObject, ImplGetDDEData ) );
176*cdf0e10cSrcweir 		aReq.SetFormat( SotExchange::GetFormatIdFromMimeType( rMimeType ));
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 		pGetData = &rData;
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 		do {
181*cdf0e10cSrcweir 			aReq.Execute();
182*cdf0e10cSrcweir 		} while( aReq.GetError() && ImplHasOtherFormat( aReq ) );
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 		if( pConnection->GetError() )
185*cdf0e10cSrcweir 			nError = DDELINK_ERROR_DATA;
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 		bWaitForData = sal_False;
188*cdf0e10cSrcweir 	}
189*cdf0e10cSrcweir 	else
190*cdf0e10cSrcweir 	{
191*cdf0e10cSrcweir 		// ansonsten wird es asynchron ausgefuehrt
192*cdf0e10cSrcweir //		if( !pLink || !pLink->IsBusy() )
193*cdf0e10cSrcweir 		{
194*cdf0e10cSrcweir 			if( pRequest )
195*cdf0e10cSrcweir 				delete pRequest;
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 			pRequest = new DdeRequest( *pConnection, sItem );
198*cdf0e10cSrcweir 			pRequest->SetDataHdl( LINK( this, SvDDEObject, ImplGetDDEData ) );
199*cdf0e10cSrcweir 			pRequest->SetDoneHdl( LINK( this, SvDDEObject, ImplDoneDDEData ) );
200*cdf0e10cSrcweir 			pRequest->SetFormat( SotExchange::GetFormatIdFromMimeType(
201*cdf0e10cSrcweir 									rMimeType ) );
202*cdf0e10cSrcweir 			pRequest->Execute();
203*cdf0e10cSrcweir 		}
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir 		::rtl::OUString aEmptyStr;
206*cdf0e10cSrcweir 		rData <<= aEmptyStr;
207*cdf0e10cSrcweir 	}
208*cdf0e10cSrcweir 	return 0 == pConnection->GetError();
209*cdf0e10cSrcweir }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir sal_Bool SvDDEObject::Connect( SvBaseLink * pSvLink )
213*cdf0e10cSrcweir {
214*cdf0e10cSrcweir #if defined(WNT)
215*cdf0e10cSrcweir 	static sal_Bool bInWinExec = sal_False;
216*cdf0e10cSrcweir #endif
217*cdf0e10cSrcweir 	sal_uInt16 nLinkType = pSvLink->GetUpdateMode();
218*cdf0e10cSrcweir 	if( pConnection )		// Verbindung steht ja schon
219*cdf0e10cSrcweir 	{
220*cdf0e10cSrcweir 		// tja, dann nur noch als Abhaengig eintragen
221*cdf0e10cSrcweir 		AddDataAdvise( pSvLink,
222*cdf0e10cSrcweir 				SotExchange::GetFormatMimeType( pSvLink->GetContentType()),
223*cdf0e10cSrcweir 				LINKUPDATE_ONCALL == nLinkType
224*cdf0e10cSrcweir 						? ADVISEMODE_ONLYONCE
225*cdf0e10cSrcweir 						: 0 );
226*cdf0e10cSrcweir 		AddConnectAdvise( pSvLink );
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 		return sal_True;
229*cdf0e10cSrcweir 	}
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 	if( !pSvLink->GetLinkManager() )
232*cdf0e10cSrcweir 		return sal_False;
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir 	String sServer, sTopic;
235*cdf0e10cSrcweir 	pSvLink->GetLinkManager()->GetDisplayNames( pSvLink, &sServer, &sTopic, &sItem );
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 	if( !sServer.Len() || !sTopic.Len() || !sItem.Len() )
238*cdf0e10cSrcweir 		return sal_False;
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir 	pConnection = new DdeConnection( sServer, sTopic );
241*cdf0e10cSrcweir 	if( pConnection->GetError() )
242*cdf0e10cSrcweir 	{
243*cdf0e10cSrcweir 		// kann man denn das System-Topic ansprechen ?
244*cdf0e10cSrcweir 		// dann ist der Server oben, kennt nur nicht das Topic!
245*cdf0e10cSrcweir 		if( sTopic.EqualsIgnoreCaseAscii( "SYSTEM" ) )
246*cdf0e10cSrcweir 		{
247*cdf0e10cSrcweir 			sal_Bool bSysTopic;
248*cdf0e10cSrcweir 			{
249*cdf0e10cSrcweir 				DdeConnection aTmp( sServer, String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "SYSTEM" ) ) );
250*cdf0e10cSrcweir 				bSysTopic = !aTmp.GetError();
251*cdf0e10cSrcweir 			}
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir 			if( bSysTopic )
254*cdf0e10cSrcweir 			{
255*cdf0e10cSrcweir 				nError = DDELINK_ERROR_DATA;
256*cdf0e10cSrcweir 				return sal_False;
257*cdf0e10cSrcweir 			}
258*cdf0e10cSrcweir 			// ansonsten unter Win/WinNT die Applikation direkt starten
259*cdf0e10cSrcweir 		}
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir #if defined(WNT)
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir 		// Server nicht da, starten und nochmal versuchen
264*cdf0e10cSrcweir 		if( !bInWinExec )
265*cdf0e10cSrcweir 		{
266*cdf0e10cSrcweir 			ByteString aCmdLine( sServer, RTL_TEXTENCODING_ASCII_US );
267*cdf0e10cSrcweir 			aCmdLine.Append( ".exe " );
268*cdf0e10cSrcweir 			aCmdLine.Append( ByteString( sTopic, RTL_TEXTENCODING_ASCII_US ) );
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir 			if( WinExec( aCmdLine.GetBuffer(), SW_SHOWMINIMIZED ) < 32 )
271*cdf0e10cSrcweir 				nError = DDELINK_ERROR_APP;
272*cdf0e10cSrcweir 			else
273*cdf0e10cSrcweir 			{
274*cdf0e10cSrcweir 				sal_uInt16 i;
275*cdf0e10cSrcweir 				for( i=0; i<5; i++ )
276*cdf0e10cSrcweir 				{
277*cdf0e10cSrcweir 					bInWinExec = sal_True;
278*cdf0e10cSrcweir 					Application::Reschedule();
279*cdf0e10cSrcweir 					bInWinExec = sal_False;
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir 					delete pConnection;
282*cdf0e10cSrcweir 					pConnection = new DdeConnection( sServer, sTopic );
283*cdf0e10cSrcweir 					if( !pConnection->GetError() )
284*cdf0e10cSrcweir 						break;
285*cdf0e10cSrcweir 				}
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir 				if( i == 5 )
288*cdf0e10cSrcweir 				{
289*cdf0e10cSrcweir 					nError = DDELINK_ERROR_APP;
290*cdf0e10cSrcweir 				}
291*cdf0e10cSrcweir 			}
292*cdf0e10cSrcweir 		}
293*cdf0e10cSrcweir 		else
294*cdf0e10cSrcweir #endif	// WNT
295*cdf0e10cSrcweir 		{
296*cdf0e10cSrcweir 			nError = DDELINK_ERROR_APP;
297*cdf0e10cSrcweir 		}
298*cdf0e10cSrcweir 	}
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir 	if( LINKUPDATE_ALWAYS == nLinkType && !pLink && !pConnection->GetError() )
301*cdf0e10cSrcweir 	{
302*cdf0e10cSrcweir 		// Hot Link einrichten, Daten kommen irgendwann spaeter
303*cdf0e10cSrcweir 		pLink = new DdeHotLink( *pConnection, sItem );
304*cdf0e10cSrcweir 		pLink->SetDataHdl( LINK( this, SvDDEObject, ImplGetDDEData ) );
305*cdf0e10cSrcweir 		pLink->SetDoneHdl( LINK( this, SvDDEObject, ImplDoneDDEData ) );
306*cdf0e10cSrcweir 		pLink->SetFormat( pSvLink->GetContentType() );
307*cdf0e10cSrcweir 		pLink->Execute();
308*cdf0e10cSrcweir 	}
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir 	if( pConnection->GetError() )
311*cdf0e10cSrcweir 		return sal_False;
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir 	AddDataAdvise( pSvLink,
314*cdf0e10cSrcweir 				SotExchange::GetFormatMimeType( pSvLink->GetContentType()),
315*cdf0e10cSrcweir 				LINKUPDATE_ONCALL == nLinkType
316*cdf0e10cSrcweir 						? ADVISEMODE_ONLYONCE
317*cdf0e10cSrcweir 						: 0 );
318*cdf0e10cSrcweir 	AddConnectAdvise( pSvLink );
319*cdf0e10cSrcweir 	SetUpdateTimeout( 0 );
320*cdf0e10cSrcweir 	return sal_True;
321*cdf0e10cSrcweir }
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir void SvDDEObject::Edit( Window* pParent, sfx2::SvBaseLink* pBaseLink, const Link& rEndEditHdl )
324*cdf0e10cSrcweir {
325*cdf0e10cSrcweir     SvDDELinkEditDialog aDlg( pParent, pBaseLink );
326*cdf0e10cSrcweir     if ( RET_OK == aDlg.Execute() && rEndEditHdl.IsSet() )
327*cdf0e10cSrcweir     {
328*cdf0e10cSrcweir         String sCommand = aDlg.GetCmd();
329*cdf0e10cSrcweir         rEndEditHdl.Call( &sCommand );
330*cdf0e10cSrcweir     }
331*cdf0e10cSrcweir }
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir sal_Bool SvDDEObject::ImplHasOtherFormat( DdeTransaction& rReq )
334*cdf0e10cSrcweir {
335*cdf0e10cSrcweir 	sal_uInt16 nFmt = 0;
336*cdf0e10cSrcweir 	switch( rReq.GetFormat() )
337*cdf0e10cSrcweir 	{
338*cdf0e10cSrcweir 	case FORMAT_RTF:
339*cdf0e10cSrcweir 		nFmt = FORMAT_STRING;
340*cdf0e10cSrcweir 		break;
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir 	case SOT_FORMATSTR_ID_HTML_SIMPLE:
343*cdf0e10cSrcweir 	case SOT_FORMATSTR_ID_HTML:
344*cdf0e10cSrcweir 		nFmt = FORMAT_RTF;
345*cdf0e10cSrcweir 		break;
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir 	case FORMAT_GDIMETAFILE:
348*cdf0e10cSrcweir 		nFmt = FORMAT_BITMAP;
349*cdf0e10cSrcweir 		break;
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir 	case SOT_FORMATSTR_ID_SVXB:
352*cdf0e10cSrcweir 		nFmt = FORMAT_GDIMETAFILE;
353*cdf0e10cSrcweir 		break;
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir 	// sonst noch irgendwas ??
356*cdf0e10cSrcweir 	}
357*cdf0e10cSrcweir 	if( nFmt )
358*cdf0e10cSrcweir 		rReq.SetFormat( nFmt );		// damit nochmal versuchen
359*cdf0e10cSrcweir 	return 0 != nFmt;
360*cdf0e10cSrcweir }
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir sal_Bool SvDDEObject::IsPending() const
363*cdf0e10cSrcweir /*	[Beschreibung]
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir 	Die Methode stellt fest, ob aus einem DDE-Object die Daten gelesen
366*cdf0e10cSrcweir 	werden kann.
367*cdf0e10cSrcweir 	Zurueckgegeben wird:
368*cdf0e10cSrcweir 		ERRCODE_NONE 			wenn sie komplett gelesen wurde
369*cdf0e10cSrcweir 		ERRCODE_SO_PENDING		wenn sie noch nicht komplett gelesen wurde
370*cdf0e10cSrcweir 		ERRCODE_SO_FALSE		sonst
371*cdf0e10cSrcweir */
372*cdf0e10cSrcweir {
373*cdf0e10cSrcweir 	return bWaitForData;
374*cdf0e10cSrcweir }
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir sal_Bool SvDDEObject::IsDataComplete() const
377*cdf0e10cSrcweir {
378*cdf0e10cSrcweir 	return bWaitForData;
379*cdf0e10cSrcweir }
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir IMPL_LINK( SvDDEObject, ImplGetDDEData, DdeData*, pData )
382*cdf0e10cSrcweir {
383*cdf0e10cSrcweir 	sal_uIntPtr nFmt = pData->GetFormat();
384*cdf0e10cSrcweir 	switch( nFmt )
385*cdf0e10cSrcweir 	{
386*cdf0e10cSrcweir 	case FORMAT_GDIMETAFILE:
387*cdf0e10cSrcweir 		break;
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir 	case FORMAT_BITMAP:
390*cdf0e10cSrcweir 		break;
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir 	default:
393*cdf0e10cSrcweir 		{
394*cdf0e10cSrcweir 			const sal_Char* p = (sal_Char*)( pData->operator const void*() );
395*cdf0e10cSrcweir 			long nLen = FORMAT_STRING == nFmt ? (p ? strlen( p ) : 0) : (long)*pData;
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir 			Sequence< sal_Int8 > aSeq( (const sal_Int8*)p, nLen );
398*cdf0e10cSrcweir 			if( pGetData )
399*cdf0e10cSrcweir 			{
400*cdf0e10cSrcweir 				*pGetData <<= aSeq; 	// Daten kopieren
401*cdf0e10cSrcweir 				pGetData = 0;			// und den Pointer bei mir zuruecksetzen
402*cdf0e10cSrcweir 			}
403*cdf0e10cSrcweir 			else
404*cdf0e10cSrcweir 			{
405*cdf0e10cSrcweir 				Any aVal;
406*cdf0e10cSrcweir 				aVal <<= aSeq;
407*cdf0e10cSrcweir 				DataChanged( SotExchange::GetFormatMimeType(
408*cdf0e10cSrcweir 												pData->GetFormat() ), aVal );
409*cdf0e10cSrcweir 				bWaitForData = sal_False;
410*cdf0e10cSrcweir 			}
411*cdf0e10cSrcweir 		}
412*cdf0e10cSrcweir 	}
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir 	return 0;
415*cdf0e10cSrcweir }
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir IMPL_LINK( SvDDEObject, ImplDoneDDEData, void*, pData )
418*cdf0e10cSrcweir {
419*cdf0e10cSrcweir 	sal_Bool bValid = (sal_Bool)(sal_uIntPtr)pData;
420*cdf0e10cSrcweir 	if( !bValid && ( pRequest || pLink ))
421*cdf0e10cSrcweir 	{
422*cdf0e10cSrcweir 		DdeTransaction* pReq = 0;
423*cdf0e10cSrcweir 		if( !pLink || ( pLink && pLink->IsBusy() ))
424*cdf0e10cSrcweir 			pReq = pRequest;		// dann kann nur der fertig sein
425*cdf0e10cSrcweir 		else if( pRequest && pRequest->IsBusy() )
426*cdf0e10cSrcweir 			pReq = pLink;			// dann kann nur der fertig sein
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir 		if( pReq )
429*cdf0e10cSrcweir 		{
430*cdf0e10cSrcweir 			if( ImplHasOtherFormat( *pReq ) )
431*cdf0e10cSrcweir 			{
432*cdf0e10cSrcweir 				pReq->Execute();
433*cdf0e10cSrcweir 			}
434*cdf0e10cSrcweir 			else if( pReq == pRequest )
435*cdf0e10cSrcweir 			{
436*cdf0e10cSrcweir 				// das wars dann
437*cdf0e10cSrcweir 				bWaitForData = sal_False;
438*cdf0e10cSrcweir 			}
439*cdf0e10cSrcweir 		}
440*cdf0e10cSrcweir 	}
441*cdf0e10cSrcweir 	else
442*cdf0e10cSrcweir 		// das warten ist beendet
443*cdf0e10cSrcweir 		bWaitForData = sal_False;
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir 	return 0;
446*cdf0e10cSrcweir }
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir }
449