1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_TOOLKIT_CONTROLS_UNOCONTROL_HXX
21 #define INCLUDED_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 <com/sun/star/util/XModeChangeBroadcaster.hpp>
43 #include <com/sun/star/awt/XVclWindowPeer.hpp>
46 struct UnoControlComponentInfos
50 long nX
, nY
, nWidth
, nHeight
;
54 UnoControlComponentInfos()
58 nX
= nY
= nWidth
= nHeight
= 0;
59 nFlags
= 0; // POSSIZE_POSSIZE;
60 nZoomX
= nZoomY
= 1.0f
;
64 struct UnoControl_Data
;
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
79 class TOOLKIT_DLLPUBLIC UnoControl
: public UnoControl_Base
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
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
;
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
;
101 ::com::sun::star::uno::WeakReferenceHelper
102 maAccessibleContext
; /// our most recent XAccessibleContext instance
105 bool mbRefeshingPeer
;
107 bool mbCreatingCompatiblePeer
;
110 UnoControlComponentInfos maComponentInfos
;
111 UnoControl_Data
* mpData
;
113 ::osl::Mutex
& GetMutex() { return maMutex
; }
115 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> getParentPeer() const;
116 virtual void updateFromModel();
118 bool ImplCheckLocalize( OUString
& _rPossiblyLocalizable
);
119 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
> ImplGetCompatiblePeer( 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
);
124 void ImplLockPropertyChangeNotification( const OUString
& rPropertyName
, bool bLock
);
125 void ImplLockPropertyChangeNotifications( const ::com::sun::star::uno::Sequence
< OUString
>& rPropertyNames
, bool bLock
);
127 void DisposeAccessibleContext(::com::sun::star::uno::Reference
<
128 ::com::sun::star::lang::XComponent
> const& xContext
);
130 inline void setPeer( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
>& _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 bool requiresNewPeer( const OUString
& _rPropertyName
) const;
140 virtual ~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
, std::exception
) SAL_OVERRIDE
;
150 // ::com::sun::star::lang::XComponent
151 void SAL_CALL
dispose( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
152 void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
153 void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
156 void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
160 virtual ::com::sun::star::awt::Size SAL_CALL
getOutputSize( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
161 virtual sal_Bool SAL_CALL
isVisible( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
162 virtual sal_Bool SAL_CALL
isActive( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
163 virtual sal_Bool SAL_CALL
isEnabled( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
164 virtual sal_Bool SAL_CALL
hasFocus( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
168 ::com::sun::star::awt::Rectangle SAL_CALL
getPosSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
169 void SAL_CALL
setVisible( sal_Bool Visible
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
170 void SAL_CALL
setEnable( sal_Bool Enable
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
171 void SAL_CALL
setFocus( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
172 void SAL_CALL
addWindowListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
173 void SAL_CALL
removeWindowListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
174 void SAL_CALL
addFocusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFocusListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
175 void SAL_CALL
removeFocusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFocusListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
176 void SAL_CALL
addKeyListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XKeyListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
177 void SAL_CALL
removeKeyListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XKeyListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
178 void SAL_CALL
addMouseListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XMouseListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
179 void SAL_CALL
removeMouseListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XMouseListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
180 void SAL_CALL
addMouseMotionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XMouseMotionListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
181 void SAL_CALL
removeMouseMotionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XMouseMotionListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
182 void SAL_CALL
addPaintListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XPaintListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
183 void SAL_CALL
removePaintListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XPaintListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
187 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XGraphics
> SAL_CALL
getGraphics( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
188 ::com::sun::star::awt::Size SAL_CALL
getSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
189 void SAL_CALL
draw( sal_Int32 nX
, sal_Int32 nY
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
190 void SAL_CALL
setZoom( float fZoomX
, float fZoomY
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
194 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
getContext( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
196 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
> SAL_CALL
getPeer( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
197 sal_Bool SAL_CALL
setModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
>& Model
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
198 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
> SAL_CALL
getModel( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
199 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XView
> SAL_CALL
getView( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
200 void SAL_CALL
setDesignMode( sal_Bool bOn
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
201 sal_Bool SAL_CALL
isDesignMode( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
202 sal_Bool SAL_CALL
isTransparent( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
204 // ::com::sun::star::lang::XServiceInfo
205 OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
206 sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
207 ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
210 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
214 virtual void SAL_CALL
removeModeChangeListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XModeChangeListener
>& _rxListener
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
224 // XStyleSettingsSupplier
225 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XStyleSettings
> SAL_CALL
getStyleSettings() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
235 #endif // INCLUDED_TOOLKIT_CONTROLS_UNOCONTROL_HXX
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */