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 _TOOLKIT_AWT_VCLXTOOLKIT_HXX_
25 #define _TOOLKIT_AWT_VCLXTOOLKIT_HXX_
26 
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/awt/XSystemChildFactory.hpp>
29 #include <com/sun/star/awt/XToolkit.hpp>
30 #include <com/sun/star/awt/XDataTransferProviderAccess.hpp>
31 #include <com/sun/star/lang/XTypeProvider.hpp>
32 #include <com/sun/star/awt/XExtendedToolkit.hpp>
33 #include <com/sun/star/awt/XReschedule.hpp>
34 #include <com/sun/star/awt/XMessageBoxFactory.hpp>
35 #include <cppuhelper/compbase7.hxx>
36 #include "cppuhelper/interfacecontainer.hxx"
37 #include <osl/mutex.hxx>
38 #include <osl/module.h>
39 #include <tools/link.hxx>
40 #include <tools/wintypes.hxx>
41 
42 #include <toolkit/dllapi.h>
43 
44 TOOLKIT_DLLPUBLIC WinBits ImplGetWinBits( sal_uInt32 nComponentAttribs, sal_uInt16 nCompType );
45 
46 class Window;
47 class VCLXWindow;
48 class VclSimpleEvent;
49 
50 namespace com {
51 namespace sun {
52 namespace star {
53 namespace lang {
54     struct EventObject;
55 }
56 namespace awt {
57 	struct WindowDescriptor;
58 	class XDataTransfer;
59 } } } }
60 
61 extern "C" {
62 	typedef Window* (SAL_CALL *FN_SvtCreateWindow)( VCLXWindow** ppNewComp, const ::com::sun::star::awt::WindowDescriptor* pDescriptor, Window* pParent, WinBits nWinBits );
63 }
64 
65 
66 //	----------------------------------------------------
67 //	class VCLXTOOLKIT
68 //	----------------------------------------------------
69 
70 class VCLXToolkit_Impl
71 {
72 protected:
73 	::osl::Mutex	maMutex;
74 };
75 
76 class VCLXToolkit :	public VCLXToolkit_Impl,
77 					public cppu::WeakComponentImplHelper7<
78 					::com::sun::star::awt::XToolkit,
79 					::com::sun::star::lang::XServiceInfo,
80 					::com::sun::star::awt::XSystemChildFactory,
81                     ::com::sun::star::awt::XMessageBoxFactory,
82 					::com::sun::star::awt::XDataTransferProviderAccess,
83                     ::com::sun::star::awt::XExtendedToolkit,
84                     ::com::sun::star::awt::XReschedule >
85 {
86 	::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > mxClipboard;
87 	::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > mxSelection;
88 
89 	oslModule			hSvToolsLib;
90 	FN_SvtCreateWindow	fnSvtCreateWindow;
91 
92     ::cppu::OInterfaceContainerHelper m_aTopWindowListeners;
93     ::cppu::OInterfaceContainerHelper m_aKeyHandlers;
94     ::cppu::OInterfaceContainerHelper m_aFocusListeners;
95     ::Link m_aEventListenerLink;
96     ::Link m_aKeyListenerLink;
97     bool m_bEventListener;
98     bool m_bKeyListener;
99 
100     DECL_LINK(eventListenerHandler, ::VclSimpleEvent const *);
101 
102     DECL_LINK(keyListenerHandler, ::VclSimpleEvent const *);
103 
104     void callTopWindowListeners(
105         ::VclSimpleEvent const * pEvent,
106         void (SAL_CALL ::com::sun::star::awt::XTopWindowListener::* pFn)(
107             ::com::sun::star::lang::EventObject const &));
108 
109     long callKeyHandlers(::VclSimpleEvent const * pEvent, bool bPressed);
110 
111     void callFocusListeners(::VclSimpleEvent const * pEvent, bool bGained);
112 
113 protected:
GetMutex()114 	::osl::Mutex&	GetMutex() { return maMutex; }
115 
116 	virtual void SAL_CALL disposing();
117 
118 	Window*	ImplCreateWindow( VCLXWindow** ppNewComp, const ::com::sun::star::awt::WindowDescriptor& rDescriptor, Window* pParent, WinBits nWinBits );
119     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > ImplCreateWindow( const ::com::sun::star::awt::WindowDescriptor& Descriptor, WinBits nWinBits );
120 
121 public:
122 
123 	VCLXToolkit( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & );
124 	~VCLXToolkit();
125 
126 	// ::com::sun::star::awt::XToolkit
127     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >	SAL_CALL getDesktopWindow(  ) throw(::com::sun::star::uno::RuntimeException);
128     ::com::sun::star::awt::Rectangle										SAL_CALL getWorkArea(  ) throw(::com::sun::star::uno::RuntimeException);
129     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >	SAL_CALL createWindow( const ::com::sun::star::awt::WindowDescriptor& Descriptor ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
130     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > > SAL_CALL createWindows( const ::com::sun::star::uno::Sequence< ::com::sun::star::awt::WindowDescriptor >& Descriptors ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
131     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice >		SAL_CALL createScreenCompatibleDevice( sal_Int32 Width, sal_Int32 Height ) throw(::com::sun::star::uno::RuntimeException);
132     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >		SAL_CALL createRegion(  ) throw(::com::sun::star::uno::RuntimeException);
133 
134     // ::com::sun::star::awt::XSystemChildFactory
135 	::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > SAL_CALL createSystemChild( const ::com::sun::star::uno::Any& Parent, const ::com::sun::star::uno::Sequence< sal_Int8 >& ProcessId, sal_Int16 SystemType ) throw(::com::sun::star::uno::RuntimeException);
136 
137     // ::com::sun::star::awt::XMessageBoxFactory
138     virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMessageBox > SAL_CALL createMessageBox( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& aParent, ::com::sun::star::awt::MessageBoxType eType, ::sal_Int32 nButtons, const ::rtl::OUString& sTitle, const ::rtl::OUString& sMessage ) throw (::com::sun::star::uno::RuntimeException);
139 
140     // ::com::sun::star::awt::XDataTransfer
141 	::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer > SAL_CALL getDragGestureRecognizer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& window ) throw(::com::sun::star::uno::RuntimeException);
142 	::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource > SAL_CALL getDragSource( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& window ) throw(::com::sun::star::uno::RuntimeException);
143 	::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTarget > SAL_CALL getDropTarget( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& window ) throw(::com::sun::star::uno::RuntimeException);
144 	::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > SAL_CALL getClipboard( const ::rtl::OUString& clipboardName ) throw(::com::sun::star::uno::RuntimeException);
145 
146 	// ::com::sun::star::lang::XServiceInfo
147     ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
148     sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
149     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
150 
151     // ::com::sun::star::awt::XExtendedToolkit:
152 
153     virtual ::sal_Int32 SAL_CALL getTopWindowCount()
154         throw (::com::sun::star::uno::RuntimeException);
155 
156     virtual
157     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTopWindow >
158     SAL_CALL getTopWindow(::sal_Int32 nIndex)
159         throw (::com::sun::star::uno::RuntimeException);
160 
161     virtual
162     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTopWindow >
163     SAL_CALL getActiveTopWindow()
164         throw (::com::sun::star::uno::RuntimeException);
165 
166     virtual void SAL_CALL addTopWindowListener(
167         ::com::sun::star::uno::Reference<
168         ::com::sun::star::awt::XTopWindowListener > const & rListener)
169         throw (::com::sun::star::uno::RuntimeException);
170 
171     virtual void SAL_CALL removeTopWindowListener(
172         ::com::sun::star::uno::Reference<
173         ::com::sun::star::awt::XTopWindowListener > const & rListener)
174         throw (::com::sun::star::uno::RuntimeException);
175 
176     virtual void SAL_CALL addKeyHandler(
177         ::com::sun::star::uno::Reference<
178         ::com::sun::star::awt::XKeyHandler > const & rHandler)
179         throw (::com::sun::star::uno::RuntimeException);
180 
181     virtual void SAL_CALL removeKeyHandler(
182         ::com::sun::star::uno::Reference<
183         ::com::sun::star::awt::XKeyHandler > const & rHandler)
184         throw (::com::sun::star::uno::RuntimeException);
185 
186     virtual void SAL_CALL addFocusListener(
187         ::com::sun::star::uno::Reference<
188         ::com::sun::star::awt::XFocusListener > const & rListener)
189         throw (::com::sun::star::uno::RuntimeException);
190 
191     virtual void SAL_CALL removeFocusListener(
192         ::com::sun::star::uno::Reference<
193         ::com::sun::star::awt::XFocusListener > const & rListener)
194         throw (::com::sun::star::uno::RuntimeException);
195 
196     virtual void SAL_CALL fireFocusGained(
197         ::com::sun::star::uno::Reference<
198         ::com::sun::star::uno::XInterface > const & source)
199         throw (::com::sun::star::uno::RuntimeException);
200 
201     virtual void SAL_CALL fireFocusLost(
202         ::com::sun::star::uno::Reference<
203         ::com::sun::star::uno::XInterface > const & source)
204         throw (::com::sun::star::uno::RuntimeException);
205 
206     // ::com::sun::star::awt::XReschedule:
207     virtual void SAL_CALL reschedule()
208         throw (::com::sun::star::uno::RuntimeException);
209 
210 
211 };
212 
213 #endif // _TOOLKIT_AWT_VCLXTOOLKIT_HXX_
214