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