1*9f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9f62ea84SAndrew Rist * distributed with this work for additional information 6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 10*9f62ea84SAndrew Rist * 11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*9f62ea84SAndrew Rist * 13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an 15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 17*9f62ea84SAndrew Rist * specific language governing permissions and limitations 18*9f62ea84SAndrew Rist * under the License. 19*9f62ea84SAndrew Rist * 20*9f62ea84SAndrew Rist *************************************************************/ 21*9f62ea84SAndrew Rist 22*9f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "rtl/logfile.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "osl/file.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include "vos/signal.hxx" 32cdf0e10cSrcweir #include "vos/process.hxx" 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include "tools/tools.h" 35cdf0e10cSrcweir #include "tools/debug.hxx" 36cdf0e10cSrcweir #include "tools/unqid.hxx" 37cdf0e10cSrcweir #include "tools/resmgr.hxx" 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include "comphelper/processfactory.hxx" 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include "unotools/syslocaleoptions.hxx" 42cdf0e10cSrcweir #include "unotools/fontcfg.hxx" 43cdf0e10cSrcweir 44cdf0e10cSrcweir #include "vcl/svapp.hxx" 45cdf0e10cSrcweir #include "vcl/wrkwin.hxx" 46cdf0e10cSrcweir #include "vcl/cvtgrf.hxx" 47cdf0e10cSrcweir #include "vcl/image.hxx" 48cdf0e10cSrcweir #include "vcl/settings.hxx" 49cdf0e10cSrcweir #include "vcl/unowrap.hxx" 50cdf0e10cSrcweir #include "vcl/configsettings.hxx" 51cdf0e10cSrcweir #include "vcl/lazydelete.hxx" 52cdf0e10cSrcweir 53cdf0e10cSrcweir #ifdef WNT 54cdf0e10cSrcweir #include <tools/prewin.h> 55cdf0e10cSrcweir #include <process.h> // for _beginthreadex 56cdf0e10cSrcweir #include <ole2.h> // for _beginthreadex 57cdf0e10cSrcweir #include <tools/postwin.h> 58cdf0e10cSrcweir #endif 59cdf0e10cSrcweir 60cdf0e10cSrcweir // [ed 5/14/02 Add in explicit check for quartz graphics. OS X will define 61cdf0e10cSrcweir // unx for both quartz and X11 graphics, but we include svunx.h only if we're 62cdf0e10cSrcweir // building X11 graphics layers. 63cdf0e10cSrcweir 64cdf0e10cSrcweir #if defined UNX && ! defined QUARTZ 65cdf0e10cSrcweir //#include "svunx.h" 66cdf0e10cSrcweir #endif 67cdf0e10cSrcweir 68cdf0e10cSrcweir //#include "svsys.h" 69cdf0e10cSrcweir 70cdf0e10cSrcweir #include "salinst.hxx" 71cdf0e10cSrcweir #include "salwtype.hxx" 72cdf0e10cSrcweir #include "svdata.hxx" 73cdf0e10cSrcweir #include "dbggui.hxx" 74cdf0e10cSrcweir #include "accmgr.hxx" 75cdf0e10cSrcweir #include "idlemgr.hxx" 76cdf0e10cSrcweir #include "outdev.h" 77cdf0e10cSrcweir #include "outfont.hxx" 78cdf0e10cSrcweir #include "print.h" 79cdf0e10cSrcweir #include "salsys.hxx" 80cdf0e10cSrcweir #include "saltimer.hxx" 81cdf0e10cSrcweir #include "salimestatus.hxx" 82cdf0e10cSrcweir #include "impimagetree.hxx" 83cdf0e10cSrcweir #include "xconnection.hxx" 84cdf0e10cSrcweir 85cdf0e10cSrcweir #include "com/sun/star/lang/XMultiServiceFactory.hpp" 86cdf0e10cSrcweir #include "com/sun/star/lang/XComponent.hpp" 87cdf0e10cSrcweir 88cdf0e10cSrcweir #include "cppuhelper/implbase1.hxx" 89cdf0e10cSrcweir #include "uno/current_context.hxx" 90cdf0e10cSrcweir 91cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 92cdf0e10cSrcweir #include <typeinfo> 93cdf0e10cSrcweir #include "rtl/strbuf.hxx" 94cdf0e10cSrcweir #endif 95cdf0e10cSrcweir 96cdf0e10cSrcweir namespace { 97cdf0e10cSrcweir 98cdf0e10cSrcweir namespace css = com::sun::star; 99cdf0e10cSrcweir 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir using namespace ::rtl; 103cdf0e10cSrcweir using namespace ::com::sun::star::uno; 104cdf0e10cSrcweir using namespace ::com::sun::star::lang; 105cdf0e10cSrcweir 106cdf0e10cSrcweir 107cdf0e10cSrcweir 108cdf0e10cSrcweir // ======================================================================= 109cdf0e10cSrcweir 110cdf0e10cSrcweir class ImplVCLExceptionHandler : public ::vos::OSignalHandler 111cdf0e10cSrcweir { 112cdf0e10cSrcweir public: 113cdf0e10cSrcweir virtual ::vos::OSignalHandler::TSignalAction SAL_CALL signal( ::vos::OSignalHandler::TSignalInfo* pInfo ); 114cdf0e10cSrcweir }; 115cdf0e10cSrcweir 116cdf0e10cSrcweir // ----------------------------------------------------------------------- 117cdf0e10cSrcweir 118cdf0e10cSrcweir ::vos::OSignalHandler::TSignalAction SAL_CALL ImplVCLExceptionHandler::signal( ::vos::OSignalHandler::TSignalInfo* pInfo ) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir static sal_Bool bIn = sal_False; 121cdf0e10cSrcweir 122cdf0e10cSrcweir // Wenn wir nocheinmal abstuerzen, verabschieden wir uns gleich 123cdf0e10cSrcweir if ( !bIn ) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir sal_uInt16 nVCLException = 0; 126cdf0e10cSrcweir 127cdf0e10cSrcweir // UAE 128cdf0e10cSrcweir if ( (pInfo->Signal == osl_Signal_AccessViolation) || 129cdf0e10cSrcweir (pInfo->Signal == osl_Signal_IntegerDivideByZero) || 130cdf0e10cSrcweir (pInfo->Signal == osl_Signal_FloatDivideByZero) || 131cdf0e10cSrcweir (pInfo->Signal == osl_Signal_DebugBreak) ) 132cdf0e10cSrcweir nVCLException = EXC_SYSTEM; 133cdf0e10cSrcweir 134cdf0e10cSrcweir // RC 135cdf0e10cSrcweir if ((pInfo->Signal == osl_Signal_User) && 136cdf0e10cSrcweir (pInfo->UserSignal == OSL_SIGNAL_USER_RESOURCEFAILURE) ) 137cdf0e10cSrcweir nVCLException = EXC_RSCNOTLOADED; 138cdf0e10cSrcweir 139cdf0e10cSrcweir // DISPLAY-Unix 140cdf0e10cSrcweir if ((pInfo->Signal == osl_Signal_User) && 141cdf0e10cSrcweir (pInfo->UserSignal == OSL_SIGNAL_USER_X11SUBSYSTEMERROR) ) 142cdf0e10cSrcweir nVCLException = EXC_DISPLAY; 143cdf0e10cSrcweir 144cdf0e10cSrcweir // Remote-Client 145cdf0e10cSrcweir if ((pInfo->Signal == osl_Signal_User) && 146cdf0e10cSrcweir (pInfo->UserSignal == OSL_SIGNAL_USER_RVPCONNECTIONERROR) ) 147cdf0e10cSrcweir nVCLException = EXC_REMOTE; 148cdf0e10cSrcweir 149cdf0e10cSrcweir if ( nVCLException ) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir bIn = sal_True; 152cdf0e10cSrcweir 153cdf0e10cSrcweir ::vos::OGuard aLock(&Application::GetSolarMutex()); 154cdf0e10cSrcweir 155cdf0e10cSrcweir // Timer nicht mehr anhalten, da ansonsten die UAE-Box 156cdf0e10cSrcweir // auch nicht mehr gepaintet wird 157cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 158cdf0e10cSrcweir if ( pSVData->mpApp ) 159cdf0e10cSrcweir { 160cdf0e10cSrcweir sal_uInt16 nOldMode = Application::GetSystemWindowMode(); 161cdf0e10cSrcweir Application::SetSystemWindowMode( nOldMode & ~SYSTEMWINDOW_MODE_NOAUTOMODE ); 162cdf0e10cSrcweir pSVData->mpApp->Exception( nVCLException ); 163cdf0e10cSrcweir Application::SetSystemWindowMode( nOldMode ); 164cdf0e10cSrcweir } 165cdf0e10cSrcweir bIn = sal_False; 166cdf0e10cSrcweir 167cdf0e10cSrcweir return vos::OSignalHandler::TAction_CallNextHandler; 168cdf0e10cSrcweir } 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir return vos::OSignalHandler::TAction_CallNextHandler; 172cdf0e10cSrcweir } 173cdf0e10cSrcweir 174cdf0e10cSrcweir // ======================================================================= 175cdf0e10cSrcweir sal_Bool ImplSVMain() 176cdf0e10cSrcweir { 177cdf0e10cSrcweir // The 'real' SVMain() 178cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "vcl (ss112471) ::SVMain" ); 179cdf0e10cSrcweir 180cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 181cdf0e10cSrcweir 182cdf0e10cSrcweir DBG_ASSERT( pSVData->mpApp, "no instance of class Application" ); 183cdf0e10cSrcweir 184cdf0e10cSrcweir css::uno::Reference<XMultiServiceFactory> xMS; 185cdf0e10cSrcweir 186cdf0e10cSrcweir 187cdf0e10cSrcweir sal_Bool bInit = InitVCL( xMS ); 188cdf0e10cSrcweir 189cdf0e10cSrcweir if( bInit ) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir // Application-Main rufen 192cdf0e10cSrcweir pSVData->maAppData.mbInAppMain = sal_True; 193cdf0e10cSrcweir pSVData->mpApp->Main(); 194cdf0e10cSrcweir pSVData->maAppData.mbInAppMain = sal_False; 195cdf0e10cSrcweir } 196cdf0e10cSrcweir 197cdf0e10cSrcweir if( pSVData->mxDisplayConnection.is() ) 198cdf0e10cSrcweir { 199cdf0e10cSrcweir pSVData->mxDisplayConnection->terminate(); 200cdf0e10cSrcweir pSVData->mxDisplayConnection.clear(); 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir // This is a hack to work around the problem of the asynchronous nature 204cdf0e10cSrcweir // of bridging accessibility through Java: on shutdown there might still 205cdf0e10cSrcweir // be some events in the AWT EventQueue, which need the SolarMutex which 206cdf0e10cSrcweir // - on the other hand - is destroyed in DeInitVCL(). So empty the queue 207cdf0e10cSrcweir // here .. 208cdf0e10cSrcweir css::uno::Reference< XComponent > xComponent(pSVData->mxAccessBridge, UNO_QUERY); 209cdf0e10cSrcweir if( xComponent.is() ) 210cdf0e10cSrcweir { 211cdf0e10cSrcweir sal_uLong nCount = Application::ReleaseSolarMutex(); 212cdf0e10cSrcweir xComponent->dispose(); 213cdf0e10cSrcweir Application::AcquireSolarMutex(nCount); 214cdf0e10cSrcweir pSVData->mxAccessBridge.clear(); 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir DeInitVCL(); 218cdf0e10cSrcweir return bInit; 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir sal_Bool SVMain() 222cdf0e10cSrcweir { 223cdf0e10cSrcweir // #i47888# allow for alternative initialization as required for e.g. MacOSX 224cdf0e10cSrcweir extern sal_Bool ImplSVMainHook( sal_Bool* ); 225cdf0e10cSrcweir 226cdf0e10cSrcweir sal_Bool bInit; 227cdf0e10cSrcweir if( ImplSVMainHook( &bInit ) ) 228cdf0e10cSrcweir return bInit; 229cdf0e10cSrcweir else 230cdf0e10cSrcweir return ImplSVMain(); 231cdf0e10cSrcweir } 232cdf0e10cSrcweir // This variable is set, when no Application object is instantiated 233cdf0e10cSrcweir // before SVInit is called 234cdf0e10cSrcweir static Application * pOwnSvApp = NULL; 235cdf0e10cSrcweir // Exception handler. pExceptionHandler != NULL => VCL already inited 236cdf0e10cSrcweir ImplVCLExceptionHandler * pExceptionHandler = NULL; 237cdf0e10cSrcweir 238cdf0e10cSrcweir class Application_Impl : public Application 239cdf0e10cSrcweir { 240cdf0e10cSrcweir public: 241cdf0e10cSrcweir void Main(){}; 242cdf0e10cSrcweir }; 243cdf0e10cSrcweir 244cdf0e10cSrcweir class DesktopEnvironmentContext: public cppu::WeakImplHelper1< com::sun::star::uno::XCurrentContext > 245cdf0e10cSrcweir { 246cdf0e10cSrcweir public: 247cdf0e10cSrcweir DesktopEnvironmentContext( const com::sun::star::uno::Reference< com::sun::star::uno::XCurrentContext > & ctx) 248cdf0e10cSrcweir : m_xNextContext( ctx ) {} 249cdf0e10cSrcweir 250cdf0e10cSrcweir // XCurrentContext 251cdf0e10cSrcweir virtual com::sun::star::uno::Any SAL_CALL getValueByName( const rtl::OUString& Name ) 252cdf0e10cSrcweir throw (com::sun::star::uno::RuntimeException); 253cdf0e10cSrcweir 254cdf0e10cSrcweir private: 255cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::uno::XCurrentContext > m_xNextContext; 256cdf0e10cSrcweir }; 257cdf0e10cSrcweir 258cdf0e10cSrcweir Any SAL_CALL DesktopEnvironmentContext::getValueByName( const rtl::OUString& Name) throw (RuntimeException) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir Any retVal; 261cdf0e10cSrcweir 262cdf0e10cSrcweir if ( 0 == Name.compareToAscii( "system.desktop-environment" ) ) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir retVal = makeAny( Application::GetDesktopEnvironment() ); 265cdf0e10cSrcweir } 266cdf0e10cSrcweir else if( m_xNextContext.is() ) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir // Call next context in chain if found 269cdf0e10cSrcweir retVal = m_xNextContext->getValueByName( Name ); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir return retVal; 272cdf0e10cSrcweir } 273cdf0e10cSrcweir 274cdf0e10cSrcweir sal_Bool InitVCL( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr ) 275cdf0e10cSrcweir { 276cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "vcl (ss112471) ::InitVCL" ); 277cdf0e10cSrcweir 278cdf0e10cSrcweir if( pExceptionHandler != NULL ) 279cdf0e10cSrcweir return sal_False; 280cdf0e10cSrcweir 281cdf0e10cSrcweir if( ! ImplGetSVData() ) 282cdf0e10cSrcweir ImplInitSVData(); 283cdf0e10cSrcweir 284cdf0e10cSrcweir if( !ImplGetSVData()->mpApp ) 285cdf0e10cSrcweir { 286cdf0e10cSrcweir pOwnSvApp = new Application_Impl(); 287cdf0e10cSrcweir } 288cdf0e10cSrcweir InitSalMain(); 289cdf0e10cSrcweir 290cdf0e10cSrcweir /*AllSettings aAS; 291cdf0e10cSrcweir Application::SetSettings( aAS );// ??? 292cdf0e10cSrcweir */ 293cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 294cdf0e10cSrcweir 295cdf0e10cSrcweir // SV bei den Tools anmelden 296cdf0e10cSrcweir InitTools(); 297cdf0e10cSrcweir 298cdf0e10cSrcweir DBG_ASSERT( !pSVData->maAppData.mxMSF.is(), "VCL service factory already set" ); 299cdf0e10cSrcweir pSVData->maAppData.mxMSF = rSMgr; 300cdf0e10cSrcweir 301cdf0e10cSrcweir // Main-Thread-Id merken 302cdf0e10cSrcweir pSVData->mnMainThreadId = ::vos::OThread::getCurrentIdentifier(); 303cdf0e10cSrcweir 304cdf0e10cSrcweir vos::OStartupInfo aStartInfo; 305cdf0e10cSrcweir rtl::OUString aExeFileName; 306cdf0e10cSrcweir 307cdf0e10cSrcweir 308cdf0e10cSrcweir // Sal initialisieren 309cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ ::CreateSalInstance" ); 310cdf0e10cSrcweir pSVData->mpDefInst = CreateSalInstance(); 311cdf0e10cSrcweir if ( !pSVData->mpDefInst ) 312cdf0e10cSrcweir return sal_False; 313cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_TRACE( aLog, "} ::CreateSalInstance" ); 314cdf0e10cSrcweir 315cdf0e10cSrcweir // Desktop Environment context (to be able to get value of "system.desktop-environment" as soon as possible) 316cdf0e10cSrcweir com::sun::star::uno::setCurrentContext( 317cdf0e10cSrcweir new DesktopEnvironmentContext( com::sun::star::uno::getCurrentContext() ) ); 318cdf0e10cSrcweir 319cdf0e10cSrcweir // Initialize application instance (should be done after initialization of VCL SAL part) 320cdf0e10cSrcweir if( pSVData->mpApp ) 321cdf0e10cSrcweir // call init to initialize application class 322cdf0e10cSrcweir // soffice/sfx implementation creates the global service manager 323cdf0e10cSrcweir pSVData->mpApp->Init(); 324cdf0e10cSrcweir 325cdf0e10cSrcweir // Den AppFileName gleich holen und absolut machen, bevor das 326cdf0e10cSrcweir // WorkingDirectory sich aendert... 327cdf0e10cSrcweir aStartInfo.getExecutableFile( aExeFileName ); 328cdf0e10cSrcweir 329cdf0e10cSrcweir // convert path to native file format 330cdf0e10cSrcweir rtl::OUString aNativeFileName; 331cdf0e10cSrcweir osl::FileBase::getSystemPathFromFileURL( aExeFileName, aNativeFileName ); 332cdf0e10cSrcweir pSVData->maAppData.mpAppFileName = new String( aNativeFileName ); 333cdf0e10cSrcweir 334cdf0e10cSrcweir // Initialize global data 335cdf0e10cSrcweir pSVData->maGDIData.mpScreenFontList = new ImplDevFontList; 336cdf0e10cSrcweir pSVData->maGDIData.mpScreenFontCache = new ImplFontCache( sal_False ); 337cdf0e10cSrcweir pSVData->maGDIData.mpGrfConverter = new GraphicConverter; 338cdf0e10cSrcweir 339cdf0e10cSrcweir // Exception-Handler setzen 340cdf0e10cSrcweir pExceptionHandler = new ImplVCLExceptionHandler(); 341cdf0e10cSrcweir 342cdf0e10cSrcweir // Debug-Daten initialisieren 343cdf0e10cSrcweir DBGGUI_INIT(); 344cdf0e10cSrcweir 345cdf0e10cSrcweir return sal_True; 346cdf0e10cSrcweir } 347cdf0e10cSrcweir 348cdf0e10cSrcweir void DeInitVCL() 349cdf0e10cSrcweir { 350cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 351cdf0e10cSrcweir pSVData->mbDeInit = sal_True; 352cdf0e10cSrcweir 353cdf0e10cSrcweir vcl::DeleteOnDeinitBase::ImplDeleteOnDeInit(); 354cdf0e10cSrcweir 355cdf0e10cSrcweir // give ime status a chance to destroy its own windows 356cdf0e10cSrcweir delete pSVData->mpImeStatus; 357cdf0e10cSrcweir pSVData->mpImeStatus = NULL; 358cdf0e10cSrcweir 359cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 360cdf0e10cSrcweir rtl::OStringBuffer aBuf( 256 ); 361cdf0e10cSrcweir aBuf.append( "DeInitVCL: some top Windows are still alive\n" ); 362cdf0e10cSrcweir long nTopWindowCount = Application::GetTopWindowCount(); 363cdf0e10cSrcweir long nBadTopWindows = nTopWindowCount; 364cdf0e10cSrcweir for( long i = 0; i < nTopWindowCount; i++ ) 365cdf0e10cSrcweir { 366cdf0e10cSrcweir Window* pWin = Application::GetTopWindow( i ); 367cdf0e10cSrcweir // default window will be destroyed further down 368cdf0e10cSrcweir // but may still be useful during deinit up to that point 369cdf0e10cSrcweir if( pWin == pSVData->mpDefaultWin ) 370cdf0e10cSrcweir nBadTopWindows--; 371cdf0e10cSrcweir else 372cdf0e10cSrcweir { 373cdf0e10cSrcweir aBuf.append( "text = \"" ); 374cdf0e10cSrcweir aBuf.append( rtl::OUStringToOString( pWin->GetText(), osl_getThreadTextEncoding() ) ); 375cdf0e10cSrcweir aBuf.append( "\" type = \"" ); 376cdf0e10cSrcweir aBuf.append( typeid(*pWin).name() ); 377cdf0e10cSrcweir aBuf.append( "\", ptr = 0x" ); 378cdf0e10cSrcweir aBuf.append( sal_Int64( pWin ), 16 ); 379cdf0e10cSrcweir aBuf.append( "\n" ); 380cdf0e10cSrcweir } 381cdf0e10cSrcweir } 382cdf0e10cSrcweir DBG_ASSERT( nBadTopWindows==0, aBuf.getStr() ); 383cdf0e10cSrcweir #endif 384cdf0e10cSrcweir 385cdf0e10cSrcweir ImplImageTreeSingletonRef()->shutDown(); 386cdf0e10cSrcweir 387cdf0e10cSrcweir delete pExceptionHandler; 388cdf0e10cSrcweir pExceptionHandler = NULL; 389cdf0e10cSrcweir 390cdf0e10cSrcweir // Debug Daten zuruecksetzen 391cdf0e10cSrcweir DBGGUI_DEINIT(); 392cdf0e10cSrcweir 393cdf0e10cSrcweir // free global data 394cdf0e10cSrcweir delete pSVData->maGDIData.mpGrfConverter; 395cdf0e10cSrcweir 396cdf0e10cSrcweir if( pSVData->mpSettingsConfigItem ) 397cdf0e10cSrcweir delete pSVData->mpSettingsConfigItem, pSVData->mpSettingsConfigItem = NULL; 398cdf0e10cSrcweir if( pSVData->maGDIData.mpDefaultFontConfiguration ) 399cdf0e10cSrcweir delete pSVData->maGDIData.mpDefaultFontConfiguration, pSVData->maGDIData.mpDefaultFontConfiguration = NULL; 400cdf0e10cSrcweir if( pSVData->maGDIData.mpFontSubstConfiguration ) 401cdf0e10cSrcweir delete pSVData->maGDIData.mpFontSubstConfiguration, pSVData->maGDIData.mpFontSubstConfiguration = NULL; 402cdf0e10cSrcweir 403cdf0e10cSrcweir if ( pSVData->maAppData.mpIdleMgr ) 404cdf0e10cSrcweir delete pSVData->maAppData.mpIdleMgr; 405cdf0e10cSrcweir Timer::ImplDeInitTimer(); 406cdf0e10cSrcweir 407cdf0e10cSrcweir if ( pSVData->maWinData.mpMsgBoxImgList ) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir delete pSVData->maWinData.mpMsgBoxImgList; 410cdf0e10cSrcweir pSVData->maWinData.mpMsgBoxImgList = NULL; 411cdf0e10cSrcweir } 412cdf0e10cSrcweir if ( pSVData->maWinData.mpMsgBoxHCImgList ) 413cdf0e10cSrcweir { 414cdf0e10cSrcweir delete pSVData->maWinData.mpMsgBoxHCImgList; 415cdf0e10cSrcweir pSVData->maWinData.mpMsgBoxHCImgList = NULL; 416cdf0e10cSrcweir } 417cdf0e10cSrcweir if ( pSVData->maCtrlData.mpCheckImgList ) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir delete pSVData->maCtrlData.mpCheckImgList; 420cdf0e10cSrcweir pSVData->maCtrlData.mpCheckImgList = NULL; 421cdf0e10cSrcweir } 422cdf0e10cSrcweir if ( pSVData->maCtrlData.mpRadioImgList ) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir delete pSVData->maCtrlData.mpRadioImgList; 425cdf0e10cSrcweir pSVData->maCtrlData.mpRadioImgList = NULL; 426cdf0e10cSrcweir } 427cdf0e10cSrcweir if ( pSVData->maCtrlData.mpPinImgList ) 428cdf0e10cSrcweir { 429cdf0e10cSrcweir delete pSVData->maCtrlData.mpPinImgList; 430cdf0e10cSrcweir pSVData->maCtrlData.mpPinImgList = NULL; 431cdf0e10cSrcweir } 432cdf0e10cSrcweir if ( pSVData->maCtrlData.mpSplitHPinImgList ) 433cdf0e10cSrcweir { 434cdf0e10cSrcweir delete pSVData->maCtrlData.mpSplitHPinImgList; 435cdf0e10cSrcweir pSVData->maCtrlData.mpSplitHPinImgList = NULL; 436cdf0e10cSrcweir } 437cdf0e10cSrcweir if ( pSVData->maCtrlData.mpSplitVPinImgList ) 438cdf0e10cSrcweir { 439cdf0e10cSrcweir delete pSVData->maCtrlData.mpSplitVPinImgList; 440cdf0e10cSrcweir pSVData->maCtrlData.mpSplitVPinImgList = NULL; 441cdf0e10cSrcweir } 442cdf0e10cSrcweir if ( pSVData->maCtrlData.mpSplitHArwImgList ) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir delete pSVData->maCtrlData.mpSplitHArwImgList; 445cdf0e10cSrcweir pSVData->maCtrlData.mpSplitHArwImgList = NULL; 446cdf0e10cSrcweir } 447cdf0e10cSrcweir if ( pSVData->maCtrlData.mpSplitVArwImgList ) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir delete pSVData->maCtrlData.mpSplitVArwImgList; 450cdf0e10cSrcweir pSVData->maCtrlData.mpSplitVArwImgList = NULL; 451cdf0e10cSrcweir } 452cdf0e10cSrcweir if ( pSVData->maCtrlData.mpDisclosurePlus ) 453cdf0e10cSrcweir { 454cdf0e10cSrcweir delete pSVData->maCtrlData.mpDisclosurePlus; 455cdf0e10cSrcweir pSVData->maCtrlData.mpDisclosurePlus = NULL; 456cdf0e10cSrcweir } 457cdf0e10cSrcweir if ( pSVData->maCtrlData.mpDisclosurePlusHC ) 458cdf0e10cSrcweir { 459cdf0e10cSrcweir delete pSVData->maCtrlData.mpDisclosurePlusHC; 460cdf0e10cSrcweir pSVData->maCtrlData.mpDisclosurePlusHC = NULL; 461cdf0e10cSrcweir } 462cdf0e10cSrcweir if ( pSVData->maCtrlData.mpDisclosureMinus ) 463cdf0e10cSrcweir { 464cdf0e10cSrcweir delete pSVData->maCtrlData.mpDisclosureMinus; 465cdf0e10cSrcweir pSVData->maCtrlData.mpDisclosureMinus = NULL; 466cdf0e10cSrcweir } 467cdf0e10cSrcweir if ( pSVData->maCtrlData.mpDisclosureMinusHC ) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir delete pSVData->maCtrlData.mpDisclosureMinusHC; 470cdf0e10cSrcweir pSVData->maCtrlData.mpDisclosureMinusHC = NULL; 471cdf0e10cSrcweir } 472cdf0e10cSrcweir if ( pSVData->mpDefaultWin ) 473cdf0e10cSrcweir { 474cdf0e10cSrcweir delete pSVData->mpDefaultWin; 475cdf0e10cSrcweir pSVData->mpDefaultWin = NULL; 476cdf0e10cSrcweir } 477cdf0e10cSrcweir 478cdf0e10cSrcweir // #114285# Moved here from ImplDeInitSVData... 479cdf0e10cSrcweir if ( pSVData->mpUnoWrapper ) 480cdf0e10cSrcweir { 481cdf0e10cSrcweir pSVData->mpUnoWrapper->Destroy(); 482cdf0e10cSrcweir pSVData->mpUnoWrapper = NULL; 483cdf0e10cSrcweir } 484cdf0e10cSrcweir 485cdf0e10cSrcweir pSVData->maAppData.mxMSF.clear(); 486cdf0e10cSrcweir 487cdf0e10cSrcweir if( pSVData->mpApp ) 488cdf0e10cSrcweir // call deinit to deinitialize application class 489cdf0e10cSrcweir // soffice/sfx implementation disposes the global service manager 490cdf0e10cSrcweir // Warning: After this call you can't call uno services 491cdf0e10cSrcweir pSVData->mpApp->DeInit(); 492cdf0e10cSrcweir 493cdf0e10cSrcweir if ( pSVData->maAppData.mpSettings ) 494cdf0e10cSrcweir { 495cdf0e10cSrcweir if ( pSVData->maAppData.mpCfgListener ) 496cdf0e10cSrcweir { 497cdf0e10cSrcweir pSVData->maAppData.mpSettings->GetSysLocale().GetOptions().RemoveListener( pSVData->maAppData.mpCfgListener ); 498cdf0e10cSrcweir delete pSVData->maAppData.mpCfgListener; 499cdf0e10cSrcweir } 500cdf0e10cSrcweir 501cdf0e10cSrcweir delete pSVData->maAppData.mpSettings; 502cdf0e10cSrcweir pSVData->maAppData.mpSettings = NULL; 503cdf0e10cSrcweir } 504cdf0e10cSrcweir if ( pSVData->maAppData.mpAccelMgr ) 505cdf0e10cSrcweir { 506cdf0e10cSrcweir delete pSVData->maAppData.mpAccelMgr; 507cdf0e10cSrcweir pSVData->maAppData.mpAccelMgr = NULL; 508cdf0e10cSrcweir } 509cdf0e10cSrcweir if ( pSVData->maAppData.mpUniqueIdCont ) 510cdf0e10cSrcweir { 511cdf0e10cSrcweir delete pSVData->maAppData.mpUniqueIdCont; 512cdf0e10cSrcweir pSVData->maAppData.mpUniqueIdCont = NULL; 513cdf0e10cSrcweir } 514cdf0e10cSrcweir if ( pSVData->maAppData.mpAppFileName ) 515cdf0e10cSrcweir { 516cdf0e10cSrcweir delete pSVData->maAppData.mpAppFileName; 517cdf0e10cSrcweir pSVData->maAppData.mpAppFileName = NULL; 518cdf0e10cSrcweir } 519cdf0e10cSrcweir if ( pSVData->maAppData.mpAppName ) 520cdf0e10cSrcweir { 521cdf0e10cSrcweir delete pSVData->maAppData.mpAppName; 522cdf0e10cSrcweir pSVData->maAppData.mpAppName = NULL; 523cdf0e10cSrcweir } 524cdf0e10cSrcweir if ( pSVData->maAppData.mpDisplayName ) 525cdf0e10cSrcweir { 526cdf0e10cSrcweir delete pSVData->maAppData.mpDisplayName; 527cdf0e10cSrcweir pSVData->maAppData.mpDisplayName = NULL; 528cdf0e10cSrcweir } 529cdf0e10cSrcweir if ( pSVData->maAppData.mpEventListeners ) 530cdf0e10cSrcweir { 531cdf0e10cSrcweir delete pSVData->maAppData.mpEventListeners; 532cdf0e10cSrcweir pSVData->maAppData.mpEventListeners = NULL; 533cdf0e10cSrcweir } 534cdf0e10cSrcweir if ( pSVData->maAppData.mpKeyListeners ) 535cdf0e10cSrcweir { 536cdf0e10cSrcweir delete pSVData->maAppData.mpKeyListeners; 537cdf0e10cSrcweir pSVData->maAppData.mpKeyListeners = NULL; 538cdf0e10cSrcweir } 539cdf0e10cSrcweir 540cdf0e10cSrcweir if ( pSVData->maAppData.mpFirstHotKey ) 541cdf0e10cSrcweir ImplFreeHotKeyData(); 542cdf0e10cSrcweir if ( pSVData->maAppData.mpFirstEventHook ) 543cdf0e10cSrcweir ImplFreeEventHookData(); 544cdf0e10cSrcweir 545cdf0e10cSrcweir ImplDeletePrnQueueList(); 546cdf0e10cSrcweir delete pSVData->maGDIData.mpScreenFontList; 547cdf0e10cSrcweir pSVData->maGDIData.mpScreenFontList = NULL; 548cdf0e10cSrcweir delete pSVData->maGDIData.mpScreenFontCache; 549cdf0e10cSrcweir pSVData->maGDIData.mpScreenFontCache = NULL; 550cdf0e10cSrcweir ImplFreeOutDevFontData(); 551cdf0e10cSrcweir 552cdf0e10cSrcweir if ( pSVData->mpResMgr ) 553cdf0e10cSrcweir { 554cdf0e10cSrcweir delete pSVData->mpResMgr; 555cdf0e10cSrcweir pSVData->mpResMgr = NULL; 556cdf0e10cSrcweir } 557cdf0e10cSrcweir 558cdf0e10cSrcweir ResMgr::DestroyAllResMgr(); 559cdf0e10cSrcweir 560cdf0e10cSrcweir // destroy all Sal interfaces before destorying the instance 561cdf0e10cSrcweir // and thereby unloading the plugin 562cdf0e10cSrcweir delete pSVData->mpSalSystem; 563cdf0e10cSrcweir pSVData->mpSalSystem = NULL; 564cdf0e10cSrcweir delete pSVData->mpSalTimer; 565cdf0e10cSrcweir pSVData->mpSalTimer = NULL; 566cdf0e10cSrcweir 567cdf0e10cSrcweir // Sal deinitialisieren 568cdf0e10cSrcweir DestroySalInstance( pSVData->mpDefInst ); 569cdf0e10cSrcweir 570cdf0e10cSrcweir DeInitTools(); 571cdf0e10cSrcweir 572cdf0e10cSrcweir DeInitSalMain(); 573cdf0e10cSrcweir 574cdf0e10cSrcweir if( pOwnSvApp ) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir delete pOwnSvApp; 577cdf0e10cSrcweir pOwnSvApp = NULL; 578cdf0e10cSrcweir } 579cdf0e10cSrcweir } 580cdf0e10cSrcweir 581cdf0e10cSrcweir // only one call is allowed 582cdf0e10cSrcweir struct WorkerThreadData 583cdf0e10cSrcweir { 584cdf0e10cSrcweir oslWorkerFunction pWorker; 585cdf0e10cSrcweir void * pThreadData; 586cdf0e10cSrcweir WorkerThreadData( oslWorkerFunction pWorker_, void * pThreadData_ ) 587cdf0e10cSrcweir : pWorker( pWorker_ ) 588cdf0e10cSrcweir , pThreadData( pThreadData_ ) 589cdf0e10cSrcweir { 590cdf0e10cSrcweir } 591cdf0e10cSrcweir }; 592cdf0e10cSrcweir 593cdf0e10cSrcweir #ifdef WNT 594cdf0e10cSrcweir static HANDLE hThreadID = 0; 595cdf0e10cSrcweir static unsigned __stdcall _threadmain( void *pArgs ) 596cdf0e10cSrcweir { 597cdf0e10cSrcweir OleInitialize( NULL ); 598cdf0e10cSrcweir ((WorkerThreadData*)pArgs)->pWorker( ((WorkerThreadData*)pArgs)->pThreadData ); 599cdf0e10cSrcweir delete (WorkerThreadData*)pArgs; 600cdf0e10cSrcweir OleUninitialize(); 601cdf0e10cSrcweir hThreadID = 0; 602cdf0e10cSrcweir return 0; 603cdf0e10cSrcweir } 604cdf0e10cSrcweir #else 605cdf0e10cSrcweir static oslThread hThreadID = 0; 606cdf0e10cSrcweir extern "C" 607cdf0e10cSrcweir { 608cdf0e10cSrcweir static void SAL_CALL MainWorkerFunction( void* pArgs ) 609cdf0e10cSrcweir { 610cdf0e10cSrcweir ((WorkerThreadData*)pArgs)->pWorker( ((WorkerThreadData*)pArgs)->pThreadData ); 611cdf0e10cSrcweir delete (WorkerThreadData*)pArgs; 612cdf0e10cSrcweir hThreadID = 0; 613cdf0e10cSrcweir } 614cdf0e10cSrcweir } // extern "C" 615cdf0e10cSrcweir #endif 616cdf0e10cSrcweir 617cdf0e10cSrcweir void CreateMainLoopThread( oslWorkerFunction pWorker, void * pThreadData ) 618cdf0e10cSrcweir { 619cdf0e10cSrcweir #ifdef WNT 620cdf0e10cSrcweir // sal thread alway call CoInitializeEx, so a sysdepen implementation is necessary 621cdf0e10cSrcweir 622cdf0e10cSrcweir unsigned uThreadID; 623cdf0e10cSrcweir hThreadID = (HANDLE)_beginthreadex( 624cdf0e10cSrcweir NULL, // no security handle 625cdf0e10cSrcweir 0, // stacksize 0 means default 626cdf0e10cSrcweir _threadmain, // thread worker function 627cdf0e10cSrcweir new WorkerThreadData( pWorker, pThreadData ), // arguments for worker function 628cdf0e10cSrcweir 0, // 0 means: create immediatly otherwise use CREATE_SUSPENDED 629cdf0e10cSrcweir &uThreadID ); // thread id to fill 630cdf0e10cSrcweir #else 631cdf0e10cSrcweir hThreadID = osl_createThread( MainWorkerFunction, new WorkerThreadData( pWorker, pThreadData ) ); 632cdf0e10cSrcweir #endif 633cdf0e10cSrcweir } 634cdf0e10cSrcweir 635cdf0e10cSrcweir void JoinMainLoopThread() 636cdf0e10cSrcweir { 637cdf0e10cSrcweir if( hThreadID ) 638cdf0e10cSrcweir { 639cdf0e10cSrcweir #ifdef WNT 640cdf0e10cSrcweir WaitForSingleObject(hThreadID, INFINITE); 641cdf0e10cSrcweir #else 642cdf0e10cSrcweir osl_joinWithThread(hThreadID); 643cdf0e10cSrcweir osl_destroyThread( hThreadID ); 644cdf0e10cSrcweir #endif 645cdf0e10cSrcweir } 646cdf0e10cSrcweir } 647