LibreOffice Module UnoControls (master)  1
basecontrol.hxx
Go to the documentation of this file.
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 <com/sun/star/awt/XPaintListener.hpp>
23 #include <com/sun/star/awt/XWindowListener.hpp>
24 #include <com/sun/star/awt/XControl.hpp>
25 #include <com/sun/star/awt/XWindow.hpp>
26 #include <com/sun/star/awt/XView.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <cppuhelper/component.hxx>
29 #include <cppuhelper/basemutex.hxx>
30 #include <rtl/ref.hxx>
31 
32 namespace com::sun::star::uno { class XComponentContext; }
33 namespace com::sun::star::awt { class XFocusListener; }
34 namespace com::sun::star::awt { class XMouseListener; }
35 namespace com::sun::star::awt { class XMouseMotionListener; }
36 namespace com::sun::star::awt { struct PaintEvent; }
37 namespace com::sun::star::awt { struct WindowEvent; }
38 namespace unocontrols { class OMRCListenerMultiplexerHelper; }
39 
40 namespace unocontrols {
41 
42 class BaseControl : public css::lang::XServiceInfo
43  , public css::awt::XPaintListener
44  , public css::awt::XWindowListener
45  , public css::awt::XView
46  , public css::awt::XWindow
47  , public css::awt::XControl
48  , public cppu::BaseMutex
50 {
51 public:
52  BaseControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
53 
54  virtual ~BaseControl() override;
55 
56  // XInterface
57 
71  virtual css::uno::Any SAL_CALL queryInterface(
72  const css::uno::Type& aType
73  ) override;
74 
82  virtual void SAL_CALL acquire() noexcept override;
83 
91  virtual void SAL_CALL release() noexcept override;
92 
93  // XTypeProvider
94 
103  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
104 
116  virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
117 
118  // XAggregation
119 
120  virtual void SAL_CALL setDelegator(
121  const css::uno::Reference< css::uno::XInterface >& xDelegator
122  ) override;
123 
124  virtual css::uno::Any SAL_CALL queryAggregation(
125  const css::uno::Type& aType
126  ) override;
127 
128  // XServiceInfo
129 
130  virtual sal_Bool SAL_CALL supportsService(
131  const OUString& sServiceName
132  ) override;
133 
134  virtual OUString SAL_CALL getImplementationName() override;
135 
136  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
137 
138  // XComponent
139 
140  virtual void SAL_CALL dispose() override;
141 
142  virtual void SAL_CALL addEventListener(
143  const css::uno::Reference< css::lang::XEventListener >& xListener
144  ) override;
145 
146  virtual void SAL_CALL removeEventListener(
147  const css::uno::Reference< css::lang::XEventListener >& xListener
148  ) override;
149 
150  // XControl
151 
152  virtual void SAL_CALL createPeer(
153  const css::uno::Reference< css::awt::XToolkit >& xToolkit,
154  const css::uno::Reference< css::awt::XWindowPeer >& xParent
155  ) override;
156 
157  virtual void SAL_CALL setContext(
158  const css::uno::Reference< css::uno::XInterface >& xContext
159  ) override;
160 
161  virtual sal_Bool SAL_CALL setModel(
162  const css::uno::Reference< css::awt::XControlModel >& xModel
163  ) override = 0;
164 
165  virtual void SAL_CALL setDesignMode( sal_Bool bOn ) override;
166 
167  virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getContext() override;
168 
169  virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override = 0;
170 
171  virtual css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getPeer() override;
172 
173  virtual css::uno::Reference< css::awt::XView > SAL_CALL getView() override;
174 
175  virtual sal_Bool SAL_CALL isDesignMode() override;
176 
177  virtual sal_Bool SAL_CALL isTransparent() override;
178 
179  // XWindow
180 
181  virtual void SAL_CALL setPosSize( sal_Int32 nX ,
182  sal_Int32 nY ,
183  sal_Int32 nWidth ,
184  sal_Int32 nHeight ,
185  sal_Int16 nFlags ) override;
186 
187  virtual void SAL_CALL setVisible( sal_Bool bVisible ) override;
188 
189  virtual void SAL_CALL setEnable( sal_Bool bEnable ) override;
190 
191  virtual void SAL_CALL setFocus() override;
192 
193  virtual css::awt::Rectangle SAL_CALL getPosSize() override;
194 
195  virtual void SAL_CALL addWindowListener(
196  const css::uno::Reference< css::awt::XWindowListener >& xListener
197  ) override;
198 
199  virtual void SAL_CALL addFocusListener(
200  const css::uno::Reference< css::awt::XFocusListener >& xListener
201  ) override;
202 
203  virtual void SAL_CALL addKeyListener(
204  const css::uno::Reference< css::awt::XKeyListener >& xListener ) override;
205 
206  virtual void SAL_CALL addMouseListener(
207  const css::uno::Reference< css::awt::XMouseListener >& xListener
208  ) override;
209 
210  virtual void SAL_CALL addMouseMotionListener(
211  const css::uno::Reference< css::awt::XMouseMotionListener >& xListener
212  ) override;
213 
214  virtual void SAL_CALL addPaintListener(
215  const css::uno::Reference< css::awt::XPaintListener >& xListener
216  ) override;
217 
218  virtual void SAL_CALL removeWindowListener(
219  const css::uno::Reference< css::awt::XWindowListener >& xListener
220  ) override;
221 
222  virtual void SAL_CALL removeFocusListener(
223  const css::uno::Reference< css::awt::XFocusListener >& xListener
224  ) override;
225 
226  virtual void SAL_CALL removeKeyListener(
227  const css::uno::Reference< css::awt::XKeyListener >& xListener
228  ) override;
229 
230  virtual void SAL_CALL removeMouseListener(
231  const css::uno::Reference< css::awt::XMouseListener >& xListener
232  ) override;
233 
234  virtual void SAL_CALL removeMouseMotionListener(
235  const css::uno::Reference< css::awt::XMouseMotionListener >& xListener
236  ) override;
237 
238  virtual void SAL_CALL removePaintListener(
239  const css::uno::Reference< css::awt::XPaintListener >& xListener
240  ) override;
241 
242  // XView
243 
244  virtual void SAL_CALL draw( sal_Int32 nX ,
245  sal_Int32 nY ) override;
246 
247  virtual sal_Bool SAL_CALL setGraphics(
248  const css::uno::Reference< css::awt::XGraphics >& xDevice
249  ) override;
250 
251  virtual void SAL_CALL setZoom( float fZoomX ,
252  float fZoomY ) override;
253 
254  virtual css::uno::Reference< css::awt::XGraphics > SAL_CALL getGraphics() override;
255 
256  virtual css::awt::Size SAL_CALL getSize() override;
257 
258  // css::lang::XEventListener
259 
260  virtual void SAL_CALL disposing(
261  const css::lang::EventObject& rSource
262  ) override;
263 
264  // XPaintListener
265 
266  virtual void SAL_CALL windowPaint(
267  const css::awt::PaintEvent& rEvent
268  ) override;
269 
270  // XWindowListener
271 
272  virtual void SAL_CALL windowResized( const css::awt::WindowEvent& aEvent ) override;
273  virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& aEvent ) override;
274  virtual void SAL_CALL windowShown( const css::lang::EventObject& aEvent ) override;
275  virtual void SAL_CALL windowHidden( const css::lang::EventObject& aEvent ) override;
276 
277 protected:
278  using OComponentHelper::disposing;
279 
280  const css::uno::Reference< css::uno::XComponentContext >& impl_getComponentContext() const { return m_xComponentContext;}
281 
282  const css::uno::Reference< css::awt::XWindow >& impl_getPeerWindow() const { return m_xPeerWindow;}
283 
284  const css::uno::Reference< css::awt::XGraphics >& impl_getGraphicsPeer() const { return m_xGraphicsPeer;}
285 
286  sal_Int32 impl_getWidth() const { return m_nWidth;}
287 
288  sal_Int32 impl_getHeight() const { return m_nHeight;}
289 
290  virtual css::awt::WindowDescriptor impl_getWindowDescriptor(
291  const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer
292  );
293 
294  virtual void impl_paint( sal_Int32 nX ,
295  sal_Int32 nY ,
296  const css::uno::Reference< css::awt::XGraphics >& xGraphics );
297 
298  virtual void impl_recalcLayout( const css::awt::WindowEvent& aEvent );
299 
300  const css::uno::Reference< css::uno::XInterface >& impl_getDelegator() const { return m_xDelegator;}
301 
302 private:
304 
305  css::uno::Reference< css::uno::XComponentContext > m_xComponentContext;
306  css::uno::Reference< css::uno::XInterface > m_xDelegator;
308  css::uno::Reference< css::uno::XInterface > m_xContext;
309  css::uno::Reference< css::awt::XWindowPeer > m_xPeer;
310  css::uno::Reference< css::awt::XWindow > m_xPeerWindow;
311  css::uno::Reference< css::awt::XGraphics > m_xGraphicsView; // graphics for css::awt::XView-operations
312  css::uno::Reference< css::awt::XGraphics > m_xGraphicsPeer; // graphics for painting on a peer
313  sal_Int32 m_nX; // Position ...
314  sal_Int32 m_nY;
315  sal_Int32 m_nWidth; // ... and size of window
316  sal_Int32 m_nHeight;
317  bool m_bVisible; // Some state flags
319  bool m_bEnable;
320 };
321 
322 }
323 
324 
325 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OMRCListenerMultiplexerHelper * impl_getMultiplexer()
css::uno::Reference< css::uno::XComponentContext > m_xComponentContext
virtual void SAL_CALL acquire() noexcept override
increment refcount XInterface release() A RuntimeException is thrown.
Definition: basecontrol.cxx:90
bool bVisible
rtl::Reference< OMRCListenerMultiplexerHelper > m_xMultiplexer
const css::uno::Reference< css::uno::XComponentContext > & impl_getComponentContext() const
virtual void SAL_CALL windowPaint(const css::awt::PaintEvent &rEvent) override
virtual void SAL_CALL setContext(const css::uno::Reference< css::uno::XInterface > &xContext) override
virtual void impl_paint(sal_Int32 nX, sal_Int32 nY, const css::uno::Reference< css::awt::XGraphics > &xGraphics)
virtual void SAL_CALL setEnable(sal_Bool bEnable) override
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
virtual void SAL_CALL setVisible(sal_Bool bVisible) override
virtual void SAL_CALL windowMoved(const css::awt::WindowEvent &aEvent) override
virtual void SAL_CALL removePaintListener(const css::uno::Reference< css::awt::XPaintListener > &xListener) override
virtual void SAL_CALL setZoom(float fZoomX, float fZoomY) override
const css::uno::Reference< css::awt::XGraphics > & impl_getGraphicsPeer() const
virtual void SAL_CALL windowResized(const css::awt::WindowEvent &aEvent) override
css::uno::Reference< css::awt::XGraphics > m_xGraphicsView
virtual void SAL_CALL createPeer(const css::uno::Reference< css::awt::XToolkit > &xToolkit, const css::uno::Reference< css::awt::XWindowPeer > &xParent) override
virtual void SAL_CALL dispose() override
sal_Int32 impl_getHeight() const
constexpr OUStringLiteral sServiceName
virtual OUString SAL_CALL getImplementationName() override
css::uno::Reference< css::awt::XWindowPeer > m_xPeer
virtual void SAL_CALL addWindowListener(const css::uno::Reference< css::awt::XWindowListener > &xListener) override
virtual css::uno::Reference< css::awt::XView > SAL_CALL getView() override
css::uno::Reference< css::awt::XGraphics > m_xGraphicsPeer
css::uno::Reference< css::awt::XWindow > m_xPeerWindow
virtual void SAL_CALL disposing()
virtual void SAL_CALL addMouseMotionListener(const css::uno::Reference< css::awt::XMouseMotionListener > &xListener) override
virtual void SAL_CALL removeMouseListener(const css::uno::Reference< css::awt::XMouseListener > &xListener) override
virtual sal_Bool SAL_CALL setModel(const css::uno::Reference< css::awt::XControlModel > &xModel) override=0
virtual void SAL_CALL setDesignMode(sal_Bool bOn) override
virtual css::awt::Size SAL_CALL getSize() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL removeKeyListener(const css::uno::Reference< css::awt::XKeyListener > &xListener) override
sal_Int32 impl_getWidth() const
virtual void SAL_CALL release() noexcept override
decrement refcount XInterface acquire() A RuntimeException is thrown.
css::uno::Reference< css::uno::XInterface > m_xDelegator
unsigned char sal_Bool
virtual void SAL_CALL setFocus() override
virtual void SAL_CALL setPosSize(sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nFlags) override
virtual void impl_recalcLayout(const css::awt::WindowEvent &aEvent)
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &aType) override
virtual void SAL_CALL removeMouseMotionListener(const css::uno::Reference< css::awt::XMouseMotionListener > &xListener) override
virtual css::awt::WindowDescriptor impl_getWindowDescriptor(const css::uno::Reference< css::awt::XWindowPeer > &xParentPeer)
BaseControl(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Definition: basecontrol.cxx:51
virtual css::awt::Rectangle SAL_CALL getPosSize() override
virtual ~BaseControl() override
Definition: basecontrol.cxx:64
virtual css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getPeer() override
virtual void SAL_CALL windowShown(const css::lang::EventObject &aEvent) override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getContext() override
virtual sal_Bool SAL_CALL isDesignMode() override
virtual css::uno::Reference< css::awt::XGraphics > SAL_CALL getGraphics() override
virtual void SAL_CALL addFocusListener(const css::uno::Reference< css::awt::XFocusListener > &xListener) override
virtual void SAL_CALL removeFocusListener(const css::uno::Reference< css::awt::XFocusListener > &xListener) override
const css::uno::Reference< css::uno::XInterface > & impl_getDelegator() const
virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override=0
virtual sal_Bool SAL_CALL setGraphics(const css::uno::Reference< css::awt::XGraphics > &xDevice) override
virtual void SAL_CALL addMouseListener(const css::uno::Reference< css::awt::XMouseListener > &xListener) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
get information about supported interfaces XTypeProvider
virtual void SAL_CALL addKeyListener(const css::uno::Reference< css::awt::XKeyListener > &xListener) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
give answer, if interface is supported The interfaces are searched by type.
Definition: basecontrol.cxx:70
virtual void SAL_CALL draw(sal_Int32 nX, sal_Int32 nY) override
virtual void SAL_CALL addPaintListener(const css::uno::Reference< css::awt::XPaintListener > &xListener) override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Reference< XModel > xModel
virtual sal_Bool SAL_CALL isTransparent() override
css::uno::WeakReferenceHelper xDelegator
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
get implementation id This ID is necessary for UNO-caching.
virtual void SAL_CALL setDelegator(const css::uno::Reference< css::uno::XInterface > &xDelegator) override
AnyEventRef aEvent
virtual void SAL_CALL windowHidden(const css::lang::EventObject &aEvent) override
const css::uno::Reference< css::awt::XWindow > & impl_getPeerWindow() const
css::uno::Reference< css::uno::XInterface > m_xContext
virtual void SAL_CALL removeWindowListener(const css::uno::Reference< css::awt::XWindowListener > &xListener) override