/src/libreoffice/toolkit/source/awt/vclxtoolkit.cxx
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 | | #include <sal/config.h> |
21 | | |
22 | | #include <string_view> |
23 | | #include <thread> |
24 | | |
25 | | #ifdef _WIN32 |
26 | | #include <prewin.h> |
27 | | #include <postwin.h> |
28 | | #endif |
29 | | #include <config_features.h> |
30 | | #include <com/sun/star/awt/WindowAttribute.hpp> |
31 | | #include <com/sun/star/awt/VclWindowPeerAttribute.hpp> |
32 | | #include <com/sun/star/awt/WindowClass.hpp> |
33 | | #include <com/sun/star/awt/MessageBoxButtons.hpp> |
34 | | #include <com/sun/star/lang/XMultiServiceFactory.hpp> |
35 | | #include <com/sun/star/lang/SystemDependent.hpp> |
36 | | #include <com/sun/star/awt/FocusEvent.hpp> |
37 | | #include <com/sun/star/awt/KeyEvent.hpp> |
38 | | #include <com/sun/star/awt/KeyModifier.hpp> |
39 | | #include <com/sun/star/lang/EventObject.hpp> |
40 | | #include <com/sun/star/uno/DeploymentException.hpp> |
41 | | #include <com/sun/star/uno/Reference.hxx> |
42 | | #include <com/sun/star/uno/Sequence.hxx> |
43 | | #include <com/sun/star/uno/XComponentContext.hpp> |
44 | | #include <com/sun/star/uno/XInterface.hpp> |
45 | | #include <com/sun/star/beans/NamedValue.hpp> |
46 | | #include <com/sun/star/beans/XPropertyChangeListener.hpp> |
47 | | #include <com/sun/star/beans/XPropertySet.hpp> |
48 | | #include <com/sun/star/lang/XServiceInfo.hpp> |
49 | | #include <com/sun/star/awt/XToolkitExperimental.hpp> |
50 | | #include <com/sun/star/awt/XToolkitRobot.hpp> |
51 | | |
52 | | #include <cppuhelper/bootstrap.hxx> |
53 | | #include <comphelper/compbase.hxx> |
54 | | #include <cppuhelper/supportsservice.hxx> |
55 | | #include <o3tl/safeint.hxx> |
56 | | #include <osl/conditn.hxx> |
57 | | #include <osl/module.h> |
58 | | #include <osl/thread.hxx> |
59 | | #include <osl/mutex.hxx> |
60 | | #include <rtl/ref.hxx> |
61 | | #include <rtl/process.h> |
62 | | #include <sal/log.hxx> |
63 | | #include <tools/link.hxx> |
64 | | #include <vcl/dndlistenercontainer.hxx> |
65 | | #include <vcl/idletask.hxx> |
66 | | #include <vcl/transfer.hxx> |
67 | | #include <vcl/unohelp.hxx> |
68 | | #include <vcl/vclevent.hxx> |
69 | | #include <vcl/wintypes.hxx> |
70 | | |
71 | | #include <frozen/bits/defines.h> |
72 | | #include <frozen/bits/elsa_std.h> |
73 | | #include <frozen/unordered_map.h> |
74 | | |
75 | | #ifdef MACOSX |
76 | | #include <premac.h> |
77 | | #include <Cocoa/Cocoa.h> |
78 | | #include <postmac.h> |
79 | | #endif |
80 | | |
81 | | #include <utility> |
82 | | #include <vcl/sysdata.hxx> |
83 | | #include <vcl/textrectinfo.hxx> |
84 | | #include <vcl/toolkit/vclmedit.hxx> |
85 | | |
86 | | #include <toolkit/awt/vclxwindows.hxx> |
87 | | #include <awt/vclxwindows.hxx> |
88 | | #include <awt/vclxsystemdependentwindow.hxx> |
89 | | #include <awt/vclxregion.hxx> |
90 | | #include <awt/vclxtabpagecontainer.hxx> |
91 | | #include <awt/vclxtopwindow.hxx> |
92 | | |
93 | | #include <awt/animatedimagespeer.hxx> |
94 | | #include <toolkit/awt/vclxwindow.hxx> |
95 | | #include <toolkit/helper/vclunohelper.hxx> |
96 | | #include <helper/property.hxx> |
97 | | |
98 | | #include <controls/filectrl.hxx> |
99 | | #include <controls/svmedit.hxx> |
100 | | #include <controls/table/tablecontrol.hxx> |
101 | | #include <controls/treecontrolpeer.hxx> |
102 | | #include <vcl/toolkit/button.hxx> |
103 | | #include <vcl/toolkit/calendar.hxx> |
104 | | #include <vcl/toolkit/combobox.hxx> |
105 | | #include <vcl/ctrl.hxx> |
106 | | #include <vcl/toolkit/dialog.hxx> |
107 | | #include <vcl/dockingarea.hxx> |
108 | | #include <vcl/dockwin.hxx> |
109 | | #include <vcl/toolkit/edit.hxx> |
110 | | #include <vcl/event.hxx> |
111 | | #include <vcl/toolkit/field.hxx> |
112 | | #include <vcl/toolkit/fixed.hxx> |
113 | | #include <vcl/toolkit/fixedhyper.hxx> |
114 | | #include <vcl/toolkit/floatwin.hxx> |
115 | | #include <vcl/toolkit/fmtfield.hxx> |
116 | | #include <vcl/toolkit/prgsbar.hxx> |
117 | | #include <vcl/scheduler.hxx> |
118 | | #include <vcl/toolkit/lstbox.hxx> |
119 | | #include <vcl/toolkit/longcurr.hxx> |
120 | | #include <vcl/toolkit/MenuButton.hxx> |
121 | | #include <vcl/stdtext.hxx> |
122 | | #include <vcl/toolkit/scrbar.hxx> |
123 | | #include <vcl/split.hxx> |
124 | | #include <vcl/splitwin.hxx> |
125 | | #include <vcl/status.hxx> |
126 | | #include <vcl/svapp.hxx> |
127 | | #include <vcl/syschild.hxx> |
128 | | #include <vcl/tabctrl.hxx> |
129 | | #include <vcl/tabpage.hxx> |
130 | | #include <vcl/toolbox.hxx> |
131 | | #include <vcl/virdev.hxx> |
132 | | #include <vcl/window.hxx> |
133 | | #include <vcl/wrkwin.hxx> |
134 | | #include <vcl/toolkit/group.hxx> |
135 | | #include <vcl/toolkit/imgctrl.hxx> |
136 | | #include <vcl/toolkit/morebtn.hxx> |
137 | | #include <vcl/toolkit/roadmap.hxx> |
138 | | #include <vcl/toolkit/spin.hxx> |
139 | | #include <vcl/toolkit/tabdlg.hxx> |
140 | | #include <vcl/toolkit/throbber.hxx> |
141 | | #if HAVE_FEATURE_OPENGL |
142 | | #include <vcl/opengl/OpenGLWrapper.hxx> |
143 | | #endif |
144 | | #include <awt/vclxspinbutton.hxx> |
145 | | #include <tools/debug.hxx> |
146 | | #include <comphelper/lok.hxx> |
147 | | #include <comphelper/diagnose_ex.hxx> |
148 | | #include <comphelper/interfacecontainer4.hxx> |
149 | | #include <comphelper/processfactory.hxx> |
150 | | #include <comphelper/profilezone.hxx> |
151 | | |
152 | | #include <helper/msgbox.hxx> |
153 | | #include <helper/scrollabledialog.hxx> |
154 | | #include <helper/unowrapper.hxx> |
155 | | |
156 | | #if defined(_WIN32) |
157 | | #define SYSTEM_DEPENDENT_TYPE css::lang::SystemDependent::SYSTEM_WIN32 |
158 | | #elif defined(MACOSX) |
159 | | #define SYSTEM_DEPENDENT_TYPE css::lang::SystemDependent::SYSTEM_MAC |
160 | | #elif defined(UNX) |
161 | 0 | #define SYSTEM_DEPENDENT_TYPE css::lang::SystemDependent::SYSTEM_XWINDOW |
162 | | #endif |
163 | | |
164 | | void MessBox::ImplInitButtons() |
165 | 0 | { |
166 | 0 | ButtonDialogFlags nOKFlags = ButtonDialogFlags::OK; |
167 | 0 | ButtonDialogFlags nCancelFlags = ButtonDialogFlags::Cancel; |
168 | 0 | ButtonDialogFlags nRetryFlags = ButtonDialogFlags::NONE; |
169 | 0 | ButtonDialogFlags nYesFlags = ButtonDialogFlags::NONE; |
170 | 0 | ButtonDialogFlags nNoFlags = ButtonDialogFlags::NONE; |
171 | |
|
172 | 0 | if ( mnMessBoxStyle & MessBoxStyle::OkCancel ) |
173 | 0 | { |
174 | 0 | if ( mnMessBoxStyle & MessBoxStyle::DefaultCancel ) |
175 | 0 | nCancelFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; |
176 | 0 | else // MessBoxStyle::DefaultOk |
177 | 0 | nOKFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; |
178 | |
|
179 | 0 | AddButton( StandardButtonType::OK, RET_OK, nOKFlags ); |
180 | 0 | AddButton( StandardButtonType::Cancel, RET_CANCEL, nCancelFlags ); |
181 | 0 | } |
182 | 0 | else if ( mnMessBoxStyle & MessBoxStyle::YesNo ) |
183 | 0 | { |
184 | 0 | if ( mnMessBoxStyle & MessBoxStyle::DefaultYes ) |
185 | 0 | nYesFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; |
186 | 0 | else // MessBoxStyle::DefaultNo |
187 | 0 | nNoFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; |
188 | 0 | nNoFlags |= ButtonDialogFlags::Cancel; |
189 | |
|
190 | 0 | AddButton( StandardButtonType::Yes, RET_YES, nYesFlags ); |
191 | 0 | AddButton( StandardButtonType::No, RET_NO, nNoFlags ); |
192 | 0 | } |
193 | 0 | else if ( mnMessBoxStyle & MessBoxStyle::YesNoCancel ) |
194 | 0 | { |
195 | 0 | if ( mnMessBoxStyle & MessBoxStyle::DefaultYes ) |
196 | 0 | nYesFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; |
197 | 0 | else if ( mnMessBoxStyle & MessBoxStyle::DefaultNo ) |
198 | 0 | nNoFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; |
199 | 0 | else |
200 | 0 | nCancelFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; |
201 | |
|
202 | 0 | AddButton( StandardButtonType::Yes, RET_YES, nYesFlags ); |
203 | 0 | AddButton( StandardButtonType::No, RET_NO, nNoFlags ); |
204 | 0 | AddButton( StandardButtonType::Cancel, RET_CANCEL, nCancelFlags ); |
205 | 0 | } |
206 | 0 | else if ( mnMessBoxStyle & MessBoxStyle::RetryCancel ) |
207 | 0 | { |
208 | 0 | if ( mnMessBoxStyle & MessBoxStyle::DefaultCancel ) |
209 | 0 | nCancelFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; |
210 | 0 | else // MessBoxStyle::DefaultRetry |
211 | 0 | nRetryFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; |
212 | |
|
213 | 0 | AddButton( StandardButtonType::Retry, RET_RETRY, nRetryFlags ); |
214 | 0 | AddButton( StandardButtonType::Cancel, RET_CANCEL, nCancelFlags ); |
215 | 0 | } |
216 | 0 | else if ( mnMessBoxStyle & MessBoxStyle::AbortRetryIgnore ) |
217 | 0 | { |
218 | 0 | ButtonDialogFlags nAbortFlags = ButtonDialogFlags::NONE; |
219 | 0 | ButtonDialogFlags nIgnoreFlags = ButtonDialogFlags::NONE; |
220 | |
|
221 | 0 | if ( mnMessBoxStyle & MessBoxStyle::DefaultCancel ) |
222 | 0 | nAbortFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; |
223 | 0 | else if ( mnMessBoxStyle & MessBoxStyle::DefaultRetry ) |
224 | 0 | nRetryFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; |
225 | 0 | else if ( mnMessBoxStyle & MessBoxStyle::DefaultIgnore ) |
226 | 0 | nIgnoreFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; |
227 | |
|
228 | 0 | AddButton( StandardButtonType::Abort, RET_CANCEL, nAbortFlags ); |
229 | 0 | AddButton( StandardButtonType::Retry, RET_RETRY, nRetryFlags ); |
230 | 0 | AddButton( StandardButtonType::Ignore, RET_IGNORE, nIgnoreFlags ); |
231 | 0 | } |
232 | 0 | else if ( mnMessBoxStyle & MessBoxStyle::Ok ) |
233 | 0 | { |
234 | 0 | nOKFlags |= ButtonDialogFlags::Default | ButtonDialogFlags::Focus; |
235 | |
|
236 | 0 | AddButton( StandardButtonType::OK, RET_OK, nOKFlags ); |
237 | 0 | } |
238 | 0 | } |
239 | | |
240 | | MessBox::MessBox(vcl::Window* pParent, MessBoxStyle nMessBoxStyle, WinBits nWinBits, |
241 | | const OUString& rTitle, OUString aMessage) : |
242 | 0 | ButtonDialog( WindowType::MESSBOX ), |
243 | 0 | mbHelpBtn( false ), |
244 | 0 | mnMessBoxStyle( nMessBoxStyle ), |
245 | 0 | maMessText(std::move( aMessage )) |
246 | 0 | { |
247 | 0 | ImplLOKNotifier(pParent); |
248 | 0 | ImplInitDialog(pParent, nWinBits | WB_MOVEABLE | WB_HORZ | WB_CENTER); |
249 | 0 | ImplInitButtons(); |
250 | |
|
251 | 0 | if ( !rTitle.isEmpty() ) |
252 | 0 | SetText( rTitle ); |
253 | 0 | } Unexecuted instantiation: MessBox::MessBox(vcl::Window*, MessBoxStyle, long, rtl::OUString const&, rtl::OUString) Unexecuted instantiation: MessBox::MessBox(vcl::Window*, MessBoxStyle, long, rtl::OUString const&, rtl::OUString) |
254 | | |
255 | | MessBox::~MessBox() |
256 | 0 | { |
257 | 0 | disposeOnce(); |
258 | 0 | } |
259 | | |
260 | | void MessBox::dispose() |
261 | 0 | { |
262 | 0 | mpVCLMultiLineEdit.disposeAndClear(); |
263 | 0 | mpFixedImage.disposeAndClear(); |
264 | 0 | ButtonDialog::dispose(); |
265 | 0 | } |
266 | | |
267 | | void MessBox::ImplPosControls() |
268 | 0 | { |
269 | 0 | if ( !GetHelpId().isEmpty() ) |
270 | 0 | { |
271 | 0 | if ( !mbHelpBtn ) |
272 | 0 | { |
273 | 0 | AddButton( StandardButtonType::Help, RET_HELP, ButtonDialogFlags::Help, 3 ); |
274 | 0 | mbHelpBtn = true; |
275 | 0 | } |
276 | 0 | } |
277 | 0 | else |
278 | 0 | { |
279 | 0 | if ( mbHelpBtn ) |
280 | 0 | { |
281 | 0 | RemoveButton( RET_HELP ); |
282 | 0 | mbHelpBtn = false; |
283 | 0 | } |
284 | 0 | } |
285 | |
|
286 | 0 | TextRectInfo aTextInfo; |
287 | 0 | tools::Rectangle aRect( 0, 0, 30000, 30000 ); |
288 | 0 | tools::Rectangle aFormatRect; |
289 | 0 | Point aTextPos( IMPL_DIALOG_OFFSET, IMPL_DIALOG_OFFSET+IMPL_MSGBOX_OFFSET_EXTRA_Y ); |
290 | 0 | Size aImageSize; |
291 | 0 | Size aPageSize; |
292 | 0 | Size aMEditSize; |
293 | 0 | tools::Long nTitleWidth; |
294 | 0 | tools::Long nButtonSize = ImplGetButtonSize(); |
295 | 0 | tools::Long nMaxLineWidth; |
296 | 0 | tools::Long nWidth; |
297 | 0 | WinBits nWinStyle = WB_LEFT | WB_NOLABEL; |
298 | 0 | DrawTextFlags nTextStyle = DrawTextFlags::MultiLine | DrawTextFlags::Top | DrawTextFlags::Left; |
299 | |
|
300 | 0 | mpVCLMultiLineEdit.disposeAndClear(); |
301 | 0 | mpFixedImage.disposeAndClear(); |
302 | | |
303 | | // Clean up message text with tabs |
304 | 0 | OUString aMessText(maMessText.replaceAll("\t", " ")); |
305 | | |
306 | | //If window too small, we make dialog box be wider |
307 | 0 | tools::Long nMaxWidth = 630 * GetDPIScaleFactor(); |
308 | | |
309 | | // MessagBox should be at least as wide as to see the title |
310 | | // Extra-Width for Close button, because Close button is set after this call |
311 | 0 | nTitleWidth = CalcTitleWidth(); |
312 | |
|
313 | 0 | nMaxWidth -= (IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_X*2); |
314 | | |
315 | | // for an image, get its size, create a suitable control and position it |
316 | 0 | aImageSize = maImage.GetSizePixel(); |
317 | 0 | if ( aImageSize.Width() ) |
318 | 0 | { |
319 | 0 | aImageSize.AdjustWidth(4 ); |
320 | 0 | aImageSize.AdjustHeight(4 ); |
321 | 0 | aTextPos.AdjustX(aImageSize.Width()+IMPL_SEP_MSGBOX_IMAGE ); |
322 | 0 | mpFixedImage = VclPtr<FixedImage>::Create( this ); |
323 | 0 | mpFixedImage->SetPosSizePixel( Point( IMPL_DIALOG_OFFSET-2+IMPL_MSGBOX_OFFSET_EXTRA_X, |
324 | 0 | IMPL_DIALOG_OFFSET-2+IMPL_MSGBOX_OFFSET_EXTRA_Y ), |
325 | 0 | aImageSize ); |
326 | 0 | mpFixedImage->SetImage( maImage ); |
327 | 0 | mpFixedImage->Show(); |
328 | 0 | nMaxWidth -= aImageSize.Width()+IMPL_SEP_MSGBOX_IMAGE; |
329 | 0 | } |
330 | 0 | else |
331 | 0 | aTextPos.AdjustX(IMPL_MSGBOX_OFFSET_EXTRA_X ); |
332 | | |
333 | | // Determine maximum line length without wordbreak |
334 | 0 | aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo ); |
335 | 0 | nMaxLineWidth = aFormatRect.GetWidth(); |
336 | 0 | nTextStyle |= DrawTextFlags::WordBreak; |
337 | | |
338 | | // Determine the width for text formatting |
339 | 0 | if ( nMaxLineWidth > 450 ) |
340 | 0 | nWidth = 450; |
341 | 0 | else if ( nMaxLineWidth > 300 ) |
342 | 0 | nWidth = nMaxLineWidth+5; |
343 | 0 | else |
344 | 0 | nWidth = 300; |
345 | |
|
346 | 0 | nWidth *= GetDPIScaleFactor(); |
347 | |
|
348 | 0 | if ( nButtonSize > nWidth ) |
349 | 0 | nWidth = nButtonSize-(aTextPos.X()-IMPL_DIALOG_OFFSET); |
350 | 0 | if ( nWidth > nMaxWidth ) |
351 | 0 | nWidth = nMaxWidth; |
352 | |
|
353 | 0 | aRect.SetRight( nWidth ); |
354 | 0 | aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo ); |
355 | 0 | if ( aTextInfo.GetMaxLineWidth() > nWidth ) |
356 | 0 | { |
357 | 0 | nWidth = aTextInfo.GetMaxLineWidth()+8; |
358 | 0 | aRect.SetRight( nWidth ); |
359 | 0 | aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo ); |
360 | 0 | } |
361 | | |
362 | | // get Style for VCLMultiLineEdit |
363 | 0 | aMEditSize.setWidth( aTextInfo.GetMaxLineWidth()+1 ); |
364 | 0 | aMEditSize.setHeight( aFormatRect.GetHeight() ); |
365 | 0 | aPageSize.setWidth( aImageSize.Width() ); |
366 | 0 | if ( aMEditSize.Height() < aImageSize.Height() ) |
367 | 0 | { |
368 | 0 | nWinStyle |= WB_VCENTER; |
369 | 0 | aPageSize.setHeight( aImageSize.Height() ); |
370 | 0 | aMEditSize.setHeight( aImageSize.Height() ); |
371 | 0 | } |
372 | 0 | else |
373 | 0 | { |
374 | 0 | nWinStyle |= WB_TOP; |
375 | 0 | aPageSize.setHeight( aMEditSize.Height() ); |
376 | 0 | } |
377 | 0 | if ( aImageSize.Width() ) |
378 | 0 | aPageSize.AdjustWidth(IMPL_SEP_MSGBOX_IMAGE ); |
379 | 0 | aPageSize.AdjustWidth((IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_X*2) ); |
380 | 0 | aPageSize.AdjustWidth(aMEditSize.Width()+1 ); |
381 | 0 | aPageSize.AdjustHeight((IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_Y*2) ); |
382 | |
|
383 | 0 | if ( aPageSize.Width() < IMPL_MINSIZE_MSGBOX_WIDTH ) |
384 | 0 | aPageSize.setWidth( IMPL_MINSIZE_MSGBOX_WIDTH ); |
385 | 0 | if ( aPageSize.Width() < nTitleWidth ) |
386 | 0 | aPageSize.setWidth( nTitleWidth ); |
387 | |
|
388 | 0 | mpVCLMultiLineEdit = VclPtr<VclMultiLineEdit>::Create( this, nWinStyle ); |
389 | 0 | mpVCLMultiLineEdit->SetText( aMessText ); |
390 | 0 | mpVCLMultiLineEdit->SetPosSizePixel( aTextPos, aMEditSize ); |
391 | 0 | mpVCLMultiLineEdit->Show(); |
392 | 0 | mpVCLMultiLineEdit->SetPaintTransparent(true); |
393 | 0 | mpVCLMultiLineEdit->EnableCursor(false); |
394 | 0 | SetPageSizePixel( aPageSize ); |
395 | 0 | } |
396 | | |
397 | | void MessBox::StateChanged( StateChangedType nType ) |
398 | 0 | { |
399 | 0 | if ( nType == StateChangedType::InitShow ) |
400 | 0 | { |
401 | 0 | ImplPosControls(); |
402 | 0 | } |
403 | 0 | ButtonDialog::StateChanged( nType ); |
404 | 0 | } |
405 | | |
406 | | Size MessBox::GetOptimalSize() const |
407 | 0 | { |
408 | | // FIXME: base me on the font size ? |
409 | 0 | return Size( 250, 100 ); |
410 | 0 | } |
411 | | |
412 | | |
413 | | namespace |
414 | | { |
415 | | |
416 | | class Pause : public Idle |
417 | | { |
418 | | public: |
419 | | explicit Pause(sal_Int32 nPauseMilliseconds) : |
420 | 0 | Idle("pause"), |
421 | 0 | m_nPauseMilliseconds(nPauseMilliseconds) |
422 | 0 | { |
423 | 0 | SetPriority(TaskPriority::HIGHEST); |
424 | 0 | Start(); |
425 | 0 | } |
426 | | |
427 | | virtual void Invoke() override |
428 | 0 | { |
429 | 0 | SolarMutexGuard aSolarGuard; |
430 | 0 | std::this_thread::sleep_for(std::chrono::milliseconds(m_nPauseMilliseconds)); |
431 | 0 | Stop(); |
432 | 0 | delete this; |
433 | 0 | } |
434 | | |
435 | | sal_Int32 m_nPauseMilliseconds; |
436 | | }; |
437 | | |
438 | | class VCLXToolkit : public comphelper::WeakComponentImplHelper< |
439 | | css::awt::XToolkitExperimental, |
440 | | css::awt::XToolkitRobot, |
441 | | css::lang::XServiceInfo > |
442 | | { |
443 | | css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxClipboard; |
444 | | css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxSelection; |
445 | | |
446 | | ::comphelper::OInterfaceContainerHelper4<css::awt::XTopWindowListener> m_aTopWindowListeners; |
447 | | ::comphelper::OInterfaceContainerHelper4<css::awt::XKeyHandler> m_aKeyHandlers; |
448 | | ::comphelper::OInterfaceContainerHelper4<css::awt::XFocusListener> m_aFocusListeners; |
449 | | ::Link<VclSimpleEvent&,void> m_aEventListenerLink; |
450 | | ::Link<VclWindowEvent&,bool> m_aKeyListenerLink; |
451 | | bool m_bEventListener; |
452 | | bool m_bKeyListener; |
453 | | |
454 | | DECL_LINK(eventListenerHandler, ::VclSimpleEvent&, void); |
455 | | |
456 | | DECL_LINK(keyListenerHandler, ::VclWindowEvent&, bool); |
457 | | |
458 | | void callTopWindowListeners( |
459 | | ::VclSimpleEvent const * pEvent, |
460 | | void (SAL_CALL css::awt::XTopWindowListener::* pFn)( |
461 | | css::lang::EventObject const &)); |
462 | | |
463 | | bool callKeyHandlers(::VclSimpleEvent const * pEvent, bool bPressed); |
464 | | |
465 | | void callFocusListeners(::VclSimpleEvent const * pEvent, bool bGained); |
466 | | |
467 | | protected: |
468 | | virtual void disposing(std::unique_lock<std::mutex>& rGuard) override; |
469 | | |
470 | | static vcl::Window* ImplCreateWindow( rtl::Reference<VCLXWindow>* ppNewComp, const css::awt::WindowDescriptor& rDescriptor, vcl::Window* pParent, |
471 | | WinBits nWinBits, MessBoxStyle nMessBoxStyle ); |
472 | | static css::uno::Reference< css::awt::XWindowPeer > ImplCreateWindow( const css::awt::WindowDescriptor& Descriptor, |
473 | | MessBoxStyle nForceMessBoxStyle ); |
474 | | |
475 | | public: |
476 | | |
477 | | VCLXToolkit(); |
478 | | |
479 | | // css::awt::XToolkitExperimental |
480 | | virtual void SAL_CALL processEventsToIdle() override; |
481 | | |
482 | | virtual sal_Int64 SAL_CALL getOpenGLBufferSwapCounter() override; |
483 | | |
484 | | virtual void SAL_CALL setDeterministicScheduling(sal_Bool bDeterministicMode) override; |
485 | | |
486 | | virtual void SAL_CALL pause(sal_Int32 nMilliseconds) override; |
487 | | |
488 | | virtual void SAL_CALL startRecording() override; |
489 | | |
490 | | virtual void SAL_CALL stopRecording() override; |
491 | | |
492 | | css::uno::Sequence< OUString > SAL_CALL getRecordingAndClear() override; |
493 | | |
494 | | virtual void SAL_CALL waitUntilAllIdlesDispatched() override; |
495 | | |
496 | | // css::awt::XToolkit |
497 | | css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getDesktopWindow( ) override; |
498 | | css::awt::Rectangle SAL_CALL getWorkArea( ) override; |
499 | | css::uno::Reference< css::awt::XWindowPeer > SAL_CALL createWindow( const css::awt::WindowDescriptor& Descriptor ) override; |
500 | | css::uno::Sequence< css::uno::Reference< css::awt::XWindowPeer > > SAL_CALL createWindows( const css::uno::Sequence< css::awt::WindowDescriptor >& Descriptors ) override; |
501 | | css::uno::Reference< css::awt::XDevice > SAL_CALL createScreenCompatibleDevice( sal_Int32 Width, sal_Int32 Height ) override; |
502 | | css::uno::Reference< css::awt::XRegion > SAL_CALL createRegion( ) override; |
503 | | |
504 | | // css::awt::XSystemChildFactory |
505 | | css::uno::Reference< css::awt::XWindowPeer > SAL_CALL createSystemChild( const css::uno::Any& Parent, const css::uno::Sequence< sal_Int8 >& ProcessId, sal_Int16 SystemType ) override; |
506 | | |
507 | | // css::awt::XMessageBoxFactory |
508 | | virtual css::uno::Reference< css::awt::XMessageBox > SAL_CALL createMessageBox( const css::uno::Reference< css::awt::XWindowPeer >& aParent, css::awt::MessageBoxType eType, ::sal_Int32 aButtons, const OUString& aTitle, const OUString& aMessage ) override; |
509 | | |
510 | | // css::awt::XDataTransfer |
511 | | css::uno::Reference< css::datatransfer::dnd::XDragGestureRecognizer > SAL_CALL getDragGestureRecognizer( const css::uno::Reference< css::awt::XWindow >& window ) override; |
512 | | css::uno::Reference< css::datatransfer::dnd::XDragSource > SAL_CALL getDragSource( const css::uno::Reference< css::awt::XWindow >& window ) override; |
513 | | css::uno::Reference< css::datatransfer::dnd::XDropTarget > SAL_CALL getDropTarget( const css::uno::Reference< css::awt::XWindow >& window ) override; |
514 | | css::uno::Reference< css::datatransfer::clipboard::XClipboard > SAL_CALL getClipboard( const OUString& clipboardName ) override; |
515 | | |
516 | | // css::lang::XServiceInfo |
517 | | OUString SAL_CALL getImplementationName( ) override; |
518 | | sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; |
519 | | css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; |
520 | | |
521 | | // css::awt::XExtendedToolkit: |
522 | | |
523 | | virtual ::sal_Int32 SAL_CALL getTopWindowCount() override; |
524 | | |
525 | | virtual css::uno::Reference< css::awt::XTopWindow > |
526 | | SAL_CALL getTopWindow(::sal_Int32 nIndex) override; |
527 | | |
528 | | virtual css::uno::Reference< css::awt::XTopWindow > |
529 | | SAL_CALL getActiveTopWindow() override; |
530 | | |
531 | | virtual void SAL_CALL addTopWindowListener( |
532 | | css::uno::Reference< |
533 | | css::awt::XTopWindowListener > const & rListener) override; |
534 | | |
535 | | virtual void SAL_CALL removeTopWindowListener( |
536 | | css::uno::Reference< |
537 | | css::awt::XTopWindowListener > const & rListener) override; |
538 | | |
539 | | virtual void SAL_CALL addKeyHandler( |
540 | | css::uno::Reference< |
541 | | css::awt::XKeyHandler > const & rHandler) override; |
542 | | |
543 | | virtual void SAL_CALL removeKeyHandler( |
544 | | css::uno::Reference< |
545 | | css::awt::XKeyHandler > const & rHandler) override; |
546 | | |
547 | | virtual void SAL_CALL addFocusListener( |
548 | | css::uno::Reference< |
549 | | css::awt::XFocusListener > const & rListener) override; |
550 | | |
551 | | virtual void SAL_CALL removeFocusListener( |
552 | | css::uno::Reference< |
553 | | css::awt::XFocusListener > const & rListener) override; |
554 | | |
555 | | virtual void SAL_CALL fireFocusGained( |
556 | | css::uno::Reference< |
557 | | css::uno::XInterface > const & source) override; |
558 | | |
559 | | virtual void SAL_CALL fireFocusLost( |
560 | | css::uno::Reference< |
561 | | css::uno::XInterface > const & source) override; |
562 | | |
563 | | // css::awt::XReschedule: |
564 | | virtual void SAL_CALL reschedule() override; |
565 | | |
566 | | // css::awt::XFontMappingUse: |
567 | | virtual void SAL_CALL startTrackingFontMappingUse() override; |
568 | | |
569 | | virtual css::uno::Sequence<css::awt::XFontMappingUseItem> SAL_CALL finishTrackingFontMappingUse() override; |
570 | | |
571 | | // css:awt:XToolkitRobot |
572 | | virtual void SAL_CALL keyPress( const css::awt::KeyEvent & aKeyEvent ) override; |
573 | | |
574 | | virtual void SAL_CALL keyRelease( const css::awt::KeyEvent & aKeyEvent ) override; |
575 | | |
576 | | virtual void SAL_CALL mousePress( const css::awt::MouseEvent & aMouseEvent ) override; |
577 | | |
578 | | virtual void SAL_CALL mouseRelease( const css::awt::MouseEvent & aMouseEvent ) override; |
579 | | |
580 | | virtual void SAL_CALL mouseMove( const css::awt::MouseEvent & aMouseEvent ) override; |
581 | | |
582 | | }; |
583 | | |
584 | | std::pair<WinBits,MessBoxStyle> ImplGetWinBits( sal_uInt32 nComponentAttribs, WindowType nCompType ) |
585 | 56.8k | { |
586 | 56.8k | WinBits nWinBits = 0; |
587 | 56.8k | MessBoxStyle nStyle = MessBoxStyle::NONE; |
588 | | |
589 | 56.8k | bool bMessBox = false; |
590 | 56.8k | if ( ( nCompType == WindowType::INFOBOX ) || |
591 | 56.8k | ( nCompType == WindowType::MESSBOX ) || |
592 | 56.8k | ( nCompType == WindowType::QUERYBOX ) || |
593 | 56.8k | ( nCompType == WindowType::WARNINGBOX ) || |
594 | 56.8k | ( nCompType == WindowType::ERRORBOX ) ) |
595 | 0 | { |
596 | 0 | bMessBox = true; |
597 | 0 | } |
598 | | |
599 | 56.8k | bool bDecoratedWindow = false; |
600 | 56.8k | if ( bMessBox |
601 | 56.8k | || ( nCompType == WindowType::DIALOG ) |
602 | 56.8k | || ( nCompType == WindowType::MODELESSDIALOG ) |
603 | 56.8k | || ( nCompType == WindowType::DOCKINGWINDOW ) |
604 | 56.8k | || ( nCompType == WindowType::TABDIALOG ) |
605 | 56.8k | || ( nCompType == WindowType::BUTTONDIALOG ) |
606 | 56.8k | || ( nCompType == WindowType::SYSTEMCHILDWINDOW ) |
607 | 56.8k | ) |
608 | 0 | { |
609 | 0 | bDecoratedWindow = true; |
610 | 0 | } |
611 | | |
612 | 56.8k | if( nComponentAttribs & css::awt::WindowAttribute::BORDER ) |
613 | 8.22k | nWinBits |= WB_BORDER; |
614 | 56.8k | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::NOBORDER ) |
615 | 0 | nWinBits |= WB_NOBORDER; |
616 | 56.8k | if( nComponentAttribs & css::awt::WindowAttribute::SIZEABLE ) |
617 | 8.22k | nWinBits |= WB_SIZEABLE; |
618 | 56.8k | if( nComponentAttribs & css::awt::WindowAttribute::MOVEABLE ) |
619 | 8.22k | nWinBits |= WB_MOVEABLE; |
620 | 56.8k | if( nComponentAttribs & css::awt::WindowAttribute::CLOSEABLE ) |
621 | 8.22k | nWinBits |= WB_CLOSEABLE; |
622 | 56.8k | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::HSCROLL ) |
623 | 0 | nWinBits |= WB_HSCROLL; |
624 | 56.8k | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::VSCROLL ) |
625 | 0 | nWinBits |= WB_VSCROLL; |
626 | 56.8k | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::LEFT ) |
627 | 0 | nWinBits |= WB_LEFT; |
628 | 56.8k | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::CENTER ) |
629 | 0 | nWinBits |= WB_CENTER; |
630 | 56.8k | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::RIGHT ) |
631 | 0 | nWinBits |= WB_RIGHT; |
632 | 56.8k | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::SPIN ) |
633 | 0 | nWinBits |= WB_SPIN; |
634 | 56.8k | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::SORT ) |
635 | 0 | nWinBits |= WB_SORT; |
636 | 56.8k | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::DROPDOWN ) |
637 | 0 | nWinBits |= WB_DROPDOWN; |
638 | 56.8k | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::DEFBUTTON ) |
639 | 0 | nWinBits |= WB_DEFBUTTON; |
640 | 56.8k | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::READONLY ) |
641 | 0 | nWinBits |= WB_READONLY; |
642 | 56.8k | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::CLIPCHILDREN ) |
643 | 8.22k | nWinBits |= WB_CLIPCHILDREN; |
644 | 56.8k | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::GROUP ) |
645 | 0 | nWinBits |= WB_GROUP; |
646 | 56.8k | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::NOLABEL ) //added for issue79712 |
647 | 0 | nWinBits |= WB_NOLABEL; |
648 | | |
649 | | // These bits are not unique |
650 | 56.8k | if ( bMessBox ) |
651 | 0 | { |
652 | 0 | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::OK ) |
653 | 0 | nStyle |= MessBoxStyle::Ok; |
654 | 0 | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::OK_CANCEL ) |
655 | 0 | nStyle |= MessBoxStyle::OkCancel; |
656 | 0 | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::YES_NO ) |
657 | 0 | nStyle |= MessBoxStyle::YesNo; |
658 | 0 | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::YES_NO_CANCEL ) |
659 | 0 | nStyle |= MessBoxStyle::YesNoCancel; |
660 | 0 | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::RETRY_CANCEL ) |
661 | 0 | nStyle |= MessBoxStyle::RetryCancel; |
662 | 0 | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::DEF_OK ) |
663 | 0 | nStyle |= MessBoxStyle::DefaultOk; |
664 | 0 | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::DEF_CANCEL ) |
665 | 0 | nStyle |= MessBoxStyle::DefaultCancel; |
666 | 0 | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::DEF_RETRY ) |
667 | 0 | nStyle |= MessBoxStyle::DefaultRetry; |
668 | 0 | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::DEF_YES ) |
669 | 0 | nStyle |= MessBoxStyle::DefaultYes; |
670 | 0 | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::DEF_NO ) |
671 | 0 | nStyle |= MessBoxStyle::DefaultNo; |
672 | 0 | } |
673 | 56.8k | if ( nCompType == WindowType::MULTILINEEDIT || nCompType == WindowType::DIALOG |
674 | 56.8k | || nCompType == WindowType::GROUPBOX || nCompType == WindowType::TABPAGE ) |
675 | 0 | { |
676 | 0 | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::AUTOHSCROLL ) |
677 | 0 | nWinBits |= WB_AUTOHSCROLL; |
678 | 0 | if( nComponentAttribs & css::awt::VclWindowPeerAttribute::AUTOVSCROLL ) |
679 | 0 | nWinBits |= WB_AUTOVSCROLL; |
680 | 0 | } |
681 | | |
682 | | |
683 | 56.8k | if ( bDecoratedWindow ) |
684 | 0 | { |
685 | 0 | if( nComponentAttribs & css::awt::WindowAttribute::NODECORATION ) |
686 | 0 | { |
687 | | // No decoration removes several window attributes and must |
688 | | // set WB_NOBORDER! |
689 | 0 | nWinBits &= ~WB_BORDER; |
690 | 0 | nWinBits &= ~WB_SIZEABLE; |
691 | 0 | nWinBits &= ~WB_MOVEABLE; |
692 | 0 | nWinBits &= ~WB_CLOSEABLE; |
693 | 0 | nWinBits |= WB_NOBORDER; |
694 | 0 | } |
695 | 0 | } |
696 | | |
697 | 56.8k | return { nWinBits, nStyle }; |
698 | 56.8k | } |
699 | | |
700 | | constexpr auto constComponentTypeMapping = frozen::make_unordered_map<std::u16string_view, WindowType>( |
701 | | { |
702 | | { u"animatedimages", WindowType::CONTROL }, |
703 | | { u"buttondialog", WindowType::BUTTONDIALOG }, |
704 | | { u"cancelbutton", WindowType::CANCELBUTTON }, |
705 | | { u"checkbox", WindowType::CHECKBOX }, |
706 | | { u"combobox", WindowType::COMBOBOX }, |
707 | | { u"control", WindowType::CONTROL }, |
708 | | { u"currencybox", WindowType::CURRENCYBOX }, |
709 | | { u"currencyfield", WindowType::CURRENCYFIELD }, |
710 | | { u"datebox", WindowType::DATEBOX }, |
711 | | { u"datefield", WindowType::CONTROL }, |
712 | | { u"dialog", WindowType::DIALOG }, |
713 | | { u"dockingarea", WindowType::DOCKINGAREA }, |
714 | | { u"dockingwindow", WindowType::DOCKINGWINDOW }, |
715 | | { u"edit", WindowType::EDIT }, |
716 | | { u"errorbox", WindowType::ERRORBOX }, |
717 | | { u"filecontrol", WindowType::CONTROL }, |
718 | | { u"fixedbitmap", WindowType::FIXEDBITMAP }, |
719 | | { u"fixedhyperlink", WindowType::CONTROL }, |
720 | | { u"fixedimage", WindowType::FIXEDIMAGE }, |
721 | | { u"fixedline", WindowType::FIXEDLINE }, |
722 | | { u"fixedtext", WindowType::FIXEDTEXT }, |
723 | | { u"floatingwindow", WindowType::FLOATINGWINDOW }, |
724 | | { u"formattedfield", WindowType::CONTROL }, |
725 | | { u"frame", WindowType::GROUPBOX }, |
726 | | { u"framewindow", WindowType::TOOLKIT_FRAMEWINDOW }, |
727 | | { u"grid", WindowType::CONTROL }, |
728 | | { u"groupbox", WindowType::GROUPBOX }, |
729 | | { u"helpbutton", WindowType::HELPBUTTON }, |
730 | | { u"imagebutton", WindowType::IMAGEBUTTON }, |
731 | | { u"infobox", WindowType::INFOBOX }, |
732 | | { u"listbox", WindowType::LISTBOX }, |
733 | | { u"longcurrencybox", WindowType::LONGCURRENCYBOX }, |
734 | | { u"longcurrencyfield", WindowType::CONTROL }, |
735 | | { u"menubutton", WindowType::MENUBUTTON }, |
736 | | { u"messbox", WindowType::MESSBOX }, |
737 | | { u"metricbox", WindowType::METRICBOX }, |
738 | | { u"metricfield", WindowType::METRICFIELD }, |
739 | | { u"modelessdialog", WindowType::MODELESSDIALOG }, |
740 | | { u"morebutton", WindowType::MOREBUTTON }, |
741 | | { u"multilineedit", WindowType::MULTILINEEDIT }, |
742 | | { u"multilistbox", WindowType::MULTILISTBOX }, |
743 | | { u"numericbox", WindowType::NUMERICBOX }, |
744 | | { u"numericfield", WindowType::CONTROL }, |
745 | | { u"okbutton", WindowType::OKBUTTON }, |
746 | | { u"patternbox", WindowType::PATTERNBOX }, |
747 | | { u"patternfield", WindowType::PATTERNFIELD }, |
748 | | { u"progressbar", WindowType::CONTROL }, |
749 | | { u"pushbutton", WindowType::PUSHBUTTON }, |
750 | | { u"querybox", WindowType::QUERYBOX }, |
751 | | { u"radiobutton", WindowType::RADIOBUTTON }, |
752 | | { u"roadmap", WindowType::CONTROL }, |
753 | | { u"scrollbar", WindowType::SCROLLBAR }, |
754 | | { u"scrollbarbox", WindowType::SCROLLBARBOX }, |
755 | | { u"spinbutton", WindowType::SPINBUTTON }, |
756 | | { u"spinfield", WindowType::SPINFIELD }, |
757 | | { u"splitter", WindowType::SPLITTER }, |
758 | | { u"splitwindow", WindowType::SPLITWINDOW }, |
759 | | { u"statusbar", WindowType::STATUSBAR }, |
760 | | { u"systemchildwindow", WindowType::TOOLKIT_SYSTEMCHILDWINDOW }, |
761 | | { u"tabcontrol", WindowType::TABCONTROL }, |
762 | | { u"tabdialog", WindowType::TABDIALOG }, |
763 | | { u"tabpage", WindowType::TABPAGE }, |
764 | | { u"tabpagecontainer", WindowType::CONTROL }, |
765 | | { u"tabpagemodel", WindowType::TABPAGE }, |
766 | | { u"timebox", WindowType::TIMEBOX }, |
767 | | { u"timefield", WindowType::TIMEFIELD }, |
768 | | { u"toolbox", WindowType::TOOLBOX }, |
769 | | { u"tree", WindowType::CONTROL }, |
770 | | { u"tristatebox", WindowType::TRISTATEBOX }, |
771 | | { u"warningbox", WindowType::WARNINGBOX }, |
772 | | { u"window", WindowType::WINDOW }, |
773 | | { u"workwindow", WindowType::WORKWINDOW } |
774 | | }); |
775 | | |
776 | | WindowType ImplGetComponentType( const OUString& rServiceName ) |
777 | 113k | { |
778 | 113k | OUString sSearch; |
779 | 113k | if (!rServiceName.isEmpty()) |
780 | 113k | sSearch = rServiceName.toAsciiLowerCase(); |
781 | 0 | else |
782 | 0 | sSearch = "window"; |
783 | | |
784 | 113k | auto iterator = constComponentTypeMapping.find(sSearch); |
785 | 113k | if (iterator != constComponentTypeMapping.end()) |
786 | 113k | return iterator->second; |
787 | 0 | return WindowType::NONE; |
788 | 113k | } |
789 | | |
790 | | struct MessageBoxTypeInfo |
791 | | { |
792 | | css::awt::MessageBoxType eType; |
793 | | OUString sName; |
794 | | }; |
795 | | |
796 | | constexpr MessageBoxTypeInfo aMessageBoxTypeInfo[] = |
797 | | { |
798 | | { css::awt::MessageBoxType_MESSAGEBOX, u"messbox"_ustr }, |
799 | | { css::awt::MessageBoxType_INFOBOX, u"infobox"_ustr }, |
800 | | { css::awt::MessageBoxType_WARNINGBOX, u"warningbox"_ustr }, |
801 | | { css::awt::MessageBoxType_ERRORBOX, u"errorbox"_ustr }, |
802 | | { css::awt::MessageBoxType_QUERYBOX, u"querybox"_ustr } |
803 | | }; |
804 | | |
805 | | OUString lcl_convertMessageBoxType(css::awt::MessageBoxType eType) |
806 | 0 | { |
807 | 0 | for (const MessageBoxTypeInfo& rInfo : aMessageBoxTypeInfo) |
808 | 0 | { |
809 | 0 | if (rInfo.eType == eType) |
810 | 0 | return rInfo.sName; |
811 | 0 | } |
812 | | |
813 | 0 | return OUString(); |
814 | 0 | } |
815 | | |
816 | | #ifndef IOS |
817 | | |
818 | | sal_Int32 nVCLToolkitInstanceCount = 0; |
819 | | bool bInitedByVCLToolkit = false; |
820 | | |
821 | | osl::Mutex & getInitMutex() |
822 | 84.7k | { |
823 | 84.7k | static osl::Mutex aMutex; |
824 | 84.7k | return aMutex; |
825 | 84.7k | } |
826 | | |
827 | | osl::Condition & getInitCondition() |
828 | 12 | { |
829 | 12 | static osl::Condition aCondition; |
830 | 12 | return aCondition; |
831 | 12 | } |
832 | | |
833 | | extern "C" |
834 | | { |
835 | | static void ToolkitWorkerFunction( void* pArgs ) |
836 | 6 | { |
837 | 6 | osl_setThreadName("VCLXToolkit VCL main thread"); |
838 | | |
839 | 6 | css::uno::Reference<css::lang::XMultiServiceFactory> xServiceManager; |
840 | 6 | try |
841 | 6 | { |
842 | 6 | xServiceManager = ::comphelper::getProcessServiceFactory(); |
843 | 6 | } |
844 | 6 | catch (const css::uno::DeploymentException&) |
845 | 6 | { |
846 | 0 | } |
847 | 6 | if (!xServiceManager.is()) |
848 | 0 | { |
849 | 0 | css::uno::Reference<css::uno::XComponentContext> xContext = |
850 | 0 | ::cppu::defaultBootstrap_InitialComponentContext(); |
851 | |
|
852 | 0 | xServiceManager.set( xContext->getServiceManager(), css::uno::UNO_QUERY_THROW ); |
853 | | // set global process service factory used by unotools config helpers |
854 | 0 | ::comphelper::setProcessServiceFactory( xServiceManager ); |
855 | 0 | } |
856 | | |
857 | 6 | VCLXToolkit * pTk = static_cast<VCLXToolkit *>(pArgs); |
858 | 6 | bInitedByVCLToolkit = !IsVCLInit() && InitVCL(); |
859 | 6 | if( bInitedByVCLToolkit ) |
860 | 0 | { |
861 | 0 | UnoWrapper* pUnoWrapper = new UnoWrapper( pTk ); |
862 | 0 | UnoWrapperBase::SetUnoWrapper( pUnoWrapper ); |
863 | 0 | } |
864 | 6 | getInitCondition().set(); |
865 | 6 | if( bInitedByVCLToolkit ) |
866 | 0 | { |
867 | 0 | { |
868 | 0 | SolarMutexGuard aGuard; |
869 | 0 | Application::Execute(); |
870 | 0 | } |
871 | 0 | try |
872 | 0 | { |
873 | 0 | pTk->dispose(); |
874 | 0 | } |
875 | 0 | catch( css::uno::Exception & ) |
876 | 0 | { |
877 | 0 | } |
878 | 0 | DeInitVCL(); |
879 | 0 | } |
880 | 6 | else |
881 | 6 | { |
882 | | // having the thread join itself is pretty stupid. |
883 | | // but we can't get the osl_Thread to destroy here so just leak it. |
884 | 6 | } |
885 | 6 | } |
886 | | } // end extern |
887 | | |
888 | | #endif |
889 | | |
890 | | // constructor, which might initialize VCL |
891 | | VCLXToolkit::VCLXToolkit(): |
892 | 84.7k | m_aEventListenerLink(LINK(this, VCLXToolkit, eventListenerHandler)), |
893 | 84.7k | m_aKeyListenerLink(LINK(this, VCLXToolkit, keyListenerHandler)), |
894 | 84.7k | m_bEventListener(false), |
895 | 84.7k | m_bKeyListener(false) |
896 | 84.7k | { |
897 | 84.7k | #ifndef IOS |
898 | 84.7k | osl::Guard< osl::Mutex > aGuard( getInitMutex() ); |
899 | 84.7k | nVCLToolkitInstanceCount++; |
900 | 84.7k | if( nVCLToolkitInstanceCount == 1 && !Application::IsInMain() && |
901 | 6 | !comphelper::LibreOfficeKit::isActive() ) |
902 | 6 | { |
903 | | // setup execute thread |
904 | 6 | CreateMainLoopThread( ToolkitWorkerFunction, this ); |
905 | 6 | getInitCondition().wait(); |
906 | 6 | } |
907 | 84.7k | #endif |
908 | 84.7k | } |
909 | | |
910 | | void VCLXToolkit::disposing(std::unique_lock<std::mutex>& rGuard) |
911 | 0 | { |
912 | 0 | #ifndef IOS |
913 | 0 | rGuard.unlock(); |
914 | 0 | { |
915 | 0 | osl::Guard< osl::Mutex > aGuard( getInitMutex() ); |
916 | 0 | if( --nVCLToolkitInstanceCount == 0 ) |
917 | 0 | { |
918 | 0 | if( bInitedByVCLToolkit ) |
919 | 0 | { |
920 | 0 | Application::Quit(); |
921 | 0 | JoinMainLoopThread(); |
922 | 0 | bInitedByVCLToolkit = false; |
923 | 0 | } |
924 | 0 | } |
925 | 0 | } |
926 | 0 | rGuard.lock(); |
927 | 0 | #endif |
928 | 0 | if (m_bEventListener) |
929 | 0 | { |
930 | 0 | ::Application::RemoveEventListener(m_aEventListenerLink); |
931 | 0 | m_bEventListener = false; |
932 | 0 | } |
933 | 0 | if (m_bKeyListener) |
934 | 0 | { |
935 | 0 | ::Application::RemoveKeyListener(m_aKeyListenerLink); |
936 | 0 | m_bKeyListener = false; |
937 | 0 | } |
938 | 0 | css::lang::EventObject aEvent( |
939 | 0 | getXWeak()); |
940 | 0 | m_aTopWindowListeners.disposeAndClear(rGuard, aEvent); |
941 | 0 | m_aKeyHandlers.disposeAndClear(rGuard, aEvent); |
942 | 0 | m_aFocusListeners.disposeAndClear(rGuard, aEvent); |
943 | 0 | } |
944 | | |
945 | | |
946 | | css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::getDesktopWindow( ) |
947 | 0 | { |
948 | 0 | css::uno::Reference< css::awt::XWindowPeer > xRef; |
949 | | // 07/00: AppWindow doesn't exist anymore... |
950 | 0 | return xRef; |
951 | 0 | } |
952 | | |
953 | | css::awt::Rectangle VCLXToolkit::getWorkArea( ) |
954 | 0 | { |
955 | 0 | sal_Int32 nDisplay = Application::GetDisplayBuiltInScreen(); |
956 | 0 | AbsoluteScreenPixelRectangle aWorkRect = Application::GetScreenPosSizePixel( nDisplay ); |
957 | 0 | css::awt::Rectangle aNotherRect; |
958 | 0 | aNotherRect.X = aWorkRect.Left(); |
959 | 0 | aNotherRect.Y = aWorkRect.Top(); |
960 | 0 | aNotherRect.Width = aWorkRect.GetWidth(); |
961 | 0 | aNotherRect.Height = aWorkRect.GetHeight(); |
962 | 0 | return aNotherRect; |
963 | 0 | } |
964 | | |
965 | | css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::createWindow( const css::awt::WindowDescriptor& rDescriptor ) |
966 | 56.8k | { |
967 | 56.8k | return ImplCreateWindow( rDescriptor, MessBoxStyle::NONE ); |
968 | 56.8k | } |
969 | | |
970 | | css::uno::Reference< css::awt::XDevice > VCLXToolkit::createScreenCompatibleDevice( sal_Int32 Width, sal_Int32 Height ) |
971 | 0 | { |
972 | 0 | rtl::Reference<VCLXVirtualDevice> pVDev = new VCLXVirtualDevice; |
973 | |
|
974 | 0 | SolarMutexGuard aSolarGuard; |
975 | |
|
976 | 0 | VclPtrInstance<VirtualDevice> pV; |
977 | 0 | pV->SetOutputSizePixel( Size( Width, Height ) ); |
978 | 0 | pVDev->SetVirtualDevice( pV ); |
979 | |
|
980 | 0 | return pVDev; |
981 | 0 | } |
982 | | |
983 | | css::uno::Reference< css::awt::XRegion > VCLXToolkit::createRegion( ) |
984 | 0 | { |
985 | 0 | css::uno::Reference< css::awt::XRegion > xRef = new VCLXRegion; |
986 | 0 | return xRef; |
987 | 0 | } |
988 | | |
989 | | class InfoBox : public MessBox |
990 | | { |
991 | | public: |
992 | | InfoBox(vcl::Window* pParent, const OUString& rMessage) |
993 | 0 | : MessBox(pParent, MessBoxStyle::Ok | MessBoxStyle::DefaultOk, 0, OUString(), rMessage) |
994 | 0 | { |
995 | | // Default Text is the display title from the application |
996 | 0 | if (GetText().isEmpty()) |
997 | 0 | SetText(GetStandardInfoBoxText()); |
998 | 0 | SetImage(GetStandardInfoBoxImage()); |
999 | 0 | } |
1000 | | }; |
1001 | | |
1002 | | class ErrorBox : public MessBox |
1003 | | { |
1004 | | public: |
1005 | | ErrorBox(vcl::Window* pParent, MessBoxStyle nStyle, WinBits nWinBits, const OUString& rMessage) |
1006 | 0 | : MessBox(pParent, nStyle, nWinBits, OUString(), rMessage) |
1007 | 0 | { |
1008 | | // Default Text is the display title from the application |
1009 | 0 | if (GetText().isEmpty()) |
1010 | 0 | SetText(GetStandardErrorBoxText()); |
1011 | 0 | SetImage(GetStandardErrorBoxImage()); |
1012 | 0 | } |
1013 | | }; |
1014 | | |
1015 | | class QueryBox : public MessBox |
1016 | | { |
1017 | | public: |
1018 | | QueryBox(vcl::Window* pParent, MessBoxStyle nStyle, WinBits nWinBits, const OUString& rMessage) |
1019 | 0 | : MessBox(pParent, nStyle, nWinBits, OUString(), rMessage) |
1020 | 0 | { |
1021 | | // Default Text is the display title from the application |
1022 | 0 | if (GetText().isEmpty()) |
1023 | 0 | SetText(GetStandardQueryBoxText()); |
1024 | 0 | SetImage(GetStandardQueryBoxImage()); |
1025 | 0 | } |
1026 | | }; |
1027 | | |
1028 | | class WarningBox : public MessBox |
1029 | | { |
1030 | | public: |
1031 | | WarningBox(vcl::Window* pParent, MessBoxStyle nStyle, WinBits nWinBits, const OUString& rMessage) |
1032 | 0 | : MessBox(pParent, nStyle, nWinBits, OUString(), rMessage) |
1033 | 0 | { |
1034 | | // Default Text is the display title from the application |
1035 | 0 | if (GetText().isEmpty()) |
1036 | 0 | SetText(GetStandardWarningBoxText()); |
1037 | 0 | SetImage(GetStandardWarningBoxImage()); |
1038 | 0 | } |
1039 | | }; |
1040 | | |
1041 | | |
1042 | | struct RMItemData |
1043 | | { |
1044 | | bool b_Enabled; |
1045 | | sal_Int32 n_ID; |
1046 | | OUString Label; |
1047 | | }; |
1048 | | |
1049 | | typedef ::cppu::ImplInheritanceHelper < VCLXGraphicControl |
1050 | | , css::container::XContainerListener |
1051 | | , css::beans::XPropertyChangeListener |
1052 | | , css::awt::XItemEventBroadcaster |
1053 | | > SVTXRoadmap_Base; |
1054 | | class SVTXRoadmap final : public SVTXRoadmap_Base |
1055 | | { |
1056 | | public: |
1057 | | SVTXRoadmap(); |
1058 | | |
1059 | 0 | void SAL_CALL disposing(const css::lang::EventObject&) override { } |
1060 | | |
1061 | | // css::awt::XVclWindowPeer |
1062 | | void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; |
1063 | | |
1064 | | css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; |
1065 | | |
1066 | | // XContainerListener |
1067 | | void SAL_CALL elementInserted( const css::container::ContainerEvent& rEvent ) override; |
1068 | | void SAL_CALL elementRemoved( const css::container::ContainerEvent& rEvent ) override; |
1069 | | void SAL_CALL elementReplaced( const css::container::ContainerEvent& rEvent ) override; |
1070 | | |
1071 | | // XItemEventBroadcaster |
1072 | | virtual void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; |
1073 | | virtual void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; |
1074 | | |
1075 | | // XPropertyChangeListener |
1076 | | virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& evt ) override; |
1077 | | |
1078 | | private: |
1079 | | |
1080 | | // VCLXGraphicControl overridables |
1081 | | virtual void ImplSetNewImage() override; |
1082 | | |
1083 | | static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); |
1084 | 0 | virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } |
1085 | | |
1086 | | static RMItemData GetRMItemData( const css::container::ContainerEvent& _rEvent ); |
1087 | | |
1088 | | virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; |
1089 | | |
1090 | | virtual ~SVTXRoadmap() override; |
1091 | | |
1092 | | ItemListenerMultiplexer maItemListeners; |
1093 | | }; |
1094 | | |
1095 | | |
1096 | | |
1097 | | |
1098 | 0 | SVTXRoadmap::SVTXRoadmap() : maItemListeners( *this ) |
1099 | 0 | { |
1100 | 0 | } |
1101 | | |
1102 | | SVTXRoadmap::~SVTXRoadmap() |
1103 | 0 | { |
1104 | 0 | } |
1105 | | |
1106 | | void SVTXRoadmap::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) |
1107 | 0 | { |
1108 | 0 | switch ( rVclWindowEvent.GetId() ) |
1109 | 0 | { |
1110 | 0 | case VclEventId::RoadmapItemSelected: |
1111 | 0 | { |
1112 | 0 | SolarMutexGuard aGuard; |
1113 | 0 | VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); |
1114 | 0 | if ( pField ) |
1115 | 0 | { |
1116 | 0 | sal_Int16 CurItemID = pField->GetCurrentRoadmapItemID(); |
1117 | 0 | css::awt::ItemEvent aEvent; |
1118 | 0 | aEvent.Selected = CurItemID; |
1119 | 0 | aEvent.Highlighted = CurItemID; |
1120 | 0 | aEvent.ItemId = CurItemID; |
1121 | 0 | maItemListeners.itemStateChanged( aEvent ); |
1122 | 0 | } |
1123 | 0 | } |
1124 | 0 | break; |
1125 | 0 | default: |
1126 | 0 | SVTXRoadmap_Base::ProcessWindowEvent( rVclWindowEvent ); |
1127 | 0 | break; |
1128 | 0 | } |
1129 | 0 | } |
1130 | | |
1131 | | void SVTXRoadmap::propertyChange( const css::beans::PropertyChangeEvent& evt ) |
1132 | 0 | { |
1133 | 0 | SolarMutexGuard aGuard; |
1134 | 0 | VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); |
1135 | 0 | if ( !pField ) |
1136 | 0 | return; |
1137 | | |
1138 | 0 | css::uno::Reference< css::uno::XInterface > xRoadmapItem = evt.Source; |
1139 | 0 | sal_Int32 nID = 0; |
1140 | 0 | css::uno::Reference< css::beans::XPropertySet > xPropertySet( xRoadmapItem, css::uno::UNO_QUERY ); |
1141 | 0 | css::uno::Any aValue = xPropertySet->getPropertyValue(u"ID"_ustr); |
1142 | 0 | aValue >>= nID; |
1143 | |
|
1144 | 0 | OUString sPropertyName = evt.PropertyName; |
1145 | 0 | if ( sPropertyName == "Enabled" ) |
1146 | 0 | { |
1147 | 0 | bool bEnable = false; |
1148 | 0 | evt.NewValue >>= bEnable; |
1149 | 0 | pField->EnableRoadmapItem( static_cast<vcl::RoadmapTypes::ItemId>(nID) , bEnable ); |
1150 | 0 | } |
1151 | 0 | else if ( sPropertyName == "Label" ) |
1152 | 0 | { |
1153 | 0 | OUString sLabel; |
1154 | 0 | evt.NewValue >>= sLabel; |
1155 | 0 | pField->ChangeRoadmapItemLabel( static_cast<vcl::RoadmapTypes::ItemId>(nID) , sLabel ); |
1156 | 0 | } |
1157 | 0 | else if ( sPropertyName == "ID" ) |
1158 | 0 | { |
1159 | 0 | sal_Int32 nNewID = 0; |
1160 | 0 | evt.NewValue >>= nNewID; |
1161 | 0 | evt.OldValue >>= nID; |
1162 | 0 | pField->ChangeRoadmapItemID( static_cast<vcl::RoadmapTypes::ItemId>(nID), static_cast<vcl::RoadmapTypes::ItemId>(nNewID) ); |
1163 | 0 | } |
1164 | | // else |
1165 | | // TODO handle Interactive appropriately |
1166 | 0 | } |
1167 | | |
1168 | | void SVTXRoadmap::addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) |
1169 | 0 | { |
1170 | 0 | maItemListeners.addInterface( l ); |
1171 | 0 | } |
1172 | | |
1173 | | void SVTXRoadmap::removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) |
1174 | 0 | { |
1175 | 0 | maItemListeners.removeInterface( l ); |
1176 | 0 | } |
1177 | | |
1178 | | RMItemData SVTXRoadmap::GetRMItemData( const css::container::ContainerEvent& _rEvent ) |
1179 | 0 | { |
1180 | 0 | RMItemData aCurRMItemData; |
1181 | 0 | css::uno::Reference< css::uno::XInterface > xRoadmapItem; |
1182 | 0 | _rEvent.Element >>= xRoadmapItem; |
1183 | 0 | css::uno::Reference< css::beans::XPropertySet > xPropertySet( xRoadmapItem, css::uno::UNO_QUERY ); |
1184 | 0 | if ( xPropertySet.is() ) |
1185 | 0 | { |
1186 | 0 | css::uno::Any aValue = xPropertySet->getPropertyValue(u"Label"_ustr); |
1187 | 0 | aValue >>= aCurRMItemData.Label; |
1188 | 0 | aValue = xPropertySet->getPropertyValue(u"ID"_ustr); |
1189 | 0 | aValue >>= aCurRMItemData.n_ID; |
1190 | 0 | aValue = xPropertySet->getPropertyValue(u"Enabled"_ustr); |
1191 | 0 | aValue >>= aCurRMItemData.b_Enabled; |
1192 | 0 | } |
1193 | 0 | else |
1194 | 0 | { |
1195 | 0 | aCurRMItemData.b_Enabled = false; |
1196 | 0 | aCurRMItemData.n_ID = 0; |
1197 | 0 | } |
1198 | 0 | return aCurRMItemData; |
1199 | 0 | } |
1200 | | |
1201 | | void SVTXRoadmap::elementInserted( const css::container::ContainerEvent& _rEvent ) |
1202 | 0 | { |
1203 | 0 | SolarMutexGuard aGuard; |
1204 | 0 | VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); |
1205 | 0 | if ( pField ) |
1206 | 0 | { |
1207 | 0 | RMItemData CurItemData = GetRMItemData( _rEvent ); |
1208 | 0 | sal_Int32 InsertIndex = 0; |
1209 | 0 | _rEvent.Accessor >>= InsertIndex; |
1210 | 0 | pField->InsertRoadmapItem( InsertIndex, CurItemData.Label, static_cast<vcl::RoadmapTypes::ItemId>(CurItemData.n_ID), CurItemData.b_Enabled ); |
1211 | 0 | } |
1212 | 0 | } |
1213 | | |
1214 | | void SVTXRoadmap::elementRemoved( const css::container::ContainerEvent& _rEvent ) |
1215 | 0 | { |
1216 | 0 | SolarMutexGuard aGuard; |
1217 | 0 | VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); |
1218 | 0 | if ( pField ) |
1219 | 0 | { |
1220 | 0 | sal_Int32 DelIndex = 0; |
1221 | 0 | _rEvent.Accessor >>= DelIndex; |
1222 | 0 | pField->DeleteRoadmapItem(DelIndex); |
1223 | 0 | } |
1224 | 0 | } |
1225 | | |
1226 | | void SVTXRoadmap::elementReplaced( const css::container::ContainerEvent& _rEvent ) |
1227 | 0 | { |
1228 | 0 | SolarMutexGuard aGuard; |
1229 | 0 | VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); |
1230 | 0 | if ( pField ) |
1231 | 0 | { |
1232 | 0 | RMItemData CurItemData = GetRMItemData( _rEvent ); |
1233 | 0 | sal_Int32 ReplaceIndex = 0; |
1234 | 0 | _rEvent.Accessor >>= ReplaceIndex; |
1235 | 0 | pField->ReplaceRoadmapItem( ReplaceIndex, CurItemData.Label, static_cast<vcl::RoadmapTypes::ItemId>(CurItemData.n_ID), CurItemData.b_Enabled ); |
1236 | 0 | } |
1237 | 0 | } |
1238 | | |
1239 | | void SVTXRoadmap::setProperty( const OUString& PropertyName, const css::uno::Any& Value) |
1240 | 0 | { |
1241 | 0 | SolarMutexGuard aGuard; |
1242 | |
|
1243 | 0 | VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); |
1244 | 0 | if ( pField ) |
1245 | 0 | { |
1246 | 0 | sal_uInt16 nPropType = GetPropertyId( PropertyName ); |
1247 | 0 | switch (nPropType) |
1248 | 0 | { |
1249 | 0 | case BASEPROPERTY_COMPLETE: |
1250 | 0 | { |
1251 | 0 | bool b = false; |
1252 | 0 | Value >>= b; |
1253 | 0 | pField->SetRoadmapComplete( b); |
1254 | 0 | } |
1255 | 0 | break; |
1256 | | |
1257 | 0 | case BASEPROPERTY_ACTIVATED: |
1258 | 0 | { |
1259 | 0 | bool b = false; |
1260 | 0 | Value >>= b; |
1261 | 0 | pField->SetRoadmapInteractive( b); |
1262 | 0 | } |
1263 | 0 | break; |
1264 | | |
1265 | 0 | case BASEPROPERTY_CURRENTITEMID: |
1266 | 0 | { |
1267 | 0 | sal_Int32 nId = 0; |
1268 | 0 | Value >>= nId; |
1269 | 0 | pField->SelectRoadmapItemByID( static_cast<vcl::RoadmapTypes::ItemId>(nId) ); |
1270 | 0 | } |
1271 | 0 | break; |
1272 | | |
1273 | 0 | case BASEPROPERTY_TEXT: |
1274 | 0 | { |
1275 | 0 | OUString aStr; |
1276 | 0 | Value >>= aStr; |
1277 | 0 | pField->SetText( aStr ); |
1278 | 0 | pField->Invalidate(); |
1279 | 0 | } |
1280 | 0 | break; |
1281 | | |
1282 | 0 | default: |
1283 | 0 | SVTXRoadmap_Base::setProperty( PropertyName, Value ); |
1284 | 0 | break; |
1285 | 0 | } |
1286 | |
|
1287 | 0 | } |
1288 | 0 | else |
1289 | 0 | SVTXRoadmap_Base::setProperty( PropertyName, Value ); |
1290 | 0 | } |
1291 | | |
1292 | | |
1293 | | css::uno::Any SVTXRoadmap::getProperty( const OUString& PropertyName ) |
1294 | 0 | { |
1295 | 0 | SolarMutexGuard aGuard; |
1296 | |
|
1297 | 0 | css::uno::Any aReturn; |
1298 | |
|
1299 | 0 | VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); |
1300 | 0 | if ( pField ) |
1301 | 0 | { |
1302 | 0 | sal_uInt16 nPropType = GetPropertyId( PropertyName ); |
1303 | 0 | switch (nPropType) |
1304 | 0 | { |
1305 | 0 | case BASEPROPERTY_COMPLETE: |
1306 | 0 | aReturn <<= pField->IsRoadmapComplete(); |
1307 | 0 | break; |
1308 | 0 | case BASEPROPERTY_ACTIVATED: |
1309 | 0 | aReturn <<= pField->IsRoadmapInteractive(); |
1310 | 0 | break; |
1311 | 0 | case BASEPROPERTY_CURRENTITEMID: |
1312 | 0 | aReturn <<= pField->GetCurrentRoadmapItemID(); |
1313 | 0 | break; |
1314 | 0 | default: |
1315 | 0 | aReturn = SVTXRoadmap_Base::getProperty(PropertyName); |
1316 | 0 | break; |
1317 | 0 | } |
1318 | 0 | } |
1319 | 0 | return aReturn; |
1320 | 0 | } |
1321 | | |
1322 | | void SVTXRoadmap::ImplSetNewImage() |
1323 | 0 | { |
1324 | 0 | OSL_PRECOND( GetWindow(), "SVTXRoadmap::ImplSetNewImage: window is required to be not-NULL!" ); |
1325 | 0 | VclPtr< ::vcl::ORoadmap > pButton = GetAs< ::vcl::ORoadmap >(); |
1326 | 0 | pButton->SetRoadmapBitmap( GetImage().GetBitmap() ); |
1327 | 0 | } |
1328 | | |
1329 | | void SVTXRoadmap::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) |
1330 | 0 | { |
1331 | 0 | PushPropertyIds( rIds, |
1332 | 0 | BASEPROPERTY_COMPLETE, |
1333 | 0 | BASEPROPERTY_ACTIVATED, |
1334 | 0 | BASEPROPERTY_CURRENTITEMID, |
1335 | 0 | BASEPROPERTY_TEXT, |
1336 | 0 | 0); |
1337 | 0 | VCLXWindow::ImplGetPropertyIds( rIds, true ); |
1338 | 0 | VCLXGraphicControl::ImplGetPropertyIds( rIds ); |
1339 | 0 | } |
1340 | | |
1341 | | vcl::Window* VCLXToolkit::ImplCreateWindow( rtl::Reference<VCLXWindow>* ppNewComp, |
1342 | | const css::awt::WindowDescriptor& rDescriptor, |
1343 | | vcl::Window* pParent, WinBits nWinBits, MessBoxStyle nMessBoxStyle ) |
1344 | 56.8k | { |
1345 | 56.8k | OUString aServiceName = rDescriptor.WindowServiceName.toAsciiLowerCase(); |
1346 | | |
1347 | 56.8k | VclPtr<vcl::Window> pNewWindow; |
1348 | 56.8k | WindowType eType = ImplGetComponentType( aServiceName ); |
1349 | 56.8k | bool bFrameControl = false; |
1350 | 56.8k | if ( aServiceName == "frame" ) |
1351 | 0 | bFrameControl = true; |
1352 | 56.8k | if ( aServiceName == "tabcontrolnotabs" ) |
1353 | 0 | { |
1354 | 0 | nWinBits |= WB_NOBORDER; |
1355 | 0 | eType = ImplGetComponentType( u"tabcontrol"_ustr ); |
1356 | 0 | } |
1357 | 56.8k | if ( !pParent ) |
1358 | 8.22k | { |
1359 | | // If the component needs a parent, then return NULL, |
1360 | | // some time later css::uno::Exception... |
1361 | 8.22k | bool bException = true; |
1362 | 8.22k | if ( ( eType == WindowType::DIALOG ) |
1363 | 8.22k | || ( eType == WindowType::MODELESSDIALOG ) |
1364 | 8.22k | || ( eType == WindowType::MESSBOX ) |
1365 | 8.22k | || ( eType == WindowType::INFOBOX ) |
1366 | 8.22k | || ( eType == WindowType::WARNINGBOX ) |
1367 | 8.22k | || ( eType == WindowType::ERRORBOX ) |
1368 | 8.22k | || ( eType == WindowType::QUERYBOX ) |
1369 | 8.22k | ) |
1370 | 0 | bException = false; |
1371 | 8.22k | else if ( ( eType == WindowType::WINDOW ) || |
1372 | 0 | ( eType == WindowType::WORKWINDOW ) || |
1373 | 0 | ( eType == WindowType::TOOLKIT_FRAMEWINDOW ) ) |
1374 | 8.22k | { |
1375 | 8.22k | if ( rDescriptor.Type == css::awt::WindowClass_TOP ) |
1376 | 8.22k | bException = false; |
1377 | 8.22k | } |
1378 | | |
1379 | 8.22k | if ( bException ) |
1380 | 0 | { |
1381 | 0 | *ppNewComp = nullptr; |
1382 | 0 | return nullptr; |
1383 | 0 | } |
1384 | 8.22k | } |
1385 | | |
1386 | 56.8k | if ( eType != WindowType::NONE ) |
1387 | 56.8k | { |
1388 | 56.8k | SolarMutexGuard aVclGuard; |
1389 | 56.8k | switch ( eType ) |
1390 | 56.8k | { |
1391 | 0 | case WindowType::CANCELBUTTON: |
1392 | 0 | pNewWindow = VclPtr<CancelButton>::Create( pParent, nWinBits ); |
1393 | 0 | *ppNewComp = new VCLXButton; |
1394 | 0 | break; |
1395 | 0 | case WindowType::CHECKBOX: |
1396 | 0 | pNewWindow = VclPtr<CheckBox>::Create( pParent, nWinBits ); |
1397 | 0 | *ppNewComp = new VCLXCheckBox; |
1398 | 0 | break; |
1399 | 0 | case WindowType::COMBOBOX: |
1400 | 0 | pNewWindow = VclPtr<ComboBox>::Create( pParent, nWinBits|WB_AUTOHSCROLL ); |
1401 | 0 | static_cast<ComboBox*>(pNewWindow.get())->EnableAutoSize( false ); |
1402 | 0 | *ppNewComp = new VCLXComboBox; |
1403 | 0 | break; |
1404 | 0 | case WindowType::CURRENCYBOX: |
1405 | 0 | pNewWindow = VclPtr<CurrencyBox>::Create( pParent, nWinBits ); |
1406 | 0 | break; |
1407 | 0 | case WindowType::CURRENCYFIELD: |
1408 | 0 | pNewWindow = VclPtr<CurrencyField>::Create( pParent, nWinBits ); |
1409 | 0 | static_cast<CurrencyField*>(pNewWindow.get())->EnableEmptyFieldValue( true ); |
1410 | 0 | *ppNewComp = new VCLXNumericField; |
1411 | 0 | static_cast<VCLXFormattedSpinField*>((*ppNewComp).get())->SetFormatter( static_cast<FormatterBase*>(static_cast<CurrencyField*>(pNewWindow.get())) ); |
1412 | 0 | break; |
1413 | 0 | case WindowType::DATEBOX: |
1414 | 0 | pNewWindow = VclPtr<DateBox>::Create( pParent, nWinBits ); |
1415 | 0 | break; |
1416 | 48.6k | case WindowType::DOCKINGAREA: |
1417 | 48.6k | pNewWindow = VclPtr<DockingAreaWindow>::Create( pParent ); |
1418 | 48.6k | break; |
1419 | 0 | case WindowType::MULTILINEEDIT: |
1420 | 0 | pNewWindow = VclPtr<MultiLineEdit>::Create(pParent, nWinBits|WB_IGNORETAB); |
1421 | 0 | static_cast<MultiLineEdit*>(pNewWindow.get())->DisableSelectionOnFocus(); |
1422 | 0 | *ppNewComp = new VCLXMultiLineEdit; |
1423 | 0 | break; |
1424 | 0 | case WindowType::EDIT: |
1425 | 0 | pNewWindow = VclPtr<Edit>::Create( pParent, nWinBits ); |
1426 | 0 | *ppNewComp = new VCLXEdit; |
1427 | 0 | break; |
1428 | 0 | case WindowType::ERRORBOX: |
1429 | 0 | pNewWindow = VclPtr<ErrorBox>::Create( pParent, nMessBoxStyle, nWinBits, OUString() ); |
1430 | 0 | *ppNewComp = new VCLXMessageBox; |
1431 | 0 | break; |
1432 | 0 | case WindowType::FIXEDBITMAP: |
1433 | 0 | pNewWindow = VclPtr<FixedBitmap>::Create( pParent, nWinBits ); |
1434 | 0 | break; |
1435 | 0 | case WindowType::FIXEDIMAGE: |
1436 | 0 | pNewWindow = VclPtr<ImageControl>::Create( pParent, nWinBits ); |
1437 | 0 | *ppNewComp = new VCLXImageControl; |
1438 | 0 | break; |
1439 | 0 | case WindowType::FIXEDLINE: |
1440 | 0 | pNewWindow = VclPtr<FixedLine>::Create( pParent, nWinBits ); |
1441 | 0 | break; |
1442 | 0 | case WindowType::FIXEDTEXT: |
1443 | 0 | pNewWindow = VclPtr<FixedText>::Create( pParent, nWinBits ); |
1444 | 0 | *ppNewComp = new VCLXFixedText; |
1445 | 0 | break; |
1446 | 0 | case WindowType::FLOATINGWINDOW: |
1447 | 0 | pNewWindow = VclPtr<FloatingWindow>::Create( pParent, nWinBits ); |
1448 | 0 | break; |
1449 | 0 | case WindowType::GROUPBOX: |
1450 | 0 | pNewWindow = VclPtr<GroupBox>::Create( pParent, nWinBits ); |
1451 | 0 | if ( bFrameControl ) |
1452 | 0 | { |
1453 | 0 | GroupBox* pGroupBox = static_cast< GroupBox* >( pNewWindow.get() ); |
1454 | 0 | *ppNewComp = new VCLXFrame; |
1455 | | // Frame control needs to receive |
1456 | | // Mouse events |
1457 | 0 | pGroupBox->SetMouseTransparent( false ); |
1458 | 0 | } |
1459 | 0 | break; |
1460 | 0 | case WindowType::HELPBUTTON: |
1461 | 0 | pNewWindow = VclPtr<HelpButton>::Create( pParent, nWinBits ); |
1462 | 0 | *ppNewComp = new VCLXButton; |
1463 | 0 | break; |
1464 | 0 | case WindowType::IMAGEBUTTON: |
1465 | 0 | pNewWindow = VclPtr<ImageButton>::Create( pParent, nWinBits ); |
1466 | 0 | *ppNewComp = new VCLXButton; |
1467 | 0 | break; |
1468 | 0 | case WindowType::INFOBOX: |
1469 | 0 | pNewWindow = VclPtr<InfoBox>::Create( pParent, OUString() ); |
1470 | 0 | *ppNewComp = new VCLXMessageBox; |
1471 | 0 | break; |
1472 | 0 | case WindowType::LISTBOX: |
1473 | 0 | pNewWindow = VclPtr<ListBox>::Create( pParent, nWinBits|WB_SIMPLEMODE|WB_AUTOHSCROLL ); |
1474 | 0 | static_cast<ListBox*>(pNewWindow.get())->EnableAutoSize( false ); |
1475 | 0 | *ppNewComp = new VCLXListBox; |
1476 | 0 | break; |
1477 | 0 | case WindowType::LONGCURRENCYBOX: |
1478 | 0 | pNewWindow = VclPtr<LongCurrencyBox>::Create( pParent, nWinBits ); |
1479 | 0 | break; |
1480 | 0 | case WindowType::MENUBUTTON: |
1481 | 0 | pNewWindow = VclPtr<MenuButton>::Create( pParent, nWinBits ); |
1482 | 0 | *ppNewComp = new VCLXButton; |
1483 | 0 | break; |
1484 | 0 | case WindowType::MESSBOX: |
1485 | 0 | pNewWindow = VclPtr<MessBox>::Create( pParent, nMessBoxStyle, nWinBits, OUString(), OUString() ); |
1486 | 0 | *ppNewComp = new VCLXMessageBox; |
1487 | 0 | break; |
1488 | 0 | case WindowType::METRICBOX: |
1489 | 0 | pNewWindow = VclPtr<MetricBox>::Create( pParent, nWinBits ); |
1490 | 0 | break; |
1491 | 0 | case WindowType::METRICFIELD: |
1492 | 0 | pNewWindow = VclPtr<MetricField>::Create( pParent, nWinBits ); |
1493 | 0 | *ppNewComp = new VCLXMetricField; |
1494 | 0 | static_cast<VCLXFormattedSpinField*>((*ppNewComp).get())->SetFormatter( static_cast<FormatterBase*>(static_cast<MetricField*>(pNewWindow.get())) ); |
1495 | 0 | break; |
1496 | 0 | case WindowType::DIALOG: |
1497 | 0 | case WindowType::MODELESSDIALOG: |
1498 | 0 | { |
1499 | | // Modal/Modeless only via Show/Execute |
1500 | 0 | if ( (pParent == nullptr ) && ( rDescriptor.ParentIndex == -1 ) ) |
1501 | 0 | pNewWindow = VclPtr<toolkit::ScrollableDialog>::Create( nullptr, nWinBits, Dialog::InitFlag::NoParent ); |
1502 | 0 | else |
1503 | 0 | pNewWindow = VclPtr<toolkit::ScrollableDialog>::Create( pParent, nWinBits ); |
1504 | | // #i70217# Don't always create a new component object. It's possible that VCL has called |
1505 | | // GetComponentInterface( sal_True ) in the Dialog ctor itself (see Window::IsTopWindow() ) |
1506 | | // which creates a component object. |
1507 | 0 | css::uno::Reference< css::awt::XWindowPeer > xWinPeer = pNewWindow->GetComponentInterface( false ); |
1508 | 0 | if ( xWinPeer.is() ) |
1509 | 0 | *ppNewComp = dynamic_cast< VCLXDialog* >( xWinPeer.get() ); |
1510 | 0 | else |
1511 | 0 | *ppNewComp = new VCLXDialog; |
1512 | 0 | } |
1513 | 0 | break; |
1514 | 0 | case WindowType::MOREBUTTON: |
1515 | 0 | pNewWindow = VclPtr<MoreButton>::Create( pParent, nWinBits ); |
1516 | 0 | *ppNewComp = new VCLXButton; |
1517 | 0 | break; |
1518 | 0 | case WindowType::MULTILISTBOX: |
1519 | 0 | pNewWindow = VclPtr<MultiListBox>::Create( pParent, nWinBits ); |
1520 | 0 | *ppNewComp = new VCLXListBox; |
1521 | 0 | break; |
1522 | 0 | case WindowType::NUMERICBOX: |
1523 | 0 | pNewWindow = VclPtr<NumericBox>::Create( pParent, nWinBits ); |
1524 | 0 | break; |
1525 | 0 | case WindowType::OKBUTTON: |
1526 | 0 | pNewWindow = VclPtr<OKButton>::Create( pParent, nWinBits ); |
1527 | 0 | *ppNewComp = new VCLXButton; |
1528 | 0 | break; |
1529 | 0 | case WindowType::PATTERNBOX: |
1530 | 0 | pNewWindow = VclPtr<PatternBox>::Create( pParent, nWinBits ); |
1531 | 0 | break; |
1532 | 0 | case WindowType::PATTERNFIELD: |
1533 | 0 | pNewWindow = VclPtr<PatternField>::Create( pParent, nWinBits ); |
1534 | 0 | *ppNewComp = new VCLXPatternField; |
1535 | 0 | static_cast<VCLXFormattedSpinField*>((*ppNewComp).get())->SetFormatter( static_cast<FormatterBase*>(static_cast<PatternField*>(pNewWindow.get())) ); |
1536 | 0 | break; |
1537 | 0 | case WindowType::PUSHBUTTON: |
1538 | 0 | pNewWindow = VclPtr<PushButton>::Create( pParent, nWinBits ); |
1539 | 0 | *ppNewComp = new VCLXButton; |
1540 | 0 | break; |
1541 | 0 | case WindowType::QUERYBOX: |
1542 | 0 | pNewWindow = VclPtr<QueryBox>::Create( pParent, nMessBoxStyle, nWinBits, OUString() ); |
1543 | 0 | *ppNewComp = new VCLXMessageBox; |
1544 | 0 | break; |
1545 | 0 | case WindowType::RADIOBUTTON: |
1546 | 0 | pNewWindow = VclPtr<RadioButton>::Create(pParent, false, nWinBits); |
1547 | 0 | *ppNewComp = new VCLXRadioButton; |
1548 | | |
1549 | | // by default, disable RadioCheck |
1550 | | // Since the VCLXRadioButton really cares for its RadioCheck settings, this is important: |
1551 | | // if we enable it, the VCLXRadioButton will use RadioButton::Check instead of RadioButton::SetState |
1552 | | // This leads to a strange behaviour if the control is newly created: when settings the initial |
1553 | | // state to "checked", the RadioButton::Check (called because RadioCheck=sal_True) will uncheck |
1554 | | // _all_other_ radio buttons in the same group. However, at this moment the grouping of the controls |
1555 | | // is not really valid: the controls are grouped after they have been created, but we're still in |
1556 | | // the creation process, so the RadioButton::Check relies on invalid grouping information. |
1557 | | // 07.08.2001 - #87254# - frank.schoenheit@sun.com |
1558 | 0 | static_cast<RadioButton*>(pNewWindow.get())->EnableRadioCheck( false ); |
1559 | 0 | break; |
1560 | 0 | case WindowType::SCROLLBAR: |
1561 | 0 | pNewWindow = VclPtr<ScrollBar>::Create( pParent, nWinBits ); |
1562 | 0 | *ppNewComp = new VCLXScrollBar; |
1563 | 0 | break; |
1564 | 0 | case WindowType::SCROLLBARBOX: |
1565 | 0 | pNewWindow = VclPtr<ScrollBarBox>::Create( pParent, nWinBits ); |
1566 | 0 | break; |
1567 | 0 | case WindowType::SPINBUTTON: |
1568 | 0 | pNewWindow = VclPtr<SpinButton>::Create( pParent, nWinBits ); |
1569 | 0 | *ppNewComp = new ::toolkit::VCLXSpinButton; |
1570 | 0 | break; |
1571 | 0 | case WindowType::SPINFIELD: |
1572 | 0 | pNewWindow = VclPtr<SpinField>::Create( pParent, nWinBits ); |
1573 | 0 | *ppNewComp = new VCLXNumericField; |
1574 | 0 | break; |
1575 | 0 | case WindowType::SPLITTER: |
1576 | 0 | pNewWindow = VclPtr<Splitter>::Create( pParent, nWinBits ); |
1577 | 0 | break; |
1578 | 0 | case WindowType::SPLITWINDOW: |
1579 | 0 | pNewWindow = VclPtr<SplitWindow>::Create( pParent, nWinBits ); |
1580 | 0 | break; |
1581 | 0 | case WindowType::STATUSBAR: |
1582 | 0 | pNewWindow = VclPtr<StatusBar>::Create( pParent, nWinBits ); |
1583 | 0 | break; |
1584 | 0 | case WindowType::TOOLKIT_SYSTEMCHILDWINDOW: |
1585 | 0 | pNewWindow = VclPtr<SystemChildWindow>::Create( pParent, nWinBits ); |
1586 | 0 | *ppNewComp = new VCLXSystemDependentWindow(); |
1587 | 0 | break; |
1588 | 0 | case WindowType::TABCONTROL: |
1589 | 0 | pNewWindow = VclPtr<TabControl>::Create( pParent, nWinBits ); |
1590 | 0 | *ppNewComp = new VCLXMultiPage; |
1591 | 0 | break; |
1592 | 0 | case WindowType::TABDIALOG: |
1593 | 0 | pNewWindow = VclPtr<TabDialog>::Create( pParent, nWinBits ); |
1594 | 0 | break; |
1595 | 0 | case WindowType::TABPAGE: |
1596 | 0 | { |
1597 | 0 | pNewWindow = VclPtr<TabPage>::Create( pParent, nWinBits ); |
1598 | 0 | *ppNewComp = new VCLXTabPage; |
1599 | 0 | } |
1600 | 0 | break; |
1601 | 0 | case WindowType::TIMEBOX: |
1602 | 0 | pNewWindow = VclPtr<TimeBox>::Create( pParent, nWinBits ); |
1603 | 0 | break; |
1604 | 0 | case WindowType::TIMEFIELD: |
1605 | 0 | pNewWindow = VclPtr<TimeField>::Create( pParent, nWinBits ); |
1606 | 0 | static_cast<TimeField*>(pNewWindow.get())->EnableEmptyFieldValue( true ); |
1607 | 0 | *ppNewComp = new VCLXTimeField; |
1608 | 0 | static_cast<VCLXFormattedSpinField*>((*ppNewComp).get())->SetFormatter( static_cast<FormatterBase*>(static_cast<TimeField*>(pNewWindow.get())) ); |
1609 | 0 | break; |
1610 | 0 | case WindowType::TOOLBOX: |
1611 | 0 | pNewWindow = VclPtr<ToolBox>::Create( pParent, nWinBits ); |
1612 | 0 | *ppNewComp = new VCLXWindow; |
1613 | 0 | break; |
1614 | 0 | case WindowType::TRISTATEBOX: |
1615 | 0 | pNewWindow = VclPtr<CheckBox>::Create( pParent, nWinBits ); |
1616 | 0 | static_cast<CheckBox*>(pNewWindow.get())->EnableTriState(true); |
1617 | 0 | break; |
1618 | 0 | case WindowType::WARNINGBOX: |
1619 | 0 | pNewWindow = VclPtr<WarningBox>::Create( pParent, nMessBoxStyle, nWinBits, OUString() ); |
1620 | 0 | *ppNewComp = new VCLXMessageBox; |
1621 | 0 | break; |
1622 | 0 | case WindowType::WORKWINDOW: |
1623 | 8.22k | case WindowType::WINDOW: |
1624 | 8.22k | case WindowType::TOOLKIT_FRAMEWINDOW: |
1625 | 8.22k | case WindowType::DOCKINGWINDOW: |
1626 | 8.22k | if ( rDescriptor.Type == css::awt::WindowClass_TOP ) |
1627 | 8.22k | { |
1628 | 8.22k | if (eType == WindowType::DOCKINGWINDOW ) |
1629 | 0 | pNewWindow = VclPtr<DockingWindow>::Create( pParent, nWinBits ); |
1630 | 8.22k | else |
1631 | 8.22k | { |
1632 | 8.22k | if ((pParent == nullptr) && rDescriptor.Parent.is()) |
1633 | 0 | { |
1634 | | // try to get a system dependent window handle |
1635 | 0 | css::uno::Reference< css::awt::XSystemDependentWindowPeer > xSystemDepParent(rDescriptor.Parent, css::uno::UNO_QUERY); |
1636 | |
|
1637 | 0 | if (xSystemDepParent.is()) |
1638 | 0 | { |
1639 | 0 | sal_Int8 processID[16]; |
1640 | |
|
1641 | 0 | rtl_getGlobalProcessId( reinterpret_cast<sal_uInt8*>(processID) ); |
1642 | |
|
1643 | 0 | css::uno::Sequence<sal_Int8> processIdSeq(processID, 16); |
1644 | |
|
1645 | 0 | css::uno::Any anyHandle = xSystemDepParent->getWindowHandle(processIdSeq, SYSTEM_DEPENDENT_TYPE); |
1646 | | |
1647 | | // use sal_Int64 here to accommodate all int types |
1648 | | // uno::Any shift operator will upcast if necessary |
1649 | 0 | sal_Int64 nWindowHandle = 0; |
1650 | 0 | bool bXEmbed = false; |
1651 | |
|
1652 | 0 | bool bUseParentData = true; |
1653 | 0 | if( ! (anyHandle >>= nWindowHandle) ) |
1654 | 0 | { |
1655 | 0 | css::uno::Sequence< css::beans::NamedValue > aProps; |
1656 | 0 | if( anyHandle >>= aProps ) |
1657 | 0 | { |
1658 | 0 | for (const css::beans::NamedValue& rProp : aProps) |
1659 | 0 | { |
1660 | 0 | if ( rProp.Name == "WINDOW" ) |
1661 | 0 | rProp.Value >>= nWindowHandle; |
1662 | 0 | else if ( rProp.Name == "XEMBED" ) |
1663 | 0 | rProp.Value >>= bXEmbed; |
1664 | 0 | } |
1665 | 0 | } |
1666 | 0 | else |
1667 | 0 | bUseParentData = false; |
1668 | 0 | } |
1669 | |
|
1670 | 0 | if( bUseParentData ) |
1671 | 0 | { |
1672 | 0 | SystemParentData aParentData; |
1673 | 0 | aParentData.nSize = sizeof( aParentData ); |
1674 | | #if defined MACOSX |
1675 | | aParentData.pView = reinterpret_cast<NSView*>(nWindowHandle); |
1676 | | #elif defined ANDROID |
1677 | | // Nothing |
1678 | | #elif defined IOS |
1679 | | // Nothing |
1680 | | #elif defined UNX |
1681 | | aParentData.aWindow = nWindowHandle; |
1682 | 0 | aParentData.bXEmbedSupport = bXEmbed; |
1683 | | #elif defined _WIN32 |
1684 | | aParentData.hWnd = reinterpret_cast<HWND>(nWindowHandle); |
1685 | | #endif |
1686 | 0 | pNewWindow = VclPtr<WorkWindow>::Create( &aParentData ); |
1687 | 0 | } |
1688 | 0 | } |
1689 | 0 | } |
1690 | | |
1691 | 8.22k | if (!pNewWindow) |
1692 | 8.22k | pNewWindow = VclPtr<WorkWindow>::Create( pParent, nWinBits ); |
1693 | 8.22k | } |
1694 | | |
1695 | 8.22k | *ppNewComp = new VCLXTopWindow(); |
1696 | 8.22k | } |
1697 | 0 | else if ( rDescriptor.Type == css::awt::WindowClass_CONTAINER ) |
1698 | 0 | { |
1699 | 0 | if (eType == WindowType::DOCKINGWINDOW ) |
1700 | 0 | pNewWindow = VclPtr<DockingWindow>::Create( pParent, nWinBits ); |
1701 | 0 | else |
1702 | 0 | pNewWindow = VclPtr<vcl::Window>::Create( pParent, nWinBits ); |
1703 | 0 | *ppNewComp = new VCLXContainer; |
1704 | 0 | } |
1705 | 0 | else |
1706 | 0 | { |
1707 | 0 | if (eType == WindowType::DOCKINGWINDOW ) |
1708 | 0 | pNewWindow = VclPtr<DockingWindow>::Create( pParent, nWinBits ); |
1709 | 0 | else |
1710 | 0 | pNewWindow = VclPtr<vcl::Window>::Create( pParent, nWinBits ); |
1711 | 0 | *ppNewComp = new VCLXWindow; |
1712 | 0 | } |
1713 | 8.22k | break; |
1714 | 0 | case WindowType::CONTROL: |
1715 | 0 | if ( aServiceName == "tabpagecontainer" ) |
1716 | 0 | { |
1717 | | // TabControl has a special case for tabs without border: they are displayed |
1718 | | // in a different way, so we need to ensure that this style is not set, so |
1719 | | // we can guarantee normal tab behavior |
1720 | 0 | pNewWindow = VclPtr<TabControl>::Create( pParent, nWinBits & (~WB_NOBORDER)); |
1721 | 0 | *ppNewComp = new VCLXTabPageContainer; |
1722 | 0 | } |
1723 | 0 | else if ( aServiceName == "animatedimages" ) |
1724 | 0 | { |
1725 | 0 | pNewWindow = VclPtr<Throbber>::Create( pParent, nWinBits ); |
1726 | 0 | *ppNewComp = new ::toolkit::AnimatedImagesPeer; |
1727 | 0 | } |
1728 | 0 | else if (aServiceName == "roadmap") |
1729 | 0 | { |
1730 | 0 | pNewWindow = VclPtr<::vcl::ORoadmap>::Create( pParent, WB_TABSTOP ); |
1731 | 0 | *ppNewComp = new SVTXRoadmap; |
1732 | 0 | } |
1733 | 0 | else if (aServiceName == "fixedhyperlink") |
1734 | 0 | { |
1735 | 0 | pNewWindow = VclPtr<FixedHyperlink>::Create( pParent, nWinBits ); |
1736 | 0 | *ppNewComp = new VCLXFixedHyperlink; |
1737 | 0 | } |
1738 | 0 | else if (aServiceName == "progressbar") |
1739 | 0 | { |
1740 | 0 | pNewWindow = VclPtr<ProgressBar>::Create( pParent, nWinBits, ProgressBar::BarStyle::Progress ); |
1741 | 0 | *ppNewComp = new VCLXProgressBar; |
1742 | 0 | } |
1743 | 0 | else if (aServiceName == "filecontrol") |
1744 | 0 | { |
1745 | 0 | pNewWindow = VclPtr<FileControl>::Create( pParent, nWinBits ); |
1746 | 0 | *ppNewComp = new VCLXFileControl; |
1747 | 0 | } |
1748 | 0 | else if (aServiceName == "tree") |
1749 | 0 | { |
1750 | 0 | rtl::Reference<TreeControlPeer> pPeer = new TreeControlPeer; |
1751 | 0 | *ppNewComp = pPeer; |
1752 | 0 | pNewWindow = pPeer->createVclControl( pParent, nWinBits ); |
1753 | 0 | } |
1754 | 0 | else if (aServiceName == "formattedfield") |
1755 | 0 | { |
1756 | 0 | pNewWindow = VclPtr<FormattedField>::Create( pParent, nWinBits ); |
1757 | 0 | *ppNewComp = new SVTXFormattedField; |
1758 | 0 | } |
1759 | 0 | else if (aServiceName == "numericfield") |
1760 | 0 | { |
1761 | 0 | pNewWindow = VclPtr<DoubleNumericField>::Create( pParent, nWinBits ); |
1762 | 0 | *ppNewComp = new SVTXNumericField; |
1763 | 0 | } |
1764 | 0 | else if (aServiceName == "longcurrencyfield") |
1765 | 0 | { |
1766 | 0 | pNewWindow = VclPtr<DoubleCurrencyField>::Create( pParent, nWinBits ); |
1767 | 0 | *ppNewComp = new SVTXCurrencyField; |
1768 | 0 | } |
1769 | 0 | else if (aServiceName == "datefield") |
1770 | 0 | { |
1771 | 0 | pNewWindow = VclPtr<CalendarField>::Create(pParent, nWinBits); |
1772 | 0 | static_cast<CalendarField*>(pNewWindow.get())->EnableToday(); |
1773 | 0 | static_cast<CalendarField*>(pNewWindow.get())->EnableNone(); |
1774 | 0 | static_cast<CalendarField*>(pNewWindow.get())->EnableEmptyFieldValue( true ); |
1775 | 0 | rtl::Reference<SVTXDateField> newComp = new SVTXDateField; |
1776 | 0 | *ppNewComp = newComp; |
1777 | 0 | newComp->SetFormatter( static_cast<FormatterBase*>(static_cast<DateField*>(pNewWindow.get())) ); |
1778 | 0 | } |
1779 | 0 | else if (aServiceName == "grid") |
1780 | 0 | { |
1781 | 0 | pNewWindow = VclPtr<::svt::table::TableControl>::Create(pParent, nWinBits); |
1782 | 0 | *ppNewComp = new SVTXGridControl; |
1783 | 0 | } |
1784 | 0 | break; |
1785 | 0 | default: |
1786 | 0 | OSL_ENSURE( false, "VCLXToolkit::ImplCreateWindow: unknown window type!" ); |
1787 | 0 | break; |
1788 | 56.8k | } |
1789 | 56.8k | } |
1790 | | |
1791 | | // tdf#126717 default that formcontrols show accelerators |
1792 | 56.8k | if (Control* pControl = dynamic_cast<Control*>(pNewWindow.get())) |
1793 | 0 | pControl->SetShowAccelerator(true); |
1794 | 56.8k | return pNewWindow; |
1795 | 56.8k | } |
1796 | | |
1797 | | // static |
1798 | | css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow( |
1799 | | const css::awt::WindowDescriptor& rDescriptor, |
1800 | | MessBoxStyle nForceMessBoxStyle ) |
1801 | 56.8k | { |
1802 | 56.8k | SolarMutexGuard aSolarGuard; |
1803 | | |
1804 | 56.8k | css::uno::Reference< css::awt::XVclWindowPeer > xRef; |
1805 | | |
1806 | 56.8k | VclPtr<vcl::Window> pParent; |
1807 | 56.8k | if ( rDescriptor.Parent.is() ) |
1808 | 48.6k | { |
1809 | 48.6k | VCLXWindow* pParentComponent = dynamic_cast<VCLXWindow*>( rDescriptor.Parent.get() ); |
1810 | | |
1811 | | // #103939# Don't throw assertion, may be it's a system dependent window, used in ImplCreateWindow. |
1812 | | // DBG_ASSERT( pParentComponent, "ParentComponent not valid" ); |
1813 | | |
1814 | 48.6k | if ( pParentComponent ) |
1815 | 48.6k | pParent = pParentComponent->GetWindow(); |
1816 | 48.6k | } |
1817 | 56.8k | std::pair<WinBits, MessBoxStyle> aPair = ImplGetWinBits( rDescriptor.WindowAttributes, |
1818 | 56.8k | ImplGetComponentType( rDescriptor.WindowServiceName ) ); |
1819 | 56.8k | WinBits nWinBits = aPair.first; |
1820 | 56.8k | aPair.second |= nForceMessBoxStyle; |
1821 | | |
1822 | 56.8k | rtl::Reference<VCLXWindow> pNewComp; |
1823 | | |
1824 | 56.8k | vcl::Window* pNewWindow = ImplCreateWindow( &pNewComp, rDescriptor, pParent, nWinBits, aPair.second ); |
1825 | | |
1826 | 56.8k | DBG_ASSERT( pNewWindow, "createWindow: Unknown Component!" ); |
1827 | 56.8k | SAL_INFO_IF( !pNewComp, "toolkit", "createWindow: No special Interface!" ); |
1828 | | |
1829 | 56.8k | if ( pNewWindow ) |
1830 | 56.8k | { |
1831 | 56.8k | pNewWindow->SetCreatedWithToolkit( true ); |
1832 | | //pNewWindow->SetPosPixel( Point() ); // do not force (0,0) position, keep default pos instead |
1833 | | |
1834 | 56.8k | if ( rDescriptor.WindowAttributes & css::awt::WindowAttribute::MINSIZE ) |
1835 | 0 | { |
1836 | 0 | pNewWindow->SetSizePixel( Size() ); |
1837 | 0 | } |
1838 | 56.8k | else if ( rDescriptor.WindowAttributes & css::awt::WindowAttribute::FULLSIZE ) |
1839 | 0 | { |
1840 | 0 | if ( pParent ) |
1841 | 0 | pNewWindow->SetSizePixel( pParent->GetOutputSizePixel() ); |
1842 | 0 | } |
1843 | 56.8k | else if ( !VCLUnoHelper::IsZero( rDescriptor.Bounds ) ) |
1844 | 0 | { |
1845 | 0 | tools::Rectangle aRect = vcl::unohelper::ConvertToVCLRect(rDescriptor.Bounds); |
1846 | 0 | pNewWindow->SetPosSizePixel( aRect.TopLeft(), aRect.GetSize() ); |
1847 | 0 | } |
1848 | | |
1849 | 56.8k | if ( !pNewComp ) |
1850 | 48.6k | { |
1851 | | // Default-Interface |
1852 | 48.6k | xRef = pNewWindow->GetComponentInterface(); |
1853 | 48.6k | } |
1854 | 8.22k | else |
1855 | 8.22k | { |
1856 | 8.22k | xRef = pNewComp; |
1857 | 8.22k | pNewWindow->SetComponentInterface( xRef ); |
1858 | 8.22k | } |
1859 | 56.8k | DBG_ASSERT( pNewWindow->GetComponentInterface( false ) == xRef, |
1860 | 56.8k | "VCLXToolkit::createWindow: did #133706# resurge?" ); |
1861 | | |
1862 | 56.8k | if ( rDescriptor.WindowAttributes & css::awt::WindowAttribute::SHOW ) |
1863 | 0 | pNewWindow->Show(); |
1864 | 56.8k | } |
1865 | | |
1866 | 56.8k | return xRef; |
1867 | 56.8k | } |
1868 | | |
1869 | | css::uno::Sequence< css::uno::Reference< css::awt::XWindowPeer > > VCLXToolkit::createWindows( const css::uno::Sequence< css::awt::WindowDescriptor >& rDescriptors ) |
1870 | 0 | { |
1871 | 0 | sal_uInt32 nComponents = rDescriptors.getLength(); |
1872 | 0 | css::uno::Sequence< css::uno::Reference< css::awt::XWindowPeer > > aSeq( nComponents ); |
1873 | 0 | for ( sal_uInt32 n = 0; n < nComponents; n++ ) |
1874 | 0 | { |
1875 | 0 | css::awt::WindowDescriptor aDescr = rDescriptors.getConstArray()[n]; |
1876 | |
|
1877 | 0 | if ( aDescr.ParentIndex == -1 ) |
1878 | 0 | aDescr.Parent = nullptr; |
1879 | 0 | else if ( ( aDescr.ParentIndex >= 0 ) && ( o3tl::make_unsigned(aDescr.ParentIndex) < n ) ) |
1880 | 0 | aDescr.Parent = aSeq.getConstArray()[aDescr.ParentIndex]; |
1881 | 0 | aSeq.getArray()[n] = createWindow( aDescr ); |
1882 | 0 | } |
1883 | 0 | return aSeq; |
1884 | 0 | } |
1885 | | |
1886 | | // css::awt::XSystemChildFactory |
1887 | | css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::createSystemChild( const css::uno::Any& Parent, const css::uno::Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 nSystemType ) |
1888 | 0 | { |
1889 | 0 | VclPtr<vcl::Window> pChildWindow; |
1890 | 0 | if ( nSystemType == SYSTEM_DEPENDENT_TYPE ) |
1891 | 0 | { |
1892 | | // use sal_Int64 here to accommodate all int types |
1893 | | // uno::Any shift operator will upcast if necessary |
1894 | 0 | sal_Int64 nWindowHandle = 0; |
1895 | 0 | bool bXEmbed = false; |
1896 | |
|
1897 | 0 | bool bUseParentData = true; |
1898 | 0 | if( ! (Parent >>= nWindowHandle) ) |
1899 | 0 | { |
1900 | 0 | css::uno::Sequence< css::beans::NamedValue > aProps; |
1901 | 0 | if( Parent >>= aProps ) |
1902 | 0 | { |
1903 | 0 | for (const css::beans::NamedValue& rProp : aProps) |
1904 | 0 | { |
1905 | 0 | if ( rProp.Name == "WINDOW" ) |
1906 | 0 | rProp.Value >>= nWindowHandle; |
1907 | 0 | else if ( rProp.Name == "XEMBED" ) |
1908 | 0 | rProp.Value >>= bXEmbed; |
1909 | 0 | } |
1910 | 0 | } |
1911 | 0 | else |
1912 | 0 | bUseParentData = false; |
1913 | 0 | } |
1914 | |
|
1915 | 0 | if( bUseParentData ) |
1916 | 0 | { |
1917 | 0 | SystemParentData aParentData; |
1918 | 0 | aParentData.nSize = sizeof( aParentData ); |
1919 | | #if defined MACOSX |
1920 | | aParentData.pView = reinterpret_cast<NSView*>(nWindowHandle); |
1921 | | #elif defined ANDROID |
1922 | | // Nothing |
1923 | | #elif defined IOS |
1924 | | // Nothing |
1925 | | #elif defined UNX |
1926 | | aParentData.aWindow = nWindowHandle; |
1927 | 0 | aParentData.bXEmbedSupport = bXEmbed; |
1928 | | #elif defined _WIN32 |
1929 | | aParentData.hWnd = reinterpret_cast<HWND>(nWindowHandle); |
1930 | | #endif |
1931 | 0 | SolarMutexGuard aGuard; |
1932 | 0 | try |
1933 | 0 | { |
1934 | 0 | pChildWindow.reset( VclPtr<WorkWindow>::Create( &aParentData ) ); |
1935 | 0 | } |
1936 | 0 | catch ( const css::uno::RuntimeException & ) |
1937 | 0 | { |
1938 | | // system child window could not be created |
1939 | 0 | DBG_UNHANDLED_EXCEPTION("toolkit"); |
1940 | 0 | pChildWindow.reset(); |
1941 | 0 | } |
1942 | 0 | } |
1943 | 0 | } |
1944 | 0 | else if (nSystemType == css::lang::SystemDependent::SYSTEM_JAVA) |
1945 | 0 | { |
1946 | 0 | SolarMutexGuard aGuard; |
1947 | 0 | pChildWindow.reset(VclPtr<WorkWindow>::Create(nullptr, Parent)); |
1948 | 0 | } |
1949 | |
|
1950 | 0 | if ( !pChildWindow ) |
1951 | 0 | return nullptr; |
1952 | | |
1953 | 0 | rtl::Reference<VCLXTopWindow> pPeer = new VCLXTopWindow; |
1954 | 0 | SolarMutexGuard aGuard; |
1955 | 0 | pPeer->SetWindow( pChildWindow ); |
1956 | 0 | pChildWindow->SetWindowPeer(pPeer, pPeer.get()); |
1957 | |
|
1958 | 0 | return pPeer; |
1959 | 0 | } |
1960 | | |
1961 | | // css::awt::XMessageBoxFactory |
1962 | | css::uno::Reference< css::awt::XMessageBox > SAL_CALL VCLXToolkit::createMessageBox( |
1963 | | const css::uno::Reference< css::awt::XWindowPeer >& aParent, |
1964 | | css::awt::MessageBoxType eType, |
1965 | | ::sal_Int32 aButtons, |
1966 | | const OUString& aTitle, |
1967 | | const OUString& aMessage ) |
1968 | 0 | { |
1969 | 0 | css::awt::WindowDescriptor aDescriptor; |
1970 | |
|
1971 | 0 | sal_Int32 nWindowAttributes = css::awt::WindowAttribute::BORDER|css::awt::WindowAttribute::MOVEABLE|css::awt::WindowAttribute::CLOSEABLE; |
1972 | | |
1973 | | // Map button definitions to window attributes |
1974 | 0 | if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_OK ) |
1975 | 0 | nWindowAttributes |= css::awt::VclWindowPeerAttribute::OK; |
1976 | 0 | else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_OK_CANCEL ) |
1977 | 0 | nWindowAttributes |= css::awt::VclWindowPeerAttribute::OK_CANCEL; |
1978 | 0 | else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_YES_NO ) |
1979 | 0 | nWindowAttributes |= css::awt::VclWindowPeerAttribute::YES_NO; |
1980 | 0 | else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_YES_NO_CANCEL ) |
1981 | 0 | nWindowAttributes |= css::awt::VclWindowPeerAttribute::YES_NO_CANCEL; |
1982 | 0 | else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_RETRY_CANCEL ) |
1983 | 0 | nWindowAttributes |= css::awt::VclWindowPeerAttribute::RETRY_CANCEL; |
1984 | | |
1985 | | // Map default button definitions to window attributes |
1986 | 0 | if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_OK ) |
1987 | 0 | nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_OK; |
1988 | 0 | else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_CANCEL ) |
1989 | 0 | nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_CANCEL; |
1990 | 0 | else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_YES ) |
1991 | 0 | nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_YES; |
1992 | 0 | else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_NO ) |
1993 | 0 | nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_NO; |
1994 | 0 | else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_RETRY ) |
1995 | 0 | nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_RETRY; |
1996 | | |
1997 | | // No more bits for VclWindowPeerAttribute possible. Mapping must be |
1998 | | // done explicitly using VCL methods |
1999 | 0 | MessBoxStyle nAddWinBits = MessBoxStyle::NONE; |
2000 | 0 | if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_ABORT_IGNORE_RETRY ) |
2001 | 0 | nAddWinBits |= MessBoxStyle::AbortRetryIgnore; |
2002 | 0 | if ( sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_IGNORE ) |
2003 | 0 | nAddWinBits |= MessBoxStyle::DefaultIgnore; |
2004 | |
|
2005 | 0 | OUString aType = lcl_convertMessageBoxType(eType); |
2006 | |
|
2007 | 0 | aDescriptor.Type = css::awt::WindowClass_MODALTOP; |
2008 | 0 | aDescriptor.WindowServiceName = aType; |
2009 | 0 | aDescriptor.ParentIndex = -1; |
2010 | 0 | aDescriptor.Parent = aParent; |
2011 | 0 | aDescriptor.WindowAttributes = nWindowAttributes; |
2012 | 0 | css::uno::Reference< css::awt::XMessageBox > xMsgBox( |
2013 | 0 | ImplCreateWindow( aDescriptor, nAddWinBits ), css::uno::UNO_QUERY ); |
2014 | 0 | css::uno::Reference< css::awt::XWindow > xWindow( xMsgBox, css::uno::UNO_QUERY ); |
2015 | 0 | if ( xMsgBox.is() && xWindow.is() ) |
2016 | 0 | { |
2017 | 0 | VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow ); |
2018 | 0 | if ( pWindow ) |
2019 | 0 | { |
2020 | 0 | SolarMutexGuard aGuard; |
2021 | 0 | xMsgBox->setCaptionText( aTitle ); |
2022 | 0 | xMsgBox->setMessageText( aMessage ); |
2023 | 0 | } |
2024 | 0 | } |
2025 | |
|
2026 | 0 | return xMsgBox; |
2027 | 0 | } |
2028 | | |
2029 | | css::uno::Reference< css::datatransfer::dnd::XDragGestureRecognizer > SAL_CALL VCLXToolkit::getDragGestureRecognizer( const css::uno::Reference< css::awt::XWindow >& window ) |
2030 | 0 | { |
2031 | 0 | SolarMutexGuard g; |
2032 | |
|
2033 | 0 | VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( window ); |
2034 | |
|
2035 | 0 | if( pWindow ) |
2036 | 0 | return pWindow->GetDropTarget(); |
2037 | | |
2038 | 0 | return css::uno::Reference< css::datatransfer::dnd::XDragGestureRecognizer >(); |
2039 | 0 | } |
2040 | | |
2041 | | css::uno::Reference< css::datatransfer::dnd::XDragSource > SAL_CALL VCLXToolkit::getDragSource( const css::uno::Reference< css::awt::XWindow >& window ) |
2042 | 0 | { |
2043 | 0 | SolarMutexGuard g; |
2044 | |
|
2045 | 0 | VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( window ); |
2046 | |
|
2047 | 0 | if( pWindow ) |
2048 | 0 | return pWindow->GetDragSource(); |
2049 | | |
2050 | 0 | return css::uno::Reference< css::datatransfer::dnd::XDragSource >(); |
2051 | 0 | } |
2052 | | |
2053 | | css::uno::Reference< css::datatransfer::dnd::XDropTarget > SAL_CALL VCLXToolkit::getDropTarget( const css::uno::Reference< css::awt::XWindow >& window ) |
2054 | 27.9k | { |
2055 | 27.9k | SolarMutexGuard g; |
2056 | | |
2057 | 27.9k | VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( window ); |
2058 | | |
2059 | 27.9k | if( pWindow ) |
2060 | 27.9k | return pWindow->GetDropTarget(); |
2061 | | |
2062 | 0 | return css::uno::Reference< css::datatransfer::dnd::XDropTarget >(); |
2063 | 27.9k | } |
2064 | | |
2065 | | css::uno::Reference< css::datatransfer::clipboard::XClipboard > SAL_CALL VCLXToolkit::getClipboard( const OUString& clipboardName ) |
2066 | 0 | { |
2067 | 0 | SolarMutexGuard g; |
2068 | |
|
2069 | 0 | if( clipboardName.isEmpty() ) |
2070 | 0 | { |
2071 | 0 | if( !mxClipboard.is() ) |
2072 | 0 | { |
2073 | | // remember clipboard here |
2074 | 0 | mxClipboard = GetSystemClipboard(); |
2075 | 0 | } |
2076 | |
|
2077 | 0 | return mxClipboard; |
2078 | 0 | } |
2079 | | |
2080 | 0 | else if( clipboardName == "Selection" ) |
2081 | 0 | { |
2082 | 0 | return mxSelection; |
2083 | 0 | } |
2084 | | |
2085 | 0 | return css::uno::Reference< css::datatransfer::clipboard::XClipboard >(); |
2086 | 0 | } |
2087 | | |
2088 | | // XServiceInfo |
2089 | | OUString VCLXToolkit::getImplementationName() |
2090 | 0 | { |
2091 | 0 | return u"stardiv.Toolkit.VCLXToolkit"_ustr; |
2092 | 0 | } |
2093 | | |
2094 | | sal_Bool VCLXToolkit::supportsService( const OUString& rServiceName ) |
2095 | 0 | { |
2096 | 0 | return cppu::supportsService(this, rServiceName); |
2097 | 0 | } |
2098 | | |
2099 | | css::uno::Sequence< OUString > VCLXToolkit::getSupportedServiceNames() |
2100 | 0 | { |
2101 | 0 | return css::uno::Sequence<OUString>{ |
2102 | 0 | u"com.sun.star.awt.Toolkit"_ustr, u"stardiv.vcl.VclToolkit"_ustr}; |
2103 | 0 | } |
2104 | | |
2105 | | // css::awt::XExtendedToolkit: |
2106 | | |
2107 | | // virtual |
2108 | | ::sal_Int32 SAL_CALL VCLXToolkit::getTopWindowCount() |
2109 | 0 | { |
2110 | 0 | return static_cast< ::sal_Int32 >(::Application::GetTopWindowCount()); |
2111 | | // XXX numeric overflow |
2112 | 0 | } |
2113 | | |
2114 | | // virtual |
2115 | | css::uno::Reference< css::awt::XTopWindow > SAL_CALL |
2116 | | VCLXToolkit::getTopWindow(::sal_Int32 nIndex) |
2117 | 0 | { |
2118 | 0 | vcl::Window * p = ::Application::GetTopWindow(static_cast< tools::Long >(nIndex)); |
2119 | | // XXX numeric overflow |
2120 | 0 | return css::uno::Reference< css::awt::XTopWindow >( |
2121 | 0 | p == nullptr ? nullptr : static_cast< css::awt::XWindow * >(p->GetWindowPeer()), |
2122 | 0 | css::uno::UNO_QUERY); |
2123 | 0 | } |
2124 | | |
2125 | | // virtual |
2126 | | css::uno::Reference< css::awt::XTopWindow > SAL_CALL |
2127 | | VCLXToolkit::getActiveTopWindow() |
2128 | 0 | { |
2129 | 0 | vcl::Window * p = ::Application::GetActiveTopWindow(); |
2130 | 0 | return css::uno::Reference< css::awt::XTopWindow >( |
2131 | 0 | p == nullptr ? nullptr : static_cast< css::awt::XWindow * >(p->GetWindowPeer()), |
2132 | 0 | css::uno::UNO_QUERY); |
2133 | 0 | } |
2134 | | |
2135 | | // virtual |
2136 | | void SAL_CALL VCLXToolkit::addTopWindowListener( |
2137 | | css::uno::Reference< css::awt::XTopWindowListener > const & rListener) |
2138 | 0 | { |
2139 | 0 | OSL_ENSURE(rListener.is(), "Null rListener"); |
2140 | 0 | std::unique_lock aGuard(m_aMutex); |
2141 | 0 | if (m_bDisposed) |
2142 | 0 | { |
2143 | 0 | aGuard.unlock(); |
2144 | 0 | rListener->disposing( |
2145 | 0 | css::lang::EventObject( |
2146 | 0 | getXWeak())); |
2147 | 0 | } |
2148 | 0 | else if (m_aTopWindowListeners.addInterface(aGuard, rListener) == 1 |
2149 | 0 | && !m_bEventListener) |
2150 | 0 | { |
2151 | 0 | m_bEventListener = true; |
2152 | 0 | ::Application::AddEventListener(m_aEventListenerLink); |
2153 | 0 | } |
2154 | 0 | } |
2155 | | |
2156 | | // virtual |
2157 | | void SAL_CALL VCLXToolkit::removeTopWindowListener( |
2158 | | css::uno::Reference< css::awt::XTopWindowListener > const & rListener) |
2159 | 0 | { |
2160 | 0 | std::unique_lock aGuard(m_aMutex); |
2161 | 0 | if (!m_bDisposed |
2162 | 0 | && m_aTopWindowListeners.removeInterface(aGuard, rListener) == 0 |
2163 | 0 | && m_aFocusListeners.getLength(aGuard) == 0 && m_bEventListener) |
2164 | 0 | { |
2165 | 0 | ::Application::RemoveEventListener(m_aEventListenerLink); |
2166 | 0 | m_bEventListener = false; |
2167 | 0 | } |
2168 | 0 | } |
2169 | | |
2170 | | // virtual |
2171 | | void SAL_CALL VCLXToolkit::addKeyHandler( |
2172 | | css::uno::Reference< css::awt::XKeyHandler > const & rHandler) |
2173 | 0 | { |
2174 | 0 | OSL_ENSURE(rHandler.is(), "Null rHandler"); |
2175 | 0 | std::unique_lock aGuard(m_aMutex); |
2176 | 0 | if (m_bDisposed) |
2177 | 0 | { |
2178 | 0 | aGuard.unlock(); |
2179 | 0 | rHandler->disposing( |
2180 | 0 | css::lang::EventObject( |
2181 | 0 | getXWeak())); |
2182 | 0 | } |
2183 | 0 | else if (m_aKeyHandlers.addInterface(aGuard, rHandler) == 1 && !m_bKeyListener) |
2184 | 0 | { |
2185 | 0 | m_bKeyListener = true; |
2186 | 0 | ::Application::AddKeyListener(m_aKeyListenerLink); |
2187 | 0 | } |
2188 | 0 | } |
2189 | | |
2190 | | // virtual |
2191 | | void SAL_CALL VCLXToolkit::removeKeyHandler( |
2192 | | css::uno::Reference< css::awt::XKeyHandler > const & rHandler) |
2193 | 0 | { |
2194 | 0 | std::unique_lock aGuard(m_aMutex); |
2195 | 0 | if (!m_bDisposed |
2196 | 0 | && m_aKeyHandlers.removeInterface(aGuard, rHandler) == 0 && m_bKeyListener) |
2197 | 0 | { |
2198 | 0 | ::Application::RemoveKeyListener(m_aKeyListenerLink); |
2199 | 0 | m_bKeyListener = false; |
2200 | 0 | } |
2201 | 0 | } |
2202 | | |
2203 | | // virtual |
2204 | | void SAL_CALL VCLXToolkit::addFocusListener( |
2205 | | css::uno::Reference< css::awt::XFocusListener > const & rListener) |
2206 | 0 | { |
2207 | 0 | OSL_ENSURE(rListener.is(), "Null rListener"); |
2208 | 0 | std::unique_lock aGuard(m_aMutex); |
2209 | 0 | if (m_bDisposed) |
2210 | 0 | { |
2211 | 0 | aGuard.unlock(); |
2212 | 0 | rListener->disposing( |
2213 | 0 | css::lang::EventObject( |
2214 | 0 | getXWeak())); |
2215 | 0 | } |
2216 | 0 | else if (m_aFocusListeners.addInterface(aGuard, rListener) == 1 |
2217 | 0 | && !m_bEventListener) |
2218 | 0 | { |
2219 | 0 | m_bEventListener = true; |
2220 | 0 | ::Application::AddEventListener(m_aEventListenerLink); |
2221 | 0 | } |
2222 | 0 | } |
2223 | | |
2224 | | // virtual |
2225 | | void SAL_CALL VCLXToolkit::removeFocusListener( |
2226 | | css::uno::Reference< css::awt::XFocusListener > const & rListener) |
2227 | 0 | { |
2228 | 0 | std::unique_lock aGuard(m_aMutex); |
2229 | 0 | if (!m_bDisposed |
2230 | 0 | && m_aFocusListeners.removeInterface(aGuard, rListener) == 0 |
2231 | 0 | && m_aTopWindowListeners.getLength(aGuard) == 0 && m_bEventListener) |
2232 | 0 | { |
2233 | 0 | ::Application::RemoveEventListener(m_aEventListenerLink); |
2234 | 0 | m_bEventListener = false; |
2235 | 0 | } |
2236 | 0 | } |
2237 | | |
2238 | | // virtual |
2239 | | void SAL_CALL VCLXToolkit::fireFocusGained( |
2240 | | css::uno::Reference< |
2241 | | css::uno::XInterface > const &) |
2242 | 0 | { |
2243 | 0 | } |
2244 | | |
2245 | | // virtual |
2246 | | void SAL_CALL VCLXToolkit::fireFocusLost( |
2247 | | css::uno::Reference< |
2248 | | css::uno::XInterface > const &) |
2249 | 0 | { |
2250 | 0 | } |
2251 | | |
2252 | | |
2253 | | IMPL_LINK(VCLXToolkit, eventListenerHandler, ::VclSimpleEvent&, rEvent, void) |
2254 | 0 | { |
2255 | 0 | switch (rEvent.GetId()) |
2256 | 0 | { |
2257 | 0 | case VclEventId::WindowShow: |
2258 | 0 | callTopWindowListeners( |
2259 | 0 | &rEvent, &css::awt::XTopWindowListener::windowOpened); |
2260 | 0 | break; |
2261 | 0 | case VclEventId::WindowHide: |
2262 | 0 | callTopWindowListeners( |
2263 | 0 | &rEvent, &css::awt::XTopWindowListener::windowClosed); |
2264 | 0 | break; |
2265 | 0 | case VclEventId::WindowActivate: |
2266 | 0 | callTopWindowListeners( |
2267 | 0 | &rEvent, &css::awt::XTopWindowListener::windowActivated); |
2268 | 0 | break; |
2269 | 0 | case VclEventId::WindowDeactivate: |
2270 | 0 | callTopWindowListeners( |
2271 | 0 | &rEvent, &css::awt::XTopWindowListener::windowDeactivated); |
2272 | 0 | break; |
2273 | 0 | case VclEventId::WindowClose: |
2274 | 0 | callTopWindowListeners( |
2275 | 0 | &rEvent, &css::awt::XTopWindowListener::windowClosing); |
2276 | 0 | break; |
2277 | 0 | case VclEventId::WindowGetFocus: |
2278 | 0 | callFocusListeners(&rEvent, true); |
2279 | 0 | break; |
2280 | 0 | case VclEventId::WindowLoseFocus: |
2281 | 0 | callFocusListeners(&rEvent, false); |
2282 | 0 | break; |
2283 | 0 | case VclEventId::WindowMinimize: |
2284 | 0 | callTopWindowListeners( |
2285 | 0 | &rEvent, &css::awt::XTopWindowListener::windowMinimized); |
2286 | 0 | break; |
2287 | 0 | case VclEventId::WindowNormalize: |
2288 | 0 | callTopWindowListeners( |
2289 | 0 | &rEvent, &css::awt::XTopWindowListener::windowNormalized); |
2290 | 0 | break; |
2291 | 0 | default: break; |
2292 | 0 | } |
2293 | 0 | } |
2294 | | |
2295 | | IMPL_LINK(VCLXToolkit, keyListenerHandler, ::VclWindowEvent&, rEvent, bool) |
2296 | 0 | { |
2297 | 0 | switch (rEvent.GetId()) |
2298 | 0 | { |
2299 | 0 | case VclEventId::WindowKeyInput: |
2300 | 0 | return callKeyHandlers(&rEvent, true); |
2301 | 0 | case VclEventId::WindowKeyUp: |
2302 | 0 | return callKeyHandlers(&rEvent, false); |
2303 | 0 | default: break; |
2304 | 0 | } |
2305 | 0 | return false; |
2306 | 0 | } |
2307 | | |
2308 | | void VCLXToolkit::callTopWindowListeners( |
2309 | | ::VclSimpleEvent const * pEvent, |
2310 | | void (SAL_CALL css::awt::XTopWindowListener::* pFn)( |
2311 | | css::lang::EventObject const &)) |
2312 | 0 | { |
2313 | 0 | vcl::Window * pWindow |
2314 | 0 | = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow(); |
2315 | 0 | if (!pWindow->IsTopWindow()) |
2316 | 0 | return; |
2317 | | |
2318 | 0 | std::unique_lock aGuard(m_aMutex); |
2319 | 0 | if (m_aTopWindowListeners.getLength(aGuard) == 0) |
2320 | 0 | return; |
2321 | | |
2322 | 0 | css::lang::EventObject aAwtEvent( |
2323 | 0 | static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer())); |
2324 | 0 | m_aTopWindowListeners.forEach(aGuard, |
2325 | 0 | [&pFn, &aAwtEvent](const css::uno::Reference<css::awt::XTopWindowListener> & xListener) |
2326 | 0 | { |
2327 | 0 | try |
2328 | 0 | { |
2329 | 0 | (xListener.get()->*pFn)(aAwtEvent); |
2330 | 0 | } |
2331 | 0 | catch (const css::uno::RuntimeException &) |
2332 | 0 | { |
2333 | 0 | DBG_UNHANDLED_EXCEPTION("toolkit"); |
2334 | 0 | } |
2335 | 0 | }); |
2336 | 0 | } |
2337 | | |
2338 | | bool VCLXToolkit::callKeyHandlers(::VclSimpleEvent const * pEvent, |
2339 | | bool bPressed) |
2340 | 0 | { |
2341 | 0 | std::unique_lock aGuard(m_aMutex); |
2342 | |
|
2343 | 0 | if (m_aKeyHandlers.getLength(aGuard) != 0) |
2344 | 0 | { |
2345 | 0 | vcl::Window * pWindow = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow(); |
2346 | | |
2347 | | // See implementation in vclxwindow.cxx for mapping between VCL and UNO AWT event |
2348 | 0 | ::KeyEvent * pKeyEvent = static_cast< ::KeyEvent * >( |
2349 | 0 | static_cast< ::VclWindowEvent const * >(pEvent)->GetData()); |
2350 | 0 | css::awt::KeyEvent aAwtEvent( |
2351 | 0 | static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()), |
2352 | 0 | (pKeyEvent->GetKeyCode().IsShift() |
2353 | 0 | ? css::awt::KeyModifier::SHIFT : 0) |
2354 | 0 | | (pKeyEvent->GetKeyCode().IsMod1() |
2355 | 0 | ? css::awt::KeyModifier::MOD1 : 0) |
2356 | 0 | | (pKeyEvent->GetKeyCode().IsMod2() |
2357 | 0 | ? css::awt::KeyModifier::MOD2 : 0) |
2358 | 0 | | (pKeyEvent->GetKeyCode().IsMod3() |
2359 | 0 | ? css::awt::KeyModifier::MOD3 : 0), |
2360 | 0 | pKeyEvent->GetKeyCode().GetCode(), pKeyEvent->GetCharCode(), |
2361 | 0 | sal::static_int_cast< sal_Int16 >( |
2362 | 0 | pKeyEvent->GetKeyCode().GetFunction())); |
2363 | 0 | comphelper::OInterfaceIteratorHelper4 aIt(aGuard, m_aKeyHandlers); |
2364 | 0 | aGuard.unlock(); |
2365 | 0 | while (aIt.hasMoreElements()) |
2366 | 0 | { |
2367 | 0 | css::awt::XKeyHandler* pL = aIt.next().get(); |
2368 | 0 | try |
2369 | 0 | { |
2370 | 0 | if (bPressed ? pL->keyPressed(aAwtEvent) |
2371 | 0 | : pL->keyReleased(aAwtEvent)) |
2372 | 0 | return true; |
2373 | 0 | } |
2374 | 0 | catch (const css::uno::RuntimeException &) |
2375 | 0 | { |
2376 | 0 | DBG_UNHANDLED_EXCEPTION("toolkit"); |
2377 | 0 | } |
2378 | 0 | } |
2379 | 0 | } |
2380 | 0 | return false; |
2381 | 0 | } |
2382 | | |
2383 | | void VCLXToolkit::callFocusListeners(::VclSimpleEvent const * pEvent, |
2384 | | bool bGained) |
2385 | 0 | { |
2386 | 0 | vcl::Window * pWindow |
2387 | 0 | = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow(); |
2388 | 0 | if (!pWindow->IsTopWindow()) |
2389 | 0 | return; |
2390 | | |
2391 | 0 | std::unique_lock aGuard(m_aMutex); |
2392 | 0 | if (m_aFocusListeners.getLength(aGuard) == 0) |
2393 | 0 | return; |
2394 | | |
2395 | | // Ignore the interior of compound controls when determining the |
2396 | | // window that gets the focus next (see implementation in |
2397 | | // vclxwindow.cxx for mapping between VCL and UNO AWT event): |
2398 | 0 | css::uno::Reference< css::uno::XInterface > xNext; |
2399 | 0 | vcl::Window * pFocus = ::Application::GetFocusWindow(); |
2400 | 0 | for (vcl::Window * p = pFocus; p != nullptr; p = p->GetParent()) |
2401 | 0 | if (!p->IsCompoundControl()) |
2402 | 0 | { |
2403 | 0 | pFocus = p; |
2404 | 0 | break; |
2405 | 0 | } |
2406 | 0 | if (pFocus != nullptr) |
2407 | 0 | xNext = pFocus->GetComponentInterface(); |
2408 | 0 | css::awt::FocusEvent aAwtEvent( |
2409 | 0 | static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()), |
2410 | 0 | static_cast<sal_Int16>(pWindow->GetGetFocusFlags()), |
2411 | 0 | xNext, false); |
2412 | 0 | m_aFocusListeners.forEach(aGuard, |
2413 | 0 | [bGained, &aAwtEvent] (const css::uno::Reference<css::awt::XFocusListener> & xListener) |
2414 | 0 | { |
2415 | 0 | try |
2416 | 0 | { |
2417 | 0 | bGained ? xListener->focusGained(aAwtEvent) |
2418 | 0 | : xListener->focusLost(aAwtEvent); |
2419 | 0 | } |
2420 | 0 | catch (const css::uno::RuntimeException &) |
2421 | 0 | { |
2422 | 0 | DBG_UNHANDLED_EXCEPTION("toolkit"); |
2423 | 0 | } |
2424 | 0 | }); |
2425 | 0 | } |
2426 | | |
2427 | | // css::awt::XReschedule: |
2428 | | |
2429 | | void SAL_CALL VCLXToolkit::reschedule() |
2430 | 0 | { |
2431 | 0 | SolarMutexGuard aSolarGuard; |
2432 | 0 | Application::Reschedule(true); |
2433 | 0 | } |
2434 | | |
2435 | | // css::awt::XFontMappingUse: |
2436 | | void SAL_CALL VCLXToolkit::startTrackingFontMappingUse() |
2437 | 0 | { |
2438 | 0 | SolarMutexGuard aSolarGuard; |
2439 | 0 | OutputDevice::StartTrackingFontMappingUse(); |
2440 | 0 | } |
2441 | | |
2442 | | css::uno::Sequence<css::awt::XFontMappingUseItem> |
2443 | | SAL_CALL VCLXToolkit::finishTrackingFontMappingUse() |
2444 | 0 | { |
2445 | 0 | SolarMutexGuard aSolarGuard; |
2446 | 0 | OutputDevice::FontMappingUseData data = OutputDevice::FinishTrackingFontMappingUse(); |
2447 | 0 | css::uno::Sequence<css::awt::XFontMappingUseItem> ret( data.size()); |
2448 | 0 | css::awt::XFontMappingUseItem* retData = ret.getArray(); |
2449 | 0 | for( size_t i = 0; i < data.size(); ++i ) |
2450 | 0 | { |
2451 | 0 | retData[ i ].originalFont = data[ i ].mOriginalFont; |
2452 | 0 | retData[ i ].usedFonts = comphelper::arrayToSequence<OUString,OUString> |
2453 | 0 | (data[ i ].mUsedFonts.data(), data[ i ].mUsedFonts.size()); |
2454 | 0 | retData[ i ].count = data[ i ].mCount; |
2455 | 0 | } |
2456 | 0 | return ret; |
2457 | 0 | } |
2458 | | |
2459 | | // css::awt::XToolkitExperimental |
2460 | | |
2461 | | void SAL_CALL VCLXToolkit::processEventsToIdle() |
2462 | 0 | { |
2463 | 0 | SolarMutexGuard aSolarGuard; |
2464 | 0 | comphelper::ProfileZone aZone("processEvents"); |
2465 | 0 | Scheduler::ProcessEventsToIdle(); |
2466 | 0 | } |
2467 | | |
2468 | | sal_Int64 SAL_CALL VCLXToolkit::getOpenGLBufferSwapCounter() |
2469 | 0 | { |
2470 | | #if HAVE_FEATURE_OPENGL |
2471 | | return OpenGLWrapper::getBufferSwapCounter(); |
2472 | | #else |
2473 | 0 | return 0; |
2474 | 0 | #endif |
2475 | 0 | } |
2476 | | |
2477 | | void SAL_CALL VCLXToolkit::setDeterministicScheduling(sal_Bool bDeterministicMode) |
2478 | 0 | { |
2479 | 0 | SolarMutexGuard aSolarGuard; |
2480 | 0 | Scheduler::SetDeterministicMode(bDeterministicMode); |
2481 | 0 | } |
2482 | | |
2483 | | void SAL_CALL VCLXToolkit::pause(sal_Int32 nMilliseconds) |
2484 | 0 | { |
2485 | 0 | new Pause(nMilliseconds); |
2486 | 0 | } |
2487 | | |
2488 | | void SAL_CALL VCLXToolkit::startRecording() |
2489 | 0 | { |
2490 | 0 | comphelper::TraceEvent::startRecording(); |
2491 | 0 | } |
2492 | | |
2493 | | void SAL_CALL VCLXToolkit::stopRecording() |
2494 | 0 | { |
2495 | 0 | comphelper::TraceEvent::stopRecording(); |
2496 | 0 | } |
2497 | | |
2498 | | css::uno::Sequence< OUString > VCLXToolkit::getRecordingAndClear() |
2499 | 0 | { |
2500 | 0 | return comphelper::ProfileZone::getRecordingAndClear(); |
2501 | 0 | } |
2502 | | |
2503 | | void VCLXToolkit::waitUntilAllIdlesDispatched() |
2504 | 0 | { |
2505 | 0 | IdleTask::waitUntilIdleDispatched(); |
2506 | 0 | } |
2507 | | |
2508 | | // css:awt:XToolkitRobot |
2509 | | |
2510 | | void SAL_CALL VCLXToolkit::keyPress( const css::awt::KeyEvent & aKeyEvent ) |
2511 | 0 | { |
2512 | 0 | css::uno::Reference<css::awt::XWindow> xWindow ( aKeyEvent.Source, css::uno::UNO_QUERY_THROW ); |
2513 | 0 | VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow ); |
2514 | 0 | if( !pWindow ) |
2515 | 0 | throw css::uno::RuntimeException( u"invalid event source"_ustr ); |
2516 | | |
2517 | 0 | ::KeyEvent aVCLKeyEvent = VCLUnoHelper::createVCLKeyEvent( aKeyEvent ); |
2518 | 0 | ::Application::PostKeyEvent( VclEventId::WindowKeyInput, pWindow, &aVCLKeyEvent ); |
2519 | 0 | } |
2520 | | |
2521 | | void SAL_CALL VCLXToolkit::keyRelease( const css::awt::KeyEvent & aKeyEvent ) |
2522 | 0 | { |
2523 | 0 | css::uno::Reference<css::awt::XWindow> xWindow ( aKeyEvent.Source, css::uno::UNO_QUERY_THROW ); |
2524 | 0 | VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow ); |
2525 | 0 | if( !pWindow ) |
2526 | 0 | throw css::uno::RuntimeException( u"invalid event source"_ustr ); |
2527 | | |
2528 | 0 | ::KeyEvent aVCLKeyEvent = VCLUnoHelper::createVCLKeyEvent( aKeyEvent ); |
2529 | 0 | ::Application::PostKeyEvent( VclEventId::WindowKeyUp, pWindow, &aVCLKeyEvent ); |
2530 | 0 | } |
2531 | | |
2532 | | |
2533 | | void SAL_CALL VCLXToolkit::mousePress( const css::awt::MouseEvent & aMouseEvent ) |
2534 | 0 | { |
2535 | 0 | css::uno::Reference<css::awt::XWindow> xWindow ( aMouseEvent.Source, css::uno::UNO_QUERY_THROW ); |
2536 | 0 | VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow ); |
2537 | 0 | if( !pWindow ) |
2538 | 0 | throw css::uno::RuntimeException( u"invalid event source"_ustr ); |
2539 | | |
2540 | 0 | ::MouseEvent aVCLMouseEvent = VCLUnoHelper::createVCLMouseEvent( aMouseEvent ); |
2541 | 0 | ::Application::PostMouseEvent( VclEventId::WindowMouseButtonDown, pWindow, &aVCLMouseEvent ); |
2542 | 0 | } |
2543 | | |
2544 | | void SAL_CALL VCLXToolkit::mouseRelease( const css::awt::MouseEvent & aMouseEvent ) |
2545 | 0 | { |
2546 | 0 | css::uno::Reference<css::awt::XWindow> xWindow ( aMouseEvent.Source, css::uno::UNO_QUERY_THROW ); |
2547 | 0 | VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow ); |
2548 | 0 | if( !pWindow ) |
2549 | 0 | throw css::uno::RuntimeException( u"invalid event source"_ustr ); |
2550 | | |
2551 | 0 | ::MouseEvent aVCLMouseEvent = VCLUnoHelper::createVCLMouseEvent( aMouseEvent ); |
2552 | 0 | ::Application::PostMouseEvent( VclEventId::WindowMouseButtonUp, pWindow, &aVCLMouseEvent ); |
2553 | 0 | } |
2554 | | |
2555 | | void SAL_CALL VCLXToolkit::mouseMove( const css::awt::MouseEvent & aMouseEvent ) |
2556 | 0 | { |
2557 | 0 | css::uno::Reference<css::awt::XWindow> xWindow ( aMouseEvent.Source, css::uno::UNO_QUERY_THROW ); |
2558 | 0 | VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow ); |
2559 | 0 | if( !pWindow ) |
2560 | 0 | throw css::uno::RuntimeException( u"invalid event source"_ustr ); |
2561 | | |
2562 | 0 | ::MouseEvent aVCLMouseEvent = VCLUnoHelper::createVCLMouseEvent( aMouseEvent ); |
2563 | 0 | ::Application::PostMouseEvent( VclEventId::WindowMouseMove, pWindow, &aVCLMouseEvent ); |
2564 | 0 | } |
2565 | | |
2566 | | |
2567 | | } // end anonymous namespace |
2568 | | |
2569 | | extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * |
2570 | | stardiv_Toolkit_VCLXToolkit_get_implementation( |
2571 | | css::uno::XComponentContext *, |
2572 | | css::uno::Sequence<css::uno::Any> const &) |
2573 | 84.7k | { |
2574 | 84.7k | return cppu::acquire(new VCLXToolkit()); |
2575 | 84.7k | } |
2576 | | |
2577 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |