Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _TOOLKIT_CONTROLS_UNOCONTROL_HXX_
21 : #define _TOOLKIT_CONTROLS_UNOCONTROL_HXX_
22 :
23 : #include <toolkit/dllapi.h>
24 : #include <com/sun/star/awt/XControl.hpp>
25 : #include <com/sun/star/awt/XWindow2.hpp>
26 : #include <com/sun/star/awt/XView.hpp>
27 : #include <com/sun/star/beans/XPropertiesChangeListener.hpp>
28 : #include <com/sun/star/lang/XServiceInfo.hpp>
29 : #include <com/sun/star/lang/XTypeProvider.hpp>
30 : #include <com/sun/star/lang/XUnoTunnel.hpp>
31 : #include <com/sun/star/awt/XUnitConversion.hpp>
32 : #include <com/sun/star/awt/XStyleSettingsSupplier.hpp>
33 : #include <com/sun/star/accessibility/XAccessible.hpp>
34 : #include <cppuhelper/weakagg.hxx>
35 : #include <osl/mutex.hxx>
36 : #include <toolkit/helper/mutexandbroadcasthelper.hxx>
37 : #include <toolkit/helper/listenermultiplexer.hxx>
38 : #include <cppuhelper/propshlp.hxx>
39 : #include <cppuhelper/interfacecontainer.hxx>
40 : #include <cppuhelper/weakref.hxx>
41 : #include <cppuhelper/implbase9.hxx>
42 : #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
43 : #include <com/sun/star/awt/XVclWindowPeer.hpp>
44 :
45 :
46 : struct UnoControlComponentInfos
47 : {
48 : sal_Bool bVisible;
49 : sal_Bool bEnable;
50 : long nX, nY, nWidth, nHeight;
51 : sal_uInt16 nFlags;
52 : float nZoomX, nZoomY;
53 :
54 839 : UnoControlComponentInfos()
55 : {
56 839 : bVisible = sal_True;
57 839 : bEnable = sal_True;
58 839 : nX = nY = nWidth = nHeight = 0;
59 839 : nFlags = 0; // POSSIZE_POSSIZE;
60 839 : nZoomX = nZoomY = 1.0f;
61 839 : }
62 : };
63 :
64 : struct UnoControl_Data;
65 : // ----------------------------------------------------
66 : // class UnoControl
67 : // ----------------------------------------------------
68 : typedef ::cppu::WeakAggImplHelper9 < ::com::sun::star::awt::XControl
69 : , ::com::sun::star::awt::XWindow2
70 : , ::com::sun::star::awt::XView
71 : , ::com::sun::star::beans::XPropertiesChangeListener
72 : , ::com::sun::star::lang::XServiceInfo
73 : , ::com::sun::star::accessibility::XAccessible
74 : , ::com::sun::star::util::XModeChangeBroadcaster
75 : , ::com::sun::star::awt::XUnitConversion
76 : , ::com::sun::star::awt::XStyleSettingsSupplier
77 : > UnoControl_Base;
78 :
79 : class TOOLKIT_DLLPUBLIC UnoControl : public UnoControl_Base
80 : {
81 : private:
82 : ::osl::Mutex maMutex;
83 :
84 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > mxPeer;
85 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclWindowPeer > mxVclWindowPeer; // just to avoid the query_interface thing
86 :
87 : protected:
88 : EventListenerMultiplexer maDisposeListeners;
89 : WindowListenerMultiplexer maWindowListeners;
90 : FocusListenerMultiplexer maFocusListeners;
91 : KeyListenerMultiplexer maKeyListeners;
92 : MouseListenerMultiplexer maMouseListeners;
93 : MouseMotionListenerMultiplexer maMouseMotionListeners;
94 : PaintListenerMultiplexer maPaintListeners;
95 : ::cppu::OInterfaceContainerHelper maModeChangeListeners;
96 :
97 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxContext;
98 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > mxModel;
99 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > mxGraphics;
100 :
101 : ::com::sun::star::uno::WeakReferenceHelper
102 : maAccessibleContext; /// our most recent XAccessibleContext instance
103 :
104 : sal_Bool mbDisposePeer;
105 : sal_Bool mbRefeshingPeer;
106 : sal_Bool mbCreatingPeer;
107 : sal_Bool mbCreatingCompatiblePeer;
108 : sal_Bool mbDesignMode;
109 :
110 : UnoControlComponentInfos maComponentInfos;
111 : UnoControl_Data* mpData;
112 :
113 107869 : ::osl::Mutex& GetMutex() { return maMutex; }
114 :
115 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > getParentPeer() const;
116 : virtual void updateFromModel();
117 : void peerCreated();
118 : bool ImplCheckLocalize( OUString& _rPossiblyLocalizable );
119 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > ImplGetCompatiblePeer( sal_Bool bAcceptExistingPeer );
120 : virtual void ImplSetPeerProperty( const OUString& rPropName, const ::com::sun::star::uno::Any& rVal );
121 : virtual void PrepareWindowDescriptor( ::com::sun::star::awt::WindowDescriptor& rDesc );
122 : virtual void ImplModelPropertiesChanged( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& rEvents );
123 :
124 : void ImplLockPropertyChangeNotification( const OUString& rPropertyName, bool bLock );
125 : void ImplLockPropertyChangeNotifications( const ::com::sun::star::uno::Sequence< OUString >& rPropertyNames, bool bLock );
126 :
127 : void disposeAccessibleContext();
128 :
129 1718 : inline void setPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& _xPeer)
130 : {
131 1718 : mxPeer = _xPeer;
132 1718 : mxVclWindowPeer = ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclWindowPeer >(mxPeer,::com::sun::star::uno::UNO_QUERY); // just to avoid the query_interface thing
133 1718 : }
134 :
135 : virtual sal_Bool requiresNewPeer( const OUString& _rPropertyName ) const;
136 :
137 : public:
138 : UnoControl();
139 : ~UnoControl();
140 :
141 0 : UnoControlComponentInfos& GetComponentInfos() { return maComponentInfos; }
142 :
143 :
144 : virtual OUString GetComponentServiceName();
145 :
146 : // ::com::sun::star::lang::XTypeProvider
147 : ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
148 :
149 : // ::com::sun::star::lang::XComponent
150 : void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException);
151 : void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
152 : void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);
153 :
154 : // XEventListener
155 : void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
156 :
157 : // ::com::sun::star::awt::XWindow2
158 : virtual void SAL_CALL setOutputSize( const ::com::sun::star::awt::Size& aSize ) throw (::com::sun::star::uno::RuntimeException);
159 : virtual ::com::sun::star::awt::Size SAL_CALL getOutputSize( ) throw (::com::sun::star::uno::RuntimeException);
160 : virtual ::sal_Bool SAL_CALL isVisible( ) throw (::com::sun::star::uno::RuntimeException);
161 : virtual ::sal_Bool SAL_CALL isActive( ) throw (::com::sun::star::uno::RuntimeException);
162 : virtual ::sal_Bool SAL_CALL isEnabled( ) throw (::com::sun::star::uno::RuntimeException);
163 : virtual ::sal_Bool SAL_CALL hasFocus( ) throw (::com::sun::star::uno::RuntimeException);
164 :
165 : // ::com::sun::star::awt::XWindow
166 : void SAL_CALL setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) throw(::com::sun::star::uno::RuntimeException);
167 : ::com::sun::star::awt::Rectangle SAL_CALL getPosSize( ) throw(::com::sun::star::uno::RuntimeException);
168 : void SAL_CALL setVisible( sal_Bool Visible ) throw(::com::sun::star::uno::RuntimeException);
169 : void SAL_CALL setEnable( sal_Bool Enable ) throw(::com::sun::star::uno::RuntimeException);
170 : void SAL_CALL setFocus( ) throw(::com::sun::star::uno::RuntimeException);
171 : void SAL_CALL addWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
172 : void SAL_CALL removeWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
173 : void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
174 : void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
175 : void SAL_CALL addKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
176 : void SAL_CALL removeKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
177 : void SAL_CALL addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
178 : void SAL_CALL removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
179 : void SAL_CALL addMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
180 : void SAL_CALL removeMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
181 : void SAL_CALL addPaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
182 : void SAL_CALL removePaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
183 :
184 : // ::com::sun::star::awt::XView
185 : sal_Bool SAL_CALL setGraphics( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& aDevice ) throw(::com::sun::star::uno::RuntimeException);
186 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > SAL_CALL getGraphics( ) throw(::com::sun::star::uno::RuntimeException);
187 : ::com::sun::star::awt::Size SAL_CALL getSize( ) throw(::com::sun::star::uno::RuntimeException);
188 : void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException);
189 : void SAL_CALL setZoom( float fZoomX, float fZoomY ) throw(::com::sun::star::uno::RuntimeException);
190 :
191 : // ::com::sun::star::awt::XControl
192 : void SAL_CALL setContext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Context ) throw(::com::sun::star::uno::RuntimeException);
193 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getContext( ) throw(::com::sun::star::uno::RuntimeException);
194 : void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& Toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent ) throw(::com::sun::star::uno::RuntimeException);
195 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > SAL_CALL getPeer( ) throw(::com::sun::star::uno::RuntimeException);
196 : sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& Model ) throw(::com::sun::star::uno::RuntimeException);
197 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > SAL_CALL getModel( ) throw(::com::sun::star::uno::RuntimeException);
198 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XView > SAL_CALL getView( ) throw(::com::sun::star::uno::RuntimeException);
199 : void SAL_CALL setDesignMode( sal_Bool bOn ) throw(::com::sun::star::uno::RuntimeException);
200 : sal_Bool SAL_CALL isDesignMode( ) throw(::com::sun::star::uno::RuntimeException);
201 : sal_Bool SAL_CALL isTransparent( ) throw(::com::sun::star::uno::RuntimeException);
202 :
203 : // ::com::sun::star::lang::XServiceInfo
204 : OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
205 : sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
206 : ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
207 :
208 : // XAccessible
209 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException);
210 :
211 : // XModeChangeBroadcaster
212 : virtual void SAL_CALL addModeChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
213 : virtual void SAL_CALL removeModeChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
214 : virtual void SAL_CALL addModeChangeApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeApproveListener >& _rxListener ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
215 : virtual void SAL_CALL removeModeChangeApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeApproveListener >& _rxListener ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
216 :
217 : // XUnitConversion
218 : virtual ::com::sun::star::awt::Point SAL_CALL convertPointToLogic( const ::com::sun::star::awt::Point& Point, ::sal_Int16 TargetUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
219 : virtual ::com::sun::star::awt::Point SAL_CALL convertPointToPixel( const ::com::sun::star::awt::Point& aPoint, ::sal_Int16 SourceUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
220 : virtual ::com::sun::star::awt::Size SAL_CALL convertSizeToLogic( const ::com::sun::star::awt::Size& aSize, ::sal_Int16 TargetUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
221 : virtual ::com::sun::star::awt::Size SAL_CALL convertSizeToPixel( const ::com::sun::star::awt::Size& aSize, ::sal_Int16 SourceUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
222 :
223 : // XStyleSettingsSupplier
224 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XStyleSettings > SAL_CALL getStyleSettings() throw (::com::sun::star::uno::RuntimeException);
225 :
226 : private:
227 : // ::com::sun::star::beans::XPropertiesChangeListener
228 : void SAL_CALL propertiesChange( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& evt ) throw(::com::sun::star::uno::RuntimeException);
229 : };
230 :
231 :
232 :
233 :
234 : #endif // _TOOLKIT_CONTROLS_UNOCONTROL_HXX_
235 :
236 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|