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 #ifndef __FRAMEWORK_CLASSES_DROPTARGETLISTENER_HXX_
25 #define __FRAMEWORK_CLASSES_DROPTARGETLISTENER_HXX_
26 
27 //_________________________________________________________________________________________________________________
28 //	my own includes
29 //_________________________________________________________________________________________________________________
30 
31 #include <threadhelp/threadhelpbase.hxx>
32 #include <general.h>
33 
34 //_________________________________________________________________________________________________________________
35 //	interface includes
36 //_________________________________________________________________________________________________________________
37 
38 #ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDROPTARGETELISTENER_HPP_
39 #include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp>
40 #endif
41 #include <com/sun/star/frame/XFrame.hpp>
42 
43 //_________________________________________________________________________________________________________________
44 //	includes of other projects
45 //_________________________________________________________________________________________________________________
46 #include <cppuhelper/implbase1.hxx>
47 
48 #ifndef _SOT_EXCHANGE_HXX_
49 #include <sot/exchange.hxx>
50 #endif
51 
52 namespace framework
53 {
54 
55 class DropTargetListener : private ThreadHelpBase
56                          , public ::cppu::WeakImplHelper1< ::com::sun::star::datatransfer::dnd::XDropTargetListener >
57 {
58     //___________________________________________
59     // member
60 	private:
61 
62         /// uno service manager to create necessary services
63         css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
64         /// weakreference to target frame (Don't use a hard reference. Owner can't delete us then!)
65         css::uno::WeakReference< css::frame::XFrame > m_xTargetFrame;
66         /// drag/drop info
67         DataFlavorExVector* m_pFormats;
68 
69     //___________________________________________
70     // c++ interface
71 	public:
72 
73          DropTargetListener( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ,
74                              const css::uno::Reference< css::frame::XFrame >& xFrame                );
75         ~DropTargetListener(                                                                        );
76 
77     //___________________________________________
78     // uno interface
79     public:
80 
81 		// XEventListener
82         virtual void SAL_CALL disposing        ( const css::lang::EventObject& Source ) throw(css::uno::RuntimeException);
83 
84 		// XDropTargetListener
85         virtual void SAL_CALL drop             ( const css::datatransfer::dnd::DropTargetDropEvent&      dtde  ) throw(css::uno::RuntimeException);
86         virtual void SAL_CALL dragEnter        ( const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) throw(css::uno::RuntimeException);
87         virtual void SAL_CALL dragExit         ( const css::datatransfer::dnd::DropTargetEvent&          dte   ) throw(css::uno::RuntimeException);
88         virtual void SAL_CALL dragOver         ( const css::datatransfer::dnd::DropTargetDragEvent&      dtde  ) throw(css::uno::RuntimeException);
89         virtual void SAL_CALL dropActionChanged( const css::datatransfer::dnd::DropTargetDragEvent&      dtde  ) throw(css::uno::RuntimeException);
90 
91     //___________________________________________
92     // internal helper
93 	private:
94 
95         void     implts_BeginDrag            ( const css::uno::Sequence< css::datatransfer::DataFlavor >& rSupportedDataFlavors );
96         void     implts_EndDrag              (                                                                                  );
97         sal_Bool implts_IsDropFormatSupported( SotFormatStringId nFormat                                                        );
98         void     implts_OpenFile             ( const String& rFilePath                                                          );
99 
100 }; // class DropTargetListener
101 
102 } // namespace framework
103 
104 #endif // __FRAMEWORK_CLASSES_DROPTARGETLISTENER_HXX_
105