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/awt/XUnitConversion.hpp>
30 #include <com/sun/star/awt/XStyleSettingsSupplier.hpp>
31 #include <com/sun/star/accessibility/XAccessible.hpp>
32 #include <osl/mutex.hxx>
33 #include <toolkit/helper/listenermultiplexer.hxx>
34 #include <tools/long.hxx>
35 #include <comphelper/interfacecontainer3.hxx>
36 #include <cppuhelper/weakref.hxx>
37 #include <cppuhelper/implbase9.hxx>
38 #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
39 #include <com/sun/star/awt/XVclWindowPeer.hpp>
43 struct UnoControlComponentInfos
45 tools::Long nX
, nY
, nWidth
, nHeight
;
51 UnoControlComponentInfos()
55 nX
= nY
= nWidth
= nHeight
= 0;
56 nFlags
= 0; // POSSIZE_POSSIZE;
57 nZoomX
= nZoomY
= 1.0f
;
61 struct UnoControl_Data
;
64 typedef ::cppu::WeakAggImplHelper9
< css::awt::XControl
67 , css::beans::XPropertiesChangeListener
68 , css::lang::XServiceInfo
69 , css::accessibility::XAccessible
70 , css::util::XModeChangeBroadcaster
71 , css::awt::XUnitConversion
72 , css::awt::XStyleSettingsSupplier
75 class TOOLKIT_DLLPUBLIC UnoControl
: public UnoControl_Base
80 css::uno::Reference
< css::awt::XVclWindowPeer
> mxVclWindowPeer
;
83 EventListenerMultiplexer maDisposeListeners
;
84 WindowListenerMultiplexer maWindowListeners
;
85 FocusListenerMultiplexer maFocusListeners
;
86 KeyListenerMultiplexer maKeyListeners
;
87 MouseListenerMultiplexer maMouseListeners
;
88 MouseMotionListenerMultiplexer maMouseMotionListeners
;
89 PaintListenerMultiplexer maPaintListeners
;
90 ::comphelper::OInterfaceContainerHelper3
<css::util::XModeChangeListener
> maModeChangeListeners
;
92 css::uno::Reference
< css::uno::XInterface
> mxContext
;
93 css::uno::Reference
< css::awt::XControlModel
> mxModel
;
94 css::uno::Reference
< css::awt::XGraphics
> mxGraphics
;
96 css::uno::WeakReferenceHelper
97 maAccessibleContext
; /// our most recent XAccessibleContext instance
100 bool mbRefreshingPeer
;
102 bool mbCreatingCompatiblePeer
;
105 UnoControlComponentInfos maComponentInfos
;
106 std::unique_ptr
<UnoControl_Data
> mpData
;
108 ::osl::Mutex
& GetMutex() { return maMutex
; }
110 css::uno::Reference
< css::awt::XWindow
> getParentPeer() const;
111 virtual void updateFromModel();
113 bool ImplCheckLocalize( OUString
& _rPossiblyLocalizable
);
114 css::uno::Reference
< css::awt::XVclWindowPeer
> ImplGetCompatiblePeer();
115 virtual void ImplSetPeerProperty( const OUString
& rPropName
, const css::uno::Any
& rVal
);
116 virtual void PrepareWindowDescriptor( css::awt::WindowDescriptor
& rDesc
);
117 virtual void ImplModelPropertiesChanged( const css::uno::Sequence
< css::beans::PropertyChangeEvent
>& rEvents
);
119 void ImplLockPropertyChangeNotification( const OUString
& rPropertyName
, bool bLock
);
120 void ImplLockPropertyChangeNotifications( const css::uno::Sequence
< OUString
>& rPropertyNames
, bool bLock
);
122 void DisposeAccessibleContext(css::uno::Reference
<
123 css::lang::XComponent
> const& xContext
);
125 void setPeer( const css::uno::Reference
< css::awt::XVclWindowPeer
>& _xPeer
)
127 mxVclWindowPeer
= _xPeer
;
130 virtual bool requiresNewPeer( const OUString
& _rPropertyName
) const;
134 virtual ~UnoControl() override
;
136 UnoControlComponentInfos
& GetComponentInfos() { return maComponentInfos
; }
139 virtual OUString
GetComponentServiceName() const;
141 // css::lang::XTypeProvider
142 css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
144 // css::lang::XComponent
145 void SAL_CALL
dispose( ) override
;
146 void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
147 void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
150 void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
152 // css::awt::XWindow2
153 virtual void SAL_CALL
setOutputSize( const css::awt::Size
& aSize
) override
;
154 virtual css::awt::Size SAL_CALL
getOutputSize( ) override
;
155 virtual sal_Bool SAL_CALL
isVisible( ) override
;
156 virtual sal_Bool SAL_CALL
isActive( ) override
;
157 virtual sal_Bool SAL_CALL
isEnabled( ) override
;
158 virtual sal_Bool SAL_CALL
hasFocus( ) override
;
161 void SAL_CALL
setPosSize( sal_Int32 X
, sal_Int32 Y
, sal_Int32 Width
, sal_Int32 Height
, sal_Int16 Flags
) override
;
162 css::awt::Rectangle SAL_CALL
getPosSize( ) override
;
163 void SAL_CALL
setVisible( sal_Bool Visible
) override
;
164 void SAL_CALL
setEnable( sal_Bool Enable
) override
;
165 void SAL_CALL
setFocus( ) override
;
166 void SAL_CALL
addWindowListener( const css::uno::Reference
< css::awt::XWindowListener
>& xListener
) override
;
167 void SAL_CALL
removeWindowListener( const css::uno::Reference
< css::awt::XWindowListener
>& xListener
) override
;
168 void SAL_CALL
addFocusListener( const css::uno::Reference
< css::awt::XFocusListener
>& xListener
) override
;
169 void SAL_CALL
removeFocusListener( const css::uno::Reference
< css::awt::XFocusListener
>& xListener
) override
;
170 void SAL_CALL
addKeyListener( const css::uno::Reference
< css::awt::XKeyListener
>& xListener
) override
;
171 void SAL_CALL
removeKeyListener( const css::uno::Reference
< css::awt::XKeyListener
>& xListener
) override
;
172 void SAL_CALL
addMouseListener( const css::uno::Reference
< css::awt::XMouseListener
>& xListener
) override
;
173 void SAL_CALL
removeMouseListener( const css::uno::Reference
< css::awt::XMouseListener
>& xListener
) override
;
174 void SAL_CALL
addMouseMotionListener( const css::uno::Reference
< css::awt::XMouseMotionListener
>& xListener
) override
;
175 void SAL_CALL
removeMouseMotionListener( const css::uno::Reference
< css::awt::XMouseMotionListener
>& xListener
) override
;
176 void SAL_CALL
addPaintListener( const css::uno::Reference
< css::awt::XPaintListener
>& xListener
) override
;
177 void SAL_CALL
removePaintListener( const css::uno::Reference
< css::awt::XPaintListener
>& xListener
) override
;
180 sal_Bool SAL_CALL
setGraphics( const css::uno::Reference
< css::awt::XGraphics
>& aDevice
) override
;
181 css::uno::Reference
< css::awt::XGraphics
> SAL_CALL
getGraphics( ) override
;
182 css::awt::Size SAL_CALL
getSize( ) override
;
183 void SAL_CALL
draw( sal_Int32 nX
, sal_Int32 nY
) override
;
184 void SAL_CALL
setZoom( float fZoomX
, float fZoomY
) override
;
186 // css::awt::XControl
187 void SAL_CALL
setContext( const css::uno::Reference
< css::uno::XInterface
>& Context
) override
;
188 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getContext( ) override
;
189 void SAL_CALL
createPeer( const css::uno::Reference
< css::awt::XToolkit
>& Toolkit
, const css::uno::Reference
< css::awt::XWindowPeer
>& Parent
) override
;
190 css::uno::Reference
< css::awt::XWindowPeer
> SAL_CALL
getPeer( ) override
;
191 sal_Bool SAL_CALL
setModel( const css::uno::Reference
< css::awt::XControlModel
>& Model
) override
;
192 css::uno::Reference
< css::awt::XControlModel
> SAL_CALL
getModel( ) override
;
193 css::uno::Reference
< css::awt::XView
> SAL_CALL
getView( ) override
;
194 void SAL_CALL
setDesignMode( sal_Bool bOn
) override
;
195 sal_Bool SAL_CALL
isDesignMode( ) override
;
196 sal_Bool SAL_CALL
isTransparent( ) override
;
198 // css::lang::XServiceInfo
199 OUString SAL_CALL
getImplementationName( ) override
;
200 sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
201 css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
204 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) override
;
206 // XModeChangeBroadcaster
207 virtual void SAL_CALL
addModeChangeListener( const css::uno::Reference
< css::util::XModeChangeListener
>& _rxListener
) override
;
208 virtual void SAL_CALL
removeModeChangeListener( const css::uno::Reference
< css::util::XModeChangeListener
>& _rxListener
) override
;
209 virtual void SAL_CALL
addModeChangeApproveListener( const css::uno::Reference
< css::util::XModeChangeApproveListener
>& _rxListener
) override
;
210 virtual void SAL_CALL
removeModeChangeApproveListener( const css::uno::Reference
< css::util::XModeChangeApproveListener
>& _rxListener
) override
;
213 virtual css::awt::Point SAL_CALL
convertPointToLogic( const css::awt::Point
& Point
, ::sal_Int16 TargetUnit
) override
;
214 virtual css::awt::Point SAL_CALL
convertPointToPixel( const css::awt::Point
& aPoint
, ::sal_Int16 SourceUnit
) override
;
215 virtual css::awt::Size SAL_CALL
convertSizeToLogic( const css::awt::Size
& aSize
, ::sal_Int16 TargetUnit
) override
;
216 virtual css::awt::Size SAL_CALL
convertSizeToPixel( const css::awt::Size
& aSize
, ::sal_Int16 SourceUnit
) override
;
218 // XStyleSettingsSupplier
219 virtual css::uno::Reference
< css::awt::XStyleSettings
> SAL_CALL
getStyleSettings() override
;
221 css::uno::Reference
< css::awt::XVclWindowPeer
> getVclWindowPeer();
224 // css::beans::XPropertiesChangeListener
225 void SAL_CALL
propertiesChange( const css::uno::Sequence
< css::beans::PropertyChangeEvent
>& evt
) override
;
229 #endif // INCLUDED_TOOLKIT_CONTROLS_UNOCONTROL_HXX
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */