/src/libreoffice/include/toolkit/controls/unocontrol.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include <toolkit/dllapi.h> |
23 | | #include <com/sun/star/awt/XControl.hpp> |
24 | | #include <com/sun/star/awt/XWindow2.hpp> |
25 | | #include <com/sun/star/awt/XView.hpp> |
26 | | #include <com/sun/star/beans/XPropertiesChangeListener.hpp> |
27 | | #include <com/sun/star/lang/XServiceInfo.hpp> |
28 | | #include <com/sun/star/awt/XUnitConversion.hpp> |
29 | | #include <com/sun/star/awt/XStyleSettingsSupplier.hpp> |
30 | | #include <com/sun/star/accessibility/XAccessible.hpp> |
31 | | #include <osl/mutex.hxx> |
32 | | #include <toolkit/helper/listenermultiplexer.hxx> |
33 | | #include <tools/long.hxx> |
34 | | #include <comphelper/interfacecontainer3.hxx> |
35 | | #include <cppuhelper/weakref.hxx> |
36 | | #include <cppuhelper/implbase9.hxx> |
37 | | #include <com/sun/star/util/XModeChangeBroadcaster.hpp> |
38 | | #include <memory> |
39 | | |
40 | | namespace com::sun::star::awt { class XVclWindowPeer; } |
41 | | |
42 | | struct UnoControlComponentInfos |
43 | | { |
44 | | tools::Long nX, nY, nWidth, nHeight; |
45 | | float nZoomX, nZoomY; |
46 | | sal_uInt16 nFlags; |
47 | | bool bVisible; |
48 | | bool bEnable; |
49 | | |
50 | | UnoControlComponentInfos() |
51 | 62 | { |
52 | 62 | bVisible = true; |
53 | 62 | bEnable = true; |
54 | 62 | nX = nY = nWidth = nHeight = 0; |
55 | 62 | nFlags = 0; // POSSIZE_POSSIZE; |
56 | 62 | nZoomX = nZoomY = 1.0f; |
57 | 62 | } |
58 | | }; |
59 | | |
60 | | struct UnoControl_Data; |
61 | | |
62 | | |
63 | | typedef ::cppu::WeakAggImplHelper9 < css::awt::XControl |
64 | | , css::awt::XWindow2 |
65 | | , css::awt::XView |
66 | | , css::beans::XPropertiesChangeListener |
67 | | , css::lang::XServiceInfo |
68 | | , css::accessibility::XAccessible |
69 | | , css::util::XModeChangeBroadcaster |
70 | | , css::awt::XUnitConversion |
71 | | , css::awt::XStyleSettingsSupplier |
72 | | > UnoControl_Base; |
73 | | |
74 | | class TOOLKIT_DLLPUBLIC UnoControl : public UnoControl_Base |
75 | | { |
76 | | private: |
77 | | ::osl::Mutex maMutex; |
78 | | |
79 | | css::uno::Reference< css::awt::XVclWindowPeer > mxVclWindowPeer; |
80 | | |
81 | | protected: |
82 | | EventListenerMultiplexer maDisposeListeners; |
83 | | WindowListenerMultiplexer maWindowListeners; |
84 | | FocusListenerMultiplexer maFocusListeners; |
85 | | KeyListenerMultiplexer maKeyListeners; |
86 | | MouseListenerMultiplexer maMouseListeners; |
87 | | MouseMotionListenerMultiplexer maMouseMotionListeners; |
88 | | PaintListenerMultiplexer maPaintListeners; |
89 | | ::comphelper::OInterfaceContainerHelper3<css::util::XModeChangeListener> maModeChangeListeners; |
90 | | |
91 | | css::uno::Reference< css::uno::XInterface > mxContext; |
92 | | css::uno::Reference< css::awt::XControlModel > mxModel; |
93 | | css::uno::Reference< css::awt::XGraphics > mxGraphics; |
94 | | |
95 | | css::uno::WeakReferenceHelper |
96 | | maAccessibleContext; /// our most recent XAccessibleContext instance |
97 | | |
98 | | bool mbDisposePeer; |
99 | | bool mbRefreshingPeer; |
100 | | bool mbCreatingPeer; |
101 | | bool mbCreatingCompatiblePeer; |
102 | | bool mbDesignMode; |
103 | | |
104 | | UnoControlComponentInfos maComponentInfos; |
105 | | std::unique_ptr<UnoControl_Data> mpData; |
106 | | |
107 | 710 | ::osl::Mutex& GetMutex() { return maMutex; } |
108 | | |
109 | | css::uno::Reference< css::awt::XWindow > getParentPeer() const; |
110 | | virtual void updateFromModel(); |
111 | | void peerCreated(); |
112 | | bool ImplCheckLocalize( OUString& _rPossiblyLocalizable ); |
113 | | css::uno::Reference< css::awt::XVclWindowPeer > ImplGetCompatiblePeer(); |
114 | | virtual void ImplSetPeerProperty( const OUString& rPropName, const css::uno::Any& rVal ); |
115 | | virtual void PrepareWindowDescriptor( css::awt::WindowDescriptor& rDesc ); |
116 | | virtual void ImplModelPropertiesChanged( const css::uno::Sequence< css::beans::PropertyChangeEvent >& rEvents ); |
117 | | |
118 | | void ImplLockPropertyChangeNotification( const OUString& rPropertyName, bool bLock ); |
119 | | void ImplLockPropertyChangeNotifications( const css::uno::Sequence< OUString >& rPropertyNames, bool bLock ); |
120 | | |
121 | | void DisposeAccessibleContext(css::uno::Reference< |
122 | | css::lang::XComponent> const& xContext); |
123 | | |
124 | | void setPeer( const css::uno::Reference< css::awt::XVclWindowPeer >& _xPeer) |
125 | 90 | { |
126 | 90 | mxVclWindowPeer = _xPeer; |
127 | 90 | } |
128 | | |
129 | | virtual bool requiresNewPeer( const OUString& _rPropertyName ) const; |
130 | | |
131 | | public: |
132 | | UnoControl(); |
133 | | virtual ~UnoControl() override; |
134 | | |
135 | 0 | UnoControlComponentInfos& GetComponentInfos() { return maComponentInfos; } |
136 | | |
137 | | |
138 | | virtual OUString GetComponentServiceName() const; |
139 | | |
140 | | // css::lang::XTypeProvider |
141 | | css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; |
142 | | |
143 | | // css::lang::XComponent |
144 | | void SAL_CALL dispose( ) override; |
145 | | void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; |
146 | | void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; |
147 | | |
148 | | // XEventListener |
149 | | void SAL_CALL disposing( const css::lang::EventObject& Source ) override; |
150 | | |
151 | | // css::awt::XWindow2 |
152 | | virtual void SAL_CALL setOutputSize( const css::awt::Size& aSize ) override; |
153 | | virtual css::awt::Size SAL_CALL getOutputSize( ) override; |
154 | | virtual sal_Bool SAL_CALL isVisible( ) override; |
155 | | virtual sal_Bool SAL_CALL isActive( ) override; |
156 | | virtual sal_Bool SAL_CALL isEnabled( ) override; |
157 | | virtual sal_Bool SAL_CALL hasFocus( ) override; |
158 | | |
159 | | // css::awt::XWindow |
160 | | void SAL_CALL setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) override; |
161 | | css::awt::Rectangle SAL_CALL getPosSize( ) override; |
162 | | void SAL_CALL setVisible( sal_Bool Visible ) override; |
163 | | void SAL_CALL setEnable( sal_Bool Enable ) override; |
164 | | void SAL_CALL setFocus( ) override; |
165 | | void SAL_CALL addWindowListener( const css::uno::Reference< css::awt::XWindowListener >& xListener ) override; |
166 | | void SAL_CALL removeWindowListener( const css::uno::Reference< css::awt::XWindowListener >& xListener ) override; |
167 | | void SAL_CALL addFocusListener( const css::uno::Reference< css::awt::XFocusListener >& xListener ) override; |
168 | | void SAL_CALL removeFocusListener( const css::uno::Reference< css::awt::XFocusListener >& xListener ) override; |
169 | | void SAL_CALL addKeyListener( const css::uno::Reference< css::awt::XKeyListener >& xListener ) override; |
170 | | void SAL_CALL removeKeyListener( const css::uno::Reference< css::awt::XKeyListener >& xListener ) override; |
171 | | void SAL_CALL addMouseListener( const css::uno::Reference< css::awt::XMouseListener >& xListener ) override; |
172 | | void SAL_CALL removeMouseListener( const css::uno::Reference< css::awt::XMouseListener >& xListener ) override; |
173 | | void SAL_CALL addMouseMotionListener( const css::uno::Reference< css::awt::XMouseMotionListener >& xListener ) override; |
174 | | void SAL_CALL removeMouseMotionListener( const css::uno::Reference< css::awt::XMouseMotionListener >& xListener ) override; |
175 | | void SAL_CALL addPaintListener( const css::uno::Reference< css::awt::XPaintListener >& xListener ) override; |
176 | | void SAL_CALL removePaintListener( const css::uno::Reference< css::awt::XPaintListener >& xListener ) override; |
177 | | |
178 | | // css::awt::XView |
179 | | sal_Bool SAL_CALL setGraphics( const css::uno::Reference< css::awt::XGraphics >& aDevice ) override; |
180 | | css::uno::Reference< css::awt::XGraphics > SAL_CALL getGraphics( ) override; |
181 | | css::awt::Size SAL_CALL getSize( ) override; |
182 | | void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) override; |
183 | | void SAL_CALL setZoom( float fZoomX, float fZoomY ) override; |
184 | | |
185 | | // css::awt::XControl |
186 | | void SAL_CALL setContext( const css::uno::Reference< css::uno::XInterface >& Context ) override; |
187 | | css::uno::Reference< css::uno::XInterface > SAL_CALL getContext( ) override; |
188 | | void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; |
189 | | css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getPeer( ) override; |
190 | | sal_Bool SAL_CALL setModel( const css::uno::Reference< css::awt::XControlModel >& Model ) override; |
191 | | css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel( ) override; |
192 | | css::uno::Reference< css::awt::XView > SAL_CALL getView( ) override; |
193 | | void SAL_CALL setDesignMode( sal_Bool bOn ) override; |
194 | | sal_Bool SAL_CALL isDesignMode( ) override; |
195 | | sal_Bool SAL_CALL isTransparent( ) override; |
196 | | |
197 | | // css::lang::XServiceInfo |
198 | | OUString SAL_CALL getImplementationName( ) override; |
199 | | sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; |
200 | | css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; |
201 | | |
202 | | // XAccessible |
203 | | virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; |
204 | | |
205 | | // XModeChangeBroadcaster |
206 | | virtual void SAL_CALL addModeChangeListener( const css::uno::Reference< css::util::XModeChangeListener >& _rxListener ) override; |
207 | | virtual void SAL_CALL removeModeChangeListener( const css::uno::Reference< css::util::XModeChangeListener >& _rxListener ) override; |
208 | | virtual void SAL_CALL addModeChangeApproveListener( const css::uno::Reference< css::util::XModeChangeApproveListener >& _rxListener ) override; |
209 | | virtual void SAL_CALL removeModeChangeApproveListener( const css::uno::Reference< css::util::XModeChangeApproveListener >& _rxListener ) override; |
210 | | |
211 | | // XUnitConversion |
212 | | virtual css::awt::Point SAL_CALL convertPointToLogic( const css::awt::Point& Point, ::sal_Int16 TargetUnit ) override; |
213 | | virtual css::awt::Point SAL_CALL convertPointToPixel( const css::awt::Point& aPoint, ::sal_Int16 SourceUnit ) override; |
214 | | virtual css::awt::Size SAL_CALL convertSizeToLogic( const css::awt::Size& aSize, ::sal_Int16 TargetUnit ) override; |
215 | | virtual css::awt::Size SAL_CALL convertSizeToPixel( const css::awt::Size& aSize, ::sal_Int16 SourceUnit ) override; |
216 | | |
217 | | // XStyleSettingsSupplier |
218 | | virtual css::uno::Reference< css::awt::XStyleSettings > SAL_CALL getStyleSettings() override; |
219 | | |
220 | | css::uno::Reference< css::awt::XVclWindowPeer > getVclWindowPeer(); |
221 | | |
222 | | protected: |
223 | | // css::beans::XPropertiesChangeListener |
224 | | void SAL_CALL propertiesChange( const css::uno::Sequence< css::beans::PropertyChangeEvent >& evt ) override; |
225 | | }; |
226 | | |
227 | | |
228 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |