LCOV - code coverage report
Current view: top level - sfx2/source/appl - appinit.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 91 0.0 %
Date: 2014-04-14 Functions: 0 12 0.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             : 
      21             : #include <sfx2/app.hxx>
      22             : #include <com/sun/star/frame/XTerminateListener.hpp>
      23             : #include <com/sun/star/uno/Reference.hxx>
      24             : #include <com/sun/star/frame/theGlobalEventBroadcaster.hpp>
      25             : #include <com/sun/star/frame/Desktop.hpp>
      26             : #include <com/sun/star/lang/XServiceInfo.hpp>
      27             : 
      28             : #include <svtools/soerr.hxx>
      29             : #include <svtools/svtools.hrc>
      30             : #include <unotools/saveopt.hxx>
      31             : #include <unotools/localisationoptions.hxx>
      32             : #include <svl/intitem.hxx>
      33             : #include <svl/eitem.hxx>
      34             : #include <svl/stritem.hxx>
      35             : #include <vcl/msgbox.hxx>
      36             : #include <svtools/ehdl.hxx>
      37             : #include <comphelper/processfactory.hxx>
      38             : #include <unotools/configmgr.hxx>
      39             : #include <rtl/ustrbuf.hxx>
      40             : #include <osl/security.hxx>
      41             : #include <unotools/pathoptions.hxx>
      42             : #include <unotools/historyoptions.hxx>
      43             : #include <unotools/moduleoptions.hxx>
      44             : #include <cppuhelper/implbase2.hxx>
      45             : #include <cppuhelper/supportsservice.hxx>
      46             : 
      47             : #include <vcl/edit.hxx>
      48             : #include <vcl/timer.hxx>
      49             : 
      50             : #include <sfx2/unoctitm.hxx>
      51             : #include "app.hrc"
      52             : #include "sfxlocal.hrc"
      53             : #include "appdata.hxx"
      54             : #include "arrdecl.hxx"
      55             : #include <sfx2/dispatch.hxx>
      56             : #include <sfx2/docfac.hxx>
      57             : #include <sfx2/evntconf.hxx>
      58             : #include <sfx2/mnumgr.hxx>
      59             : #include <sfx2/msgpool.hxx>
      60             : #include <sfx2/progress.hxx>
      61             : #include <sfx2/sfxhelp.hxx>
      62             : #include <sfx2/sfxresid.hxx>
      63             : #include "sfxtypes.hxx"
      64             : #include <sfx2/viewsh.hxx>
      65             : #include "nochaos.hxx"
      66             : #include <sfx2/fcontnr.hxx>
      67             : #include "helper.hxx"
      68             : #include "sfxpicklist.hxx"
      69             : 
      70             : using namespace ::com::sun::star::uno;
      71             : using namespace ::com::sun::star::frame;
      72             : using namespace ::com::sun::star::lang;
      73             : using namespace ::com::sun::star;
      74             : 
      75           0 : class SfxTerminateListener_Impl : public ::cppu::WeakImplHelper2< XTerminateListener, XServiceInfo >
      76             : {
      77             : public:
      78             : 
      79             :     // XTerminateListener
      80             :     virtual void SAL_CALL queryTermination( const EventObject& aEvent ) throw( TerminationVetoException, RuntimeException, std::exception ) SAL_OVERRIDE;
      81             :     virtual void SAL_CALL notifyTermination( const EventObject& aEvent ) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
      82             :     virtual void SAL_CALL disposing( const EventObject& Source ) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
      83             : 
      84             :     // XServiceInfo
      85             :     virtual OUString SAL_CALL getImplementationName() throw (RuntimeException, std::exception) SAL_OVERRIDE;
      86             :     virtual sal_Bool SAL_CALL supportsService( const OUString& sServiceName ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
      87             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException, std::exception) SAL_OVERRIDE;
      88             : };
      89             : 
      90           0 : void SAL_CALL SfxTerminateListener_Impl::disposing( const EventObject& ) throw( RuntimeException, std::exception )
      91             : {
      92           0 : }
      93             : 
      94           0 : void SAL_CALL SfxTerminateListener_Impl::queryTermination( const EventObject& ) throw(TerminationVetoException, RuntimeException, std::exception )
      95             : {
      96           0 :     SolarMutexGuard aGuard;
      97           0 :     if ( !SFX_APP()->QueryExit_Impl() )
      98           0 :         throw TerminationVetoException();
      99           0 : }
     100             : 
     101           0 : void SAL_CALL SfxTerminateListener_Impl::notifyTermination( const EventObject& aEvent ) throw(RuntimeException, std::exception )
     102             : {
     103           0 :     Reference< XDesktop > xDesktop( aEvent.Source, UNO_QUERY );
     104           0 :     if( xDesktop.is() )
     105           0 :         xDesktop->removeTerminateListener( this );
     106             : 
     107           0 :     SolarMutexGuard aGuard;
     108           0 :     utl::ConfigManager::storeConfigItems();
     109             : 
     110             :     // Timers may access the SfxApplication and are only deleted in
     111             :     // Application::Quit(), which is asynchronous (PostUserEvent) - disable!
     112           0 :     Timer::ImplDeInitTimer();
     113             : 
     114           0 :     SfxApplication* pApp = SFX_APP();
     115           0 :     pApp->Broadcast( SfxSimpleHint( SFX_HINT_DEINITIALIZING ) );
     116           0 :     pApp->Get_Impl()->pAppDispatch->ReleaseAll();
     117           0 :     pApp->Get_Impl()->pAppDispatch->release();
     118             : 
     119           0 :     css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
     120           0 :     css::uno::Reference< css::document::XEventListener > xGlobalBroadcaster(css::frame::theGlobalEventBroadcaster::get(xContext), css::uno::UNO_QUERY_THROW);
     121             : 
     122           0 :     css::document::EventObject aEvent2;
     123           0 :     aEvent2.EventName = "OnCloseApp";
     124           0 :     xGlobalBroadcaster->notifyEvent(aEvent2);
     125             : 
     126           0 :     delete pApp;
     127           0 :     Application::Quit();
     128           0 : }
     129             : 
     130           0 : OUString SAL_CALL SfxTerminateListener_Impl::getImplementationName() throw (RuntimeException, std::exception)
     131             : {
     132           0 :     return OUString("com.sun.star.comp.sfx2.SfxTerminateListener");
     133             : }
     134             : 
     135           0 : sal_Bool SAL_CALL SfxTerminateListener_Impl::supportsService( const OUString& sServiceName ) throw (RuntimeException, std::exception)
     136             : {
     137           0 :     return cppu::supportsService(this, sServiceName);
     138             : }
     139             : 
     140           0 : Sequence< OUString > SAL_CALL SfxTerminateListener_Impl::getSupportedServiceNames() throw (RuntimeException, std::exception)
     141             : {
     142             :     // Note: That service  does not really exists .-)
     143             :     // But this implementation is not thought to be registered really within our service.rdb.
     144             :     // At least we need the implementation name only to identify these service at the global desktop instance.
     145             :     // The desktop must know, which listener will terminate the SfxApplication in real !
     146             :     // It must call this special listener as last one ... otherwise we shutdown the SfxApplication BEFORE other listener
     147             :     // can react ...
     148           0 :     static const OUString SERVICENAME("com.sun.star.frame.TerminateListener");
     149           0 :     Sequence< OUString > lNames(1);
     150           0 :     lNames[0] = SERVICENAME;
     151           0 :     return lNames;
     152             : }
     153             : 
     154             : 
     155             : 
     156             : typedef bool ( *PFunc_getSpecialCharsForEdit)( Window* i_pParent, const Font& i_rFont, OUString& o_rOutString );
     157             : 
     158             : 
     159             : // Lazy binding of the GetSpecialCharsForEdit function as it resides in
     160             : // a library above us.
     161             : 
     162             : 
     163             : #ifndef DISABLE_DYNLOADING
     164             : 
     165           0 : extern "C" { static void SAL_CALL thisModule() {} }
     166             : 
     167             : #else
     168             : 
     169             : extern "C" bool GetSpecialCharsForEdit( Window* i_pParent, const Font& i_rFont, OUString& o_rOutString );
     170             : 
     171             : #endif
     172             : 
     173           0 : OUString GetSpecialCharsForEdit(Window* pParent, const Font& rFont)
     174             : {
     175             :     static bool bDetermineFunction = false;
     176             :     static PFunc_getSpecialCharsForEdit pfunc_getSpecialCharsForEdit = 0;
     177             : 
     178           0 :     SolarMutexGuard aGuard;
     179           0 :     if ( !bDetermineFunction )
     180             :     {
     181           0 :         bDetermineFunction = true;
     182             : 
     183             : #ifndef DISABLE_DYNLOADING
     184           0 :         static OUString aLibName( SVLIBRARY( "cui" ) );
     185             :         oslModule handleMod = osl_loadModuleRelative(
     186           0 :             &thisModule, aLibName.pData, 0 );
     187             : 
     188             :         // get symbol
     189           0 :         OUString aSymbol( "GetSpecialCharsForEdit"  );
     190           0 :         pfunc_getSpecialCharsForEdit = (PFunc_getSpecialCharsForEdit)osl_getFunctionSymbol( handleMod, aSymbol.pData );
     191           0 :         DBG_ASSERT( pfunc_getSpecialCharsForEdit, "GetSpecialCharsForEdit() not found!" );
     192             : #else
     193             :         pfunc_getSpecialCharsForEdit = GetSpecialCharsForEdit;
     194             : #endif
     195             :     }
     196             : 
     197           0 :     OUString aRet;
     198           0 :     if ( pfunc_getSpecialCharsForEdit )
     199           0 :         (*pfunc_getSpecialCharsForEdit)( pParent, rFont, aRet );
     200           0 :     return aRet;
     201             : }
     202             : 
     203             : 
     204             : 
     205           0 : bool SfxApplication::Initialize_Impl()
     206             : {
     207             :     SAL_INFO( "sfx.appl", "SfxApplication::Initialize_Impl" );
     208             : 
     209             : #ifdef TLX_VALIDATE
     210             :     StgIo::SetErrorLink( LINK( this, SfxStorageErrHdl, Error ) );
     211             : #endif
     212             : 
     213           0 :     Reference < XDesktop2 > xDesktop = Desktop::create ( ::comphelper::getProcessComponentContext() );
     214           0 :     xDesktop->addTerminateListener( new SfxTerminateListener_Impl() );
     215             : 
     216           0 :     Application::EnableAutoHelpId();
     217             : 
     218           0 :     pAppData_Impl->pAppDispatch = new SfxStatusDispatcher;
     219           0 :     pAppData_Impl->pAppDispatch->acquire();
     220             : 
     221             :     // SV-Look
     222           0 :     Help::EnableContextHelp();
     223           0 :     Help::EnableExtHelp();
     224             : 
     225           0 :     SvtLocalisationOptions aLocalisation;
     226           0 :     Application::EnableAutoMnemonic ( aLocalisation.IsAutoMnemonic() );
     227           0 :     Application::SetDialogScaleX    ( (short)(aLocalisation.GetDialogScale()) );
     228             : 
     229             :     pAppData_Impl->m_pToolsErrorHdl = new SfxErrorHandler(
     230           0 :         RID_ERRHDL, ERRCODE_AREA_TOOLS, ERRCODE_AREA_LIB1);
     231             : 
     232             : #ifndef DISABLE_SCRIPTING
     233           0 :     pAppData_Impl->pBasicResMgr = CreateResManager("sb");
     234             : #endif
     235           0 :     pAppData_Impl->pSvtResMgr = CreateResManager("svt");
     236             : 
     237             :     pAppData_Impl->m_pSoErrorHdl = new SfxErrorHandler(
     238           0 :         RID_SO_ERROR_HANDLER, ERRCODE_AREA_SO, ERRCODE_AREA_SO_END, pAppData_Impl->pSvtResMgr );
     239             : #ifndef DISABLE_SCRIPTING
     240             :     pAppData_Impl->m_pSbxErrorHdl = new SfxErrorHandler(
     241           0 :         RID_BASIC_START, ERRCODE_AREA_SBX, ERRCODE_AREA_SBX_END, pAppData_Impl->pBasicResMgr );
     242             : #endif
     243             :     //ensure instantiation of listener that manages the internal recently-used
     244             :     //list
     245           0 :     SfxPickList::ensure();
     246             : 
     247             :     DBG_ASSERT( !pAppData_Impl->pAppDispat, "AppDispatcher already exists" );
     248           0 :     pAppData_Impl->pAppDispat = new SfxDispatcher((SfxDispatcher*)0);
     249           0 :     pAppData_Impl->pSlotPool = new SfxSlotPool;
     250           0 :     pAppData_Impl->pTbxCtrlFac = new SfxTbxCtrlFactArr_Impl;
     251           0 :     pAppData_Impl->pStbCtrlFac = new SfxStbCtrlFactArr_Impl;
     252           0 :     pAppData_Impl->pMenuCtrlFac = new SfxMenuCtrlFactArr_Impl;
     253           0 :     pAppData_Impl->pViewFrames = new SfxViewFrameArr_Impl;
     254           0 :     pAppData_Impl->pViewShells = new SfxViewShellArr_Impl;
     255           0 :     pAppData_Impl->pObjShells = new SfxObjectShellArr_Impl;
     256           0 :     pAppData_Impl->nInterfaces = SFX_INTERFACE_APP+8;
     257           0 :     pAppData_Impl->pInterfaces = new SfxInterface*[pAppData_Impl->nInterfaces];
     258           0 :     memset( pAppData_Impl->pInterfaces, 0, sizeof(SfxInterface*) * pAppData_Impl->nInterfaces );
     259             : 
     260           0 :     Registrations_Impl();
     261             : 
     262             :     // Subklasse initialisieren
     263           0 :     pAppData_Impl->bDowning = false;
     264           0 :     Init();
     265             : 
     266             :     // get CHAOS item pool...
     267           0 :     pAppData_Impl->pPool = NoChaos::GetItemPool();
     268           0 :     SetPool( pAppData_Impl->pPool );
     269             : 
     270           0 :     if ( pAppData_Impl->bDowning )
     271           0 :         return false;
     272             : 
     273             :     // App-Dispatcher aufbauen
     274           0 :     pAppData_Impl->pAppDispat->Push(*this);
     275           0 :     pAppData_Impl->pAppDispat->Flush();
     276           0 :     pAppData_Impl->pAppDispat->DoActivate_Impl( true, NULL );
     277             : 
     278             :     {
     279           0 :         SolarMutexGuard aGuard;
     280             :         // Set special characters callback on vcl edit control
     281           0 :         Edit::SetGetSpecialCharsFunction(&GetSpecialCharsForEdit);
     282             :     }
     283             : 
     284           0 :     return true;
     285             : }
     286             : 
     287             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10