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