1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dtrans.hxx"
26 
27 
28 #include "targetlistener.hxx"
29 #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
30 #include <com/sun/star/datatransfer/DataFlavor.hpp>
31 
32 //using namespace com::sun::star::datatransfer::dnd;
33 using namespace com::sun::star::datatransfer::dnd::DNDConstants;
34 using namespace com::sun::star::datatransfer;
35 using namespace rtl;
36 
DropTargetListener(HWND hEdit)37 DropTargetListener::DropTargetListener(HWND hEdit):m_hEdit( hEdit)
38 {
39 }
~DropTargetListener()40 DropTargetListener::~DropTargetListener()
41 {
42 }
43 
disposing(const EventObject & Source)44 void SAL_CALL DropTargetListener::disposing( const EventObject& Source )
45 		throw(RuntimeException)
46 {
47 
48 }
49 
50 
51 
drop(const DropTargetDropEvent & e)52 void SAL_CALL DropTargetListener::drop( const DropTargetDropEvent& e )
53 	throw(RuntimeException)
54 {
55 //	e.Context->dropComplete( sal_True);
56 //	e.Context->acceptDrop( ACTION_COPY);
57 	e.Context->rejectDrop();
58 
59 	// if the Transferable contains text, then we send it to the edit window
60 //	Sequence<DataFlavor> flavors= e.Transferable->getTransferDataFlavors();
61 //	DataFlavor aFlavor;
62 //	for( int i=0; i < flavors.getLength(); i++)
63 //		aFlavor= flavors[4];
64 
65 	DataFlavor flavor( OUString(OUString::createFromAscii("text/plain;charset=windows-1252")),
66 		OUString(L"Text plain"), getCppuType( ( Sequence<sal_Int8>*)0 ) );
67 
68 	Any anyData= e.Transferable->getTransferData( flavor);
69 	Sequence<sal_Int8> seq= *( Sequence<sal_Int8>*)anyData.getValue();
70 	SendMessage( m_hEdit, WM_SETTEXT, 0, (LPARAM) seq.getConstArray() );
71 }
72 
dragEnter(const DropTargetDragEnterEvent & dtde)73 void SAL_CALL DropTargetListener::dragEnter( const DropTargetDragEnterEvent& dtde )
74 	 throw(RuntimeException)
75 {
76 	//If one drags something that is not moveable
77 	if( !(dtde.SourceActions & dtde.DropAction) )
78 		dtde.Context->acceptDrag( ACTION_COPY);
79 
80 //	dtde.Context->rejectDrag( );
81 
82 }
83 
dragExit(const DropTargetEvent & dte)84 void SAL_CALL DropTargetListener::dragExit( const DropTargetEvent& dte )
85 	 throw(RuntimeException)
86 {
87 }
88 
dragOver(const DropTargetDragEvent & dtde)89 void SAL_CALL DropTargetListener::dragOver( const DropTargetDragEvent& dtde )
90 	 throw(RuntimeException)
91 {
92 	if( !(dtde.SourceActions & dtde.DropAction) )
93 		dtde.Context->acceptDrag( ACTION_COPY);
94 }
95 
dropActionChanged(const DropTargetDragEvent & dtde)96 void SAL_CALL DropTargetListener::dropActionChanged( const DropTargetDragEvent& dtde )
97 	throw(RuntimeException)
98 {
99 }
100