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