xref: /aoo41x/main/vcl/test/dndtest.cxx (revision 9f62ea84)
1*9f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9f62ea84SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9f62ea84SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9f62ea84SAndrew Rist  * distributed with this work for additional information
6*9f62ea84SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9f62ea84SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9f62ea84SAndrew Rist  * "License"); you may not use this file except in compliance
9*9f62ea84SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9f62ea84SAndrew Rist  *
11*9f62ea84SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9f62ea84SAndrew Rist  *
13*9f62ea84SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9f62ea84SAndrew Rist  * software distributed under the License is distributed on an
15*9f62ea84SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9f62ea84SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9f62ea84SAndrew Rist  * specific language governing permissions and limitations
18*9f62ea84SAndrew Rist  * under the License.
19*9f62ea84SAndrew Rist  *
20*9f62ea84SAndrew Rist  *************************************************************/
21*9f62ea84SAndrew Rist 
22*9f62ea84SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir #include <vcl/event.hxx>
27cdf0e10cSrcweir #include <vcl/svapp.hxx>
28cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
29cdf0e10cSrcweir #include <vcl/msgbox.hxx>
30cdf0e10cSrcweir #include <vcl/lstbox.hxx>
31cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
32cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx>
33cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
34cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx>
35cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
36cdf0e10cSrcweir #include <com/sun/star/datatransfer/XTransferable.hpp>
37cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
38cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
39cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDragSourceListener.hpp>
40cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp>
41cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp>
42cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDragGestureListener.hpp>
43cdf0e10cSrcweir #include <vos/process.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <stdio.h>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir using namespace ::rtl;
48cdf0e10cSrcweir using namespace ::vos;
49cdf0e10cSrcweir using namespace ::com::sun::star::io;
50cdf0e10cSrcweir using namespace ::com::sun::star::uno;
51cdf0e10cSrcweir using namespace ::com::sun::star::lang;
52cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer;
53cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer::clipboard;
54cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer::dnd;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir // -----------------------------------------------------------------------
57cdf0e10cSrcweir 
58cdf0e10cSrcweir class MyApp : public Application
59cdf0e10cSrcweir {
60cdf0e10cSrcweir public:
61cdf0e10cSrcweir 	void		Main();
62cdf0e10cSrcweir };
63cdf0e10cSrcweir 
64cdf0e10cSrcweir MyApp aMyApp;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir // -----------------------------------------------------------------------
67cdf0e10cSrcweir 
68cdf0e10cSrcweir class MyWin : public WorkWindow
69cdf0e10cSrcweir {
70cdf0e10cSrcweir public:
71cdf0e10cSrcweir 				MyWin( Window* pParent, WinBits nWinStyle );
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	void		MouseMove( const MouseEvent& rMEvt );
74cdf0e10cSrcweir 	void		MouseButtonDown( const MouseEvent& rMEvt );
75cdf0e10cSrcweir 	void		MouseButtonUp( const MouseEvent& rMEvt );
76cdf0e10cSrcweir 	void		KeyInput( const KeyEvent& rKEvt );
77cdf0e10cSrcweir 	void		KeyUp( const KeyEvent& rKEvt );
78cdf0e10cSrcweir 	void		Paint( const Rectangle& rRect );
79cdf0e10cSrcweir 	void		Resize();
80cdf0e10cSrcweir };
81cdf0e10cSrcweir 
82cdf0e10cSrcweir // -----------------------------------------------------------------------
83cdf0e10cSrcweir 
84cdf0e10cSrcweir class MyDragAndDropListener: public ::cppu::WeakImplHelper3 < XDropTargetListener, XDragGestureListener, XDragSourceListener >
85cdf0e10cSrcweir {
86cdf0e10cSrcweir 	Window * m_pWindow;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir public:
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	MyDragAndDropListener( Window * pWindow ) : m_pWindow( pWindow ) {};
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	virtual void SAL_CALL dragGestureRecognized( const DragGestureEvent& dge ) throw(RuntimeException);
93cdf0e10cSrcweir 	virtual void SAL_CALL drop( const DropTargetDropEvent& dtde ) throw(RuntimeException);
94cdf0e10cSrcweir 	virtual void SAL_CALL dragEnter( const DropTargetDragEnterEvent& dtde ) throw(RuntimeException);
95cdf0e10cSrcweir 	virtual void SAL_CALL dragExit( const DropTargetEvent& dte ) throw(RuntimeException);
96cdf0e10cSrcweir 	virtual void SAL_CALL dragOver( const DropTargetDragEvent& dtde ) throw(RuntimeException);
97cdf0e10cSrcweir 	virtual void SAL_CALL dropActionChanged( const DropTargetDragEvent& dtde ) throw(RuntimeException);
98cdf0e10cSrcweir     virtual void SAL_CALL dragDropEnd( const DragSourceDropEvent& dsde ) throw(RuntimeException);
99cdf0e10cSrcweir     virtual void SAL_CALL dragEnter( const DragSourceDragEvent& dsdee ) throw(RuntimeException);
100cdf0e10cSrcweir     virtual void SAL_CALL dragExit( const DragSourceEvent& dse ) throw(RuntimeException);
101cdf0e10cSrcweir     virtual void SAL_CALL dragOver( const DragSourceDragEvent& dsde ) throw(RuntimeException);
102cdf0e10cSrcweir     virtual void SAL_CALL dropActionChanged( const DragSourceDragEvent& dsde ) throw(RuntimeException);
103cdf0e10cSrcweir 	virtual void SAL_CALL disposing( const EventObject& eo ) throw(RuntimeException);
104cdf0e10cSrcweir };
105cdf0e10cSrcweir 
106cdf0e10cSrcweir // -----------------------------------------------------------------------
107cdf0e10cSrcweir 
108cdf0e10cSrcweir class MyInfoBox : public InfoBox
109cdf0e10cSrcweir {
110cdf0e10cSrcweir 
111cdf0e10cSrcweir public:
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	MyInfoBox( Window* pParent );
114cdf0e10cSrcweir };
115cdf0e10cSrcweir 
116cdf0e10cSrcweir // -----------------------------------------------------------------------
117cdf0e10cSrcweir 
118cdf0e10cSrcweir class MyListBox : public ListBox
119cdf0e10cSrcweir {
120cdf0e10cSrcweir 
121cdf0e10cSrcweir public:
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 	MyListBox( Window* pParent );
124cdf0e10cSrcweir };
125cdf0e10cSrcweir 
126cdf0e10cSrcweir // -----------------------------------------------------------------------
127cdf0e10cSrcweir 
128cdf0e10cSrcweir class StringTransferable : public ::cppu::WeakImplHelper1< XTransferable >
129cdf0e10cSrcweir {
130cdf0e10cSrcweir 	const OUString         m_aData;
131cdf0e10cSrcweir 	Sequence< DataFlavor > m_aFlavorList;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir public:
134cdf0e10cSrcweir 	StringTransferable( const OUString& rString ) : m_aData( rString ), m_aFlavorList( 1 )
135cdf0e10cSrcweir 	{
136cdf0e10cSrcweir 		DataFlavor df;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 		df.MimeType = OUString::createFromAscii( "text/plain;charset=utf-16" );
139cdf0e10cSrcweir 		df.DataType = getCppuType( static_cast < OUString * > ( 0 ) );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	 	m_aFlavorList[0] = df;
142cdf0e10cSrcweir 	};
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	virtual Any SAL_CALL getTransferData( const DataFlavor& aFlavor ) throw(UnsupportedFlavorException, IOException, RuntimeException);
145cdf0e10cSrcweir     virtual Sequence< DataFlavor > SAL_CALL getTransferDataFlavors(  ) throw(RuntimeException);
146cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL isDataFlavorSupported( const DataFlavor& aFlavor ) throw(RuntimeException);
147cdf0e10cSrcweir };
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 
150cdf0e10cSrcweir // -----------------------------------------------------------------------
151cdf0e10cSrcweir 
152cdf0e10cSrcweir void MyApp::Main()
153cdf0e10cSrcweir {
154cdf0e10cSrcweir 	OUString aRegistry;
155cdf0e10cSrcweir 	OStartupInfo aInfo;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	for( sal_Int32 n = 0, nmax = aInfo.getCommandArgCount(); n < nmax; n++ )
158cdf0e10cSrcweir 	{
159cdf0e10cSrcweir 		OUString aArg;
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 		aInfo.getCommandArg( n, aArg );
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 		if( aArg.compareTo( OUString::createFromAscii( "-r" ), 2 ) == 0 )
164cdf0e10cSrcweir 		{
165cdf0e10cSrcweir 			if ( n + 1 < nmax )
166cdf0e10cSrcweir 				aInfo.getCommandArg( ++n, aRegistry );
167cdf0e10cSrcweir 		}
168cdf0e10cSrcweir 	}
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 	Reference< XMultiServiceFactory > xServiceManager;
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 	if( aRegistry.getLength() )
173cdf0e10cSrcweir 	{
174cdf0e10cSrcweir 		xServiceManager = ::cppu::createRegistryServiceFactory( aRegistry, sal_True );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 		if( xServiceManager.is() )
177cdf0e10cSrcweir 		{
178cdf0e10cSrcweir 			::comphelper::setProcessServiceFactory( xServiceManager );
179cdf0e10cSrcweir 		}
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 		if( ! xServiceManager.is() )
182cdf0e10cSrcweir 			printf( "No servicemanager available.\n" );
183cdf0e10cSrcweir 		else
184cdf0e10cSrcweir 			printf( "Ok\n" );
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 	}
187cdf0e10cSrcweir 	else
188cdf0e10cSrcweir 		fprintf( stderr, "Usage: %s -r full-path-to-applicat.rdb\n", "dnddemo" );
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	MyWin aMainWin( NULL, WB_APP | WB_STDWORK );
192cdf0e10cSrcweir 	aMainWin.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "Drag And Drop - Workbench" ) ) );
193cdf0e10cSrcweir 	aMainWin.Show();
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 	// test the clipboard code
196cdf0e10cSrcweir 	Reference< XClipboard > xClipboard = aMainWin.GetClipboard();
197cdf0e10cSrcweir 	if( xClipboard.is() )
198cdf0e10cSrcweir 	{
199cdf0e10cSrcweir 		printf( "System clipboard available.\n" );
200cdf0e10cSrcweir 		xClipboard->getContents();
201cdf0e10cSrcweir 	}
202cdf0e10cSrcweir 	else
203cdf0e10cSrcweir 		fprintf( stderr, "System clipboard not available.\n" );
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	MyInfoBox aInfoBox( &aMainWin );
206cdf0e10cSrcweir 	aInfoBox.Execute();
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 	MyListBox aListBox( &aMainWin );
209cdf0e10cSrcweir 	aListBox.SetPosSizePixel( 10, 10, 100, 100 );
210cdf0e10cSrcweir 	aListBox.InsertEntry( OUString::createFromAscii( "TestItem" ));
211cdf0e10cSrcweir 	aListBox.Show();
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	Execute();
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 	Reference< XComponent > xComponent( xServiceManager, UNO_QUERY );
216cdf0e10cSrcweir 	if( xComponent.is() )
217cdf0e10cSrcweir 		xComponent->dispose();
218cdf0e10cSrcweir 
219cdf0e10cSrcweir }
220cdf0e10cSrcweir 
221cdf0e10cSrcweir // -----------------------------------------------------------------------
222cdf0e10cSrcweir 
223cdf0e10cSrcweir MyWin::MyWin( Window* pParent, WinBits nWinStyle ) :
224cdf0e10cSrcweir 	WorkWindow( pParent, nWinStyle )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir 	Reference< XDropTargetListener > xListener = new MyDragAndDropListener( this );
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 	Reference< XDropTarget > xDropTarget = GetDropTarget();
229cdf0e10cSrcweir 	if( xDropTarget.is() )
230cdf0e10cSrcweir 	{
231cdf0e10cSrcweir 		xDropTarget->addDropTargetListener( xListener );
232cdf0e10cSrcweir 		xDropTarget->setActive( sal_True );
233cdf0e10cSrcweir 	}
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 	Reference< XDragGestureRecognizer > xRecognizer = GetDragGestureRecognizer();
236cdf0e10cSrcweir 	if( xRecognizer.is() )
237cdf0e10cSrcweir 		xRecognizer->addDragGestureListener( Reference< XDragGestureListener > ( xListener, UNO_QUERY ) );
238cdf0e10cSrcweir }
239cdf0e10cSrcweir 
240cdf0e10cSrcweir // -----------------------------------------------------------------------
241cdf0e10cSrcweir 
242cdf0e10cSrcweir void MyWin::MouseMove( const MouseEvent& rMEvt )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir 	WorkWindow::MouseMove( rMEvt );
245cdf0e10cSrcweir }
246cdf0e10cSrcweir 
247cdf0e10cSrcweir // -----------------------------------------------------------------------
248cdf0e10cSrcweir 
249cdf0e10cSrcweir void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
250cdf0e10cSrcweir {
251cdf0e10cSrcweir 	WorkWindow::MouseButtonDown( rMEvt );
252cdf0e10cSrcweir }
253cdf0e10cSrcweir 
254cdf0e10cSrcweir // -----------------------------------------------------------------------
255cdf0e10cSrcweir 
256cdf0e10cSrcweir void MyWin::MouseButtonUp( const MouseEvent& rMEvt )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir 	WorkWindow::MouseButtonUp( rMEvt );
259cdf0e10cSrcweir }
260cdf0e10cSrcweir 
261cdf0e10cSrcweir // -----------------------------------------------------------------------
262cdf0e10cSrcweir 
263cdf0e10cSrcweir void MyWin::KeyInput( const KeyEvent& rKEvt )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir 	WorkWindow::KeyInput( rKEvt );
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
268cdf0e10cSrcweir // -----------------------------------------------------------------------
269cdf0e10cSrcweir 
270cdf0e10cSrcweir void MyWin::KeyUp( const KeyEvent& rKEvt )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir 	WorkWindow::KeyUp( rKEvt );
273cdf0e10cSrcweir }
274cdf0e10cSrcweir 
275cdf0e10cSrcweir // -----------------------------------------------------------------------
276cdf0e10cSrcweir 
277cdf0e10cSrcweir void MyWin::Paint( const Rectangle& rRect )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir 	WorkWindow::Paint( rRect );
280cdf0e10cSrcweir }
281cdf0e10cSrcweir 
282cdf0e10cSrcweir // -----------------------------------------------------------------------
283cdf0e10cSrcweir 
284cdf0e10cSrcweir void MyWin::Resize()
285cdf0e10cSrcweir {
286cdf0e10cSrcweir 	WorkWindow::Resize();
287cdf0e10cSrcweir }
288cdf0e10cSrcweir 
289cdf0e10cSrcweir // -----------------------------------------------------------------------
290cdf0e10cSrcweir 
291cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragGestureRecognized( const DragGestureEvent& dge ) throw(RuntimeException)
292cdf0e10cSrcweir {
293cdf0e10cSrcweir 	printf( "XDragGestureListener::dragGestureRecognized called ( Window: %p, %"SAL_PRIdINT32", %"SAL_PRIdINT32" ).\n", m_pWindow, dge.DragOriginX, dge.DragOriginY );
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 	Reference< XDragSource > xDragSource( dge.DragSource, UNO_QUERY );
296cdf0e10cSrcweir 	xDragSource->startDrag( dge, -1, 0, 0, new StringTransferable( OUString::createFromAscii( "TestString" ) ), this );
297cdf0e10cSrcweir 	printf( "XDragSource::startDrag returned.\n" );
298cdf0e10cSrcweir }
299cdf0e10cSrcweir 
300cdf0e10cSrcweir // -----------------------------------------------------------------------
301cdf0e10cSrcweir 
302cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::drop( const DropTargetDropEvent& dtde ) throw(RuntimeException)
303cdf0e10cSrcweir {
304cdf0e10cSrcweir 	printf( "XDropTargetListener::drop called ( Window: %p, %"SAL_PRIdINT32", %"SAL_PRIdINT32" ).\n", m_pWindow, dtde.LocationX, dtde.LocationY );
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 	dtde.Context->dropComplete( sal_True );
307cdf0e10cSrcweir }
308cdf0e10cSrcweir 
309cdf0e10cSrcweir // -----------------------------------------------------------------------
310cdf0e10cSrcweir 
311cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragEnter( const DropTargetDragEnterEvent& dtdee ) throw(RuntimeException)
312cdf0e10cSrcweir {
313cdf0e10cSrcweir 	printf( "XDropTargetListener::dragEnter called ( Window: %p, %"SAL_PRIdINT32", %"SAL_PRIdINT32" ).\n", m_pWindow, dtdee.LocationX, dtdee.LocationY );
314cdf0e10cSrcweir 	dtdee.Context->acceptDrag( dtdee.DropAction );
315cdf0e10cSrcweir }
316cdf0e10cSrcweir 
317cdf0e10cSrcweir // -----------------------------------------------------------------------
318cdf0e10cSrcweir 
319cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragExit( const DropTargetEvent& ) throw(RuntimeException)
320cdf0e10cSrcweir {
321cdf0e10cSrcweir 	printf( "XDropTargetListener::dragExit called ( Window: %p ).\n", m_pWindow );
322cdf0e10cSrcweir }
323cdf0e10cSrcweir 
324cdf0e10cSrcweir // -----------------------------------------------------------------------
325cdf0e10cSrcweir 
326cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragOver( const DropTargetDragEvent& dtde ) throw(RuntimeException)
327cdf0e10cSrcweir {
328cdf0e10cSrcweir 	printf( "XDropTargetListener::dragOver called ( Window: %p, %"SAL_PRIdINT32", %"SAL_PRIdINT32" ).\n", m_pWindow, dtde.LocationX, dtde.LocationY );
329cdf0e10cSrcweir 	dtde.Context->acceptDrag( dtde.DropAction );
330cdf0e10cSrcweir }
331cdf0e10cSrcweir 
332cdf0e10cSrcweir // -----------------------------------------------------------------------
333cdf0e10cSrcweir 
334cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dropActionChanged( const DropTargetDragEvent& dtde ) throw(RuntimeException)
335cdf0e10cSrcweir {
336cdf0e10cSrcweir 	printf( "XDropTargetListener::dropActionChanged called ( Window: %p, %"SAL_PRIdINT32", %"SAL_PRIdINT32" ).\n", m_pWindow, dtde.LocationX, dtde.LocationY );
337cdf0e10cSrcweir 	dtde.Context->acceptDrag( dtde.DropAction );
338cdf0e10cSrcweir }
339cdf0e10cSrcweir 
340cdf0e10cSrcweir // -----------------------------------------------------------------------
341cdf0e10cSrcweir 
342cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragDropEnd( const DragSourceDropEvent& dsde ) throw(RuntimeException)
343cdf0e10cSrcweir {
344cdf0e10cSrcweir 	printf( "XDragSourceListener::dropDropEnd called ( Window: %p, %s ).\n", m_pWindow, dsde.DropSuccess ? "sucess" : "failed" );
345cdf0e10cSrcweir }
346cdf0e10cSrcweir 
347cdf0e10cSrcweir // -----------------------------------------------------------------------
348cdf0e10cSrcweir 
349cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragEnter( const DragSourceDragEvent& ) throw(RuntimeException)
350cdf0e10cSrcweir {
351cdf0e10cSrcweir 	printf( "XDragSourceListener::dragEnter called ( Window: %p ).\n", m_pWindow );
352cdf0e10cSrcweir }
353cdf0e10cSrcweir 
354cdf0e10cSrcweir // -----------------------------------------------------------------------
355cdf0e10cSrcweir 
356cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragExit( const DragSourceEvent& ) throw(RuntimeException)
357cdf0e10cSrcweir {
358cdf0e10cSrcweir 	printf( "XDragSourceListener::dragExit called ( Window: %p ).\n", m_pWindow );
359cdf0e10cSrcweir }
360cdf0e10cSrcweir 
361cdf0e10cSrcweir // -----------------------------------------------------------------------
362cdf0e10cSrcweir 
363cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dragOver( const DragSourceDragEvent& ) throw(RuntimeException)
364cdf0e10cSrcweir {
365cdf0e10cSrcweir 	printf( "XDragSourceListener::dragOver called ( Window: %p ).\n", m_pWindow );
366cdf0e10cSrcweir }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir // -----------------------------------------------------------------------
369cdf0e10cSrcweir 
370cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::dropActionChanged( const DragSourceDragEvent& ) throw(RuntimeException)
371cdf0e10cSrcweir {
372cdf0e10cSrcweir 	printf( "XDragSourceListener::dropActionChanged called ( Window: %p ).\n", m_pWindow );
373cdf0e10cSrcweir }
374cdf0e10cSrcweir 
375cdf0e10cSrcweir // -----------------------------------------------------------------------
376cdf0e10cSrcweir 
377cdf0e10cSrcweir void SAL_CALL MyDragAndDropListener::disposing( const EventObject& ) throw(RuntimeException)
378cdf0e10cSrcweir {
379cdf0e10cSrcweir 	printf( "XEventListener::disposing called ( Window: %p ).\n", m_pWindow );
380cdf0e10cSrcweir }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir // -----------------------------------------------------------------------
383cdf0e10cSrcweir 
384cdf0e10cSrcweir MyInfoBox::MyInfoBox( Window* pParent ) : InfoBox( pParent,
385cdf0e10cSrcweir 	OUString::createFromAscii( "dragging over this box should result in another window id in the drag log." ) )
386cdf0e10cSrcweir {
387cdf0e10cSrcweir 	Reference< XDropTargetListener > xListener = new MyDragAndDropListener( this );
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 	Reference< XDropTarget > xDropTarget = GetDropTarget();
390cdf0e10cSrcweir 	if( xDropTarget.is() )
391cdf0e10cSrcweir 	{
392cdf0e10cSrcweir 		xDropTarget->addDropTargetListener( xListener );
393cdf0e10cSrcweir 		xDropTarget->setActive( sal_True );
394cdf0e10cSrcweir 	}
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 	Reference< XDragGestureRecognizer > xRecognizer = GetDragGestureRecognizer();
397cdf0e10cSrcweir 	if( xRecognizer.is() )
398cdf0e10cSrcweir 		xRecognizer->addDragGestureListener( Reference< XDragGestureListener > ( xListener, UNO_QUERY ) );
399cdf0e10cSrcweir };
400cdf0e10cSrcweir 
401cdf0e10cSrcweir // -----------------------------------------------------------------------
402cdf0e10cSrcweir 
403cdf0e10cSrcweir MyListBox::MyListBox( Window* pParent ) : ListBox( pParent )
404cdf0e10cSrcweir {
405cdf0e10cSrcweir 	Reference< XDropTargetListener > xListener = new MyDragAndDropListener( this );
406cdf0e10cSrcweir 
407cdf0e10cSrcweir 	Reference< XDropTarget > xDropTarget = GetDropTarget();
408cdf0e10cSrcweir 	if( xDropTarget.is() )
409cdf0e10cSrcweir 	{
410cdf0e10cSrcweir 		xDropTarget->addDropTargetListener( xListener );
411cdf0e10cSrcweir 		xDropTarget->setActive( sal_True );
412cdf0e10cSrcweir 	}
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 	Reference< XDragGestureRecognizer > xRecognizer = GetDragGestureRecognizer();
415cdf0e10cSrcweir 	if( xRecognizer.is() )
416cdf0e10cSrcweir 		xRecognizer->addDragGestureListener( Reference< XDragGestureListener > ( xListener, UNO_QUERY ) );
417cdf0e10cSrcweir };
418cdf0e10cSrcweir 
419cdf0e10cSrcweir // -----------------------------------------------------------------------
420cdf0e10cSrcweir 
421cdf0e10cSrcweir Any SAL_CALL StringTransferable::getTransferData( const DataFlavor& )
422cdf0e10cSrcweir 	throw(UnsupportedFlavorException, IOException, RuntimeException)
423cdf0e10cSrcweir {
424cdf0e10cSrcweir 	return makeAny( m_aData );
425cdf0e10cSrcweir }
426cdf0e10cSrcweir 
427cdf0e10cSrcweir // -----------------------------------------------------------------------
428cdf0e10cSrcweir 
429cdf0e10cSrcweir Sequence< DataFlavor > SAL_CALL StringTransferable::getTransferDataFlavors(  )
430cdf0e10cSrcweir 	throw(RuntimeException)
431cdf0e10cSrcweir {
432cdf0e10cSrcweir 	return m_aFlavorList;
433cdf0e10cSrcweir }
434cdf0e10cSrcweir 
435cdf0e10cSrcweir // -----------------------------------------------------------------------
436cdf0e10cSrcweir 
437cdf0e10cSrcweir sal_Bool SAL_CALL StringTransferable::isDataFlavorSupported( const DataFlavor& )
438cdf0e10cSrcweir 	throw(RuntimeException)
439cdf0e10cSrcweir {
440cdf0e10cSrcweir 	return sal_True;
441cdf0e10cSrcweir }
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 
444