LCOV - code coverage report
Current view: top level - vcl/source/app - svapp.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 373 750 49.7 %
Date: 2014-04-11 Functions: 76 131 58.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10