/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "sfx2/sfxresid.hxx" #include #include "appdata.hxx" #include "arrdecl.hxx" #include #include "sfx2/stbitem.hxx" #include #include #include #include #include #include #include #include "workwin.hxx" #include #include "sfxlocal.hrc" #include #include "app.hrc" #include #include #include #include #include "openflag.hxx" #include #include #include "helper.hxx" // SfxContentHelper::Kill() using namespace ::com::sun::star::uno; using namespace ::com::sun::star::util; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; //=================================================================== #define SfxApplication #include "sfxslots.hxx" class SfxSpecialConfigError_Impl { String aError; public: SfxSpecialConfigError_Impl( const String& rStr ); DECL_LINK( TimerHdl, Timer*); }; SfxSpecialConfigError_Impl::SfxSpecialConfigError_Impl( const String& rStr ) : aError( rStr ) { Timer *pTimer = new Timer; pTimer->SetTimeoutHdl( LINK(this, SfxSpecialConfigError_Impl, TimerHdl) ); pTimer->SetTimeout( 0 ); pTimer->Start(); } IMPL_LINK( SfxSpecialConfigError_Impl, TimerHdl, Timer*, pTimer ) { delete pTimer; ErrorBox( 0, WinBits( WB_OK ) , aError ).Execute(); delete this; SFX_APP()->GetAppDispatcher_Impl()->Execute( SID_QUITAPP ); return 0L; } //==================================================================== #define SFX_ITEMTYPE_STATBAR 4 SFX_IMPL_INTERFACE(SfxApplication,SfxShell,SfxResId(RID_DESKTOP)) { SFX_STATUSBAR_REGISTRATION(SfxResId(SFX_ITEMTYPE_STATBAR)); SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_0); SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_1); SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_2); SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_3); SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_4); SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_5); SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_6); SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_7); SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_8); SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_9); } //-------------------------------------------------------------------- SfxProgress* SfxApplication::GetProgress() const /* [Description] Returns the running SfxProgress for the entire application or 0 if none is running for the entire application. [Cross-reference] */ { return pAppData_Impl->pProgress; } //------------------------------------------------------------------------ std::vector* SfxApplication::GetDisabledSlotList_Impl() { sal_Bool bError = sal_False; std::vector* pList = pAppData_Impl->pDisabledSlotList; if ( !pList ) { // Is there a slot file? INetURLObject aUserObj( SvtPathOptions().GetUserConfigPath() ); aUserObj.insertName( DEFINE_CONST_UNICODE( "slots.cfg" ) ); SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aUserObj.GetMainURL( INetURLObject::NO_DECODE ), STREAM_STD_READ ); if ( !pStream || pStream->GetError() == ERRCODE_IO_NOTEXISTS ) { delete pStream; INetURLObject aObj( SvtPathOptions().GetConfigPath() ); aObj.insertName( DEFINE_CONST_UNICODE( "slots.cfg" ) ); pStream = ::utl::UcbStreamHelper::CreateStream( aObj.GetMainURL( INetURLObject::NO_DECODE ), STREAM_STD_READ ); } sal_Bool bSlotsEnabled = SvtInternalOptions().SlotCFGEnabled(); sal_Bool bSlots = ( pStream && !pStream->GetError() ); if( bSlots && bSlotsEnabled ) { // Read Slot file String aTitle = pStream->ReadUniOrByteString(pStream->GetStreamCharSet()); if ( aTitle.CompareToAscii("SfxSlotFile" ) == COMPARE_EQUAL ) { sal_uInt16 nCount; (*pStream) >> nCount; pList = pAppData_Impl->pDisabledSlotList = new std::vector; sal_uInt16 nSlot; for ( sal_uInt16 n=0; n> nSlot; pList->push_back( nSlot ); } aTitle = pStream->ReadUniOrByteString(pStream->GetStreamCharSet()); if ( aTitle.CompareToAscii("END" ) != COMPARE_EQUAL || pStream->GetError() ) { // Read failed DELETEZ( pList ); bError = sal_True; } } else { // Stream detection failure bError = sal_True; } } else if ( bSlots != bSlotsEnabled ) { // If no slot list entry, then no slot file shall exist bError = sal_True; } delete pStream; } else if ( pList == (std::vector*) -1L ) { return NULL; } if ( !pList ) pAppData_Impl->pDisabledSlotList = (std::vector*) -1L; if ( bError ) { // If an entry slot is present, but no or faulty slot file, or a slot // file, but no slot entry, then this is considered to be a // misconfiguration new SfxSpecialConfigError_Impl( SfxResId( RID_SPECIALCONFIG_ERROR ).toString() ); } return pList; } SfxModule* SfxApplication::GetModule_Impl() { SfxModule* pModule = SfxModule::GetActiveModule(); if ( !pModule ) pModule = SfxModule::GetActiveModule( SfxViewFrame::GetFirst( sal_False ) ); if( pModule ) return pModule; else { OSL_FAIL( "No module!" ); return NULL; } } ISfxTemplateCommon* SfxApplication::GetCurrentTemplateCommon( SfxBindings& rBindings ) { if( pAppData_Impl->pTemplateCommon ) return pAppData_Impl->pTemplateCommon; SfxChildWindow *pChild = rBindings.GetWorkWindow_Impl()->GetChildWindow_Impl( SfxTemplateDialogWrapper::GetChildWindowId() ); if ( pChild ) return ((SfxTemplateDialog*) pChild->GetWindow())->GetISfxTemplateCommon(); return 0; } sal_Bool SfxApplication::IsDowning() const { return pAppData_Impl->bDowning; } SfxDispatcher* SfxApplication::GetAppDispatcher_Impl() { return pAppData_Impl->pAppDispat; } SfxSlotPool& SfxApplication::GetAppSlotPool_Impl() const { return *pAppData_Impl->pSlotPool; } /** loads the application logo as used in the about dialog and impress slideshow pause screen */ Image SfxApplication::GetApplicationLogo() { BitmapEx aBitmap; Application::LoadBrandBitmap ("about", aBitmap); return Image( aBitmap ); } SfxChildWinFactArr_Impl::~SfxChildWinFactArr_Impl() { for( const_iterator it = begin(); it != end(); ++it ) delete *it; } SfxMenuCtrlFactArr_Impl::~SfxMenuCtrlFactArr_Impl() { for( const_iterator it = begin(); it != end(); ++it ) delete *it; } SfxStbCtrlFactArr_Impl::~SfxStbCtrlFactArr_Impl() { for( const_iterator it = begin(); it != end(); ++it ) delete *it; } SfxTbxCtrlFactArr_Impl::~SfxTbxCtrlFactArr_Impl() { for( const_iterator it = begin(); it != end(); ++it ) delete *it; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */