1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <com/sun/star/awt/XPaintListener.hpp>
#include <com/sun/star/awt/XWindowListener.hpp>
#include <com/sun/star/awt/XControl.hpp>
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/awt/XView.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <osl/mutex.hxx>
#include <cppuhelper/component.hxx>
#include <rtl/ref.hxx>
namespace com::sun::star::uno { class XComponentContext; }
namespace com::sun::star::awt { class XFocusListener; }
namespace com::sun::star::awt { class XMouseListener; }
namespace com::sun::star::awt { class XMouseMotionListener; }
namespace com::sun::star::awt { struct PaintEvent; }
namespace com::sun::star::awt { struct WindowEvent; }
namespace unocontrols { class OMRCListenerMultiplexerHelper; }
namespace unocontrols {
struct IMPL_MutexContainer
{
// Is necessary to initialize "BaseControl" and make this class thread-safe.
::osl::Mutex m_aMutex;
};
class BaseControl : public css::lang::XServiceInfo
, public css::awt::XPaintListener
, public css::awt::XWindowListener
, public css::awt::XView
, public css::awt::XWindow
, public css::awt::XControl
, public IMPL_MutexContainer
, public ::cppu::OComponentHelper
{
public:
BaseControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
virtual ~BaseControl() override;
// XInterface
/**
@short give answer, if interface is supported
@descr The interfaces are searched by type.
@seealso XInterface
@param "rType" is the type of searched interface.
@return Any information about found interface
@onerror A RuntimeException is thrown.
*/
virtual css::uno::Any SAL_CALL queryInterface(
const css::uno::Type& aType
) override;
/**
@short increment refcount
@seealso XInterface
@seealso release()
@onerror A RuntimeException is thrown.
*/
virtual void SAL_CALL acquire() throw() override;
/**
@short decrement refcount
@seealso XInterface
@seealso acquire()
@onerror A RuntimeException is thrown.
*/
virtual void SAL_CALL release() throw() override;
// XTypeProvider
/**
@short get information about supported interfaces
@seealso XTypeProvider
@return Sequence of types of all supported interfaces
@onerror A RuntimeException is thrown.
*/
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
/**
@short get implementation id
@descr This ID is necessary for UNO-caching. If there no ID, cache is disabled.
Another way, cache is enabled.
@seealso XTypeProvider
@return ID as Sequence of byte
@onerror A RuntimeException is thrown.
*/
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
// XAggregation
virtual void SAL_CALL setDelegator(
const css::uno::Reference< css::uno::XInterface >& xDelegator
) override;
virtual css::uno::Any SAL_CALL queryAggregation(
const css::uno::Type& aType
) override;
// XServiceInfo
virtual sal_Bool SAL_CALL supportsService(
const OUString& sServiceName
) override;
virtual OUString SAL_CALL getImplementationName() override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
// XComponent
virtual void SAL_CALL dispose() override;
virtual void SAL_CALL addEventListener(
const css::uno::Reference< css::lang::XEventListener >& xListener
) override;
virtual void SAL_CALL removeEventListener(
const css::uno::Reference< css::lang::XEventListener >& xListener
) override;
// XControl
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 setContext(
const css::uno::Reference< css::uno::XInterface >& xContext
) 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::uno::Reference< css::uno::XInterface > SAL_CALL getContext() override;
virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override = 0;
virtual css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getPeer() override;
virtual css::uno::Reference< css::awt::XView > SAL_CALL getView() override;
virtual sal_Bool SAL_CALL isDesignMode() override;
virtual sal_Bool SAL_CALL isTransparent() override;
// XWindow
virtual void SAL_CALL setPosSize( sal_Int32 nX ,
sal_Int32 nY ,
sal_Int32 nWidth ,
sal_Int32 nHeight ,
sal_Int16 nFlags ) override;
virtual void SAL_CALL setVisible( sal_Bool bVisible ) override;
virtual void SAL_CALL setEnable( sal_Bool bEnable ) override;
virtual void SAL_CALL setFocus() override;
virtual css::awt::Rectangle SAL_CALL getPosSize() override;
virtual void SAL_CALL addWindowListener(
const css::uno::Reference< css::awt::XWindowListener >& xListener
) override;
virtual void SAL_CALL addFocusListener(
const css::uno::Reference< css::awt::XFocusListener >& xListener
) 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;
virtual void SAL_CALL addMouseMotionListener(
const css::uno::Reference< css::awt::XMouseMotionListener >& xListener
) override;
virtual void SAL_CALL addPaintListener(
const css::uno::Reference< css::awt::XPaintListener >& xListener
) override;
virtual void SAL_CALL removeWindowListener(
const css::uno::Reference< css::awt::XWindowListener >& xListener
) override;
virtual void SAL_CALL removeFocusListener(
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 removeMouseListener(
const css::uno::Reference< css::awt::XMouseListener >& xListener
) override;
virtual void SAL_CALL removeMouseMotionListener(
const css::uno::Reference< css::awt::XMouseMotionListener >& xListener
) override;
virtual void SAL_CALL removePaintListener(
const css::uno::Reference< css::awt::XPaintListener >& xListener
) override;
// XView
virtual void SAL_CALL draw( sal_Int32 nX ,
sal_Int32 nY ) override;
virtual sal_Bool SAL_CALL setGraphics(
const css::uno::Reference< css::awt::XGraphics >& xDevice
) override;
virtual void SAL_CALL setZoom( float fZoomX ,
float fZoomY ) override;
virtual css::uno::Reference< css::awt::XGraphics > SAL_CALL getGraphics() override;
virtual css::awt::Size SAL_CALL getSize() override;
// css::lang::XEventListener
virtual void SAL_CALL disposing(
const css::lang::EventObject& rSource
) override;
// XPaintListener
virtual void SAL_CALL windowPaint(
const css::awt::PaintEvent& rEvent
) override;
// XWindowListener
virtual void SAL_CALL windowResized( const css::awt::WindowEvent& aEvent ) override;
virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& aEvent ) override;
virtual void SAL_CALL windowShown( const css::lang::EventObject& aEvent ) override;
virtual void SAL_CALL windowHidden( const css::lang::EventObject& aEvent ) override;
protected:
using OComponentHelper::disposing;
const css::uno::Reference< css::uno::XComponentContext >& impl_getComponentContext() const { return m_xComponentContext;}
const css::uno::Reference< css::awt::XWindow >& impl_getPeerWindow() const { return m_xPeerWindow;}
const css::uno::Reference< css::awt::XGraphics >& impl_getGraphicsPeer() const { return m_xGraphicsPeer;}
sal_Int32 impl_getWidth() const { return m_nWidth;}
sal_Int32 impl_getHeight() const { return m_nHeight;}
virtual css::awt::WindowDescriptor impl_getWindowDescriptor(
const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer
);
virtual void impl_paint( sal_Int32 nX ,
sal_Int32 nY ,
const css::uno::Reference< css::awt::XGraphics >& xGraphics );
virtual void impl_recalcLayout( const css::awt::WindowEvent& aEvent );
const css::uno::Reference< css::uno::XInterface >& impl_getDelegator() const { return m_xDelegator;}
private:
OMRCListenerMultiplexerHelper* impl_getMultiplexer();
css::uno::Reference< css::uno::XComponentContext > m_xComponentContext;
css::uno::Reference< css::uno::XInterface > m_xDelegator;
rtl::Reference<OMRCListenerMultiplexerHelper> m_xMultiplexer; // multiplex events
css::uno::Reference< css::uno::XInterface > m_xContext;
css::uno::Reference< css::awt::XWindowPeer > m_xPeer;
css::uno::Reference< css::awt::XWindow > m_xPeerWindow;
css::uno::Reference< css::awt::XGraphics > m_xGraphicsView; // graphics for css::awt::XView-operations
css::uno::Reference< css::awt::XGraphics > m_xGraphicsPeer; // graphics for painting on a peer
sal_Int32 m_nX; // Position ...
sal_Int32 m_nY;
sal_Int32 m_nWidth; // ... and size of window
sal_Int32 m_nHeight;
bool m_bVisible; // Some state flags
bool m_bInDesignMode;
bool m_bEnable;
};
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|