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