update dev300-m58
[ooovba.git] / dtrans / test / win32 / dnd / targetlistener.cxx
blob04490bf86bc101b2e0cd644c4db2c98dbbf00977
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: targetlistener.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dtrans.hxx"
35 #include "targetlistener.hxx"
36 #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
37 #include <com/sun/star/datatransfer/DataFlavor.hpp>
39 //using namespace com::sun::star::datatransfer::dnd;
40 using namespace com::sun::star::datatransfer::dnd::DNDConstants;
41 using namespace com::sun::star::datatransfer;
42 using namespace rtl;
44 DropTargetListener::DropTargetListener(HWND hEdit):m_hEdit( hEdit)
47 DropTargetListener::~DropTargetListener()
51 void SAL_CALL DropTargetListener::disposing( const EventObject& Source )
52 throw(RuntimeException)
59 void SAL_CALL DropTargetListener::drop( const DropTargetDropEvent& e )
60 throw(RuntimeException)
62 // e.Context->dropComplete( sal_True);
63 // e.Context->acceptDrop( ACTION_COPY);
64 e.Context->rejectDrop();
66 // if the Transferable contains text, then we send it to the edit window
67 // Sequence<DataFlavor> flavors= e.Transferable->getTransferDataFlavors();
68 // DataFlavor aFlavor;
69 // for( int i=0; i < flavors.getLength(); i++)
70 // aFlavor= flavors[4];
72 DataFlavor flavor( OUString(OUString::createFromAscii("text/plain;charset=windows-1252")),
73 OUString(L"Text plain"), getCppuType( ( Sequence<sal_Int8>*)0 ) );
75 Any anyData= e.Transferable->getTransferData( flavor);
76 Sequence<sal_Int8> seq= *( Sequence<sal_Int8>*)anyData.getValue();
77 SendMessage( m_hEdit, WM_SETTEXT, 0, (LPARAM) seq.getConstArray() );
80 void SAL_CALL DropTargetListener::dragEnter( const DropTargetDragEnterEvent& dtde )
81 throw(RuntimeException)
83 //If one drags something that is not moveable
84 if( !(dtde.SourceActions & dtde.DropAction) )
85 dtde.Context->acceptDrag( ACTION_COPY);
87 // dtde.Context->rejectDrag( );
91 void SAL_CALL DropTargetListener::dragExit( const DropTargetEvent& dte )
92 throw(RuntimeException)
96 void SAL_CALL DropTargetListener::dragOver( const DropTargetDragEvent& dtde )
97 throw(RuntimeException)
99 if( !(dtde.SourceActions & dtde.DropAction) )
100 dtde.Context->acceptDrag( ACTION_COPY);
103 void SAL_CALL DropTargetListener::dropActionChanged( const DropTargetDragEvent& dtde )
104 throw(RuntimeException)