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 : : #include "comphelper/processfactory.hxx"
30 : :
31 : : #include "osl/module.h"
32 : : #include "osl/file.hxx"
33 : : #include "osl/thread.h"
34 : :
35 : : #include "rtl/tencinfo.h"
36 : : #include "rtl/instance.hxx"
37 : : #include "rtl/process.h"
38 : :
39 : : #include "tools/tools.h"
40 : : #include "tools/debug.hxx"
41 : : #include "tools/time.hxx"
42 : :
43 : : #include "i18npool/mslangid.hxx"
44 : :
45 : : #include "unotools/syslocaleoptions.hxx"
46 : :
47 : : #include "vcl/settings.hxx"
48 : : #include "vcl/keycod.hxx"
49 : : #include "vcl/event.hxx"
50 : : #include "vcl/vclevent.hxx"
51 : : #include "vcl/virdev.hxx"
52 : : #include "vcl/wrkwin.hxx"
53 : : #include "vcl/svapp.hxx"
54 : : #include "vcl/cvtgrf.hxx"
55 : : #include "vcl/unowrap.hxx"
56 : : #include "vcl/timer.hxx"
57 : : #include "vcl/unohelp.hxx"
58 : : #include "vcl/lazydelete.hxx"
59 : :
60 : : #include "salinst.hxx"
61 : : #include "salframe.hxx"
62 : : #include "salsys.hxx"
63 : : #include "svdata.hxx"
64 : : #include "salimestatus.hxx"
65 : : #include "xconnection.hxx"
66 : : #include "window.h"
67 : : #include "accmgr.hxx"
68 : : #include "idlemgr.hxx"
69 : : #include "svids.hrc"
70 : :
71 : : #include "com/sun/star/uno/Reference.h"
72 : : #include "com/sun/star/awt/XToolkit.hpp"
73 : : #include "com/sun/star/uno/XNamingService.hpp"
74 : : #include "com/sun/star/lang/XMultiServiceFactory.hpp"
75 : : #include "osl/mutex.hxx"
76 : : #include "osl/process.h"
77 : :
78 : : #include <utility>
79 : :
80 : : using namespace ::com::sun::star;
81 : : using namespace ::com::sun::star::uno;
82 : :
83 : : // keycodes handled internally by VCL
84 : : class ImplReservedKey
85 : : {
86 : : public:
87 : 0 : ImplReservedKey( KeyCode aKeyCode, sal_uInt16 nResId ) :
88 : 0 : mKeyCode(aKeyCode), mnResId( nResId)
89 : 0 : {}
90 : :
91 : : KeyCode mKeyCode;
92 : : sal_uInt16 mnResId;
93 : : };
94 : :
95 : : typedef std::pair<ImplReservedKey*, size_t> ReservedKeys;
96 : : namespace
97 : : {
98 : : struct ImplReservedKeysImpl
99 : : {
100 : 0 : ReservedKeys* operator()()
101 : : {
102 : : static ImplReservedKey ImplReservedKeys[] =
103 : : {
104 : : ImplReservedKey(KeyCode(KEY_F1,0), SV_SHORTCUT_HELP),
105 : : ImplReservedKey(KeyCode(KEY_F1,KEY_SHIFT), SV_SHORTCUT_ACTIVEHELP),
106 : : ImplReservedKey(KeyCode(KEY_F1,KEY_MOD1), SV_SHORTCUT_CONTEXTHELP),
107 : : ImplReservedKey(KeyCode(KEY_F2,KEY_SHIFT), SV_SHORTCUT_CONTEXTHELP),
108 : : ImplReservedKey(KeyCode(KEY_F4,KEY_MOD1), SV_SHORTCUT_DOCKUNDOCK),
109 : : ImplReservedKey(KeyCode(KEY_F4,KEY_MOD2), SV_SHORTCUT_DOCKUNDOCK),
110 : : ImplReservedKey(KeyCode(KEY_F4,KEY_MOD1|KEY_MOD2), SV_SHORTCUT_DOCKUNDOCK),
111 : : ImplReservedKey(KeyCode(KEY_F6,0), SV_SHORTCUT_NEXTSUBWINDOW),
112 : : ImplReservedKey(KeyCode(KEY_F6,KEY_MOD1), SV_SHORTCUT_TODOCUMENT),
113 : : ImplReservedKey(KeyCode(KEY_F6,KEY_SHIFT), SV_SHORTCUT_PREVSUBWINDOW),
114 : : ImplReservedKey(KeyCode(KEY_F6,KEY_MOD1|KEY_SHIFT), SV_SHORTCUT_SPLITTER),
115 : : ImplReservedKey(KeyCode(KEY_F10,0), SV_SHORTCUT_MENUBAR)
116 : : #ifdef UNX
117 : : ,
118 : : ImplReservedKey(KeyCode(KEY_1,KEY_SHIFT|KEY_MOD1), 0),
119 : : ImplReservedKey(KeyCode(KEY_2,KEY_SHIFT|KEY_MOD1), 0),
120 : : ImplReservedKey(KeyCode(KEY_3,KEY_SHIFT|KEY_MOD1), 0),
121 : : ImplReservedKey(KeyCode(KEY_4,KEY_SHIFT|KEY_MOD1), 0),
122 : : ImplReservedKey(KeyCode(KEY_5,KEY_SHIFT|KEY_MOD1), 0),
123 : : ImplReservedKey(KeyCode(KEY_6,KEY_SHIFT|KEY_MOD1), 0),
124 : : ImplReservedKey(KeyCode(KEY_7,KEY_SHIFT|KEY_MOD1), 0),
125 : : ImplReservedKey(KeyCode(KEY_8,KEY_SHIFT|KEY_MOD1), 0),
126 : : ImplReservedKey(KeyCode(KEY_9,KEY_SHIFT|KEY_MOD1), 0),
127 : : ImplReservedKey(KeyCode(KEY_0,KEY_SHIFT|KEY_MOD1), 0),
128 : : ImplReservedKey(KeyCode(KEY_ADD,KEY_SHIFT|KEY_MOD1), 0)
129 : : #endif
130 [ # # ][ # # ]: 0 : };
131 : : static ReservedKeys aKeys
132 : : (
133 : : &ImplReservedKeys[0],
134 : : sizeof(ImplReservedKeys) / sizeof(ImplReservedKey)
135 : : );
136 : 0 : return &aKeys;
137 : : }
138 : : };
139 : :
140 : : struct ImplReservedKeys
141 : : : public rtl::StaticAggregate<ReservedKeys, ImplReservedKeysImpl> {};
142 : : }
143 : :
144 : :
145 : : extern "C" {
146 : : typedef UnoWrapperBase* (SAL_CALL *FN_TkCreateUnoWrapper)();
147 : : }
148 : :
149 : : // =======================================================================
150 : :
151 : : // --------------
152 : : // - ImplHotKey -
153 : : // --------------
154 : :
155 : : struct ImplHotKey
156 : : {
157 : : ImplHotKey* mpNext;
158 : : void* mpUserData;
159 : : KeyCode maKeyCode;
160 : : Link maLink;
161 : : };
162 : :
163 : : // =======================================================================
164 : :
165 : : // -----------------
166 : : // - ImplEventHook -
167 : : // -----------------
168 : :
169 : : struct ImplEventHook
170 : : {
171 : : ImplEventHook* mpNext;
172 : : void* mpUserData;
173 : : VCLEventHookProc mpProc;
174 : : };
175 : :
176 : : // =======================================================================
177 : :
178 : : // ---------------------
179 : : // - ImplPostEventData -
180 : : // ---------------------
181 : :
182 : : struct ImplPostEventData
183 : : {
184 : : sal_uLong mnEvent;
185 : : const Window* mpWin;
186 : : sal_uLong mnEventId;
187 : : KeyEvent maKeyEvent;
188 : : MouseEvent maMouseEvent;
189 : :
190 : :
191 : 0 : ImplPostEventData( sal_uLong nEvent, const Window* pWin, const KeyEvent& rKeyEvent ) :
192 : 0 : mnEvent( nEvent ), mpWin( pWin ), mnEventId( 0 ), maKeyEvent( rKeyEvent ) {}
193 : 0 : ImplPostEventData( sal_uLong nEvent, const Window* pWin, const MouseEvent& rMouseEvent ) :
194 : 0 : mnEvent( nEvent ), mpWin( pWin ), mnEventId( 0 ), maMouseEvent( rMouseEvent ) {}
195 : :
196 : 0 : ~ImplPostEventData() {}
197 : : };
198 : :
199 : : typedef ::std::pair< Window*, ImplPostEventData* > ImplPostEventPair;
200 : :
201 : 281 : static ::std::list< ImplPostEventPair > aPostedEventList;
202 : :
203 : : // =======================================================================
204 : :
205 : 284851 : Application* GetpApp()
206 : : {
207 : 284851 : ImplSVData* pSVData = ImplGetSVData();
208 [ - + ]: 284851 : if ( !pSVData )
209 : 0 : return NULL;
210 : 284851 : return pSVData->mpApp;
211 : : }
212 : :
213 : : // -----------------------------------------------------------------------
214 : :
215 : 266 : Application::Application()
216 : : {
217 [ + + ]: 266 : if( ! ImplGetSVData() )
218 : 158 : ImplInitSVData();
219 : 266 : ImplGetSVData()->mpApp = this;
220 : 266 : InitSalData();
221 : 266 : }
222 : :
223 : : // -----------------------------------------------------------------------
224 : :
225 : 158 : Application::~Application()
226 : : {
227 : 158 : ImplDeInitSVData();
228 : 158 : DeInitSalData();
229 : 158 : ImplGetSVData()->mpApp = NULL;
230 : 158 : ImplDestroySVData();
231 : 158 : GlobalDeInitTools();
232 [ - + ]: 158 : }
233 : :
234 : : // -----------------------------------------------------------------------
235 : :
236 : 0 : sal_Bool Application::QueryExit()
237 : : {
238 : 0 : WorkWindow* pAppWin = ImplGetSVData()->maWinData.mpAppWin;
239 : :
240 : : // Aufruf des Close-Handlers des Applikationsfensters
241 [ # # ]: 0 : if ( pAppWin )
242 : 0 : return pAppWin->Close();
243 : : else
244 : 0 : return sal_True;
245 : : }
246 : :
247 : : // -----------------------------------------------------------------------
248 : :
249 : 0 : void Application::UserEvent( sal_uLong, void* )
250 : : {
251 : 0 : }
252 : :
253 : : // -----------------------------------------------------------------------
254 : :
255 : 0 : void Application::ActivateExtHelp()
256 : : {
257 : 0 : }
258 : :
259 : : // -----------------------------------------------------------------------
260 : :
261 : 0 : void Application::DeactivateExtHelp()
262 : : {
263 : 0 : }
264 : :
265 : : // -----------------------------------------------------------------------
266 : :
267 : 10251 : void Application::FocusChanged()
268 : : {
269 : 10251 : }
270 : :
271 : : // -----------------------------------------------------------------------
272 : :
273 : 328 : void Application::DataChanged( const DataChangedEvent& )
274 : : {
275 : 328 : }
276 : :
277 : : // -----------------------------------------------------------------------
278 : 108 : void Application::Init()
279 : : {
280 : 108 : }
281 : :
282 : : // -----------------------------------------------------------------------
283 : 564 : void Application::InitFinished()
284 : : {
285 : 564 : }
286 : :
287 : : // -----------------------------------------------------------------------
288 : :
289 : 0 : void Application::DeInit()
290 : : {
291 : 0 : }
292 : :
293 : : // -----------------------------------------------------------------------
294 : :
295 : 0 : sal_uInt16 Application::GetCommandLineParamCount()
296 : : {
297 : 0 : return (sal_uInt16)osl_getCommandArgCount();
298 : : }
299 : :
300 : : // -----------------------------------------------------------------------
301 : :
302 : 0 : XubString Application::GetCommandLineParam( sal_uInt16 nParam )
303 : : {
304 : 0 : rtl::OUString aParam;
305 [ # # ]: 0 : osl_getCommandArg( nParam, &aParam.pData );
306 [ # # ]: 0 : return aParam;
307 : : }
308 : :
309 : : // -----------------------------------------------------------------------
310 : :
311 : 0 : const XubString& Application::GetAppFileName()
312 : : {
313 : 0 : ImplSVData* pSVData = ImplGetSVData();
314 : : DBG_ASSERT( pSVData->maAppData.mpAppFileName, "AppFileName vor SVMain ?!" );
315 [ # # ]: 0 : if ( pSVData->maAppData.mpAppFileName )
316 : 0 : return *pSVData->maAppData.mpAppFileName;
317 : :
318 : : /*
319 : : * #91147# provide a fallback for people without initialized
320 : : * vcl here (like setup in responsefile mode)
321 : : */
322 [ # # ][ # # ]: 0 : static String aAppFileName;
[ # # ][ # # ]
323 [ # # ]: 0 : if( !aAppFileName.Len() )
324 : : {
325 : 0 : rtl::OUString aExeFileName;
326 [ # # ]: 0 : osl_getExecutableFile( &aExeFileName.pData );
327 : :
328 : : // convert path to native file format
329 : 0 : rtl::OUString aNativeFileName;
330 [ # # ]: 0 : osl::FileBase::getSystemPathFromFileURL( aExeFileName, aNativeFileName );
331 [ # # ]: 0 : aAppFileName = aNativeFileName;
332 : : }
333 : :
334 : 0 : return aAppFileName;
335 : : }
336 : :
337 : : // -----------------------------------------------------------------------
338 : :
339 : 0 : sal_uInt16 Application::Exception( sal_uInt16 nError )
340 : : {
341 [ # # # ]: 0 : switch ( nError & EXC_MAJORTYPE )
342 : : {
343 : : // System has precedence (so do nothing)
344 : : case EXC_SYSTEM:
345 : 0 : return 0;
346 : :
347 : : case EXC_DISPLAY:
348 : : case EXC_REMOTE:
349 : 0 : return 0;
350 : :
351 : : #ifdef DBG_UTIL
352 : : case EXC_RSCNOTLOADED:
353 : : Abort(rtl::OUString("Resource not loaded"));
354 : : break;
355 : : case EXC_SYSOBJNOTCREATED:
356 : : Abort(rtl::OUString("System Object not created"));
357 : : break;
358 : : default:
359 : : Abort(rtl::OUString("Unknown Error"));
360 : : break;
361 : : #else
362 : : default:
363 [ # # ][ # # ]: 0 : Abort(rtl::OUString());
[ # # ]
364 : 0 : break;
365 : : #endif
366 : : }
367 : :
368 : 0 : return 0;
369 : : }
370 : :
371 : : // -----------------------------------------------------------------------
372 : :
373 : 0 : void Application::Abort( const XubString& rErrorText )
374 : : {
375 : : //HACK: Dump core iff --norestore command line argument is given (assuming
376 : : // this process is run by developers who are interested in cores, vs. end
377 : : // users who are not):
378 : 0 : bool dumpCore = false;
379 : 0 : sal_uInt16 n = GetCommandLineParamCount();
380 [ # # ]: 0 : for (sal_uInt16 i = 0; i != n; ++i) {
381 [ # # ][ # # ]: 0 : if (GetCommandLineParam(i).EqualsAscii("--norestore")) {
382 : 0 : dumpCore = true;
383 : 0 : break;
384 : : }
385 : : }
386 : :
387 [ # # ]: 0 : SalAbort( rErrorText, dumpCore );
388 : 0 : }
389 : :
390 : : // -----------------------------------------------------------------------
391 : :
392 : 0 : sal_uLong Application::GetReservedKeyCodeCount()
393 : : {
394 : 0 : return ImplReservedKeys::get()->second;
395 : : }
396 : :
397 : 0 : const KeyCode* Application::GetReservedKeyCode( sal_uLong i )
398 : : {
399 [ # # ]: 0 : if( i >= GetReservedKeyCodeCount() )
400 : 0 : return NULL;
401 : : else
402 : 0 : return &ImplReservedKeys::get()->first[i].mKeyCode;
403 : : }
404 : :
405 : : // -----------------------------------------------------------------------
406 : :
407 : 96 : void Application::Execute()
408 : : {
409 : 96 : ImplSVData* pSVData = ImplGetSVData();
410 : 96 : pSVData->maAppData.mbInAppExecute = sal_True;
411 : :
412 [ + + ]: 218774 : while ( !pSVData->maAppData.mbAppQuit )
413 : 218678 : Application::Yield();
414 : :
415 : 96 : pSVData->maAppData.mbInAppExecute = sal_False;
416 : 96 : }
417 : :
418 : : // -----------------------------------------------------------------------
419 : :
420 : 222321 : inline void ImplYield( bool i_bWait, bool i_bAllEvents )
421 : : {
422 : 222321 : ImplSVData* pSVData = ImplGetSVData();
423 : :
424 : : // run timers that have timed out
425 [ + - ]: 222321 : if ( !pSVData->mbNoCallTimer )
426 [ - + ]: 222321 : while ( pSVData->mbNotAllTimerCalled )
427 : 0 : Timer::ImplTimerCallbackProc();
428 : :
429 : 222321 : pSVData->maAppData.mnDispatchLevel++;
430 : : // do not wait for events if application was already quit; in that
431 : : // case only dispatch events already available
432 : : // do not wait for events either if the app decided that it is too busy for timers
433 : : // (feature added for the slideshow)
434 [ + + ][ + - ]: 222321 : pSVData->mpDefInst->Yield( i_bWait && !pSVData->maAppData.mbAppQuit && !pSVData->maAppData.mbNoYield, i_bAllEvents );
[ + - ]
435 : 222321 : pSVData->maAppData.mnDispatchLevel--;
436 : :
437 : : // flush lazy deleted objects
438 [ + + ]: 222321 : if( pSVData->maAppData.mnDispatchLevel == 0 )
439 : 220832 : vcl::LazyDelete::flush();
440 : :
441 : : // the system timer events will not necesseraly come in in non waiting mode
442 : : // e.g. on aqua; need to trigger timer checks manually
443 [ - + ][ # # ]: 222321 : if( pSVData->maAppData.mbNoYield && !pSVData->mbNoCallTimer )
444 : : {
445 [ # # ]: 0 : do
446 : : {
447 : 0 : Timer::ImplTimerCallbackProc();
448 : : }
449 : : while( pSVData->mbNotAllTimerCalled );
450 : : }
451 : :
452 : : // call post yield listeners
453 [ - + ]: 222321 : if( pSVData->maAppData.mpPostYieldListeners )
454 : 0 : pSVData->maAppData.mpPostYieldListeners->callListeners( NULL );
455 : 222321 : }
456 : :
457 : : // -----------------------------------------------------------------------
458 : :
459 : 3643 : void Application::Reschedule( bool i_bAllEvents )
460 : : {
461 : 3643 : ImplYield( false, i_bAllEvents );
462 : 3643 : }
463 : :
464 : : // -----------------------------------------------------------------------
465 : :
466 : 218678 : void Application::Yield( bool i_bAllEvents )
467 : : {
468 : 218678 : ImplYield( true, i_bAllEvents );
469 : 218678 : }
470 : :
471 : : // -----------------------------------------------------------------------
472 : :
473 : 96 : IMPL_STATIC_LINK_NOINSTANCE( ImplSVAppData, ImplQuitMsg, void*, EMPTYARG )
474 : : {
475 : 96 : ImplGetSVData()->maAppData.mbAppQuit = sal_True;
476 : 96 : return 0;
477 : : }
478 : :
479 : : // -----------------------------------------------------------------------
480 : :
481 : 158 : void Application::Quit()
482 : : {
483 [ + - ]: 158 : Application::PostUserEvent( STATIC_LINK( NULL, ImplSVAppData, ImplQuitMsg ) );
484 : 158 : }
485 : :
486 : : // -----------------------------------------------------------------------
487 : :
488 : 8112974 : osl::SolarMutex& Application::GetSolarMutex()
489 : : {
490 : 8112974 : ImplSVData* pSVData = ImplGetSVData();
491 : 8112979 : return *(pSVData->mpDefInst->GetYieldMutex());
492 : : }
493 : :
494 : : // -----------------------------------------------------------------------
495 : :
496 : 0 : oslThreadIdentifier Application::GetMainThreadIdentifier()
497 : : {
498 : 0 : return ImplGetSVData()->mnMainThreadId;
499 : : }
500 : :
501 : : // -----------------------------------------------------------------------
502 : :
503 : 1902 : sal_uLong Application::ReleaseSolarMutex()
504 : : {
505 : 1902 : ImplSVData* pSVData = ImplGetSVData();
506 : 1902 : return pSVData->mpDefInst->ReleaseYieldMutex();
507 : : }
508 : :
509 : : // -----------------------------------------------------------------------
510 : :
511 : 1902 : void Application::AcquireSolarMutex( sal_uLong nCount )
512 : : {
513 : 1902 : ImplSVData* pSVData = ImplGetSVData();
514 : 1902 : pSVData->mpDefInst->AcquireYieldMutex( nCount );
515 : 1902 : }
516 : :
517 : : // -----------------------------------------------------------------------
518 : :
519 : 1460 : sal_Bool Application::IsInMain()
520 : : {
521 : 1460 : return ImplGetSVData()->maAppData.mbInAppMain;
522 : : }
523 : :
524 : : // -----------------------------------------------------------------------
525 : :
526 : 346 : sal_Bool Application::IsInExecute()
527 : : {
528 : 346 : return ImplGetSVData()->maAppData.mbInAppExecute;
529 : : }
530 : :
531 : : // -----------------------------------------------------------------------
532 : :
533 : 0 : sal_Bool Application::IsInModalMode()
534 : : {
535 : 0 : return (ImplGetSVData()->maAppData.mnModalMode != 0);
536 : : }
537 : :
538 : : // -----------------------------------------------------------------------
539 : :
540 : 0 : sal_uInt16 Application::GetDispatchLevel()
541 : : {
542 : 0 : return ImplGetSVData()->maAppData.mnDispatchLevel;
543 : : }
544 : :
545 : : // -----------------------------------------------------------------------
546 : :
547 : 49360 : sal_Bool Application::AnyInput( sal_uInt16 nType )
548 : : {
549 : 49360 : return (sal_Bool)ImplGetSVData()->mpDefInst->AnyInput( nType );
550 : : }
551 : :
552 : : // -----------------------------------------------------------------------
553 : :
554 : 5760 : sal_uLong Application::GetLastInputInterval()
555 : : {
556 : 5760 : return (Time::GetSystemTicks()-ImplGetSVData()->maAppData.mnLastInputTime);
557 : : }
558 : :
559 : : // -----------------------------------------------------------------------
560 : :
561 : : extern int nImplSysDialog;
562 : :
563 : 16 : sal_Bool Application::IsUICaptured()
564 : : {
565 : 16 : ImplSVData* pSVData = ImplGetSVData();
566 : :
567 : : // If mouse was captured, or if in tracking- or in select-mode of a floatingwindow (e.g. menus
568 : : // or pulldown toolboxes) another window should be created
569 : : // D&D active !!!
570 [ + - ][ + - ]: 16 : if ( pSVData->maWinData.mpCaptureWin || pSVData->maWinData.mpTrackWin ||
[ - + ][ + - ]
571 : : pSVData->maWinData.mpFirstFloat || nImplSysDialog )
572 : 0 : return sal_True;
573 : : else
574 : 16 : return sal_False;
575 : : }
576 : :
577 : : // -----------------------------------------------------------------------
578 : :
579 : 51 : void Application::SystemSettingsChanging( AllSettings& /*rSettings*/,
580 : : Window* /*pFrame*/ )
581 : : {
582 : 51 : }
583 : :
584 : : // -----------------------------------------------------------------------
585 : :
586 : 158 : void Application::MergeSystemSettings( AllSettings& rSettings )
587 : : {
588 : 158 : Window* pWindow = ImplGetSVData()->maWinData.mpFirstFrame;
589 [ - + ]: 158 : if( ! pWindow )
590 : 0 : pWindow = ImplGetDefaultWindow();
591 [ + - ]: 158 : if( pWindow )
592 : : {
593 : 158 : ImplSVData* pSVData = ImplGetSVData();
594 [ + - ]: 158 : if ( !pSVData->maAppData.mbSettingsInit )
595 : : {
596 : : // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings
597 : 158 : pWindow->ImplUpdateGlobalSettings( *pSVData->maAppData.mpSettings );
598 : 158 : pSVData->maAppData.mbSettingsInit = sal_True;
599 : : }
600 : : // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings
601 : 158 : pWindow->ImplUpdateGlobalSettings( rSettings, sal_False );
602 : : }
603 : 158 : }
604 : :
605 : : // -----------------------------------------------------------------------
606 : :
607 : 0 : bool Application::ValidateSystemFont()
608 : : {
609 : 0 : Window* pWindow = ImplGetSVData()->maWinData.mpFirstFrame;
610 [ # # ]: 0 : if( ! pWindow )
611 : 0 : pWindow = ImplGetDefaultWindow();
612 : :
613 [ # # ]: 0 : if( pWindow )
614 : : {
615 [ # # ]: 0 : AllSettings aSettings;
616 [ # # ][ # # ]: 0 : pWindow->ImplGetFrame()->UpdateSettings( aSettings );
617 [ # # ][ # # ]: 0 : return pWindow->ImplCheckUIFont( aSettings.GetStyleSettings().GetAppFont() );
618 : : }
619 : 0 : return false;
620 : : }
621 : :
622 : : // -----------------------------------------------------------------------
623 : :
624 : 561 : void Application::SetSettings( const AllSettings& rSettings )
625 : : {
626 : 561 : ImplSVData* pSVData = ImplGetSVData();
627 [ - + ]: 561 : if ( !pSVData->maAppData.mpSettings )
628 : : {
629 : 0 : GetSettings();
630 : 0 : *pSVData->maAppData.mpSettings = rSettings;
631 : 0 : ResMgr::SetDefaultLocale( rSettings.GetUILocale() );
632 : : }
633 : : else
634 : : {
635 [ + - ]: 561 : AllSettings aOldSettings = *pSVData->maAppData.mpSettings;
636 [ + - ][ + - ]: 561 : if( aOldSettings.GetUILanguage() != rSettings.GetUILanguage() && pSVData->mpResMgr )
[ - + ][ # # ]
[ - + ]
637 : : {
638 [ # # ][ # # ]: 0 : delete pSVData->mpResMgr;
639 : 0 : pSVData->mpResMgr = NULL;
640 : : }
641 [ + - ][ + - ]: 561 : ResMgr::SetDefaultLocale( rSettings.GetUILocale() );
642 [ + - ]: 561 : *pSVData->maAppData.mpSettings = rSettings;
643 [ + - ]: 561 : sal_uLong nChangeFlags = aOldSettings.GetChangeFlags( *pSVData->maAppData.mpSettings );
644 [ + + ]: 561 : if ( nChangeFlags )
645 : : {
646 [ + - ]: 328 : DataChangedEvent aDCEvt( DATACHANGED_SETTINGS, &aOldSettings, nChangeFlags );
647 [ + - ][ + - ]: 328 : GetpApp()->DataChanged( aDCEvt );
648 : :
649 : : // notify data change handler
650 [ + - ]: 328 : ImplCallEventListeners( VCLEVENT_APPLICATION_DATACHANGED, NULL, &aDCEvt);
651 : :
652 : : // Update all windows
653 : 328 : Window* pFirstFrame = pSVData->maWinData.mpFirstFrame;
654 : : // Reset data that needs to be re-calculated
655 : 328 : long nOldDPIX = 0;
656 : 328 : long nOldDPIY = 0;
657 [ + - ]: 328 : if ( pFirstFrame )
658 : : {
659 : 328 : nOldDPIX = pFirstFrame->mnDPIX;
660 : 328 : nOldDPIY = pFirstFrame->mnDPIY;
661 : 328 : pSVData->maGDIData.mnAppFontX = 0;
662 : : }
663 : 328 : Window* pFrame = pFirstFrame;
664 [ + + ]: 662 : while ( pFrame )
665 : : {
666 : : // restore AppFont cache data
667 : 334 : pFrame->mpWindowImpl->mpFrameData->meMapUnit = MAP_PIXEL;
668 : :
669 : : // call UpdateSettings from ClientWindow in order to prevent updating data twice
670 : 334 : Window* pClientWin = pFrame;
671 [ + - ][ + + ]: 668 : while ( pClientWin->ImplGetClientWindow() )
672 [ + - ]: 334 : pClientWin = pClientWin->ImplGetClientWindow();
673 [ + - ]: 334 : pClientWin->UpdateSettings( rSettings, sal_True );
674 : :
675 : 334 : Window* pTempWin = pFrame->mpWindowImpl->mpFrameData->mpFirstOverlap;
676 [ - + ]: 334 : while ( pTempWin )
677 : : {
678 : : // call UpdateSettings from ClientWindow in order to prevent updating data twice
679 : 0 : pClientWin = pTempWin;
680 [ # # ][ # # ]: 0 : while ( pClientWin->ImplGetClientWindow() )
681 [ # # ]: 0 : pClientWin = pClientWin->ImplGetClientWindow();
682 [ # # ]: 0 : pClientWin->UpdateSettings( rSettings, sal_True );
683 : 0 : pTempWin = pTempWin->mpWindowImpl->mpNextOverlap;
684 : : }
685 : :
686 : 334 : pFrame = pFrame->mpWindowImpl->mpFrameData->mpNextFrame;
687 : : }
688 : :
689 : : // if DPI resolution for screen output was changed set the new resolution for all
690 : : // screen compatible VirDev´s
691 : 328 : pFirstFrame = pSVData->maWinData.mpFirstFrame;
692 [ + - ]: 328 : if ( pFirstFrame )
693 : : {
694 [ + - ][ - + ]: 328 : if ( (pFirstFrame->mnDPIX != nOldDPIX) ||
695 : : (pFirstFrame->mnDPIY != nOldDPIY) )
696 : : {
697 : 0 : VirtualDevice* pVirDev = pSVData->maGDIData.mpFirstVirDev;
698 [ # # ]: 328 : while ( pVirDev )
699 : : {
700 [ # # ][ # # ]: 0 : if ( pVirDev->mbScreenComp &&
[ # # ]
701 : : (pVirDev->mnDPIX == nOldDPIX) &&
702 : : (pVirDev->mnDPIY == nOldDPIY) )
703 : : {
704 : 0 : pVirDev->mnDPIX = pFirstFrame->mnDPIX;
705 : 0 : pVirDev->mnDPIY = pFirstFrame->mnDPIY;
706 [ # # ]: 0 : if ( pVirDev->IsMapMode() )
707 : : {
708 [ # # ]: 0 : MapMode aMapMode = pVirDev->GetMapMode();
709 [ # # ]: 0 : pVirDev->SetMapMode();
710 [ # # ][ # # ]: 0 : pVirDev->SetMapMode( aMapMode );
711 : : }
712 : : }
713 : :
714 : 0 : pVirDev = pVirDev->mpNext;
715 : : }
716 : : }
717 : : }
718 [ + - ]: 561 : }
719 : : }
720 : 561 : }
721 : :
722 : : // -----------------------------------------------------------------------
723 : :
724 : 3260301 : const AllSettings& Application::GetSettings()
725 : : {
726 : 3260301 : ImplSVData* pSVData = ImplGetSVData();
727 [ + + ]: 3260301 : if ( !pSVData->maAppData.mpSettings )
728 : : {
729 [ + - ]: 251 : pSVData->maAppData.mpCfgListener = new LocaleConfigurationListener;
730 [ + - ]: 251 : pSVData->maAppData.mpSettings = new AllSettings();
731 : 251 : pSVData->maAppData.mpSettings->GetSysLocale().GetOptions().AddListener( pSVData->maAppData.mpCfgListener );
732 : : }
733 : :
734 : 3260301 : return *(pSVData->maAppData.mpSettings);
735 : : }
736 : :
737 : : // -----------------------------------------------------------------------
738 : :
739 : 0 : void Application::NotifyAllWindows( DataChangedEvent& rDCEvt )
740 : : {
741 : 0 : ImplSVData* pSVData = ImplGetSVData();
742 : 0 : Window* pFrame = pSVData->maWinData.mpFirstFrame;
743 [ # # ]: 0 : while ( pFrame )
744 : : {
745 : 0 : pFrame->NotifyAllChildren( rDCEvt );
746 : :
747 : 0 : Window* pSysWin = pFrame->mpWindowImpl->mpFrameData->mpFirstOverlap;
748 [ # # ]: 0 : while ( pSysWin )
749 : : {
750 : 0 : pSysWin->NotifyAllChildren( rDCEvt );
751 : 0 : pSysWin = pSysWin->mpWindowImpl->mpNextOverlap;
752 : : }
753 : :
754 : 0 : pFrame = pFrame->mpWindowImpl->mpFrameData->mpNextFrame;
755 : : }
756 : 0 : }
757 : :
758 : : // -----------------------------------------------------------------------
759 : :
760 : 328 : void Application::ImplCallEventListeners( sal_uLong nEvent, Window *pWin, void* pData )
761 : : {
762 [ + - ]: 328 : ImplSVData* pSVData = ImplGetSVData();
763 : 328 : VclWindowEvent aEvent( pWin, nEvent, pData );
764 : :
765 [ + + ]: 328 : if ( pSVData->maAppData.mpEventListeners )
766 [ + - ]: 328 : pSVData->maAppData.mpEventListeners->Call( &aEvent );
767 : 328 : }
768 : :
769 : : // -----------------------------------------------------------------------
770 : :
771 : 1776639 : void Application::ImplCallEventListeners( VclSimpleEvent* pEvent )
772 : : {
773 : 1776639 : ImplSVData* pSVData = ImplGetSVData();
774 : :
775 [ + + ]: 1776639 : if ( pSVData->maAppData.mpEventListeners )
776 : 1775277 : pSVData->maAppData.mpEventListeners->Call( pEvent );
777 : 1776639 : }
778 : :
779 : : // -----------------------------------------------------------------------
780 : :
781 : 2212 : void Application::AddEventListener( const Link& rEventListener )
782 : : {
783 : 2212 : ImplSVData* pSVData = ImplGetSVData();
784 [ + + ]: 2212 : if( !pSVData->maAppData.mpEventListeners )
785 [ + - ]: 131 : pSVData->maAppData.mpEventListeners = new VclEventListeners;
786 : 2212 : pSVData->maAppData.mpEventListeners->addListener( rEventListener );
787 : 2212 : }
788 : :
789 : : // -----------------------------------------------------------------------
790 : :
791 : 2050 : void Application::RemoveEventListener( const Link& rEventListener )
792 : : {
793 : 2050 : ImplSVData* pSVData = ImplGetSVData();
794 [ + - ]: 2050 : if( pSVData->maAppData.mpEventListeners )
795 : 2050 : pSVData->maAppData.mpEventListeners->removeListener( rEventListener );
796 : 2050 : }
797 : :
798 : : // -----------------------------------------------------------------------
799 : 0 : void Application::AddKeyListener( const Link& rKeyListener )
800 : : {
801 : 0 : ImplSVData* pSVData = ImplGetSVData();
802 [ # # ]: 0 : if( !pSVData->maAppData.mpKeyListeners )
803 [ # # ]: 0 : pSVData->maAppData.mpKeyListeners = new VclEventListeners;
804 : 0 : pSVData->maAppData.mpKeyListeners->addListener( rKeyListener );
805 : 0 : }
806 : :
807 : : // -----------------------------------------------------------------------
808 : :
809 : 0 : void Application::RemoveKeyListener( const Link& rKeyListener )
810 : : {
811 : 0 : ImplSVData* pSVData = ImplGetSVData();
812 [ # # ]: 0 : if( pSVData->maAppData.mpKeyListeners )
813 : 0 : pSVData->maAppData.mpKeyListeners->removeListener( rKeyListener );
814 : 0 : }
815 : :
816 : : // -----------------------------------------------------------------------
817 : :
818 : 0 : sal_Bool Application::HandleKey( sal_uLong nEvent, Window *pWin, KeyEvent* pKeyEvent )
819 : : {
820 : : // let listeners process the key event
821 : 0 : VclWindowEvent aEvent( pWin, nEvent, (void *) pKeyEvent );
822 : :
823 [ # # ]: 0 : ImplSVData* pSVData = ImplGetSVData();
824 : 0 : sal_Bool bProcessed = sal_False;
825 : :
826 [ # # ]: 0 : if ( pSVData->maAppData.mpKeyListeners )
827 [ # # ]: 0 : bProcessed = pSVData->maAppData.mpKeyListeners->Process( &aEvent );
828 : :
829 : 0 : return bProcessed;
830 : : }
831 : :
832 : : // -----------------------------------------------------------------------------
833 : :
834 : 0 : sal_uLong Application::PostKeyEvent( sal_uLong nEvent, Window *pWin, KeyEvent* pKeyEvent )
835 : : {
836 [ # # ]: 0 : const SolarMutexGuard aGuard;
837 : 0 : sal_uLong nEventId = 0;
838 : :
839 [ # # ][ # # ]: 0 : if( pWin && pKeyEvent )
840 : : {
841 [ # # ][ # # ]: 0 : ImplPostEventData* pPostEventData = new ImplPostEventData( nEvent, pWin, *pKeyEvent );
842 : :
843 : : PostUserEvent( nEventId,
844 : : STATIC_LINK( NULL, Application, PostEventHandler ),
845 [ # # ][ # # ]: 0 : pPostEventData );
846 : :
847 [ # # ]: 0 : if( nEventId )
848 : : {
849 : 0 : pPostEventData->mnEventId = nEventId;
850 [ # # ]: 0 : aPostedEventList.push_back( ImplPostEventPair( pWin, pPostEventData ) );
851 : : }
852 : : else
853 [ # # ]: 0 : delete pPostEventData;
854 : : }
855 : :
856 [ # # ]: 0 : return nEventId;
857 : : }
858 : :
859 : : // -----------------------------------------------------------------------------
860 : :
861 : 0 : sal_uLong Application::PostMouseEvent( sal_uLong nEvent, Window *pWin, MouseEvent* pMouseEvent )
862 : : {
863 [ # # ]: 0 : const SolarMutexGuard aGuard;
864 : 0 : sal_uLong nEventId = 0;
865 : :
866 [ # # ][ # # ]: 0 : if( pWin && pMouseEvent )
867 : : {
868 : 0 : Point aTransformedPos( pMouseEvent->GetPosPixel() );
869 : :
870 : 0 : aTransformedPos.X() += pWin->mnOutOffX;
871 : 0 : aTransformedPos.Y() += pWin->mnOutOffY;
872 : :
873 : 0 : const MouseEvent aTransformedEvent( aTransformedPos, pMouseEvent->GetClicks(), pMouseEvent->GetMode(),
874 [ # # ]: 0 : pMouseEvent->GetButtons(), pMouseEvent->GetModifier() );
875 : :
876 [ # # ][ # # ]: 0 : ImplPostEventData* pPostEventData = new ImplPostEventData( nEvent, pWin, aTransformedEvent );
877 : :
878 : : PostUserEvent( nEventId,
879 : : STATIC_LINK( NULL, Application, PostEventHandler ),
880 [ # # ][ # # ]: 0 : pPostEventData );
881 : :
882 [ # # ]: 0 : if( nEventId )
883 : : {
884 : 0 : pPostEventData->mnEventId = nEventId;
885 [ # # ]: 0 : aPostedEventList.push_back( ImplPostEventPair( pWin, pPostEventData ) );
886 : : }
887 : : else
888 [ # # ]: 0 : delete pPostEventData;
889 : : }
890 : :
891 [ # # ]: 0 : return nEventId;
892 : : }
893 : :
894 : : // -----------------------------------------------------------------------------
895 : :
896 : 0 : IMPL_STATIC_LINK_NOINSTANCE( Application, PostEventHandler, void*, pCallData )
897 : : {
898 [ # # ]: 0 : const SolarMutexGuard aGuard;
899 : 0 : ImplPostEventData* pData = static_cast< ImplPostEventData * >( pCallData );
900 : : const void* pEventData;
901 : : sal_uLong nEvent;
902 : 0 : const sal_uLong nEventId = pData->mnEventId;
903 : :
904 [ # # # # : 0 : switch( pData->mnEvent )
# # ]
905 : : {
906 : : case VCLEVENT_WINDOW_MOUSEMOVE:
907 : 0 : nEvent = SALEVENT_EXTERNALMOUSEMOVE;
908 : 0 : pEventData = &pData->maMouseEvent;
909 : 0 : break;
910 : :
911 : : case VCLEVENT_WINDOW_MOUSEBUTTONDOWN:
912 : 0 : nEvent = SALEVENT_EXTERNALMOUSEBUTTONDOWN;
913 : 0 : pEventData = &pData->maMouseEvent;
914 : 0 : break;
915 : :
916 : : case VCLEVENT_WINDOW_MOUSEBUTTONUP:
917 : 0 : nEvent = SALEVENT_EXTERNALMOUSEBUTTONUP;
918 : 0 : pEventData = &pData->maMouseEvent;
919 : 0 : break;
920 : :
921 : : case VCLEVENT_WINDOW_KEYINPUT:
922 : 0 : nEvent = SALEVENT_EXTERNALKEYINPUT;
923 : 0 : pEventData = &pData->maKeyEvent;
924 : 0 : break;
925 : :
926 : : case VCLEVENT_WINDOW_KEYUP:
927 : 0 : nEvent = SALEVENT_EXTERNALKEYUP;
928 : 0 : pEventData = &pData->maKeyEvent;
929 : 0 : break;
930 : :
931 : : default:
932 : 0 : nEvent = 0;
933 : 0 : pEventData = NULL;
934 : 0 : break;
935 : : };
936 : :
937 [ # # ][ # # ]: 0 : if( pData->mpWin && pData->mpWin->mpWindowImpl->mpFrameWindow && pEventData )
[ # # ]
938 [ # # ]: 0 : ImplWindowFrameProc( pData->mpWin->mpWindowImpl->mpFrameWindow, NULL, (sal_uInt16) nEvent, pEventData );
939 : :
940 : : // remove this event from list of posted events, watch for destruction of internal data
941 : 0 : ::std::list< ImplPostEventPair >::iterator aIter( aPostedEventList.begin() );
942 : :
943 [ # # ]: 0 : while( aIter != aPostedEventList.end() )
944 : : {
945 [ # # ]: 0 : if( nEventId == (*aIter).second->mnEventId )
946 : : {
947 [ # # ]: 0 : delete (*aIter).second;
948 [ # # ]: 0 : aIter = aPostedEventList.erase( aIter );
949 : : }
950 : : else
951 : 0 : ++aIter;
952 : : }
953 : :
954 [ # # ]: 0 : return 0;
955 : : }
956 : :
957 : : // -----------------------------------------------------------------------
958 : :
959 : 120493 : void Application::RemoveMouseAndKeyEvents( Window* pWin )
960 : : {
961 [ + - ]: 120493 : const SolarMutexGuard aGuard;
962 : :
963 : : // remove all events for specific window, watch for destruction of internal data
964 : 120493 : ::std::list< ImplPostEventPair >::iterator aIter( aPostedEventList.begin() );
965 : :
966 [ - + ]: 120493 : while( aIter != aPostedEventList.end() )
967 : : {
968 [ # # ]: 0 : if( pWin == (*aIter).first )
969 : : {
970 [ # # ]: 0 : if( (*aIter).second->mnEventId )
971 [ # # ]: 0 : RemoveUserEvent( (*aIter).second->mnEventId );
972 : :
973 [ # # ]: 0 : delete (*aIter).second;
974 [ # # ]: 0 : aIter = aPostedEventList.erase( aIter );
975 : : }
976 : : else
977 : 0 : ++aIter;
978 [ + - ]: 120493 : }
979 : 120493 : }
980 : :
981 : : // -----------------------------------------------------------------------
982 : :
983 : 15777 : sal_uLong Application::PostUserEvent( const Link& rLink, void* pCaller )
984 : : {
985 : : sal_uLong nEventId;
986 [ + - ]: 15777 : PostUserEvent( nEventId, rLink, pCaller );
987 : 15777 : return nEventId;
988 : : }
989 : :
990 : : // -----------------------------------------------------------------------
991 : :
992 : 27230 : sal_Bool Application::PostUserEvent( sal_uLong& rEventId, const Link& rLink, void* pCaller )
993 : : {
994 [ + - ]: 27230 : ImplSVEvent* pSVEvent = new ImplSVEvent;
995 : 27230 : pSVEvent->mnEvent = 0;
996 : 27230 : pSVEvent->mpData = pCaller;
997 : 27230 : pSVEvent->mpLink = new Link( rLink );
998 : 27230 : pSVEvent->mpWindow = NULL;
999 : 27230 : pSVEvent->mbCall = sal_True;
1000 : 27230 : rEventId = (sal_uLong)pSVEvent;
1001 : 27230 : Window* pDefWindow = ImplGetDefaultWindow();
1002 [ + - ][ + - ]: 27230 : if ( pDefWindow && pDefWindow->ImplGetFrame()->PostEvent( pSVEvent ) )
[ + - ]
1003 : 27230 : return sal_True;
1004 : : else
1005 : : {
1006 : 0 : rEventId = 0;
1007 [ # # ]: 0 : delete pSVEvent;
1008 : 27230 : return sal_False;
1009 : : }
1010 : : }
1011 : :
1012 : : // -----------------------------------------------------------------------
1013 : :
1014 : 5924 : void Application::RemoveUserEvent( sal_uLong nUserEvent )
1015 : : {
1016 [ + - ]: 5924 : if(nUserEvent)
1017 : : {
1018 : 5924 : ImplSVEvent* pSVEvent = (ImplSVEvent*)nUserEvent;
1019 : :
1020 : : DBG_ASSERT( !pSVEvent->mpWindow,
1021 : : "Application::RemoveUserEvent(): Event is send to a window" );
1022 : : DBG_ASSERT( pSVEvent->mbCall,
1023 : : "Application::RemoveUserEvent(): Event is already removed" );
1024 : :
1025 [ + + ]: 5924 : if ( pSVEvent->mpWindow )
1026 : : {
1027 [ - + ]: 1 : if( ! pSVEvent->maDelData.IsDead() )
1028 : 0 : pSVEvent->mpWindow->ImplRemoveDel( &(pSVEvent->maDelData) );
1029 : 1 : pSVEvent->mpWindow = NULL;
1030 : : }
1031 : :
1032 : 5924 : pSVEvent->mbCall = sal_False;
1033 : : }
1034 : 5924 : }
1035 : :
1036 : : // -----------------------------------------------------------------------
1037 : :
1038 : 89690 : sal_Bool Application::InsertIdleHdl( const Link& rLink, sal_uInt16 nPrio )
1039 : : {
1040 : 89690 : ImplSVData* pSVData = ImplGetSVData();
1041 : :
1042 : : // create if not existing
1043 [ + + ]: 89690 : if ( !pSVData->maAppData.mpIdleMgr )
1044 [ + - ]: 60 : pSVData->maAppData.mpIdleMgr = new ImplIdleMgr;
1045 : :
1046 : 89690 : return pSVData->maAppData.mpIdleMgr->InsertIdleHdl( rLink, nPrio );
1047 : : }
1048 : :
1049 : : // -----------------------------------------------------------------------
1050 : :
1051 : 89034 : void Application::RemoveIdleHdl( const Link& rLink )
1052 : : {
1053 : 89034 : ImplSVData* pSVData = ImplGetSVData();
1054 : :
1055 [ + - ]: 89034 : if ( pSVData->maAppData.mpIdleMgr )
1056 : 89034 : pSVData->maAppData.mpIdleMgr->RemoveIdleHdl( rLink );
1057 : 89034 : }
1058 : :
1059 : : // -----------------------------------------------------------------------
1060 : :
1061 : 0 : void Application::EnableNoYieldMode( bool i_bNoYield )
1062 : : {
1063 : 0 : ImplSVData* pSVData = ImplGetSVData();
1064 : 0 : pSVData->maAppData.mbNoYield = i_bNoYield;
1065 : 0 : }
1066 : :
1067 : : // -----------------------------------------------------------------------
1068 : :
1069 : 0 : void Application::AddPostYieldListener( const Link& i_rListener )
1070 : : {
1071 : 0 : ImplSVData* pSVData = ImplGetSVData();
1072 [ # # ]: 0 : if( ! pSVData->maAppData.mpPostYieldListeners )
1073 [ # # ]: 0 : pSVData->maAppData.mpPostYieldListeners = new VclEventListeners2();
1074 : 0 : pSVData->maAppData.mpPostYieldListeners->addListener( i_rListener );
1075 : 0 : }
1076 : :
1077 : : // -----------------------------------------------------------------------
1078 : :
1079 : 0 : void Application::RemovePostYieldListener( const Link& i_rListener )
1080 : : {
1081 : 0 : ImplSVData* pSVData = ImplGetSVData();
1082 [ # # ]: 0 : if( pSVData->maAppData.mpPostYieldListeners )
1083 : 0 : pSVData->maAppData.mpPostYieldListeners->removeListener( i_rListener );
1084 : 0 : }
1085 : :
1086 : : // -----------------------------------------------------------------------
1087 : :
1088 : 0 : WorkWindow* Application::GetAppWindow()
1089 : : {
1090 : 0 : return ImplGetSVData()->maWinData.mpAppWin;
1091 : : }
1092 : :
1093 : : // -----------------------------------------------------------------------
1094 : :
1095 : 61687 : Window* Application::GetFocusWindow()
1096 : : {
1097 : 61687 : return ImplGetSVData()->maWinData.mpFocusWin;
1098 : : }
1099 : :
1100 : : // -----------------------------------------------------------------------
1101 : :
1102 : 55034 : OutputDevice* Application::GetDefaultDevice()
1103 : : {
1104 : 55034 : return ImplGetDefaultWindow();
1105 : : }
1106 : :
1107 : : // -----------------------------------------------------------------------
1108 : :
1109 : 0 : Window* Application::GetFirstTopLevelWindow()
1110 : : {
1111 : 0 : ImplSVData* pSVData = ImplGetSVData();
1112 : 0 : return pSVData->maWinData.mpFirstFrame;
1113 : : }
1114 : :
1115 : : // -----------------------------------------------------------------------
1116 : :
1117 : 0 : Window* Application::GetNextTopLevelWindow( Window* pWindow )
1118 : : {
1119 : 0 : return pWindow->mpWindowImpl->mpFrameData->mpNextFrame;
1120 : : }
1121 : :
1122 : : // -----------------------------------------------------------------------
1123 : :
1124 : 0 : long Application::GetTopWindowCount()
1125 : : {
1126 : 0 : long nRet = 0;
1127 : 0 : ImplSVData* pSVData = ImplGetSVData();
1128 [ # # ]: 0 : Window *pWin = pSVData ? pSVData->maWinData.mpFirstFrame : NULL;
1129 [ # # ]: 0 : while( pWin )
1130 : : {
1131 [ # # ]: 0 : if( pWin->ImplGetWindow()->IsTopWindow() )
1132 : 0 : nRet++;
1133 : 0 : pWin = pWin->mpWindowImpl->mpFrameData->mpNextFrame;
1134 : : }
1135 : 0 : return nRet;
1136 : : }
1137 : :
1138 : : // -----------------------------------------------------------------------
1139 : :
1140 : 0 : Window* Application::GetTopWindow( long nIndex )
1141 : : {
1142 : 0 : long nIdx = 0;
1143 : 0 : ImplSVData* pSVData = ImplGetSVData();
1144 [ # # ]: 0 : Window *pWin = pSVData ? pSVData->maWinData.mpFirstFrame : NULL;
1145 [ # # ]: 0 : while( pWin )
1146 : : {
1147 [ # # ]: 0 : if( pWin->ImplGetWindow()->IsTopWindow() )
1148 : : {
1149 [ # # ]: 0 : if( nIdx == nIndex )
1150 : 0 : return pWin->ImplGetWindow();
1151 : : else
1152 : 0 : nIdx++;
1153 : : }
1154 : 0 : pWin = pWin->mpWindowImpl->mpFrameData->mpNextFrame;
1155 : : }
1156 : 0 : return NULL;
1157 : : }
1158 : :
1159 : : // -----------------------------------------------------------------------
1160 : :
1161 : 0 : Window* Application::GetActiveTopWindow()
1162 : : {
1163 : 0 : Window *pWin = ImplGetSVData()->maWinData.mpFocusWin;
1164 [ # # ]: 0 : while( pWin )
1165 : : {
1166 [ # # ]: 0 : if( pWin->IsTopWindow() )
1167 : 0 : return pWin;
1168 : 0 : pWin = pWin->mpWindowImpl->mpParent;
1169 : : }
1170 : 0 : return NULL;
1171 : : }
1172 : :
1173 : : // -----------------------------------------------------------------------
1174 : :
1175 : 158 : void Application::SetAppName( const XubString& rUniqueName )
1176 : : {
1177 : 158 : ImplSVData* pSVData = ImplGetSVData();
1178 : :
1179 : : // create if not existing
1180 [ + - ]: 158 : if ( !pSVData->maAppData.mpAppName )
1181 [ + - ]: 158 : pSVData->maAppData.mpAppName = new XubString( rUniqueName );
1182 : : else
1183 : 0 : *(pSVData->maAppData.mpAppName) = rUniqueName;
1184 : 158 : }
1185 : :
1186 : : // -----------------------------------------------------------------------
1187 : :
1188 : 129 : XubString Application::GetAppName()
1189 : : {
1190 : 129 : ImplSVData* pSVData = ImplGetSVData();
1191 [ + + ]: 129 : if ( pSVData->maAppData.mpAppName )
1192 : 69 : return *(pSVData->maAppData.mpAppName);
1193 : : else
1194 : 129 : return ImplGetSVEmptyStr();
1195 : : }
1196 : :
1197 : : // -----------------------------------------------------------------------
1198 : :
1199 : 158 : void Application::SetDisplayName( const UniString& rName )
1200 : : {
1201 : 158 : ImplSVData* pSVData = ImplGetSVData();
1202 : :
1203 : : // create if not existing
1204 [ + - ]: 158 : if ( !pSVData->maAppData.mpDisplayName )
1205 [ + - ]: 158 : pSVData->maAppData.mpDisplayName = new UniString( rName );
1206 : : else
1207 : 0 : *(pSVData->maAppData.mpDisplayName) = rName;
1208 : 158 : }
1209 : :
1210 : : // -----------------------------------------------------------------------
1211 : :
1212 : 0 : UniString Application::GetDisplayName()
1213 : : {
1214 : 0 : ImplSVData* pSVData = ImplGetSVData();
1215 [ # # ]: 0 : if ( pSVData->maAppData.mpDisplayName )
1216 : 0 : return *(pSVData->maAppData.mpDisplayName);
1217 [ # # ]: 0 : else if ( pSVData->maWinData.mpAppWin )
1218 : 0 : return pSVData->maWinData.mpAppWin->GetText();
1219 : : else
1220 : 0 : return ImplGetSVEmptyStr();
1221 : : }
1222 : :
1223 : : // -----------------------------------------------------------------------
1224 : :
1225 : 3782 : unsigned int Application::GetScreenCount()
1226 : : {
1227 : 3782 : SalSystem* pSys = ImplGetSalSystem();
1228 [ + - ]: 3782 : return pSys ? pSys->GetDisplayScreenCount() : 0;
1229 : : }
1230 : :
1231 : 0 : rtl::OUString Application::GetDisplayScreenName( unsigned int nScreen )
1232 : : {
1233 : 0 : SalSystem* pSys = ImplGetSalSystem();
1234 [ # # ]: 0 : return pSys ? pSys->GetDisplayScreenName( nScreen ) : rtl::OUString();
1235 : : }
1236 : :
1237 : 3742 : bool Application::IsUnifiedDisplay()
1238 : : {
1239 : 3742 : SalSystem* pSys = ImplGetSalSystem();
1240 [ + - ]: 3742 : return pSys ? pSys->IsUnifiedDisplay() : true;
1241 : : }
1242 : :
1243 : 0 : unsigned int Application::GetDisplayBuiltInScreen()
1244 : : {
1245 : 0 : SalSystem* pSys = ImplGetSalSystem();
1246 [ # # ]: 0 : return pSys ? pSys->GetDisplayBuiltInScreen() : 0;
1247 : : }
1248 : :
1249 : 3758 : Rectangle Application::GetScreenPosSizePixel( unsigned int nScreen )
1250 : : {
1251 : 3758 : SalSystem* pSys = ImplGetSalSystem();
1252 [ + - ]: 3758 : return pSys ? pSys->GetDisplayScreenPosSizePixel( nScreen ) : Rectangle();
1253 : : }
1254 : :
1255 : 0 : Rectangle Application::GetWorkAreaPosSizePixel( unsigned int nScreen )
1256 : : {
1257 : 0 : SalSystem* pSys = ImplGetSalSystem();
1258 [ # # ]: 0 : return pSys ? pSys->GetDisplayScreenWorkAreaPosSizePixel( nScreen ) : Rectangle();
1259 : : }
1260 : :
1261 : : namespace {
1262 : 0 : unsigned long calcDistSquare( const Point& i_rPoint, const Rectangle& i_rRect )
1263 : : {
1264 : 0 : const Point aRectCenter( (i_rRect.Left() + i_rRect.Right())/2,
1265 : 0 : (i_rRect.Top() + i_rRect.Bottom())/ 2 );
1266 : 0 : const long nDX = aRectCenter.X() - i_rPoint.X();
1267 : 0 : const long nDY = aRectCenter.Y() - i_rPoint.Y();
1268 : 0 : return nDX*nDX + nDY*nDY;
1269 : : }
1270 : : }
1271 : :
1272 : 0 : unsigned int Application::GetBestScreen( const Rectangle& i_rRect )
1273 : : {
1274 [ # # ][ # # ]: 0 : if( !IsUnifiedDisplay() )
1275 [ # # ]: 0 : return GetDisplayBuiltInScreen();
1276 : :
1277 [ # # ]: 0 : const unsigned int nScreens = GetScreenCount();
1278 : 0 : unsigned int nBestMatchScreen = 0;
1279 : 0 : unsigned long nOverlap = 0;
1280 [ # # ]: 0 : for( unsigned int i = 0; i < nScreens; i++ )
1281 : : {
1282 [ # # ]: 0 : const Rectangle aCurScreenRect( GetScreenPosSizePixel( i ) );
1283 : : // if a screen contains the rectangle completely it is obviously the best screen
1284 [ # # ][ # # ]: 0 : if( aCurScreenRect.IsInside( i_rRect ) )
1285 : 0 : return i;
1286 : : // next the screen which contains most of the area of the rect is the best
1287 [ # # ]: 0 : Rectangle aIntersection( aCurScreenRect.GetIntersection( i_rRect ) );
1288 [ # # ][ # # ]: 0 : if( ! aIntersection.IsEmpty() )
1289 : : {
1290 [ # # ][ # # ]: 0 : const unsigned long nCurOverlap( aIntersection.GetWidth() * aIntersection.GetHeight() );
1291 [ # # ]: 0 : if( nCurOverlap > nOverlap )
1292 : : {
1293 : 0 : nOverlap = nCurOverlap;
1294 : 0 : nBestMatchScreen = i;
1295 : : }
1296 : : }
1297 : : }
1298 [ # # ]: 0 : if( nOverlap > 0 )
1299 : 0 : return nBestMatchScreen;
1300 : :
1301 : : // finally the screen which center is nearest to the rect is the best
1302 : 0 : const Point aCenter( (i_rRect.Left() + i_rRect.Right())/2,
1303 : 0 : (i_rRect.Top() + i_rRect.Bottom())/2 );
1304 : 0 : unsigned long nDist = ULONG_MAX;
1305 [ # # ]: 0 : for( unsigned int i = 0; i < nScreens; i++ )
1306 : : {
1307 [ # # ]: 0 : const Rectangle aCurScreenRect( GetScreenPosSizePixel( i ) );
1308 : 0 : const unsigned long nCurDist( calcDistSquare( aCenter, aCurScreenRect ) );
1309 [ # # ]: 0 : if( nCurDist < nDist )
1310 : : {
1311 : 0 : nBestMatchScreen = i;
1312 : 0 : nDist = nCurDist;
1313 : : }
1314 : : }
1315 : 0 : return nBestMatchScreen;
1316 : : }
1317 : :
1318 : : // -----------------------------------------------------------------------
1319 : :
1320 : 0 : sal_Bool Application::InsertAccel( Accelerator* pAccel )
1321 : : {
1322 : 0 : ImplSVData* pSVData = ImplGetSVData();
1323 : :
1324 [ # # ]: 0 : if ( !pSVData->maAppData.mpAccelMgr )
1325 : 0 : pSVData->maAppData.mpAccelMgr = new ImplAccelManager();
1326 : 0 : return pSVData->maAppData.mpAccelMgr->InsertAccel( pAccel );
1327 : : }
1328 : :
1329 : : // -----------------------------------------------------------------------
1330 : :
1331 : 0 : void Application::RemoveAccel( Accelerator* pAccel )
1332 : : {
1333 : 0 : ImplSVData* pSVData = ImplGetSVData();
1334 : :
1335 [ # # ]: 0 : if ( pSVData->maAppData.mpAccelMgr )
1336 : 0 : pSVData->maAppData.mpAccelMgr->RemoveAccel( pAccel );
1337 : 0 : }
1338 : :
1339 : : // -----------------------------------------------------------------------
1340 : :
1341 : 391 : void Application::SetHelp( Help* pHelp )
1342 : : {
1343 : 391 : ImplGetSVData()->maAppData.mpHelp = pHelp;
1344 : 391 : }
1345 : :
1346 : : // -----------------------------------------------------------------------
1347 : :
1348 : 3065 : Help* Application::GetHelp()
1349 : : {
1350 : 3065 : return ImplGetSVData()->maAppData.mpHelp;
1351 : : }
1352 : :
1353 : : // -----------------------------------------------------------------------
1354 : :
1355 : 233 : void Application::EnableAutoHelpId( sal_Bool bEnabled )
1356 : : {
1357 : 233 : ImplGetSVData()->maHelpData.mbAutoHelpId = bEnabled;
1358 : 233 : }
1359 : :
1360 : : // -----------------------------------------------------------------------
1361 : :
1362 : 5925 : sal_Bool Application::IsAutoHelpIdEnabled()
1363 : : {
1364 : 5925 : return ImplGetSVData()->maHelpData.mbAutoHelpId;
1365 : : }
1366 : :
1367 : : // -----------------------------------------------------------------------
1368 : :
1369 : 233 : void Application::EnableAutoMnemonic( sal_Bool bEnabled )
1370 : : {
1371 [ + - ][ + - ]: 233 : AllSettings aSettings = GetSettings();
1372 [ + - ]: 233 : StyleSettings aStyle = aSettings.GetStyleSettings();
1373 [ + - ]: 233 : aStyle.SetAutoMnemonic( bEnabled );
1374 [ + - ]: 233 : aSettings.SetStyleSettings( aStyle );
1375 [ + - ][ + - ]: 233 : SetSettings( aSettings );
[ + - ]
1376 : 233 : }
1377 : :
1378 : : // -----------------------------------------------------------------------
1379 : :
1380 : 0 : sal_Bool Application::IsAutoMnemonicEnabled()
1381 : : {
1382 : 0 : return GetSettings().GetStyleSettings().GetAutoMnemonic();
1383 : : }
1384 : :
1385 : : // -----------------------------------------------------------------------
1386 : :
1387 : 233 : void Application::SetDialogScaleX( short nScale )
1388 : : {
1389 : 233 : ImplSVData* pSVData = ImplGetSVData();
1390 : 233 : pSVData->maAppData.mnDialogScaleX = nScale;
1391 : 233 : pSVData->maGDIData.mnAppFontX = pSVData->maGDIData.mnRealAppFontX;
1392 [ + - ]: 233 : if ( nScale )
1393 : 233 : pSVData->maGDIData.mnAppFontX += (pSVData->maGDIData.mnAppFontX*nScale)/100;
1394 : 233 : }
1395 : :
1396 : : // -----------------------------------------------------------------------
1397 : :
1398 : 0 : void Application::SetDefDialogParent( Window* pWindow )
1399 : : {
1400 : 0 : ImplGetSVData()->maWinData.mpDefDialogParent = pWindow;
1401 : 0 : }
1402 : :
1403 : : // -----------------------------------------------------------------------
1404 : :
1405 : 121993 : Window* Application::GetDefDialogParent()
1406 : : {
1407 : 121993 : ImplSVData* pSVData = ImplGetSVData();
1408 : : // #103442# find some useful dialog parent if there
1409 : : // was no default set
1410 : : // NOTE: currently even the default is not used
1411 : : if( sal_False && pSVData->maWinData.mpDefDialogParent != NULL )
1412 : : return pSVData->maWinData.mpDefDialogParent;
1413 : : else
1414 : : {
1415 : : // always use the topmost parent of the candidate
1416 : : // window to avoid using dialogs or floaters
1417 : : // as DefDialogParent
1418 : :
1419 : : // current focus frame
1420 : 121993 : Window *pWin = NULL;
1421 [ + + ]: 121993 : if( (pWin = pSVData->maWinData.mpFocusWin) != NULL )
1422 : : {
1423 [ + - ][ + + ]: 87200 : while( pWin->mpWindowImpl && pWin->mpWindowImpl->mpParent )
[ + + ]
1424 : 64446 : pWin = pWin->mpWindowImpl->mpParent;
1425 : :
1426 [ + - ]: 22754 : if( (pWin->mpWindowImpl->mnStyle & WB_INTROWIN) == 0 )
1427 : : {
1428 : : // check for corrupted window hierarchy, #122232#, may be we now crash somewhere else
1429 [ - + ]: 22754 : if( !pWin->mpWindowImpl )
1430 : : {
1431 : : OSL_FAIL( "Window hierarchy corrupted!" );
1432 : 0 : pSVData->maWinData.mpFocusWin = NULL; // avoid further access
1433 : 0 : return NULL;
1434 : : }
1435 : :
1436 : : // MAV: before the implementation has used only decorated windows,
1437 : : // but it is not true in case of ActiveX or plugin scenario,
1438 : : // so this check is commented out
1439 : : // if( pWin->mpWindowImpl->mpFrameWindow->GetStyle() & (WB_MOVEABLE | WB_SIZEABLE) )
1440 : 22754 : return pWin->mpWindowImpl->mpFrameWindow->ImplGetWindow();
1441 : : // else
1442 : : // return NULL;
1443 : : }
1444 : : }
1445 : : // last active application frame
1446 [ + + ]: 99239 : if( NULL != (pWin = pSVData->maWinData.mpActiveApplicationFrame) )
1447 : : {
1448 : 12 : return pWin->mpWindowImpl->mpFrameWindow->ImplGetWindow();
1449 : : }
1450 : : else
1451 : : {
1452 : : // first visible top window (may be totally wrong....)
1453 : 99227 : pWin = pSVData->maWinData.mpFirstFrame;
1454 [ + + ]: 399615 : while( pWin )
1455 : : {
1456 [ + + ][ + + ]: 309395 : if( pWin->ImplGetWindow()->IsTopWindow() &&
[ + - ][ + + ]
1457 : : pWin->mpWindowImpl->mbReallyVisible &&
1458 : : (pWin->mpWindowImpl->mnStyle & WB_INTROWIN) == 0
1459 : : )
1460 : : {
1461 [ - + ]: 9007 : while( pWin->mpWindowImpl->mpParent )
1462 : 0 : pWin = pWin->mpWindowImpl->mpParent;
1463 : 9007 : return pWin->mpWindowImpl->mpFrameWindow->ImplGetWindow();
1464 : : }
1465 : 300388 : pWin = pWin->mpWindowImpl->mpFrameData->mpNextFrame;
1466 : : }
1467 : : // use the desktop
1468 : 121993 : return NULL;
1469 : : }
1470 : : }
1471 : : }
1472 : :
1473 : : // -----------------------------------------------------------------------
1474 : :
1475 : 1656 : Application::DialogCancelMode Application::GetDialogCancelMode()
1476 : : {
1477 : 1656 : return ImplGetSVData()->maAppData.meDialogCancel;
1478 : : }
1479 : :
1480 : 4389 : void Application::SetDialogCancelMode( DialogCancelMode mode )
1481 : : {
1482 : 4389 : ImplGetSVData()->maAppData.meDialogCancel = mode;
1483 : 4389 : }
1484 : :
1485 : : // -----------------------------------------------------------------------
1486 : :
1487 : 0 : sal_Bool Application::IsDialogCancelEnabled()
1488 : : {
1489 : 0 : return ImplGetSVData()->maAppData.meDialogCancel != DIALOG_CANCEL_OFF;
1490 : : }
1491 : :
1492 : : // -----------------------------------------------------------------------
1493 : :
1494 : 1246 : void Application::SetSystemWindowMode( sal_uInt16 nMode )
1495 : : {
1496 : 1246 : ImplGetSVData()->maAppData.mnSysWinMode = nMode;
1497 : 1246 : }
1498 : :
1499 : : // -----------------------------------------------------------------------
1500 : :
1501 : 577 : sal_uInt16 Application::GetSystemWindowMode()
1502 : : {
1503 : 577 : return ImplGetSVData()->maAppData.mnSysWinMode;
1504 : : }
1505 : :
1506 : : // -----------------------------------------------------------------------
1507 : :
1508 : 678 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > Application::GetVCLToolkit()
1509 : : {
1510 : 678 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > xT;
1511 [ + - ]: 678 : UnoWrapperBase* pWrapper = Application::GetUnoWrapper( sal_True );
1512 [ + - ]: 678 : if ( pWrapper )
1513 [ + - ][ + - ]: 678 : xT = pWrapper->GetVCLToolkit();
1514 : 678 : return xT;
1515 : : }
1516 : :
1517 : : // -----------------------------------------------------------------------
1518 : :
1519 : : #ifdef DISABLE_DYNLOADING
1520 : :
1521 : : extern "C" { UnoWrapperBase* CreateUnoWrapper(); }
1522 : :
1523 : : #else
1524 : :
1525 : 0 : extern "C" { static void SAL_CALL thisModule() {} }
1526 : :
1527 : : #endif
1528 : :
1529 : 183538 : UnoWrapperBase* Application::GetUnoWrapper( sal_Bool bCreateIfNotExist )
1530 : : {
1531 : 183538 : ImplSVData* pSVData = ImplGetSVData();
1532 : : static sal_Bool bAlreadyTriedToCreate = sal_False;
1533 [ + + ][ + - ]: 183538 : if ( !pSVData->mpUnoWrapper && bCreateIfNotExist && !bAlreadyTriedToCreate )
[ + + ]
1534 : : {
1535 : : #ifndef DISABLE_DYNLOADING
1536 : : ::rtl::OUString aLibName = ::vcl::unohelper::CreateLibraryName(
1537 : : #ifdef LIBO_MERGELIBS
1538 : : "merged",
1539 : : #else
1540 : : "tk",
1541 : : #endif
1542 [ + - ]: 124 : sal_True );
1543 : : oslModule hTkLib = osl_loadModuleRelative(
1544 [ + - ]: 124 : &thisModule, aLibName.pData, SAL_LOADMODULE_DEFAULT );
1545 [ + - ]: 124 : if ( hTkLib )
1546 : : {
1547 [ + - ]: 124 : ::rtl::OUString aFunctionName( RTL_CONSTASCII_USTRINGPARAM( "CreateUnoWrapper" ) );
1548 [ + - ]: 124 : FN_TkCreateUnoWrapper fnCreateWrapper = (FN_TkCreateUnoWrapper)osl_getFunctionSymbol( hTkLib, aFunctionName.pData );
1549 [ + - ]: 124 : if ( fnCreateWrapper )
1550 : : {
1551 [ + - ]: 124 : pSVData->mpUnoWrapper = fnCreateWrapper();
1552 : 124 : }
1553 : : }
1554 : : DBG_ASSERT( pSVData->mpUnoWrapper, "UnoWrapper could not be created!" );
1555 : : #else
1556 : : pSVData->mpUnoWrapper = CreateUnoWrapper();
1557 : : #endif
1558 : 124 : bAlreadyTriedToCreate = sal_True;
1559 : : }
1560 : 183538 : return pSVData->mpUnoWrapper;
1561 : : }
1562 : :
1563 : : // -----------------------------------------------------------------------
1564 : :
1565 : 0 : void Application::SetUnoWrapper( UnoWrapperBase* pWrapper )
1566 : : {
1567 : 0 : ImplSVData* pSVData = ImplGetSVData();
1568 : : DBG_ASSERT( !pSVData->mpUnoWrapper, "SetUnoWrapper: Wrapper allready exists" );
1569 : 0 : pSVData->mpUnoWrapper = pWrapper;
1570 : 0 : }
1571 : :
1572 : : // -----------------------------------------------------------------------
1573 : :
1574 : 6751 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayConnection > Application::GetDisplayConnection()
1575 : : {
1576 : 6751 : ImplSVData* pSVData = ImplGetSVData();
1577 : :
1578 [ + + ]: 6751 : if( !pSVData->mxDisplayConnection.is() )
1579 : : {
1580 [ + - ]: 113 : pSVData->mxDisplayConnection.set( new ::vcl::DisplayConnection );
1581 : 113 : pSVData->mxDisplayConnection->start();
1582 : : }
1583 : :
1584 [ + - ]: 6751 : return pSVData->mxDisplayConnection.get();
1585 : : }
1586 : :
1587 : : // -----------------------------------------------------------------------
1588 : :
1589 : 1015 : void Application::SetFilterHdl( const Link& rLink )
1590 : : {
1591 : 1015 : ImplGetSVData()->maGDIData.mpGrfConverter->SetFilterHdl( rLink );
1592 : 1015 : }
1593 : :
1594 : : // -----------------------------------------------------------------------
1595 : :
1596 : 0 : const Link& Application::GetFilterHdl()
1597 : : {
1598 : 0 : return ImplGetSVData()->maGDIData.mpGrfConverter->GetFilterHdl();
1599 : : }
1600 : :
1601 : : // -----------------------------------------------------------------------
1602 : :
1603 : 0 : sal_Bool ImplCallHotKey( const KeyCode& rKeyCode )
1604 : : {
1605 : 0 : ImplSVData* pSVData = ImplGetSVData();
1606 : 0 : ImplHotKey* pHotKeyData = pSVData->maAppData.mpFirstHotKey;
1607 [ # # ]: 0 : while ( pHotKeyData )
1608 : : {
1609 [ # # ]: 0 : if ( pHotKeyData->maKeyCode.IsDefinedKeyCodeEqual( rKeyCode ) )
1610 : : {
1611 : 0 : pHotKeyData->maLink.Call( pHotKeyData->mpUserData );
1612 : 0 : return sal_True;
1613 : : }
1614 : :
1615 : 0 : pHotKeyData = pHotKeyData->mpNext;
1616 : : }
1617 : :
1618 : 0 : return sal_False;
1619 : : }
1620 : :
1621 : : // -----------------------------------------------------------------------
1622 : :
1623 : 0 : void ImplFreeHotKeyData()
1624 : : {
1625 : 0 : ImplSVData* pSVData = ImplGetSVData();
1626 : : ImplHotKey* pTempHotKeyData;
1627 : 0 : ImplHotKey* pHotKeyData = pSVData->maAppData.mpFirstHotKey;
1628 [ # # ]: 0 : while ( pHotKeyData )
1629 : : {
1630 : 0 : pTempHotKeyData = pHotKeyData->mpNext;
1631 : 0 : delete pHotKeyData;
1632 : 0 : pHotKeyData = pTempHotKeyData;
1633 : : }
1634 : :
1635 : 0 : pSVData->maAppData.mpFirstHotKey = NULL;
1636 : 0 : }
1637 : :
1638 : : // -----------------------------------------------------------------------
1639 : :
1640 : 0 : void ImplFreeEventHookData()
1641 : : {
1642 : 0 : ImplSVData* pSVData = ImplGetSVData();
1643 : : ImplEventHook* pTempEventHookData;
1644 : 0 : ImplEventHook* pEventHookData = pSVData->maAppData.mpFirstEventHook;
1645 [ # # ]: 0 : while ( pEventHookData )
1646 : : {
1647 : 0 : pTempEventHookData = pEventHookData->mpNext;
1648 : 0 : delete pEventHookData;
1649 : 0 : pEventHookData = pTempEventHookData;
1650 : : }
1651 : :
1652 : 0 : pSVData->maAppData.mpFirstEventHook = NULL;
1653 : 0 : }
1654 : :
1655 : : // -----------------------------------------------------------------------
1656 : :
1657 : 15977 : long Application::CallEventHooks( NotifyEvent& rEvt )
1658 : : {
1659 : 15977 : ImplSVData* pSVData = ImplGetSVData();
1660 : 15977 : long nRet = 0;
1661 : : ImplEventHook* pTempEventHookData;
1662 : 15977 : ImplEventHook* pEventHookData = pSVData->maAppData.mpFirstEventHook;
1663 [ - + ]: 15977 : while ( pEventHookData )
1664 : : {
1665 : 0 : pTempEventHookData = pEventHookData->mpNext;
1666 : 0 : nRet = pEventHookData->mpProc( rEvt, pEventHookData->mpUserData );
1667 [ # # ]: 0 : if ( nRet )
1668 : 0 : break;
1669 : 0 : pEventHookData = pTempEventHookData;
1670 : : }
1671 : :
1672 : 15977 : return nRet;
1673 : : }
1674 : :
1675 : : // -----------------------------------------------------------------------
1676 : :
1677 : 0 : const LocaleDataWrapper& Application::GetAppLocaleDataWrapper()
1678 : : {
1679 : 0 : return GetSettings().GetLocaleDataWrapper();
1680 : : }
1681 : :
1682 : : // -----------------------------------------------------------------------
1683 : :
1684 : 1077 : void Application::EnableHeadlessMode( bool dialogsAreFatal )
1685 : : {
1686 : : SetDialogCancelMode(
1687 [ + + ]: 1077 : dialogsAreFatal ? DIALOG_CANCEL_FATAL : DIALOG_CANCEL_SILENT );
1688 : 1077 : }
1689 : :
1690 : : // -----------------------------------------------------------------------
1691 : :
1692 : 0 : sal_Bool Application::IsHeadlessModeEnabled()
1693 : : {
1694 : 0 : return IsDialogCancelEnabled();
1695 : : }
1696 : :
1697 : 1131 : bool Application::IsHeadlessModeRequested()
1698 : : {
1699 : 1131 : sal_uInt32 n = rtl_getAppCommandArgCount();
1700 [ + - ]: 3867 : for (sal_uInt32 i = 0; i < n; ++i) {
1701 : 2736 : rtl::OUString arg;
1702 [ + - ]: 2736 : rtl_getAppCommandArg(i, &arg.pData);
1703 [ + + ]: 2736 : if ( arg == "--headless" ) {
1704 : 2736 : return true;
1705 : : }
1706 [ + + ]: 2736 : }
1707 : 1131 : return false;
1708 : : }
1709 : :
1710 : : // -----------------------------------------------------------------------
1711 : :
1712 : 0 : void Application::ShowNativeErrorBox(const String& sTitle ,
1713 : : const String& sMessage)
1714 : : {
1715 : 0 : int btn = ImplGetSalSystem()->ShowNativeMessageBox (
1716 : : sTitle,
1717 : : sMessage,
1718 : : SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK,
1719 [ # # ][ # # ]: 0 : SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK);
1720 : : if (btn != SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK) {
1721 : : OSL_TRACE("ShowNativeMessageBox returned %d", btn);
1722 : : }
1723 : 0 : }
1724 : :
1725 : : // -----------------------------------------------------------------------
1726 : :
1727 : 241 : bool Application::CanToggleImeStatusWindow()
1728 : : {
1729 : 241 : ImplSVData* pSVData = ImplGetSVData();
1730 [ + + ]: 241 : if( ! pSVData->mpImeStatus )
1731 : 233 : pSVData->mpImeStatus = pSVData->mpDefInst->CreateI18NImeStatus();
1732 : 241 : return pSVData->mpImeStatus->canToggle();
1733 : : }
1734 : :
1735 : 0 : void Application::ShowImeStatusWindow(bool bShow)
1736 : : {
1737 : 0 : ImplGetSVData()->maAppData.meShowImeStatusWindow = bShow
1738 : : ? ImplSVAppData::ImeStatusWindowMode_SHOW
1739 [ # # ]: 0 : : ImplSVAppData::ImeStatusWindowMode_HIDE;
1740 : :
1741 : 0 : ImplSVData* pSVData = ImplGetSVData();
1742 [ # # ]: 0 : if( ! pSVData->mpImeStatus )
1743 : 0 : pSVData->mpImeStatus = pSVData->mpDefInst->CreateI18NImeStatus();
1744 : 0 : pSVData->mpImeStatus->toggle();
1745 : 0 : }
1746 : :
1747 : 0 : bool Application::GetShowImeStatusWindowDefault()
1748 : : {
1749 : : rtl_TextEncodingInfo aInfo;
1750 : 0 : aInfo.StructSize = sizeof aInfo;
1751 [ # # ][ # # ]: 0 : return rtl_getTextEncodingInfo(osl_getThreadTextEncoding(), &aInfo)
1752 [ # # ][ # # ]: 0 : && aInfo.MaximumCharSize > 1;
1753 : : }
1754 : :
1755 : 434 : const ::rtl::OUString& Application::GetDesktopEnvironment()
1756 : : {
1757 : 434 : return SalGetDesktopEnvironment();
1758 : : }
1759 : :
1760 : 1456 : void Application::AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType)
1761 : : {
1762 : 1456 : ImplSVData* pSVData = ImplGetSVData();
1763 : 1456 : pSVData->mpDefInst->AddToRecentDocumentList(rFileUrl, rMimeType);
1764 : 1456 : }
1765 : :
1766 : 0 : sal_Bool InitAccessBridge( sal_Bool bShowCancel, sal_Bool &rCancelled )
1767 : : {
1768 : 0 : sal_Bool bRet = true;
1769 : :
1770 : : // Disable Java bridge on UNIX
1771 : : #if defined UNX
1772 : : (void) bShowCancel; // unsued
1773 : : (void) rCancelled; // unused
1774 : : #else
1775 : : bRet = ImplInitAccessBridge( bShowCancel, rCancelled );
1776 : :
1777 : : if( !bRet && bShowCancel && !rCancelled )
1778 : : {
1779 : : // disable accessibility if the user chooses to continue
1780 : : AllSettings aSettings = Application::GetSettings();
1781 : : MiscSettings aMisc = aSettings.GetMiscSettings();
1782 : : aMisc.SetEnableATToolSupport( sal_False );
1783 : : aSettings.SetMiscSettings( aMisc );
1784 : : Application::SetSettings( aSettings );
1785 : : }
1786 : : #endif // !UNX
1787 : :
1788 : 0 : return bRet;
1789 : : }
1790 : :
1791 : : // MT: AppProperty, AppEvent was in oldsv.cxx, but is still needed...
1792 : : // ------------------------------------------------------------------------
1793 : :
1794 [ # # ]: 0 : TYPEINIT0(ApplicationProperty)
1795 : :
1796 : : // ------------------------------------------------------------------------
1797 : :
1798 : 0 : void Application::Property( ApplicationProperty& /*rProp*/ )
1799 : : {
1800 : 0 : }
1801 : :
1802 : 0 : void Application::AppEvent( const ApplicationEvent& /*rAppEvent*/ )
1803 : : {
1804 : 0 : }
1805 : :
1806 : 0 : bool Application::hasNativeFileSelection()
1807 : : {
1808 : 0 : ImplSVData* pSVData = ImplGetSVData();
1809 : 0 : return pSVData->mpDefInst->hasNativeFileSelection();
1810 : : }
1811 : :
1812 : : Reference< ui::dialogs::XFilePicker2 >
1813 : 0 : Application::createFilePicker( const Reference< uno::XComponentContext >& xSM )
1814 : : {
1815 : 0 : ImplSVData* pSVData = ImplGetSVData();
1816 : 0 : return pSVData->mpDefInst->createFilePicker( xSM );
1817 : : }
1818 : :
1819 : : Reference< ui::dialogs::XFolderPicker >
1820 : 0 : Application::createFolderPicker( const Reference< uno::XComponentContext >& xSM )
1821 : : {
1822 : 0 : ImplSVData* pSVData = ImplGetSVData();
1823 : 0 : return pSVData->mpDefInst->createFolderPicker( xSM );
1824 : : }
1825 : :
1826 [ + - ][ + - ]: 843 : Application::DialogCancelledException::~DialogCancelledException() throw () {}
[ # # ][ # # ]
[ # # ][ # # ]
1827 : :
1828 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|