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