Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <boost/ptr_container/ptr_vector.hpp>
31 : :
32 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
33 : :
34 : : #include <stdio.h>
35 : : #ifdef WNT
36 : : #include <prewin.h>
37 : : #include <postwin.h>
38 : : #endif
39 : : #include <com/sun/star/awt/ImageScaleMode.hpp>
40 : : #include <com/sun/star/awt/WindowAttribute.hpp>
41 : : #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
42 : : #include <com/sun/star/awt/WindowClass.hpp>
43 : : #include <com/sun/star/awt/MessageBoxButtons.hpp>
44 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
45 : : #include <com/sun/star/lang/SystemDependent.hpp>
46 : : #include <com/sun/star/awt/FocusEvent.hpp>
47 : : #include <com/sun/star/awt/KeyEvent.hpp>
48 : : #include <com/sun/star/awt/KeyModifier.hpp>
49 : : #include <com/sun/star/lang/EventObject.hpp>
50 : : #include <com/sun/star/uno/Reference.hxx>
51 : : #include <com/sun/star/uno/Sequence.hxx>
52 : : #include <com/sun/star/uno/XInterface.hpp>
53 : : #include <com/sun/star/beans/NamedValue.hpp>
54 : : #include <cppuhelper/typeprovider.hxx>
55 : : #include <osl/conditn.hxx>
56 : : #include <rtl/memory.h>
57 : : #include <rtl/uuid.h>
58 : : #include <rtl/process.h>
59 : :
60 : : #ifdef QUARTZ
61 : : #include "premac.h"
62 : : #include <Cocoa/Cocoa.h>
63 : : #include "postmac.h"
64 : : #endif
65 : :
66 : : #ifdef ANDROID
67 : : #include <sal/ByteBufferWrapper.hxx>
68 : : using org::libreoffice::touch::ByteBufferWrapper;
69 : : #endif
70 : :
71 : : #ifdef IOS
72 : : #include "premac.h"
73 : : #include <UIKit/UIKit.h>
74 : : #include "postmac.h"
75 : : #endif
76 : :
77 : : #include <vcl/sysdata.hxx>
78 : :
79 : : #include <toolkit/awt/vclxwindows.hxx>
80 : : #include <toolkit/awt/vclxsystemdependentwindow.hxx>
81 : : #include <toolkit/awt/vclxregion.hxx>
82 : : #include <toolkit/awt/vclxtoolkit.hxx>
83 : : #include <toolkit/awt/vclxtabpagecontainer.hxx>
84 : : #include <toolkit/awt/vclxtabpagemodel.hxx>
85 : :
86 : : #include <toolkit/awt/xsimpleanimation.hxx>
87 : : #include <toolkit/awt/xthrobber.hxx>
88 : : #include <toolkit/awt/animatedimagespeer.hxx>
89 : : #include <toolkit/awt/vclxtopwindow.hxx>
90 : : #include <toolkit/awt/vclxwindow.hxx>
91 : : #include <toolkit/helper/vclunohelper.hxx>
92 : : #include <toolkit/helper/unowrapper.hxx>
93 : : #include <toolkit/helper/servicenames.hxx>
94 : :
95 : : #include <toolkit/helper/macros.hxx>
96 : : #include <toolkit/helper/convert.hxx>
97 : : #include <vcl/unohelp.hxx>
98 : : #include <vcl/btndlg.hxx>
99 : : #include <vcl/button.hxx>
100 : : #include <vcl/combobox.hxx>
101 : : #include <vcl/ctrl.hxx>
102 : : #include <vcl/dialog.hxx>
103 : : #include <vcl/dockingarea.hxx>
104 : : #include <vcl/dockwin.hxx>
105 : : #include <vcl/edit.hxx>
106 : : #include <vcl/field.hxx>
107 : : #include <vcl/fixed.hxx>
108 : : #include <vcl/floatwin.hxx>
109 : : #include <vcl/group.hxx>
110 : : #include <vcl/imgctrl.hxx>
111 : : #include <vcl/longcurr.hxx>
112 : : #include <vcl/lstbox.hxx>
113 : : #include <vcl/menubtn.hxx>
114 : : #include <vcl/morebtn.hxx>
115 : : #include <vcl/msgbox.hxx>
116 : : #include <vcl/scrbar.hxx>
117 : : #include <vcl/spin.hxx>
118 : : #include <vcl/split.hxx>
119 : : #include <vcl/splitwin.hxx>
120 : : #include <vcl/status.hxx>
121 : : #include <vcl/svapp.hxx>
122 : : #include <vcl/syschild.hxx>
123 : : #include <vcl/tabctrl.hxx>
124 : : #include <vcl/tabdlg.hxx>
125 : : #include <vcl/tabpage.hxx>
126 : : #include <vcl/toolbox.hxx>
127 : : #include <vcl/virdev.hxx>
128 : : #include <vcl/window.hxx>
129 : : #include <vcl/wrkwin.hxx>
130 : : #include <vcl/throbber.hxx>
131 : : #include "toolkit/awt/vclxspinbutton.hxx"
132 : :
133 : : #include <tools/debug.hxx>
134 : : #include <comphelper/processfactory.hxx>
135 : :
136 : : namespace css = ::com::sun::star;
137 : :
138 : : #define VCLWINDOW_FRAMEWINDOW 0x1000
139 : : #define VCLWINDOW_SYSTEMCHILDWINDOW 0x1001
140 : :
141 : : #if (defined WNT)
142 : : #define SYSTEM_DEPENDENT_TYPE ::com::sun::star::lang::SystemDependent::SYSTEM_WIN32
143 : : #elif (defined QUARTZ)
144 : : #define SYSTEM_DEPENDENT_TYPE ::com::sun::star::lang::SystemDependent::SYSTEM_MAC
145 : : #elif (defined UNX)
146 : : #define SYSTEM_DEPENDENT_TYPE ::com::sun::star::lang::SystemDependent::SYSTEM_XWINDOW
147 : : #endif
148 : :
149 : 16392 : TOOLKIT_DLLPUBLIC WinBits ImplGetWinBits( sal_uInt32 nComponentAttribs, sal_uInt16 nCompType )
150 : : {
151 : 16392 : WinBits nWinBits = 0;
152 : :
153 : 16392 : sal_Bool bMessBox = sal_False;
154 [ + - ][ + - ]: 16392 : if ( ( nCompType == WINDOW_INFOBOX ) ||
[ + - ][ + - ]
[ - + ]
155 : : ( nCompType == WINDOW_MESSBOX ) ||
156 : : ( nCompType == WINDOW_QUERYBOX ) ||
157 : : ( nCompType == WINDOW_WARNINGBOX ) ||
158 : : ( nCompType == WINDOW_ERRORBOX ) )
159 : : {
160 : 0 : bMessBox = sal_True;
161 : : }
162 : :
163 : 16392 : bool bDecoratedWindow = false;
164 [ + - ][ + + ]: 16392 : if ( bMessBox
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + + ]
[ + - ][ + - ]
[ - + ]
165 : : || ( nCompType == WINDOW_DIALOG )
166 : : || ( nCompType == WINDOW_MODELESSDIALOG )
167 : : || ( nCompType == WINDOW_MODALDIALOG )
168 : : || ( nCompType == WINDOW_SYSTEMDIALOG )
169 : : || ( nCompType == WINDOW_PATHDIALOG )
170 : : || ( nCompType == WINDOW_FILEDIALOG )
171 : : || ( nCompType == WINDOW_PRINTERSETUPDIALOG )
172 : : || ( nCompType == WINDOW_PRINTDIALOG )
173 : : || ( nCompType == WINDOW_COLORDIALOG )
174 : : || ( nCompType == WINDOW_FONTDIALOG )
175 : : || ( nCompType == WINDOW_DOCKINGWINDOW )
176 : : || ( nCompType == WINDOW_TABDIALOG )
177 : : || ( nCompType == WINDOW_BUTTONDIALOG )
178 : : || ( nCompType == WINDOW_SYSTEMCHILDWINDOW )
179 : : )
180 : : {
181 : 4 : bDecoratedWindow = true;
182 : : }
183 : :
184 [ + + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::BORDER )
185 : 2150 : nWinBits |= WB_BORDER;
186 [ + + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::NOBORDER )
187 : 6 : nWinBits |= WB_NOBORDER;
188 [ + + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::SIZEABLE )
189 : 1747 : nWinBits |= WB_SIZEABLE;
190 [ + + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::MOVEABLE )
191 : 1749 : nWinBits |= WB_MOVEABLE;
192 [ + + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::CLOSEABLE )
193 : 1749 : nWinBits |= WB_CLOSEABLE;
194 [ + + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::HSCROLL )
195 : 22 : nWinBits |= WB_HSCROLL;
196 [ + + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::VSCROLL )
197 : 22 : nWinBits |= WB_VSCROLL;
198 [ + + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::LEFT )
199 : 401 : nWinBits |= WB_LEFT;
200 [ + + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::CENTER )
201 : 102 : nWinBits |= WB_CENTER;
202 [ - + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::RIGHT )
203 : 0 : nWinBits |= WB_RIGHT;
204 [ + + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::SPIN )
205 : 48 : nWinBits |= WB_SPIN;
206 [ - + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::SORT )
207 : 0 : nWinBits |= WB_SORT;
208 [ + + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DROPDOWN )
209 : 46 : nWinBits |= WB_DROPDOWN;
210 [ - + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEFBUTTON )
211 : 0 : nWinBits |= WB_DEFBUTTON;
212 [ - + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::READONLY )
213 : 0 : nWinBits |= WB_READONLY;
214 [ + + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::CLIPCHILDREN )
215 : 1745 : nWinBits |= WB_CLIPCHILDREN;
216 [ - + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::GROUP )
217 : 0 : nWinBits |= WB_GROUP;
218 [ - + ]: 16392 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::NOLABEL ) //added for issue79712
219 : 0 : nWinBits |= WB_NOLABEL;
220 : :
221 : : // These bits are not uniqe
222 [ - + ]: 16392 : if ( bMessBox )
223 : : {
224 [ # # ]: 0 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::OK )
225 : 0 : nWinBits |= WB_OK;
226 [ # # ]: 0 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::OK_CANCEL )
227 : 0 : nWinBits |= WB_OK_CANCEL;
228 [ # # ]: 0 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::YES_NO )
229 : 0 : nWinBits |= WB_YES_NO;
230 [ # # ]: 0 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::YES_NO_CANCEL )
231 : 0 : nWinBits |= WB_YES_NO_CANCEL;
232 [ # # ]: 0 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::RETRY_CANCEL )
233 : 0 : nWinBits |= WB_RETRY_CANCEL;
234 [ # # ]: 0 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEF_OK )
235 : 0 : nWinBits |= WB_DEF_OK;
236 [ # # ]: 0 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEF_CANCEL )
237 : 0 : nWinBits |= WB_DEF_CANCEL;
238 [ # # ]: 0 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEF_RETRY )
239 : 0 : nWinBits |= WB_DEF_RETRY;
240 [ # # ]: 0 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEF_YES )
241 : 0 : nWinBits |= WB_DEF_YES;
242 [ # # ]: 0 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::DEF_NO )
243 : 0 : nWinBits |= WB_DEF_NO;
244 : : }
245 [ + + ]: 16392 : if ( nCompType == WINDOW_MULTILINEEDIT )
246 : : {
247 [ - + ]: 22 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::AUTOHSCROLL )
248 : 0 : nWinBits |= WB_AUTOHSCROLL;
249 [ - + ]: 22 : if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::AUTOVSCROLL )
250 : 0 : nWinBits |= WB_AUTOVSCROLL;
251 : : }
252 : :
253 : :
254 [ + + ]: 16392 : if ( bDecoratedWindow )
255 : : {
256 [ - + ]: 4 : if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::NODECORATION )
257 : : {
258 : : // No decoration removes several window attributes and must
259 : : // set WB_NOBORDER!
260 : 0 : nWinBits &= ~WB_BORDER;
261 : 0 : nWinBits &= ~WB_SIZEABLE;
262 : 0 : nWinBits &= ~WB_MOVEABLE;
263 : 0 : nWinBits &= ~WB_CLOSEABLE;
264 : 0 : nWinBits |= WB_NOBORDER;
265 : : }
266 : : }
267 : :
268 : 16392 : return nWinBits;
269 : : }
270 : :
271 : : struct ComponentInfo
272 : : {
273 : : const char* pName;
274 : : WindowType nWinType;
275 : : };
276 : :
277 : : static ComponentInfo aComponentInfos [] =
278 : : {
279 : : { "buttondialog", WINDOW_BUTTONDIALOG },
280 : : { "cancelbutton", WINDOW_CANCELBUTTON },
281 : : { "checkbox", WINDOW_CHECKBOX },
282 : : { "combobox", WINDOW_COMBOBOX },
283 : : { "control", WINDOW_CONTROL },
284 : : { "currencybox", WINDOW_CURRENCYBOX },
285 : : { "currencyfield", WINDOW_CURRENCYFIELD },
286 : : { "datebox", WINDOW_DATEBOX },
287 : : { "datefield", WINDOW_DATEFIELD },
288 : : { "dialog", WINDOW_DIALOG },
289 : : { "dockingarea", WINDOW_DOCKINGAREA },
290 : : { "dockingwindow", WINDOW_DOCKINGWINDOW },
291 : : { "edit", WINDOW_EDIT },
292 : : { "errorbox", WINDOW_ERRORBOX },
293 : : { "fixedbitmap", WINDOW_FIXEDBITMAP },
294 : : { "fixedimage", WINDOW_FIXEDIMAGE },
295 : : { "fixedline", WINDOW_FIXEDLINE },
296 : : { "fixedtext", WINDOW_FIXEDTEXT },
297 : : { "floatingwindow", WINDOW_FLOATINGWINDOW },
298 : : { "framewindow", VCLWINDOW_FRAMEWINDOW },
299 : : { "groupbox", WINDOW_GROUPBOX },
300 : : { "frame", WINDOW_GROUPBOX },
301 : : { "helpbutton", WINDOW_HELPBUTTON },
302 : : { "imagebutton", WINDOW_IMAGEBUTTON },
303 : : { "imageradiobutton", WINDOW_IMAGERADIOBUTTON },
304 : : { "infobox", WINDOW_INFOBOX },
305 : : { "listbox", WINDOW_LISTBOX },
306 : : { "longcurrencybox", WINDOW_LONGCURRENCYBOX },
307 : : { "longcurrencyfield", WINDOW_LONGCURRENCYFIELD },
308 : : { "menubutton", WINDOW_MENUBUTTON },
309 : : { "messbox", WINDOW_MESSBOX },
310 : : { "metricbox", WINDOW_METRICBOX },
311 : : { "metricfield", WINDOW_METRICFIELD },
312 : : { "modaldialog", WINDOW_MODALDIALOG },
313 : : { "modelessdialog", WINDOW_MODELESSDIALOG },
314 : : { "morebutton", WINDOW_MOREBUTTON },
315 : : { "multilineedit", WINDOW_MULTILINEEDIT },
316 : : { "multilistbox", WINDOW_MULTILISTBOX },
317 : : { "numericbox", WINDOW_NUMERICBOX },
318 : : { "numericfield", WINDOW_NUMERICFIELD },
319 : : { "okbutton", WINDOW_OKBUTTON },
320 : : { "patternbox", WINDOW_PATTERNBOX },
321 : : { "patternfield", WINDOW_PATTERNFIELD },
322 : : { "pushbutton", WINDOW_PUSHBUTTON },
323 : : { "querybox", WINDOW_QUERYBOX },
324 : : { "radiobutton", WINDOW_RADIOBUTTON },
325 : : { "scrollbar", WINDOW_SCROLLBAR },
326 : : { "scrollbarbox", WINDOW_SCROLLBARBOX },
327 : : { "simpleanimation", WINDOW_CONTROL },
328 : : { "animatedimages", WINDOW_CONTROL },
329 : : { "spinbutton", WINDOW_SPINBUTTON },
330 : : { "spinfield", WINDOW_SPINFIELD },
331 : : { "throbber", WINDOW_CONTROL },
332 : : { "splitter", WINDOW_SPLITTER },
333 : : { "splitwindow", WINDOW_SPLITWINDOW },
334 : : { "statusbar", WINDOW_STATUSBAR },
335 : : { "systemchildwindow", VCLWINDOW_SYSTEMCHILDWINDOW },
336 : : { "tabcontrol", WINDOW_TABCONTROL },
337 : : { "tabdialog", WINDOW_TABDIALOG },
338 : : { "tabpage", WINDOW_TABPAGE },
339 : : { "timebox", WINDOW_TIMEBOX },
340 : : { "timefield", WINDOW_TIMEFIELD },
341 : : { "toolbox", WINDOW_TOOLBOX },
342 : : { "tristatebox", WINDOW_TRISTATEBOX },
343 : : { "warningbox", WINDOW_WARNINGBOX },
344 : : { "window", WINDOW_WINDOW },
345 : : { "workwindow", WINDOW_WORKWINDOW },
346 : : { "tabpagecontainer", WINDOW_CONTROL },
347 : : { "tabpagemodel", WINDOW_TABPAGE }
348 : : };
349 : :
350 : : extern "C"
351 : : {
352 : 188686 : static int SAL_CALL ComponentInfoCompare( const void* pFirst, const void* pSecond)
353 : : {
354 : : return( strcmp( ((ComponentInfo*)pFirst)->pName,
355 : 188686 : ((ComponentInfo*)pSecond)->pName ) );
356 : : }
357 : : }
358 : :
359 : 32638 : sal_uInt16 ImplGetComponentType( const String& rServiceName )
360 : : {
361 : : static sal_Bool bSorted = sal_False;
362 [ + + ]: 32638 : if( !bSorted )
363 : : {
364 : : qsort( (void*) aComponentInfos,
365 : : sizeof( aComponentInfos ) / sizeof( ComponentInfo ),
366 : : sizeof( ComponentInfo ),
367 [ + - ]: 115 : ComponentInfoCompare );
368 : 115 : bSorted = sal_True;
369 : : }
370 : :
371 : :
372 : : ComponentInfo aSearch;
373 [ + - ][ + - ]: 32638 : rtl::OString aServiceName(rtl::OUStringToOString(rServiceName, osl_getThreadTextEncoding()).toAsciiLowerCase());
[ + - ]
374 [ + + ]: 32638 : if ( !aServiceName.isEmpty() )
375 : 32626 : aSearch.pName = aServiceName.getStr();
376 : : else
377 : 12 : aSearch.pName = "window";
378 : :
379 : : ComponentInfo* pInf = (ComponentInfo*) bsearch( &aSearch,
380 : : (void*) aComponentInfos,
381 : : sizeof( aComponentInfos ) / sizeof( ComponentInfo ),
382 : : sizeof( ComponentInfo ),
383 [ + - ]: 32638 : ComponentInfoCompare );
384 : :
385 [ + + ]: 32638 : return pInf ? pInf->nWinType : 0;
386 : : }
387 : :
388 : :
389 : : // ----------------------------------------------------
390 : : // class VCLXToolkit
391 : : // ----------------------------------------------------
392 : :
393 : : static sal_Int32 nVCLToolkitInstanceCount = 0;
394 : : static sal_Bool bInitedByVCLToolkit = sal_False;
395 : :
396 : 55620 : static osl::Mutex & getInitMutex()
397 : : {
398 : : static osl::Mutex * pM;
399 [ + + ]: 55620 : if( !pM )
400 : : {
401 [ + - ][ + - ]: 115 : osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
402 [ + - ]: 115 : if( !pM )
403 : : {
404 [ + - ][ + - ]: 115 : static osl::Mutex aMutex;
[ + - ][ # # ]
405 : 115 : pM = &aMutex;
406 [ + - ]: 115 : }
407 : : }
408 : 55620 : return *pM;
409 : : }
410 : :
411 : 1568 : static osl::Condition & getInitCondition()
412 : : {
413 : : static osl::Condition * pC = 0;
414 [ + + ]: 1568 : if( !pC )
415 : : {
416 [ + - ][ + - ]: 54 : osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
417 [ + + ]: 54 : if( !pC )
418 : : {
419 [ + - ][ + - ]: 51 : static osl::Condition aCondition;
[ + - ][ # # ]
420 : 51 : pC = &aCondition;
421 [ + - ]: 54 : }
422 : : }
423 : 1568 : return *pC;
424 : : }
425 : :
426 : 784 : struct ToolkitThreadData
427 : : {
428 : : VCLXToolkit * pTk;
429 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr;
430 : :
431 : 784 : ToolkitThreadData( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr, VCLXToolkit * pTk_ )
432 : : : pTk( pTk_ )
433 : 784 : , xSMgr( rSMgr )
434 : : {
435 : 784 : }
436 : : };
437 : :
438 : : extern "C"
439 : : {
440 : 784 : static void SAL_CALL ToolkitWorkerFunction( void* pArgs )
441 : : {
442 : 784 : ToolkitThreadData * pTTD = (ToolkitThreadData *)pArgs;
443 : 784 : bInitedByVCLToolkit = InitVCL( pTTD->xSMgr );
444 [ - + ]: 784 : if( bInitedByVCLToolkit )
445 : : {
446 [ # # ][ # # ]: 0 : UnoWrapper* pUnoWrapper = new UnoWrapper( pTTD->pTk );
[ # # ]
447 : 0 : Application::SetUnoWrapper( pUnoWrapper );
448 : : }
449 : 784 : getInitCondition().set();
450 [ - + ]: 784 : if( bInitedByVCLToolkit )
451 : : {
452 : : {
453 [ # # ]: 0 : SolarMutexGuard aGuard;
454 [ # # ]: 0 : Application::Execute();
[ # # # # ]
455 : : }
456 : : try
457 : : {
458 [ # # ]: 0 : pTTD->pTk->dispose();
459 : : }
460 : 0 : catch( com::sun::star::uno::Exception & )
461 : : {
462 : : }
463 : 0 : DeInitVCL();
464 : : }
465 : : else
466 : : {
467 : 784 : JoinMainLoopThread();
468 : : }
469 [ + - ]: 784 : delete pTTD;
470 : 784 : }
471 : : }
472 : :
473 : : // contructor, which might initialize VCL
474 : 27858 : VCLXToolkit::VCLXToolkit( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr ):
475 : : cppu::WeakComponentImplHelper7<
476 : : ::com::sun::star::awt::XToolkit2,
477 : : ::com::sun::star::lang::XServiceInfo,
478 : : ::com::sun::star::awt::XSystemChildFactory,
479 : : ::com::sun::star::awt::XMessageBoxFactory,
480 : : ::com::sun::star::awt::XDataTransferProviderAccess,
481 : : ::com::sun::star::awt::XExtendedToolkit,
482 : 27858 : ::com::sun::star::awt::XReschedule>( GetMutex() ),
483 : : m_aTopWindowListeners(rBHelper.rMutex),
484 : : m_aKeyHandlers(rBHelper.rMutex),
485 : : m_aFocusListeners(rBHelper.rMutex),
486 : : m_aEventListenerLink(LINK(this, VCLXToolkit, eventListenerHandler)),
487 : : m_aKeyListenerLink(LINK(this, VCLXToolkit, keyListenerHandler)),
488 : : m_bEventListener(false),
489 [ + - ][ + - ]: 55716 : m_bKeyListener(false)
[ + - ][ + - ]
[ + - ]
490 : : {
491 : 27858 : hSvToolsLib = NULL;
492 : 27858 : fnSvtCreateWindow = NULL;
493 : :
494 [ + - ][ + - ]: 27858 : osl::Guard< osl::Mutex > aGuard( getInitMutex() );
495 : 27858 : nVCLToolkitInstanceCount++;
496 [ + + ][ + - ]: 27858 : if( ( nVCLToolkitInstanceCount == 1 ) && ( !Application::IsInMain() ) )
[ + + ][ + + ]
497 : : {
498 : : // setup execute thread
499 [ + - ][ + - ]: 784 : CreateMainLoopThread( ToolkitWorkerFunction, new ToolkitThreadData( rSMgr, this ) );
[ + - ]
500 [ + - ][ + - ]: 784 : getInitCondition().wait();
501 [ + - ]: 27858 : }
502 : 27858 : }
503 : :
504 [ + - ][ + - ]: 27762 : VCLXToolkit::~VCLXToolkit()
[ + - ][ + - ]
505 : : {
506 [ - + ]: 55524 : }
507 : :
508 : :
509 : 27762 : void SAL_CALL VCLXToolkit::disposing()
510 : : {
511 [ + + ]: 27762 : if ( hSvToolsLib )
512 : : {
513 [ + - ]: 15849 : osl_unloadModule( hSvToolsLib );
514 : 15849 : hSvToolsLib = NULL;
515 : 15849 : fnSvtCreateWindow = NULL;
516 : : }
517 : :
518 : : {
519 [ + - ][ + - ]: 27762 : osl::Guard< osl::Mutex > aGuard( getInitMutex() );
520 [ + + ]: 27762 : if( --nVCLToolkitInstanceCount == 0 )
521 : : {
522 [ - + ]: 1446 : if( bInitedByVCLToolkit )
523 : : {
524 [ # # ]: 0 : Application::Quit();
525 [ # # ]: 0 : JoinMainLoopThread();
526 : 0 : bInitedByVCLToolkit = sal_False;
527 : : }
528 [ + - ]: 27762 : }
529 : : }
530 : :
531 [ - + ]: 27762 : if (m_bEventListener)
532 : : {
533 [ # # ]: 0 : ::Application::RemoveEventListener(m_aEventListenerLink);
534 : 0 : m_bEventListener = false;
535 : : }
536 [ - + ]: 27762 : if (m_bKeyListener)
537 : : {
538 [ # # ]: 0 : ::Application::RemoveKeyListener(m_aKeyListenerLink);
539 : 0 : m_bKeyListener = false;
540 : : }
541 : : ::css::lang::EventObject aEvent(
542 [ + - ][ + - ]: 27762 : static_cast< ::cppu::OWeakObject * >(this));
543 [ + - ]: 27762 : m_aTopWindowListeners.disposeAndClear(aEvent);
544 [ + - ]: 27762 : m_aKeyHandlers.disposeAndClear(aEvent);
545 [ + - ][ + - ]: 27762 : m_aFocusListeners.disposeAndClear(aEvent);
546 : 27762 : }
547 : :
548 : :
549 : 2 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > VCLXToolkit::getDesktopWindow( ) throw(::com::sun::star::uno::RuntimeException)
550 : : {
551 : 2 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xRef;
552 : : // 07/00: AppWindow doesn't exist anymore...
553 : 2 : return xRef;
554 : : }
555 : :
556 : 2 : ::com::sun::star::awt::Rectangle VCLXToolkit::getWorkArea( ) throw(::com::sun::star::uno::RuntimeException)
557 : : {
558 : 2 : ::com::sun::star::awt::Rectangle aRect;
559 : : // 07/00: AppWindow doesn't exist anymore...
560 : 2 : return aRect;
561 : : }
562 : :
563 : 16392 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > VCLXToolkit::createWindow( const ::com::sun::star::awt::WindowDescriptor& rDescriptor ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
564 : : {
565 : 16392 : return ImplCreateWindow( rDescriptor, WinBits(0) );
566 : : }
567 : :
568 : 66 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXToolkit::createScreenCompatibleDevice( sal_Int32 Width, sal_Int32 Height ) throw(::com::sun::star::uno::RuntimeException)
569 : : {
570 : 66 : return createScreenCompatibleDeviceUsingBuffer( Width, Height, 1, 1, 0, 0, 0 );
571 : : }
572 : :
573 : 66 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXToolkit::createScreenCompatibleDeviceUsingBuffer( sal_Int32 Width, sal_Int32 Height, sal_Int32 ScaleNumerator, sal_Int32 ScaleDenominator, sal_Int32 XOffset, sal_Int32 YOffset, sal_Int64 addressOfMemoryBufferForSharedArrayWrapper ) throw(::com::sun::star::uno::RuntimeException)
574 : : {
575 [ + - ]: 66 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
576 : :
577 : 66 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > xRef;
578 [ + - ]: 66 : VCLXVirtualDevice* pVDev = new VCLXVirtualDevice;
579 : :
580 [ + - ]: 66 : SolarMutexGuard aSolarGuard;
581 : :
582 [ + - ][ + - ]: 66 : VirtualDevice* pV = new VirtualDevice;
583 [ - + ]: 66 : if ( addressOfMemoryBufferForSharedArrayWrapper != 0 ) {
584 : : #if defined(ANDROID)
585 : : ByteBufferWrapper *bbw = (ByteBufferWrapper *) (intptr_t) addressOfMemoryBufferForSharedArrayWrapper;
586 : : pV->SetOutputSizePixelScaleOffsetAndBuffer( Size( Width, Height ), Fraction(ScaleNumerator, ScaleDenominator), Point( XOffset, YOffset), basebmp::RawMemorySharedArray( bbw->pointer(), *bbw ));
587 : : #else
588 : : (void) ScaleNumerator;
589 : : (void) ScaleDenominator;
590 : : (void) XOffset;
591 : : (void) YOffset;
592 : : OSL_FAIL( "rendering to a pre-allocated buffer not done yet for this OS" );
593 [ # # ]: 0 : pV->SetOutputSizePixel( Size( Width, Height ) );
594 : : #endif
595 : : } else {
596 [ + - ]: 66 : pV->SetOutputSizePixel( Size( Width, Height ) );
597 : : }
598 : 66 : pVDev->SetVirtualDevice( pV );
599 : :
600 [ + - ]: 66 : xRef = pVDev;
601 [ + - ][ + - ]: 66 : return xRef;
602 : : }
603 : :
604 : 2 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion > VCLXToolkit::createRegion( ) throw(::com::sun::star::uno::RuntimeException)
605 : : {
606 [ + - ]: 2 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
607 : :
608 [ + - ][ + - ]: 2 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion > xRef = new VCLXRegion;
609 [ + - ]: 2 : return xRef;
610 : : }
611 : :
612 : 16246 : Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp,
613 : : const ::com::sun::star::awt::WindowDescriptor& rDescriptor,
614 : : Window* pParent, WinBits nWinBits )
615 : : {
616 [ + - ]: 16246 : String aServiceName( rDescriptor.WindowServiceName );
617 [ + - ]: 16246 : aServiceName.ToLowerAscii();
618 : :
619 : 16246 : Window* pNewWindow = NULL;
620 [ + - ]: 16246 : sal_uInt16 nType = ImplGetComponentType( aServiceName );
621 : 16246 : bool bFrameControl = false;
622 [ + - ][ + - ]: 16246 : if ( aServiceName == String( RTL_CONSTASCII_USTRINGPARAM("frame") ) )
[ + - ][ - + ]
623 : 0 : bFrameControl = true;
624 [ + - ][ + - ]: 16246 : if ( aServiceName == String( RTL_CONSTASCII_USTRINGPARAM("tabcontrolnotabs") ) )
[ + - ][ - + ]
625 : : {
626 : 0 : nWinBits |= WB_NOBORDER;
627 [ # # ][ # # ]: 0 : nType = ImplGetComponentType( String( RTL_CONSTASCII_USTRINGPARAM("tabcontrol") ) );
[ # # ]
628 : : }
629 [ + + ]: 16246 : if ( !pParent )
630 : : {
631 : : // Wenn die Component einen Parent braucht, dann NULL zurueckgeben,
632 : : // spaeter mal ::com::sun::star::uno::Exception...
633 : 1753 : sal_Bool bException = sal_True;
634 [ + + ][ + - ]: 1753 : if ( ( nType == WINDOW_DIALOG )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
635 : : || ( nType == WINDOW_MODALDIALOG )
636 : : || ( nType == WINDOW_MODELESSDIALOG )
637 : : || ( nType == WINDOW_MESSBOX )
638 : : || ( nType == WINDOW_INFOBOX )
639 : : || ( nType == WINDOW_WARNINGBOX )
640 : : || ( nType == WINDOW_ERRORBOX )
641 : : || ( nType == WINDOW_QUERYBOX )
642 : : )
643 : 2 : bException = sal_False;
644 [ - + ][ # # ]: 1751 : else if ( ( nType == WINDOW_WINDOW ) ||
[ # # ]
645 : : ( nType == WINDOW_WORKWINDOW ) ||
646 : : ( nType == VCLWINDOW_FRAMEWINDOW ) )
647 : : {
648 [ + - ]: 1751 : if ( rDescriptor.Type == ::com::sun::star::awt::WindowClass_TOP )
649 : 1751 : bException = sal_False;
650 : : }
651 : :
652 [ - + ]: 1753 : if ( bException )
653 : : {
654 : 0 : *ppNewComp = NULL;
655 : 0 : return NULL;
656 : : }
657 : : }
658 : :
659 [ + - ]: 16246 : if ( nType )
660 : : {
661 [ + - ]: 16246 : SolarMutexGuard aVclGuard;
662 [ - + + - : 16246 : switch ( (WindowType)nType )
- - - + +
- - + - +
- + - - -
- + - - -
- - - + -
- - - - -
+ + - + +
- + - - -
- - - - -
- + - - -
+ - - ]
663 : : {
664 : : case WINDOW_CANCELBUTTON:
665 [ # # ][ # # ]: 0 : pNewWindow = new CancelButton( pParent, nWinBits );
666 [ # # ]: 0 : *ppNewComp = new VCLXButton;
667 : 0 : break;
668 : : case WINDOW_CHECKBOX:
669 [ + - ][ + - ]: 34 : pNewWindow = new CheckBox( pParent, nWinBits );
670 [ + - ][ + - ]: 34 : *ppNewComp = new VCLXCheckBox;
671 : 34 : break;
672 : : case WINDOW_COMBOBOX:
673 [ + - ][ + - ]: 40 : pNewWindow = new ComboBox( pParent, nWinBits|WB_AUTOHSCROLL );
674 [ + - ]: 40 : ((ComboBox*)pNewWindow)->EnableAutoSize( sal_False );
675 [ + - ][ + - ]: 40 : *ppNewComp = new VCLXComboBox;
676 : 40 : break;
677 : : case WINDOW_CURRENCYBOX:
678 [ # # ][ # # ]: 0 : pNewWindow = new CurrencyBox( pParent, nWinBits );
679 : 0 : break;
680 : : case WINDOW_CURRENCYFIELD:
681 [ # # ][ # # ]: 0 : pNewWindow = new CurrencyField( pParent, nWinBits );
682 : 0 : static_cast<CurrencyField*>(pNewWindow)->EnableEmptyFieldValue( sal_True );
683 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXNumericField;
684 [ # # ][ # # ]: 0 : ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(CurrencyField*)pNewWindow );
685 : 0 : break;
686 : : case WINDOW_DATEBOX:
687 [ # # ][ # # ]: 0 : pNewWindow = new DateBox( pParent, nWinBits );
688 : 0 : break;
689 : : case WINDOW_DATEFIELD:
690 [ # # ][ # # ]: 0 : pNewWindow = new DateField( pParent, nWinBits );
691 : 0 : static_cast<DateField*>(pNewWindow)->EnableEmptyFieldValue( sal_True );
692 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXDateField;
693 [ # # ][ # # ]: 0 : ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(DateField*)pNewWindow );
694 : 0 : break;
695 : : case WINDOW_DOCKINGAREA:
696 [ + - ][ + - ]: 14080 : pNewWindow = new DockingAreaWindow( pParent );
697 : 14080 : break;
698 : : case WINDOW_MULTILINEEDIT:
699 : : case WINDOW_EDIT:
700 [ + - ][ + - ]: 105 : pNewWindow = new Edit( pParent, nWinBits );
701 [ + - ][ + - ]: 105 : *ppNewComp = new VCLXEdit;
702 : 105 : break;
703 : : case WINDOW_ERRORBOX:
704 [ # # ][ # # ]: 0 : pNewWindow = new ErrorBox( pParent, nWinBits, String() );
[ # # ][ # # ]
705 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXMessageBox;
706 : 0 : break;
707 : : case WINDOW_FIXEDBITMAP:
708 [ # # ][ # # ]: 0 : pNewWindow = new FixedBitmap( pParent, nWinBits );
709 : 0 : break;
710 : : case WINDOW_FIXEDIMAGE:
711 [ + - ][ + - ]: 22 : pNewWindow = new ImageControl( pParent, nWinBits );
712 [ + - ]: 22 : *ppNewComp = new VCLXImageControl;
713 : 22 : break;
714 : : case WINDOW_FIXEDLINE:
715 [ # # ][ # # ]: 0 : pNewWindow = new FixedLine( pParent, nWinBits );
716 : 0 : break;
717 : : case WINDOW_FIXEDTEXT:
718 [ + - ][ + - ]: 4 : pNewWindow = new FixedText( pParent, nWinBits );
719 [ + - ][ + - ]: 4 : *ppNewComp = new VCLXFixedText;
720 : 4 : break;
721 : : case WINDOW_FLOATINGWINDOW:
722 [ # # ][ # # ]: 0 : pNewWindow = new FloatingWindow( pParent, nWinBits );
723 : 0 : break;
724 : : case WINDOW_GROUPBOX:
725 : : {
726 [ + - ][ + - ]: 26 : pNewWindow = new GroupBox( pParent, nWinBits );
727 [ - + ]: 26 : if ( bFrameControl )
728 : : {
729 : 0 : GroupBox* pGroupBox = static_cast< GroupBox* >( pNewWindow );
730 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXFrame;
731 : : // Frame control needs to recieve
732 : : // Mouse events
733 [ # # ]: 0 : pGroupBox->SetMouseTransparent( sal_False );
734 : : }
735 : : }
736 : 26 : break;
737 : : case WINDOW_HELPBUTTON:
738 [ # # ][ # # ]: 0 : pNewWindow = new HelpButton( pParent, nWinBits );
739 [ # # ]: 0 : *ppNewComp = new VCLXButton;
740 : 0 : break;
741 : : case WINDOW_IMAGEBUTTON:
742 [ # # ][ # # ]: 0 : pNewWindow = new ImageButton( pParent, nWinBits );
743 [ # # ]: 0 : *ppNewComp = new VCLXButton;
744 : 0 : break;
745 : : case WINDOW_IMAGERADIOBUTTON:
746 [ # # ][ # # ]: 0 : pNewWindow = new ImageRadioButton( pParent, nWinBits );
747 [ # # ]: 0 : *ppNewComp = new VCLXButton;
748 : 0 : break;
749 : : case WINDOW_INFOBOX:
750 [ # # ][ # # ]: 0 : pNewWindow = new InfoBox( pParent, String() );
[ # # ][ # # ]
751 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXMessageBox;
752 : 0 : break;
753 : : case WINDOW_LISTBOX:
754 [ + - ][ + - ]: 38 : pNewWindow = new ListBox( pParent, nWinBits|WB_SIMPLEMODE|WB_AUTOHSCROLL );
755 [ + - ]: 38 : ((ListBox*)pNewWindow)->EnableAutoSize( sal_False );
756 [ + - ]: 38 : *ppNewComp = new VCLXListBox;
757 : 38 : break;
758 : : case WINDOW_LONGCURRENCYBOX:
759 [ # # ][ # # ]: 0 : pNewWindow = new LongCurrencyBox( pParent, nWinBits );
760 : 0 : break;
761 : : case WINDOW_LONGCURRENCYFIELD:
762 [ # # ][ # # ]: 0 : pNewWindow = new LongCurrencyField( pParent, nWinBits );
763 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXCurrencyField;
764 [ # # ][ # # ]: 0 : ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(LongCurrencyField*)pNewWindow );
765 : 0 : break;
766 : : case WINDOW_MENUBUTTON:
767 [ # # ][ # # ]: 0 : pNewWindow = new MenuButton( pParent, nWinBits );
768 [ # # ]: 0 : *ppNewComp = new VCLXButton;
769 : 0 : break;
770 : : case WINDOW_MESSBOX:
771 [ # # ][ # # ]: 0 : pNewWindow = new MessBox( pParent, nWinBits, String(), String() );
[ # # ][ # # ]
[ # # ][ # # ]
772 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXMessageBox;
773 : 0 : break;
774 : : case WINDOW_METRICBOX:
775 [ # # ][ # # ]: 0 : pNewWindow = new MetricBox( pParent, nWinBits );
776 : 0 : break;
777 : : case WINDOW_METRICFIELD:
778 [ # # ][ # # ]: 0 : pNewWindow = new MetricField( pParent, nWinBits );
779 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXMetricField;
780 [ # # ][ # # ]: 0 : ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(MetricField*)pNewWindow );
781 : 0 : break;
782 : : case WINDOW_DIALOG:
783 : : case WINDOW_MODALDIALOG:
784 : : case WINDOW_MODELESSDIALOG:
785 : : {
786 : : // Modal/Modeless nur durch Show/Execute
787 [ + - ][ - + ]: 2 : if ( (pParent == NULL ) && ( rDescriptor.ParentIndex == -1 ) )
788 : 0 : pParent = DIALOG_NO_PARENT;
789 [ + - ][ + - ]: 2 : pNewWindow = new Dialog( pParent, nWinBits );
790 : : // #i70217# Don't always create a new component object. It's possible that VCL has called
791 : : // GetComponentInterface( sal_True ) in the Dialog ctor itself (see Window::IsTopWindow() )
792 : : // which creates a component object.
793 [ + - ]: 2 : css::uno::Reference< css::awt::XWindowPeer > xWinPeer = pNewWindow->GetComponentInterface( sal_False );
794 [ - + ]: 2 : if ( xWinPeer.is() )
795 [ # # ][ # # ]: 0 : *ppNewComp = dynamic_cast< VCLXDialog* >( xWinPeer.get() );
[ # # ]
796 : : else
797 [ + - ][ + - ]: 2 : *ppNewComp = new VCLXDialog;
798 : : }
799 : 2 : break;
800 : : case WINDOW_MOREBUTTON:
801 [ # # ][ # # ]: 0 : pNewWindow = new MoreButton( pParent, nWinBits );
802 [ # # ]: 0 : *ppNewComp = new VCLXButton;
803 : 0 : break;
804 : : case WINDOW_MULTILISTBOX:
805 [ # # ][ # # ]: 0 : pNewWindow = new MultiListBox( pParent, nWinBits );
806 [ # # ]: 0 : *ppNewComp = new VCLXListBox;
807 : 0 : break;
808 : : case WINDOW_NUMERICBOX:
809 [ # # ][ # # ]: 0 : pNewWindow = new NumericBox( pParent, nWinBits );
810 : 0 : break;
811 : : case WINDOW_NUMERICFIELD:
812 [ # # ][ # # ]: 0 : pNewWindow = new NumericField( pParent, nWinBits );
813 : 0 : static_cast<NumericField*>(pNewWindow)->EnableEmptyFieldValue( sal_True );
814 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXNumericField;
815 [ # # ][ # # ]: 0 : ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(NumericField*)pNewWindow );
816 : 0 : break;
817 : : case WINDOW_OKBUTTON:
818 [ # # ][ # # ]: 0 : pNewWindow = new OKButton( pParent, nWinBits );
819 [ # # ]: 0 : *ppNewComp = new VCLXButton;
820 : 0 : break;
821 : : case WINDOW_PATTERNBOX:
822 [ # # ][ # # ]: 0 : pNewWindow = new PatternBox( pParent, nWinBits );
823 : 0 : break;
824 : : case WINDOW_PATTERNFIELD:
825 [ + - ][ + - ]: 16 : pNewWindow = new PatternField( pParent, nWinBits );
826 [ + - ][ + - ]: 16 : *ppNewComp = new VCLXPatternField;
827 [ + - ][ + - ]: 16 : ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(PatternField*)pNewWindow );
828 : 16 : break;
829 : : case WINDOW_PUSHBUTTON:
830 [ + - ][ + - ]: 52 : pNewWindow = new PushButton( pParent, nWinBits );
831 [ + - ]: 52 : *ppNewComp = new VCLXButton;
832 : 52 : break;
833 : : case WINDOW_QUERYBOX:
834 [ # # ][ # # ]: 0 : pNewWindow = new QueryBox( pParent, nWinBits, String() );
[ # # ][ # # ]
835 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXMessageBox;
836 : 0 : break;
837 : : case WINDOW_RADIOBUTTON:
838 [ + - ][ + - ]: 34 : pNewWindow = new RadioButton( pParent, nWinBits );
839 [ + - ][ + - ]: 34 : *ppNewComp = new VCLXRadioButton;
840 : :
841 : : // by default, disable RadioCheck
842 : : // Since the VCLXRadioButton really cares for it's RadioCheck settings, this is important:
843 : : // if we enable it, the VCLXRadioButton will use RadioButton::Check instead of RadioButton::SetState
844 : : // This leads to a strange behaviour if the control is newly created: when settings the initial
845 : : // state to "checked", the RadioButton::Check (called because RadioCheck=sal_True) will uncheck
846 : : // _all_other_ radio buttons in the same group. However, at this moment the grouping of the controls
847 : : // is not really valid: the controls are grouped after they have been created, but we're still in
848 : : // the creation process, so the RadioButton::Check relies on invalid grouping information.
849 : : // 07.08.2001 - #87254# - frank.schoenheit@sun.com
850 : 34 : static_cast<RadioButton*>(pNewWindow)->EnableRadioCheck( sal_False );
851 : 34 : break;
852 : : case WINDOW_SCROLLBAR:
853 [ + - ][ + - ]: 2 : pNewWindow = new ScrollBar( pParent, nWinBits );
854 [ + - ][ + - ]: 2 : *ppNewComp = new VCLXScrollBar;
855 : 2 : break;
856 : : case WINDOW_SCROLLBARBOX:
857 [ # # ][ # # ]: 0 : pNewWindow = new ScrollBarBox( pParent, nWinBits );
858 : 0 : break;
859 : : case WINDOW_SPINBUTTON:
860 [ + - ][ + - ]: 2 : pNewWindow = new SpinButton( pParent, nWinBits );
861 [ + - ]: 2 : *ppNewComp = new ::toolkit::VCLXSpinButton;
862 : 2 : break;
863 : : case WINDOW_SPINFIELD:
864 [ # # ][ # # ]: 0 : pNewWindow = new SpinField( pParent, nWinBits );
865 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXNumericField;
866 : 0 : break;
867 : : case WINDOW_SPLITTER:
868 [ # # ][ # # ]: 0 : pNewWindow = new Splitter( pParent, nWinBits );
869 : 0 : break;
870 : : case WINDOW_SPLITWINDOW:
871 [ # # ][ # # ]: 0 : pNewWindow = new SplitWindow( pParent, nWinBits );
872 : 0 : break;
873 : : case WINDOW_STATUSBAR:
874 [ # # ][ # # ]: 0 : pNewWindow = new StatusBar( pParent, nWinBits );
875 : 0 : break;
876 : : case VCLWINDOW_SYSTEMCHILDWINDOW:
877 [ # # ][ # # ]: 0 : pNewWindow = new SystemChildWindow( pParent, nWinBits );
878 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXSystemDependentWindow();
879 : 0 : break;
880 : : case WINDOW_TABCONTROL:
881 [ # # ][ # # ]: 0 : pNewWindow = new TabControl( pParent, nWinBits );
882 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXMultiPage;
883 : 0 : break;
884 : : case WINDOW_TABDIALOG:
885 [ # # ][ # # ]: 0 : pNewWindow = new TabDialog( pParent, nWinBits );
886 : 0 : break;
887 : : case WINDOW_TABPAGE:
888 : : {
889 [ # # ][ # # ]: 0 : pNewWindow = new TabPage( pParent, nWinBits );
890 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXTabPage;
891 : : }
892 : 0 : break;
893 : : case WINDOW_TIMEBOX:
894 [ # # ][ # # ]: 0 : pNewWindow = new TimeBox( pParent, nWinBits );
895 : 0 : break;
896 : : case WINDOW_TIMEFIELD:
897 [ + - ][ + - ]: 34 : pNewWindow = new TimeField( pParent, nWinBits );
898 : 34 : static_cast<TimeField*>(pNewWindow)->EnableEmptyFieldValue( sal_True );
899 [ + - ][ + - ]: 34 : *ppNewComp = new VCLXTimeField;
900 [ + - ][ + - ]: 34 : ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(TimeField*)pNewWindow );
901 : 34 : break;
902 : : case WINDOW_TOOLBOX:
903 [ # # ][ # # ]: 0 : pNewWindow = new ToolBox( pParent, nWinBits );
904 [ # # ]: 0 : *ppNewComp = new VCLXToolBox;
905 : 0 : break;
906 : : case WINDOW_TRISTATEBOX:
907 [ # # ][ # # ]: 0 : pNewWindow = new TriStateBox( pParent, nWinBits );
908 : 0 : break;
909 : : case WINDOW_WARNINGBOX:
910 [ # # ][ # # ]: 0 : pNewWindow = new WarningBox( pParent, nWinBits, String() );
[ # # ][ # # ]
911 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXMessageBox;
912 : 0 : break;
913 : : case WINDOW_WORKWINDOW:
914 : : case WINDOW_WINDOW:
915 : : case VCLWINDOW_FRAMEWINDOW:
916 : : case WINDOW_DOCKINGWINDOW:
917 [ + - ]: 1755 : if ( rDescriptor.Type == ::com::sun::star::awt::WindowClass_TOP )
918 : : {
919 [ + + ]: 1755 : if (nType == WINDOW_DOCKINGWINDOW )
920 [ + - ][ + - ]: 2 : pNewWindow = new DockingWindow( pParent, nWinBits );
921 : : else
922 : : {
923 [ + + ][ - + ]: 1753 : if ((pParent == NULL) && rDescriptor.Parent.is())
[ - + ]
924 : : {
925 : : // try to get a system dependent window handle
926 [ # # ]: 0 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSystemDependentWindowPeer > xSystemDepParent(rDescriptor.Parent, ::com::sun::star::uno::UNO_QUERY);
927 : :
928 [ # # ]: 0 : if (xSystemDepParent.is())
929 : : {
930 : : sal_Int8 processID[16];
931 : :
932 [ # # ]: 0 : rtl_getGlobalProcessId( (sal_uInt8*)processID );
933 : :
934 [ # # ]: 0 : ::com::sun::star::uno::Sequence<sal_Int8> processIdSeq(processID, 16);
935 : :
936 [ # # ][ # # ]: 0 : ::com::sun::star::uno::Any anyHandle = xSystemDepParent->getWindowHandle(processIdSeq, SYSTEM_DEPENDENT_TYPE);
937 : :
938 : : // use sal_Int64 here to accomodate all int types
939 : : // uno::Any shift operator whill upcast if necessary
940 : 0 : sal_Int64 nWindowHandle = 0;
941 : 0 : sal_Bool bXEmbed = sal_False;
942 : :
943 : 0 : bool bUseParentData = true;
944 [ # # ]: 0 : if( ! (anyHandle >>= nWindowHandle) )
945 : : {
946 [ # # ]: 0 : css::uno::Sequence< css::beans::NamedValue > aProps;
947 [ # # ][ # # ]: 0 : if( anyHandle >>= aProps )
948 : : {
949 : 0 : const int nProps = aProps.getLength();
950 : 0 : const css::beans::NamedValue* pProps = aProps.getConstArray();
951 [ # # ]: 0 : for( int i = 0; i < nProps; i++ )
952 : : {
953 [ # # ]: 0 : if ( pProps[i].Name == "WINDOW" )
954 : 0 : pProps[i].Value >>= nWindowHandle;
955 [ # # ]: 0 : else if ( pProps[i].Name == "XEMBED" )
956 : 0 : pProps[i].Value >>= bXEmbed;
957 : : }
958 : : }
959 : : else
960 [ # # ]: 0 : bUseParentData = false;
961 : : }
962 : :
963 [ # # ]: 0 : if( bUseParentData )
964 : : {
965 : : SystemParentData aParentData;
966 : 0 : aParentData.nSize = sizeof( aParentData );
967 : : #if defined QUARTZ
968 : : aParentData.pView = reinterpret_cast<NSView*>(nWindowHandle);
969 : : #elif defined IOS
970 : : aParentData.pView = reinterpret_cast<UIView*>(nWindowHandle);
971 : : #elif defined UNX
972 : 0 : aParentData.aWindow = nWindowHandle;
973 : 0 : aParentData.bXEmbedSupport = bXEmbed;
974 : : #elif defined WNT
975 : : aParentData.hWnd = reinterpret_cast<HWND>(nWindowHandle);
976 : : #endif
977 [ # # ][ # # ]: 0 : pNewWindow = new WorkWindow( &aParentData );
978 [ # # ]: 0 : }
979 : 0 : }
980 : : }
981 : :
982 [ + - ]: 1753 : if (!pNewWindow)
983 [ + - ][ + - ]: 1753 : pNewWindow = new WorkWindow( pParent, nWinBits );
984 : : }
985 : :
986 [ + - ][ + - ]: 1755 : *ppNewComp = new VCLXTopWindow( pNewWindow->GetType() == WINDOW_WORKWINDOW );
[ + - ]
987 : : }
988 [ # # ]: 0 : else if ( rDescriptor.Type == ::com::sun::star::awt::WindowClass_CONTAINER )
989 : : {
990 [ # # ]: 0 : if (nType == WINDOW_DOCKINGWINDOW )
991 [ # # ][ # # ]: 0 : pNewWindow = new DockingWindow( pParent, nWinBits );
992 : : else
993 [ # # ][ # # ]: 0 : pNewWindow = new Window( pParent, nWinBits );
994 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXContainer;
995 : : }
996 : : else
997 : : {
998 [ # # ]: 0 : if (nType == WINDOW_DOCKINGWINDOW )
999 [ # # ][ # # ]: 0 : pNewWindow = new DockingWindow( pParent, nWinBits );
1000 : : else
1001 [ # # ][ # # ]: 0 : pNewWindow = new Window( pParent, nWinBits );
1002 [ # # ]: 0 : *ppNewComp = new VCLXWindow;
1003 : : }
1004 : 1755 : break;
1005 : : case WINDOW_CONTROL:
1006 [ # # ][ # # ]: 0 : if ( aServiceName.EqualsAscii( "simpleanimation" ) )
1007 : : {
1008 [ # # ][ # # ]: 0 : pNewWindow = new Throbber( pParent, nWinBits, Throbber::IMAGES_NONE );
1009 [ # # ]: 0 : ((Throbber*)pNewWindow)->SetScaleMode( css::awt::ImageScaleMode::Anisotropic );
1010 : : // (compatibility)
1011 [ # # ]: 0 : *ppNewComp = new ::toolkit::XSimpleAnimation;
1012 : : }
1013 [ # # ][ # # ]: 0 : else if ( aServiceName.EqualsAscii( "throbber" ) )
1014 : : {
1015 [ # # ][ # # ]: 0 : pNewWindow = new Throbber( pParent, nWinBits, Throbber::IMAGES_NONE );
1016 [ # # ]: 0 : ((Throbber*)pNewWindow)->SetScaleMode( css::awt::ImageScaleMode::Anisotropic );
1017 : : // (compatibility)
1018 [ # # ]: 0 : *ppNewComp = new ::toolkit::XThrobber;
1019 : : }
1020 [ # # ]: 0 : else if ( rDescriptor.WindowServiceName.equalsIgnoreAsciiCaseAsciiL(
1021 : 0 : RTL_CONSTASCII_STRINGPARAM("tabpagecontainer") ) )
1022 : : {
1023 [ # # ][ # # ]: 0 : pNewWindow = new TabControl( pParent, nWinBits );
1024 [ # # ][ # # ]: 0 : *ppNewComp = new VCLXTabPageContainer;
1025 : : }
1026 [ # # ][ # # ]: 0 : else if ( aServiceName.EqualsAscii( "animatedimages" ) )
1027 : : {
1028 [ # # ][ # # ]: 0 : pNewWindow = new Throbber( pParent, nWinBits );
1029 [ # # ]: 0 : *ppNewComp = new ::toolkit::AnimatedImagesPeer;
1030 : : }
1031 : 0 : break;
1032 : : default:
1033 : : OSL_ENSURE( false, "VCLXToolkit::ImplCreateWindow: unknown window type!" );
1034 : 0 : break;
1035 [ + - ]: 16246 : }
1036 : : }
1037 : :
1038 [ + - ]: 16246 : return pNewWindow;
1039 : : }
1040 : :
1041 : 0 : extern "C" { static void SAL_CALL thisModule() {} }
1042 : :
1043 : 16392 : css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow(
1044 : : const css::awt::WindowDescriptor& rDescriptor,
1045 : : WinBits nForceWinBits )
1046 : : {
1047 [ + - ]: 16392 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
1048 : :
1049 [ + - ]: 16392 : SolarMutexGuard aSolarGuard;
1050 : :
1051 : 16392 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xRef;
1052 : :
1053 : 16392 : Window* pParent = NULL;
1054 [ + + ]: 16392 : if ( rDescriptor.Parent.is() )
1055 : : {
1056 : 14639 : VCLXWindow* pParentComponent = VCLXWindow::GetImplementation( rDescriptor.Parent );
1057 : :
1058 : : // #103939# Don't throw assertion, may be it's a system dependend window, used in ImplCreateWindow.
1059 : : // DBG_ASSERT( pParentComponent, "ParentComponent not valid" );
1060 : :
1061 [ + - ]: 14639 : if ( pParentComponent )
1062 : 14639 : pParent = pParentComponent->GetWindow();
1063 : : }
1064 : :
1065 : : WinBits nWinBits = ImplGetWinBits( rDescriptor.WindowAttributes,
1066 [ + - ][ + - ]: 16392 : ImplGetComponentType( rDescriptor.WindowServiceName ) );
[ + - ][ + - ]
1067 : 16392 : nWinBits |= nForceWinBits;
1068 : :
1069 : 16392 : VCLXWindow* pNewComp = NULL;
1070 : :
1071 : 16392 : Window* pNewWindow = NULL;
1072 : : // Try to create the window with SvTools
1073 : : // (do this _before_ creating it on our own: The old mechanism (extended toolkit in SvTools) did it this way,
1074 : : // and we need to stay compatible)
1075 : : // try to load the lib
1076 [ + + ][ + - ]: 16392 : if ( !fnSvtCreateWindow && !hSvToolsLib )
1077 : : {
1078 : : ::rtl::OUString aLibName = ::vcl::unohelper::CreateLibraryName(
1079 : : #ifdef LIBO_MERGELIBS
1080 : : "merged",
1081 : : #else
1082 : : "svt",
1083 : : #endif
1084 [ + - ]: 15854 : sal_True );
1085 : : hSvToolsLib = osl_loadModuleRelative(
1086 [ + - ]: 15854 : &thisModule, aLibName.pData, SAL_LOADMODULE_DEFAULT );
1087 [ + - ]: 15854 : if ( hSvToolsLib )
1088 : : {
1089 : 15854 : ::rtl::OUString aFunctionName( "CreateWindow" );
1090 [ + - ]: 15854 : fnSvtCreateWindow = (FN_SvtCreateWindow)osl_getFunctionSymbol( hSvToolsLib, aFunctionName.pData );
1091 : 15854 : }
1092 : : }
1093 : : // ask the SvTool creation function
1094 [ + - ]: 16392 : if ( fnSvtCreateWindow )
1095 [ + - ]: 16392 : pNewWindow = fnSvtCreateWindow( &pNewComp, &rDescriptor, pParent, nWinBits );
1096 : :
1097 : : // if SvTools could not provide a window, create it ourself
1098 [ + + ]: 16392 : if ( !pNewWindow )
1099 [ + - ]: 16246 : pNewWindow = ImplCreateWindow( &pNewComp, rDescriptor, pParent, nWinBits );
1100 : :
1101 : : DBG_ASSERT( pNewWindow, "createWindow: Unknown Component!" );
1102 : : DBG_ASSERTWARNING( pNewComp, "createWindow: No special Interface!" );
1103 : :
1104 [ + - ]: 16392 : if ( pNewWindow )
1105 : : {
1106 [ + - ]: 16392 : pNewWindow->SetCreatedWithToolkit( sal_True );
1107 : : //pNewWindow->SetPosPixel( Point() ); // do not force (0,0) position, keep default pos instead
1108 : :
1109 [ - + ]: 16392 : if ( rDescriptor.WindowAttributes & ::com::sun::star::awt::WindowAttribute::MINSIZE )
1110 : : {
1111 [ # # ]: 0 : pNewWindow->SetSizePixel( Size() );
1112 : : }
1113 [ - + ]: 16392 : else if ( rDescriptor.WindowAttributes & ::com::sun::star::awt::WindowAttribute::FULLSIZE )
1114 : : {
1115 [ # # ]: 0 : if ( pParent )
1116 [ # # ]: 0 : pNewWindow->SetSizePixel( pParent->GetOutputSizePixel() );
1117 : : }
1118 [ + - ][ + + ]: 16392 : else if ( !VCLUnoHelper::IsZero( rDescriptor.Bounds ) )
1119 : : {
1120 [ + - ]: 563 : Rectangle aRect = VCLRectangle( rDescriptor.Bounds );
1121 [ + - ][ + - ]: 563 : pNewWindow->SetPosSizePixel( aRect.TopLeft(), aRect.GetSize() );
1122 : : }
1123 : :
1124 [ + + ]: 16392 : if ( !pNewComp )
1125 : : {
1126 : : // Default-Interface
1127 [ + - ][ + - ]: 14106 : xRef = pNewWindow->GetComponentInterface( sal_True );
1128 : : }
1129 : : else
1130 : : {
1131 [ + - ]: 2286 : pNewComp->SetCreatedWithToolkit( sal_True );
1132 [ + - ][ + - ]: 2286 : xRef = pNewComp;
1133 [ + - ]: 2286 : pNewWindow->SetComponentInterface( xRef );
1134 : : }
1135 : : DBG_ASSERT( pNewWindow->GetComponentInterface( sal_False ) == xRef,
1136 : : "VCLXToolkit::createWindow: did #133706# resurge?" );
1137 : :
1138 [ + + ]: 16392 : if ( rDescriptor.WindowAttributes & ::com::sun::star::awt::WindowAttribute::SHOW )
1139 [ + - ]: 8 : pNewWindow->Show();
1140 : : }
1141 : :
1142 [ + - ][ + - ]: 16392 : return xRef;
1143 : : }
1144 : :
1145 : 2 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > > VCLXToolkit::createWindows( const ::com::sun::star::uno::Sequence< ::com::sun::star::awt::WindowDescriptor >& rDescriptors ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
1146 : : {
1147 [ + - ]: 2 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
1148 : :
1149 : 2 : sal_uInt32 nComponents = rDescriptors.getLength();
1150 [ + - ]: 2 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > > aSeq( nComponents );
1151 [ + + ]: 6 : for ( sal_uInt32 n = 0; n < nComponents; n++ )
1152 : : {
1153 [ + - ]: 4 : ::com::sun::star::awt::WindowDescriptor aDescr = rDescriptors.getConstArray()[n];
1154 : :
1155 [ + - ]: 4 : if ( aDescr.ParentIndex == (-1) )
1156 [ + - ]: 4 : aDescr.Parent = NULL;
1157 [ # # ][ # # ]: 0 : else if ( ( aDescr.ParentIndex >= 0 ) && ( aDescr.ParentIndex < (short)n ) )
1158 [ # # ]: 0 : aDescr.Parent = aSeq.getConstArray()[aDescr.ParentIndex];
1159 [ + - ][ + - ]: 4 : aSeq.getArray()[n] = createWindow( aDescr );
[ + - ]
1160 [ + - ]: 4 : }
1161 [ + - ]: 2 : return aSeq;
1162 : : }
1163 : :
1164 : : // ::com::sun::star::awt::XSystemChildFactory
1165 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > VCLXToolkit::createSystemChild( const ::com::sun::star::uno::Any& Parent, const ::com::sun::star::uno::Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 nSystemType ) throw(::com::sun::star::uno::RuntimeException)
1166 : : {
1167 : 0 : Window* pChildWindow = NULL;
1168 [ # # ]: 0 : if ( nSystemType == SYSTEM_DEPENDENT_TYPE )
1169 : : {
1170 : : // use sal_Int64 here to accomodate all int types
1171 : : // uno::Any shift operator whill upcast if necessary
1172 : 0 : sal_Int64 nWindowHandle = 0;
1173 : 0 : sal_Bool bXEmbed = sal_False;
1174 : :
1175 : 0 : bool bUseParentData = true;
1176 [ # # ]: 0 : if( ! (Parent >>= nWindowHandle) )
1177 : : {
1178 [ # # ]: 0 : css::uno::Sequence< css::beans::NamedValue > aProps;
1179 [ # # ][ # # ]: 0 : if( Parent >>= aProps )
1180 : : {
1181 : 0 : const int nProps = aProps.getLength();
1182 : 0 : const css::beans::NamedValue* pProps = aProps.getConstArray();
1183 [ # # ]: 0 : for( int i = 0; i < nProps; i++ )
1184 : : {
1185 [ # # ]: 0 : if ( pProps[i].Name == "WINDOW" )
1186 : 0 : pProps[i].Value >>= nWindowHandle;
1187 [ # # ]: 0 : else if ( pProps[i].Name == "XEMBED" )
1188 : 0 : pProps[i].Value >>= bXEmbed;
1189 : : }
1190 : : }
1191 : : else
1192 [ # # ]: 0 : bUseParentData = false;
1193 : : }
1194 : :
1195 [ # # ]: 0 : if( bUseParentData )
1196 : : {
1197 : : SystemParentData aParentData;
1198 : 0 : aParentData.nSize = sizeof( aParentData );
1199 : : #if defined QUARTZ
1200 : : aParentData.pView = reinterpret_cast<NSView*>(nWindowHandle);
1201 : : #elif defined IOS
1202 : : aParentData.pView = reinterpret_cast<UIView*>(nWindowHandle);
1203 : : #elif defined UNX
1204 : 0 : aParentData.aWindow = nWindowHandle;
1205 : 0 : aParentData.bXEmbedSupport = bXEmbed;
1206 : : #elif defined WNT
1207 : : aParentData.hWnd = reinterpret_cast<HWND>(nWindowHandle);
1208 : : #endif
1209 [ # # ]: 0 : SolarMutexGuard aGuard;
1210 : : try
1211 : : {
1212 [ # # ][ # # ]: 0 : pChildWindow = new WorkWindow( &aParentData );
[ # # ]
1213 : : }
1214 [ # # ]: 0 : catch ( const ::com::sun::star::uno::RuntimeException & rEx )
1215 : : {
1216 : : // system child window could not be created
1217 : : OSL_TRACE(
1218 : : "VCLXToolkit::createSystemChild: caught %s\n",
1219 : : ::rtl::OUStringToOString(
1220 : : rEx.Message, RTL_TEXTENCODING_UTF8).getStr());
1221 : 0 : pChildWindow = NULL;
1222 [ # # ]: 0 : }
1223 : : }
1224 : : }
1225 [ # # ]: 0 : else if (nSystemType == com::sun::star::lang::SystemDependent::SYSTEM_JAVA)
1226 : : {
1227 [ # # ]: 0 : SolarMutexGuard aGuard;
1228 [ # # ][ # # ]: 0 : pChildWindow = new WorkWindow(0, Parent);
[ # # ]
1229 : : }
1230 : :
1231 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xPeer;
1232 [ # # ]: 0 : if ( pChildWindow )
1233 : : {
1234 [ # # ]: 0 : VCLXTopWindow* pPeer = new VCLXTopWindow(true);
1235 [ # # ]: 0 : SolarMutexGuard aGuard;
1236 [ # # ]: 0 : pPeer->SetWindow( pChildWindow );
1237 [ # # ][ # # ]: 0 : xPeer = pPeer;
[ # # ]
1238 : : }
1239 : :
1240 : 0 : return xPeer;
1241 : : }
1242 : :
1243 : : // ::com::sun::star::awt::XMessageBoxFactory
1244 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMessageBox > SAL_CALL VCLXToolkit::createMessageBox(
1245 : : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& aParent,
1246 : : const ::com::sun::star::awt::Rectangle& aPosSize,
1247 : : const ::rtl::OUString& aType,
1248 : : ::sal_Int32 aButtons,
1249 : : const ::rtl::OUString& aTitle,
1250 : : const ::rtl::OUString& aMessage ) throw (::com::sun::star::uno::RuntimeException)
1251 : : {
1252 [ # # ]: 0 : ::com::sun::star::awt::WindowDescriptor aDescriptor;
1253 : :
1254 : 0 : sal_Int32 nWindowAttributes = css::awt::WindowAttribute::BORDER|css::awt::WindowAttribute::MOVEABLE|css::awt::WindowAttribute::CLOSEABLE;
1255 : :
1256 : : // Map button definitions to window attributes
1257 [ # # ]: 0 : if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_OK )
1258 : 0 : nWindowAttributes |= css::awt::VclWindowPeerAttribute::OK;
1259 [ # # ]: 0 : else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_OK_CANCEL )
1260 : 0 : nWindowAttributes |= css::awt::VclWindowPeerAttribute::OK_CANCEL;
1261 [ # # ]: 0 : else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_YES_NO )
1262 : 0 : nWindowAttributes |= css::awt::VclWindowPeerAttribute::YES_NO;
1263 [ # # ]: 0 : else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_YES_NO_CANCEL )
1264 : 0 : nWindowAttributes |= css::awt::VclWindowPeerAttribute::YES_NO_CANCEL;
1265 [ # # ]: 0 : else if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_RETRY_CANCEL )
1266 : 0 : nWindowAttributes |= css::awt::VclWindowPeerAttribute::RETRY_CANCEL;
1267 : :
1268 : : // Map default button definitions to window attributes
1269 [ # # ]: 0 : if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_OK )
1270 : 0 : nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_OK;
1271 [ # # ]: 0 : else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_CANCEL )
1272 : 0 : nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_CANCEL;
1273 [ # # ]: 0 : else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_YES )
1274 : 0 : nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_YES;
1275 [ # # ]: 0 : else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_NO )
1276 : 0 : nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_NO;
1277 [ # # ]: 0 : else if (sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_RETRY )
1278 : 0 : nWindowAttributes |= css::awt::VclWindowPeerAttribute::DEF_RETRY;
1279 : :
1280 : : // No more bits for VclWindowPeerAttribute possible. Mapping must be
1281 : : // done explicitly using VCL methods
1282 : 0 : WinBits nAddWinBits( 0 );
1283 [ # # ]: 0 : if (( aButtons & 0x0000ffffL ) == css::awt::MessageBoxButtons::BUTTONS_ABORT_IGNORE_RETRY )
1284 : 0 : nAddWinBits |= WB_ABORT_RETRY_IGNORE;
1285 [ # # ]: 0 : if ( sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_IGNORE )
1286 : 0 : nAddWinBits |= WB_DEF_IGNORE;
1287 : :
1288 : 0 : aDescriptor.Type = css::awt::WindowClass_MODALTOP;
1289 : 0 : aDescriptor.WindowServiceName = aType;
1290 : 0 : aDescriptor.ParentIndex = -1;
1291 [ # # ]: 0 : aDescriptor.Parent = aParent;
1292 : 0 : aDescriptor.Bounds = aPosSize;
1293 : 0 : aDescriptor.WindowAttributes = nWindowAttributes;
1294 : : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMessageBox > xMsgBox(
1295 [ # # ][ # # ]: 0 : ImplCreateWindow( aDescriptor, nAddWinBits ), css::uno::UNO_QUERY );
1296 [ # # ]: 0 : css::uno::Reference< css::awt::XWindow > xWindow( xMsgBox, css::uno::UNO_QUERY );
1297 [ # # ][ # # ]: 0 : if ( xMsgBox.is() && xWindow.is() )
[ # # ]
1298 : : {
1299 [ # # ]: 0 : Window * pWindow = VCLUnoHelper::GetWindow( xWindow );
1300 [ # # ]: 0 : if ( pWindow )
1301 : : {
1302 [ # # ]: 0 : SolarMutexGuard aGuard;
1303 [ # # ][ # # ]: 0 : xMsgBox->setCaptionText( aTitle );
1304 [ # # ][ # # ]: 0 : xMsgBox->setMessageText( aMessage );
[ # # ]
1305 : : }
1306 : : }
1307 : :
1308 [ # # ]: 0 : return xMsgBox;
1309 : : }
1310 : :
1311 : 2 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer > SAL_CALL VCLXToolkit::getDragGestureRecognizer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& window ) throw(::com::sun::star::uno::RuntimeException)
1312 : : {
1313 : 2 : Window * pWindow = VCLUnoHelper::GetWindow( window );
1314 : :
1315 [ + - ]: 2 : if( pWindow )
1316 : 2 : return pWindow->GetDragGestureRecognizer();
1317 : :
1318 : 2 : return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer >();
1319 : : }
1320 : :
1321 : 2 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource > SAL_CALL VCLXToolkit::getDragSource( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& window ) throw(::com::sun::star::uno::RuntimeException)
1322 : : {
1323 : 2 : Window * pWindow = VCLUnoHelper::GetWindow( window );
1324 : :
1325 [ + - ]: 2 : if( pWindow )
1326 : 2 : return pWindow->GetDragSource();
1327 : :
1328 : 2 : return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource >();
1329 : : }
1330 : :
1331 : 10251 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTarget > SAL_CALL VCLXToolkit::getDropTarget( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& window ) throw(::com::sun::star::uno::RuntimeException)
1332 : : {
1333 : 10251 : Window * pWindow = VCLUnoHelper::GetWindow( window );
1334 : :
1335 [ + - ]: 10251 : if( pWindow )
1336 : 10251 : return pWindow->GetDropTarget();
1337 : :
1338 : 10251 : return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTarget >();
1339 : : }
1340 : :
1341 : 2 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > SAL_CALL VCLXToolkit::getClipboard( const ::rtl::OUString& clipboardName ) throw(::com::sun::star::uno::RuntimeException)
1342 : : {
1343 [ + - ]: 2 : if( clipboardName.isEmpty() )
1344 : : {
1345 [ + - ]: 2 : if( !mxClipboard.is() )
1346 : : {
1347 [ + - ]: 2 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
1348 [ + - ]: 2 : if ( xFactory.is() )
1349 : : {
1350 : : // remember clipboard here
1351 : : mxClipboard = ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > (
1352 [ + - ][ + - ]: 2 : xFactory->createInstance( ::rtl::OUString("com.sun.star.datatransfer.clipboard.SystemClipboard") ), ::com::sun::star::uno::UNO_QUERY );
[ + - ][ + - ]
1353 : 2 : }
1354 : : }
1355 : :
1356 : 2 : return mxClipboard;
1357 : : }
1358 : :
1359 [ # # ]: 0 : else if( clipboardName == "Selection" )
1360 : : {
1361 : 0 : return mxSelection;
1362 : : }
1363 : :
1364 : 2 : return ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >();
1365 : : }
1366 : :
1367 : : // XServiceInfo
1368 : 2 : ::rtl::OUString VCLXToolkit::getImplementationName() throw(::com::sun::star::uno::RuntimeException)
1369 : : {
1370 : 2 : return rtl::OUString("stardiv.Toolkit.VCLXToolkit");
1371 : : }
1372 : :
1373 : 0 : sal_Bool VCLXToolkit::supportsService( const ::rtl::OUString& rServiceName ) throw(::com::sun::star::uno::RuntimeException)
1374 : : {
1375 [ # # ]: 0 : ::osl::MutexGuard aGuard( GetMutex() );
1376 : :
1377 [ # # ]: 0 : ::com::sun::star::uno::Sequence< ::rtl::OUString > aSNL = getSupportedServiceNames();
1378 : 0 : const ::rtl::OUString* pArray = aSNL.getConstArray();
1379 : 0 : const ::rtl::OUString* pArrayEnd = aSNL.getConstArray();
1380 [ # # ]: 0 : for (; pArray != pArrayEnd; ++pArray )
1381 [ # # ]: 0 : if( *pArray == rServiceName )
1382 : 0 : break;
1383 : :
1384 [ # # ][ # # ]: 0 : return pArray != pArrayEnd;
1385 : : }
1386 : :
1387 : 0 : ::com::sun::star::uno::Sequence< ::rtl::OUString > VCLXToolkit::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
1388 : : {
1389 : 0 : ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( szServiceName2_Toolkit ) );
1390 [ # # ]: 0 : return ::com::sun::star::uno::Sequence< ::rtl::OUString >( &aServiceName, 1);
1391 : : }
1392 : :
1393 : : // css::awt::XExtendedToolkit:
1394 : :
1395 : : // virtual
1396 : 0 : ::sal_Int32 SAL_CALL VCLXToolkit::getTopWindowCount()
1397 : : throw (::css::uno::RuntimeException)
1398 : : {
1399 : 0 : return static_cast< ::sal_Int32 >(::Application::GetTopWindowCount());
1400 : : // XXX numeric overflow
1401 : : }
1402 : :
1403 : : // virtual
1404 : : ::css::uno::Reference< ::css::awt::XTopWindow > SAL_CALL
1405 : 0 : VCLXToolkit::getTopWindow(::sal_Int32 nIndex)
1406 : : throw (::css::uno::RuntimeException)
1407 : : {
1408 : 0 : ::Window * p = ::Application::GetTopWindow(static_cast< long >(nIndex));
1409 : : // XXX numeric overflow
1410 : : return ::css::uno::Reference< ::css::awt::XTopWindow >(
1411 [ # # ]: 0 : p == 0 ? 0 : static_cast< ::css::awt::XWindow * >(p->GetWindowPeer()),
1412 [ # # ]: 0 : ::css::uno::UNO_QUERY);
1413 : : }
1414 : :
1415 : : // virtual
1416 : : ::css::uno::Reference< ::css::awt::XTopWindow > SAL_CALL
1417 : 0 : VCLXToolkit::getActiveTopWindow() throw (::css::uno::RuntimeException)
1418 : : {
1419 : 0 : ::Window * p = ::Application::GetActiveTopWindow();
1420 : : return ::css::uno::Reference< ::css::awt::XTopWindow >(
1421 [ # # ]: 0 : p == 0 ? 0 : static_cast< ::css::awt::XWindow * >(p->GetWindowPeer()),
1422 [ # # ]: 0 : ::css::uno::UNO_QUERY);
1423 : : }
1424 : :
1425 : : // virtual
1426 : 0 : void SAL_CALL VCLXToolkit::addTopWindowListener(
1427 : : ::css::uno::Reference< ::css::awt::XTopWindowListener > const & rListener)
1428 : : throw (::css::uno::RuntimeException)
1429 : : {
1430 : : OSL_ENSURE(rListener.is(), "Null rListener");
1431 [ # # ]: 0 : ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex);
1432 [ # # ][ # # ]: 0 : if (rBHelper.bDisposed || rBHelper.bInDispose)
1433 : : {
1434 [ # # ]: 0 : aGuard.clear();
1435 [ # # ]: 0 : rListener->disposing(
1436 : : ::css::lang::EventObject(
1437 [ # # ][ # # ]: 0 : static_cast< ::cppu::OWeakObject * >(this)));
[ # # ][ # # ]
1438 : : }
1439 [ # # ][ # # ]: 0 : else if (m_aTopWindowListeners.addInterface(rListener) == 1
[ # # ][ # # ]
1440 : 0 : && !m_bEventListener)
1441 : : {
1442 : 0 : m_bEventListener = true;
1443 [ # # ]: 0 : ::Application::AddEventListener(m_aEventListenerLink);
1444 [ # # ]: 0 : }
1445 : 0 : }
1446 : :
1447 : : // virtual
1448 : 0 : void SAL_CALL VCLXToolkit::removeTopWindowListener(
1449 : : ::css::uno::Reference< ::css::awt::XTopWindowListener > const & rListener)
1450 : : throw (::css::uno::RuntimeException)
1451 : : {
1452 [ # # ]: 0 : ::osl::MutexGuard aGuard(rBHelper.rMutex);
1453 [ # # ][ # # ]: 0 : if (!(rBHelper.bDisposed || rBHelper.bInDispose)
[ # # ][ # # ]
[ # # ][ # # ]
1454 [ # # ]: 0 : && m_aTopWindowListeners.removeInterface(rListener) == 0
1455 [ # # ]: 0 : && m_aFocusListeners.getLength() == 0 && m_bEventListener)
1456 : : {
1457 [ # # ]: 0 : ::Application::RemoveEventListener(m_aEventListenerLink);
1458 : 0 : m_bEventListener = false;
1459 [ # # ]: 0 : }
1460 : 0 : }
1461 : :
1462 : : // virtual
1463 : 0 : void SAL_CALL VCLXToolkit::addKeyHandler(
1464 : : ::css::uno::Reference< ::css::awt::XKeyHandler > const & rHandler)
1465 : : throw (::css::uno::RuntimeException)
1466 : : {
1467 : : OSL_ENSURE(rHandler.is(), "Null rHandler");
1468 [ # # ]: 0 : ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex);
1469 [ # # ][ # # ]: 0 : if (rBHelper.bDisposed || rBHelper.bInDispose)
1470 : : {
1471 [ # # ]: 0 : aGuard.clear();
1472 [ # # ]: 0 : rHandler->disposing(
1473 : : ::css::lang::EventObject(
1474 [ # # ][ # # ]: 0 : static_cast< ::cppu::OWeakObject * >(this)));
[ # # ][ # # ]
1475 : : }
1476 [ # # ][ # # ]: 0 : else if (m_aKeyHandlers.addInterface(rHandler) == 1 && !m_bKeyListener)
[ # # ][ # # ]
1477 : : {
1478 : 0 : m_bKeyListener = true;
1479 [ # # ]: 0 : ::Application::AddKeyListener(m_aKeyListenerLink);
1480 [ # # ]: 0 : }
1481 : 0 : }
1482 : :
1483 : : // virtual
1484 : 0 : void SAL_CALL VCLXToolkit::removeKeyHandler(
1485 : : ::css::uno::Reference< ::css::awt::XKeyHandler > const & rHandler)
1486 : : throw (::css::uno::RuntimeException)
1487 : : {
1488 [ # # ]: 0 : ::osl::MutexGuard aGuard(rBHelper.rMutex);
1489 [ # # ][ # # ]: 0 : if (!(rBHelper.bDisposed || rBHelper.bInDispose)
[ # # ][ # # ]
[ # # ]
1490 [ # # ]: 0 : && m_aKeyHandlers.removeInterface(rHandler) == 0 && m_bKeyListener)
1491 : : {
1492 [ # # ]: 0 : ::Application::RemoveKeyListener(m_aKeyListenerLink);
1493 : 0 : m_bKeyListener = false;
1494 [ # # ]: 0 : }
1495 : 0 : }
1496 : :
1497 : : // virtual
1498 : 0 : void SAL_CALL VCLXToolkit::addFocusListener(
1499 : : ::css::uno::Reference< ::css::awt::XFocusListener > const & rListener)
1500 : : throw (::css::uno::RuntimeException)
1501 : : {
1502 : : OSL_ENSURE(rListener.is(), "Null rListener");
1503 [ # # ]: 0 : ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex);
1504 [ # # ][ # # ]: 0 : if (rBHelper.bDisposed || rBHelper.bInDispose)
1505 : : {
1506 [ # # ]: 0 : aGuard.clear();
1507 [ # # ]: 0 : rListener->disposing(
1508 : : ::css::lang::EventObject(
1509 [ # # ][ # # ]: 0 : static_cast< ::cppu::OWeakObject * >(this)));
[ # # ][ # # ]
1510 : : }
1511 [ # # ][ # # ]: 0 : else if (m_aFocusListeners.addInterface(rListener) == 1
[ # # ][ # # ]
1512 : 0 : && !m_bEventListener)
1513 : : {
1514 : 0 : m_bEventListener = true;
1515 [ # # ]: 0 : ::Application::AddEventListener(m_aEventListenerLink);
1516 [ # # ]: 0 : }
1517 : 0 : }
1518 : :
1519 : : // virtual
1520 : 0 : void SAL_CALL VCLXToolkit::removeFocusListener(
1521 : : ::css::uno::Reference< ::css::awt::XFocusListener > const & rListener)
1522 : : throw (::css::uno::RuntimeException)
1523 : : {
1524 [ # # ]: 0 : ::osl::MutexGuard aGuard(rBHelper.rMutex);
1525 [ # # ][ # # ]: 0 : if (!(rBHelper.bDisposed || rBHelper.bInDispose)
[ # # ][ # # ]
[ # # ][ # # ]
1526 [ # # ]: 0 : && m_aFocusListeners.removeInterface(rListener) == 0
1527 [ # # ]: 0 : && m_aTopWindowListeners.getLength() == 0 && m_bEventListener)
1528 : : {
1529 [ # # ]: 0 : ::Application::RemoveEventListener(m_aEventListenerLink);
1530 : 0 : m_bEventListener = false;
1531 [ # # ]: 0 : }
1532 : 0 : }
1533 : :
1534 : : // virtual
1535 : 5 : void SAL_CALL VCLXToolkit::fireFocusGained(
1536 : : ::com::sun::star::uno::Reference<
1537 : : ::com::sun::star::uno::XInterface > const &)
1538 : : throw (::com::sun::star::uno::RuntimeException)
1539 : : {
1540 : 5 : }
1541 : :
1542 : : // virtual
1543 : 21 : void SAL_CALL VCLXToolkit::fireFocusLost(
1544 : : ::com::sun::star::uno::Reference<
1545 : : ::com::sun::star::uno::XInterface > const &)
1546 : : throw (::com::sun::star::uno::RuntimeException)
1547 : : {
1548 : 21 : }
1549 : :
1550 : :
1551 : 0 : IMPL_LINK(VCLXToolkit, eventListenerHandler, ::VclSimpleEvent const *, pEvent)
1552 : : {
1553 [ # # # # : 0 : switch (pEvent->GetId())
# # # # #
# ]
1554 : : {
1555 : : case VCLEVENT_WINDOW_SHOW:
1556 : : callTopWindowListeners(
1557 : 0 : pEvent, &::css::awt::XTopWindowListener::windowOpened);
1558 : 0 : break;
1559 : : case VCLEVENT_WINDOW_HIDE:
1560 : : callTopWindowListeners(
1561 : 0 : pEvent, &::css::awt::XTopWindowListener::windowClosed);
1562 : 0 : break;
1563 : : case VCLEVENT_WINDOW_ACTIVATE:
1564 : : callTopWindowListeners(
1565 : 0 : pEvent, &::css::awt::XTopWindowListener::windowActivated);
1566 : 0 : break;
1567 : : case VCLEVENT_WINDOW_DEACTIVATE:
1568 : : callTopWindowListeners(
1569 : 0 : pEvent, &::css::awt::XTopWindowListener::windowDeactivated);
1570 : 0 : break;
1571 : : case VCLEVENT_WINDOW_CLOSE:
1572 : : callTopWindowListeners(
1573 : 0 : pEvent, &::css::awt::XTopWindowListener::windowClosing);
1574 : 0 : break;
1575 : : case VCLEVENT_WINDOW_GETFOCUS:
1576 : 0 : callFocusListeners(pEvent, true);
1577 : 0 : break;
1578 : : case VCLEVENT_WINDOW_LOSEFOCUS:
1579 : 0 : callFocusListeners(pEvent, false);
1580 : 0 : break;
1581 : : case VCLEVENT_WINDOW_MINIMIZE:
1582 : : callTopWindowListeners(
1583 : 0 : pEvent, &::css::awt::XTopWindowListener::windowMinimized);
1584 : 0 : break;
1585 : : case VCLEVENT_WINDOW_NORMALIZE:
1586 : : callTopWindowListeners(
1587 : 0 : pEvent, &::css::awt::XTopWindowListener::windowNormalized);
1588 : 0 : break;
1589 : : }
1590 : 0 : return 0;
1591 : : }
1592 : :
1593 : 0 : IMPL_LINK(VCLXToolkit, keyListenerHandler, ::VclSimpleEvent const *, pEvent)
1594 : : {
1595 [ # # # ]: 0 : switch (pEvent->GetId())
1596 : : {
1597 : : case VCLEVENT_WINDOW_KEYINPUT:
1598 : 0 : return callKeyHandlers(pEvent, true);
1599 : : case VCLEVENT_WINDOW_KEYUP:
1600 : 0 : return callKeyHandlers(pEvent, false);
1601 : : }
1602 : 0 : return 0;
1603 : : }
1604 : :
1605 : 0 : void VCLXToolkit::callTopWindowListeners(
1606 : : ::VclSimpleEvent const * pEvent,
1607 : : void (SAL_CALL ::css::awt::XTopWindowListener::* pFn)(
1608 : : ::css::lang::EventObject const &))
1609 : : {
1610 : : ::Window * pWindow
1611 : 0 : = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow();
1612 [ # # ]: 0 : if (pWindow->IsTopWindow())
1613 : : {
1614 : : ::css::uno::Sequence< ::css::uno::Reference< ::css::uno::XInterface > >
1615 [ # # ]: 0 : aListeners(m_aTopWindowListeners.getElements());
1616 [ # # ]: 0 : if (aListeners.hasElements())
1617 : : {
1618 : : ::css::lang::EventObject aAwtEvent(
1619 [ # # ][ # # ]: 0 : static_cast< ::css::awt::XWindow * >(pWindow->GetWindowPeer()));
[ # # ][ # # ]
[ # # ]
1620 [ # # ]: 0 : for (::sal_Int32 i = 0; i < aListeners.getLength(); ++i)
1621 : : {
1622 : : ::css::uno::Reference< ::css::awt::XTopWindowListener >
1623 [ # # ][ # # ]: 0 : xListener(aListeners[i], ::css::uno::UNO_QUERY);
1624 : : try
1625 : : {
1626 [ # # ][ # # ]: 0 : (xListener.get()->*pFn)(aAwtEvent);
[ # # ]
1627 : : }
1628 [ # # ]: 0 : catch (const ::css::uno::RuntimeException & rEx)
1629 : : {
1630 : : OSL_TRACE(
1631 : : "VCLXToolkit::callTopWindowListeners: caught %s\n",
1632 : : ::rtl::OUStringToOString(
1633 : : rEx.Message, RTL_TEXTENCODING_UTF8).getStr());
1634 : : }
1635 [ # # ]: 0 : }
1636 [ # # ]: 0 : }
1637 : : }
1638 : 0 : }
1639 : :
1640 : 0 : long VCLXToolkit::callKeyHandlers(::VclSimpleEvent const * pEvent,
1641 : : bool bPressed)
1642 : : {
1643 : : ::css::uno::Sequence< ::css::uno::Reference< ::css::uno::XInterface > >
1644 [ # # ]: 0 : aHandlers(m_aKeyHandlers.getElements());
1645 : :
1646 [ # # ]: 0 : if (aHandlers.hasElements())
1647 : : {
1648 : 0 : ::Window * pWindow = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow();
1649 : :
1650 : : // See implementation in vclxwindow.cxx for mapping between VCL and UNO AWT event
1651 : : ::KeyEvent * pKeyEvent = static_cast< ::KeyEvent * >(
1652 : 0 : static_cast< ::VclWindowEvent const * >(pEvent)->GetData());
1653 : : ::css::awt::KeyEvent aAwtEvent(
1654 [ # # ][ # # ]: 0 : static_cast< ::css::awt::XWindow * >(pWindow->GetWindowPeer()),
1655 : 0 : (pKeyEvent->GetKeyCode().IsShift()
1656 : : ? ::css::awt::KeyModifier::SHIFT : 0)
1657 : 0 : | (pKeyEvent->GetKeyCode().IsMod1()
1658 : : ? ::css::awt::KeyModifier::MOD1 : 0)
1659 : 0 : | (pKeyEvent->GetKeyCode().IsMod2()
1660 : : ? ::css::awt::KeyModifier::MOD2 : 0)
1661 : 0 : | (pKeyEvent->GetKeyCode().IsMod3()
1662 : : ? ::css::awt::KeyModifier::MOD3 : 0),
1663 : 0 : pKeyEvent->GetKeyCode().GetCode(), pKeyEvent->GetCharCode(),
1664 : : sal::static_int_cast< sal_Int16 >(
1665 [ # # ][ # # ]: 0 : pKeyEvent->GetKeyCode().GetFunction()));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1666 [ # # ]: 0 : for (::sal_Int32 i = 0; i < aHandlers.getLength(); ++i)
1667 : : {
1668 : : ::css::uno::Reference< ::css::awt::XKeyHandler > xHandler(
1669 [ # # ][ # # ]: 0 : aHandlers[i], ::css::uno::UNO_QUERY);
1670 : : try
1671 : : {
1672 [ # # ][ # # ]: 0 : if ((bPressed ? xHandler->keyPressed(aAwtEvent)
[ # # ]
1673 [ # # ][ # # ]: 0 : : xHandler->keyReleased(aAwtEvent)))
[ # # ]
1674 : 0 : return 1;
1675 : : }
1676 [ # # ]: 0 : catch (const ::css::uno::RuntimeException & rEx)
1677 : : {
1678 : : OSL_TRACE(
1679 : : "VCLXToolkit::callKeyHandlers: caught %s\n",
1680 : : ::rtl::OUStringToOString(
1681 : : rEx.Message, RTL_TEXTENCODING_UTF8).getStr());
1682 : : }
1683 [ # # ][ # # ]: 0 : }
[ # # ]
1684 : : }
1685 [ # # ]: 0 : return 0;
1686 : : }
1687 : :
1688 : 0 : void VCLXToolkit::callFocusListeners(::VclSimpleEvent const * pEvent,
1689 : : bool bGained)
1690 : : {
1691 : : ::Window * pWindow
1692 : 0 : = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow();
1693 [ # # ]: 0 : if (pWindow->IsTopWindow())
1694 : : {
1695 : : ::css::uno::Sequence< ::css::uno::Reference< ::css::uno::XInterface > >
1696 [ # # ]: 0 : aListeners(m_aFocusListeners.getElements());
1697 [ # # ]: 0 : if (aListeners.hasElements())
1698 : : {
1699 : : // Ignore the interior of compound controls when determining the
1700 : : // window that gets the focus next (see implementation in
1701 : : // vclxwindow.cxx for mapping between VCL and UNO AWT event):
1702 : 0 : ::css::uno::Reference< css::uno::XInterface > xNext;
1703 [ # # ]: 0 : ::Window * pFocus = ::Application::GetFocusWindow();
1704 [ # # ][ # # ]: 0 : for (::Window * p = pFocus; p != 0; p = p->GetParent())
1705 [ # # ][ # # ]: 0 : if (!p->IsCompoundControl())
1706 : : {
1707 : 0 : pFocus = p;
1708 : 0 : break;
1709 : : }
1710 [ # # ]: 0 : if (pFocus != 0)
1711 [ # # ][ # # ]: 0 : xNext = pFocus->GetComponentInterface(true);
1712 : : ::css::awt::FocusEvent aAwtEvent(
1713 [ # # ][ # # ]: 0 : static_cast< ::css::awt::XWindow * >(pWindow->GetWindowPeer()),
1714 [ # # ][ # # ]: 0 : pWindow->GetGetFocusFlags(), xNext, false);
[ # # ][ # # ]
1715 [ # # ]: 0 : for (::sal_Int32 i = 0; i < aListeners.getLength(); ++i)
1716 : : {
1717 : : ::css::uno::Reference< ::css::awt::XFocusListener > xListener(
1718 [ # # ][ # # ]: 0 : aListeners[i], ::css::uno::UNO_QUERY);
1719 : : try
1720 : : {
1721 [ # # ][ # # ]: 0 : bGained ? xListener->focusGained(aAwtEvent)
1722 [ # # ][ # # ]: 0 : : xListener->focusLost(aAwtEvent);
[ # # ]
1723 : : }
1724 [ # # ]: 0 : catch (const ::css::uno::RuntimeException & rEx)
1725 : : {
1726 : : OSL_TRACE(
1727 : : "VCLXToolkit::callFocusListeners: caught %s\n",
1728 : : ::rtl::OUStringToOString(
1729 : : rEx.Message, RTL_TEXTENCODING_UTF8).getStr());
1730 : : }
1731 [ # # ]: 0 : }
1732 [ # # ]: 0 : }
1733 : : }
1734 : 0 : }
1735 : :
1736 : : // css::awt::XReschedule:
1737 : :
1738 : 0 : void SAL_CALL VCLXToolkit::reschedule()
1739 : : throw (::com::sun::star::uno::RuntimeException)
1740 : : {
1741 : 0 : Application::Reschedule(true);
1742 : 0 : }
1743 : :
1744 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|