update credits
[LibreOffice.git] / include / toolkit / controls / unocontrol.hxx
blobdf5806be7e49c49ec2797672dd6fc94f7d3678f1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _TOOLKIT_CONTROLS_UNOCONTROL_HXX_
21 #define _TOOLKIT_CONTROLS_UNOCONTROL_HXX_
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 <comphelper/componentcontext.hxx>
43 #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
44 #include <com/sun/star/awt/XVclWindowPeer.hpp>
47 struct UnoControlComponentInfos
49 sal_Bool bVisible;
50 sal_Bool bEnable;
51 long nX, nY, nWidth, nHeight;
52 sal_uInt16 nFlags;
53 float nZoomX, nZoomY;
55 UnoControlComponentInfos()
57 bVisible = sal_True;
58 bEnable = sal_True;
59 nX = nY = nWidth = nHeight = 0;
60 nFlags = 0; // POSSIZE_POSSIZE;
61 nZoomX = nZoomY = 1.0f;
65 struct UnoControl_Data;
66 // ----------------------------------------------------
67 // class UnoControl
68 // ----------------------------------------------------
69 typedef ::cppu::WeakAggImplHelper9 < ::com::sun::star::awt::XControl
70 , ::com::sun::star::awt::XWindow2
71 , ::com::sun::star::awt::XView
72 , ::com::sun::star::beans::XPropertiesChangeListener
73 , ::com::sun::star::lang::XServiceInfo
74 , ::com::sun::star::accessibility::XAccessible
75 , ::com::sun::star::util::XModeChangeBroadcaster
76 , ::com::sun::star::awt::XUnitConversion
77 , ::com::sun::star::awt::XStyleSettingsSupplier
78 > UnoControl_Base;
80 class TOOLKIT_DLLPUBLIC UnoControl : public UnoControl_Base
82 private:
83 ::osl::Mutex maMutex;
85 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > mxPeer;
86 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclWindowPeer > mxVclWindowPeer; // just to avoid the query_interface thing
88 protected:
89 EventListenerMultiplexer maDisposeListeners;
90 WindowListenerMultiplexer maWindowListeners;
91 FocusListenerMultiplexer maFocusListeners;
92 KeyListenerMultiplexer maKeyListeners;
93 MouseListenerMultiplexer maMouseListeners;
94 MouseMotionListenerMultiplexer maMouseMotionListeners;
95 PaintListenerMultiplexer maPaintListeners;
96 ::cppu::OInterfaceContainerHelper maModeChangeListeners;
98 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxContext;
99 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > mxModel;
100 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > mxGraphics;
102 ::com::sun::star::uno::WeakReferenceHelper
103 maAccessibleContext; /// our most recent XAccessibleContext instance
105 sal_Bool mbDisposePeer;
106 sal_Bool mbRefeshingPeer;
107 sal_Bool mbCreatingPeer;
108 sal_Bool mbCreatingCompatiblePeer;
109 sal_Bool mbDesignMode;
111 UnoControlComponentInfos maComponentInfos;
112 UnoControl_Data* mpData;
114 ::osl::Mutex& GetMutex() { return maMutex; }
116 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > getParentPeer() const;
117 virtual void updateFromModel();
118 void peerCreated();
119 bool ImplCheckLocalize( OUString& _rPossiblyLocalizable );
120 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > ImplGetCompatiblePeer( sal_Bool bAcceptExistingPeer );
121 virtual void ImplSetPeerProperty( const OUString& rPropName, const ::com::sun::star::uno::Any& rVal );
122 virtual void PrepareWindowDescriptor( ::com::sun::star::awt::WindowDescriptor& rDesc );
123 virtual void ImplModelPropertiesChanged( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& rEvents );
125 void ImplLockPropertyChangeNotification( const OUString& rPropertyName, bool bLock );
126 void ImplLockPropertyChangeNotifications( const ::com::sun::star::uno::Sequence< OUString >& rPropertyNames, bool bLock );
128 void disposeAccessibleContext();
130 inline void setPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& _xPeer)
132 mxPeer = _xPeer;
133 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
136 virtual sal_Bool requiresNewPeer( const OUString& _rPropertyName ) const;
138 public:
139 UnoControl();
140 ~UnoControl();
142 UnoControlComponentInfos& GetComponentInfos() { return maComponentInfos; }
145 virtual OUString GetComponentServiceName();
147 // ::com::sun::star::lang::XTypeProvider
148 ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
150 // ::com::sun::star::lang::XComponent
151 void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException);
152 void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
153 void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);
155 // XEventListener
156 void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
158 // ::com::sun::star::awt::XWindow2
159 virtual void SAL_CALL setOutputSize( const ::com::sun::star::awt::Size& aSize ) throw (::com::sun::star::uno::RuntimeException);
160 virtual ::com::sun::star::awt::Size SAL_CALL getOutputSize( ) throw (::com::sun::star::uno::RuntimeException);
161 virtual ::sal_Bool SAL_CALL isVisible( ) throw (::com::sun::star::uno::RuntimeException);
162 virtual ::sal_Bool SAL_CALL isActive( ) throw (::com::sun::star::uno::RuntimeException);
163 virtual ::sal_Bool SAL_CALL isEnabled( ) throw (::com::sun::star::uno::RuntimeException);
164 virtual ::sal_Bool SAL_CALL hasFocus( ) throw (::com::sun::star::uno::RuntimeException);
166 // ::com::sun::star::awt::XWindow
167 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);
168 ::com::sun::star::awt::Rectangle SAL_CALL getPosSize( ) throw(::com::sun::star::uno::RuntimeException);
169 void SAL_CALL setVisible( sal_Bool Visible ) throw(::com::sun::star::uno::RuntimeException);
170 void SAL_CALL setEnable( sal_Bool Enable ) throw(::com::sun::star::uno::RuntimeException);
171 void SAL_CALL setFocus( ) throw(::com::sun::star::uno::RuntimeException);
172 void SAL_CALL addWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
173 void SAL_CALL removeWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
174 void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
175 void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
176 void SAL_CALL addKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
177 void SAL_CALL removeKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
178 void SAL_CALL addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
179 void SAL_CALL removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
180 void SAL_CALL addMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
181 void SAL_CALL removeMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
182 void SAL_CALL addPaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
183 void SAL_CALL removePaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
185 // ::com::sun::star::awt::XView
186 sal_Bool SAL_CALL setGraphics( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& aDevice ) throw(::com::sun::star::uno::RuntimeException);
187 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > SAL_CALL getGraphics( ) throw(::com::sun::star::uno::RuntimeException);
188 ::com::sun::star::awt::Size SAL_CALL getSize( ) throw(::com::sun::star::uno::RuntimeException);
189 void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException);
190 void SAL_CALL setZoom( float fZoomX, float fZoomY ) throw(::com::sun::star::uno::RuntimeException);
192 // ::com::sun::star::awt::XControl
193 void SAL_CALL setContext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Context ) throw(::com::sun::star::uno::RuntimeException);
194 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getContext( ) throw(::com::sun::star::uno::RuntimeException);
195 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);
196 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > SAL_CALL getPeer( ) throw(::com::sun::star::uno::RuntimeException);
197 sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& Model ) throw(::com::sun::star::uno::RuntimeException);
198 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > SAL_CALL getModel( ) throw(::com::sun::star::uno::RuntimeException);
199 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XView > SAL_CALL getView( ) throw(::com::sun::star::uno::RuntimeException);
200 void SAL_CALL setDesignMode( sal_Bool bOn ) throw(::com::sun::star::uno::RuntimeException);
201 sal_Bool SAL_CALL isDesignMode( ) throw(::com::sun::star::uno::RuntimeException);
202 sal_Bool SAL_CALL isTransparent( ) throw(::com::sun::star::uno::RuntimeException);
204 // ::com::sun::star::lang::XServiceInfo
205 OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
206 sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
207 ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
209 // XAccessible
210 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException);
212 // XModeChangeBroadcaster
213 virtual void SAL_CALL addModeChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
214 virtual void SAL_CALL removeModeChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
215 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);
216 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);
218 // XUnitConversion
219 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);
220 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);
221 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);
222 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);
224 // XStyleSettingsSupplier
225 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XStyleSettings > SAL_CALL getStyleSettings() throw (::com::sun::star::uno::RuntimeException);
227 private:
228 // ::com::sun::star::beans::XPropertiesChangeListener
229 void SAL_CALL propertiesChange( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& evt ) throw(::com::sun::star::uno::RuntimeException);
235 #endif // _TOOLKIT_CONTROLS_UNOCONTROL_HXX_
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */