1d119d52dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3d119d52dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4d119d52dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5d119d52dSAndrew Rist * distributed with this work for additional information 6d119d52dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7d119d52dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8d119d52dSAndrew Rist * "License"); you may not use this file except in compliance 9d119d52dSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11d119d52dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13d119d52dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14d119d52dSAndrew Rist * software distributed under the License is distributed on an 15d119d52dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16d119d52dSAndrew Rist * KIND, either express or implied. See the License for the 17d119d52dSAndrew Rist * specific language governing permissions and limitations 18d119d52dSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20d119d52dSAndrew Rist *************************************************************/ 21d119d52dSAndrew Rist 22d119d52dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sfx2.hxx" 26cdf0e10cSrcweir #include <vcl/status.hxx> 27cdf0e10cSrcweir #include <vcl/msgbox.hxx> 28cdf0e10cSrcweir #include <vos/process.hxx> 29cdf0e10cSrcweir #include <vos/xception.hxx> 30cdf0e10cSrcweir #include <svl/whiter.hxx> 31cdf0e10cSrcweir #include <svl/stritem.hxx> 32cdf0e10cSrcweir #include <svl/intitem.hxx> 33cdf0e10cSrcweir #include <svl/eitem.hxx> 34cdf0e10cSrcweir #include <svtools/filter.hxx> 35cdf0e10cSrcweir #include <unotools/internaloptions.hxx> 36cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 37cdf0e10cSrcweir #include <com/sun/star/registry/InvalidRegistryException.hpp> 38cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 39cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 40cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp> 41cdf0e10cSrcweir #include <com/sun/star/frame/XFramesSupplier.hpp> 42cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 43cdf0e10cSrcweir #include <tools/config.hxx> 44cdf0e10cSrcweir #include <tools/rcid.h> 45cdf0e10cSrcweir #include <vos/mutex.hxx> 46cdf0e10cSrcweir #include <unotools/configmgr.hxx> 47cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp> 48cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx> 49cdf0e10cSrcweir #include <framework/menuconfiguration.hxx> 50cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 51cdf0e10cSrcweir #include <unotools/localfilehelper.hxx> 52cdf0e10cSrcweir #include <unotools/bootstrap.hxx> 53cdf0e10cSrcweir #include <unotools/moduleoptions.hxx> 54cdf0e10cSrcweir #include <osl/file.hxx> 55cdf0e10cSrcweir #include <rtl/bootstrap.hxx> 56cdf0e10cSrcweir 57cdf0e10cSrcweir #include "sfx2/sfxresid.hxx" 58cdf0e10cSrcweir #include <sfx2/app.hxx> 59cdf0e10cSrcweir #include "appdata.hxx" 60cdf0e10cSrcweir #include "arrdecl.hxx" 61cdf0e10cSrcweir #include <sfx2/tbxctrl.hxx> 62cdf0e10cSrcweir #include "sfx2/stbitem.hxx" 63cdf0e10cSrcweir #include <sfx2/mnuitem.hxx> 64cdf0e10cSrcweir #include <sfx2/docfac.hxx> 65cdf0e10cSrcweir #include <sfx2/docfile.hxx> 66cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 67cdf0e10cSrcweir #include <sfx2/request.hxx> 68cdf0e10cSrcweir #include <sfx2/bindings.hxx> 69cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 70cdf0e10cSrcweir #include "workwin.hxx" 71cdf0e10cSrcweir #include "intro.hxx" 72cdf0e10cSrcweir #include <sfx2/fcontnr.hxx> 73cdf0e10cSrcweir #include "sfxlocal.hrc" 74cdf0e10cSrcweir #include <sfx2/sfx.hrc> 75cdf0e10cSrcweir #include "app.hrc" 76cdf0e10cSrcweir #include <sfx2/templdlg.hxx> 77cdf0e10cSrcweir #include <sfx2/module.hxx> 78cdf0e10cSrcweir #include <sfx2/msgpool.hxx> 79cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 80cdf0e10cSrcweir #include "openflag.hxx" 81cdf0e10cSrcweir #include <sfx2/viewsh.hxx> 82cdf0e10cSrcweir #include <sfx2/objface.hxx> 83cdf0e10cSrcweir #include "helper.hxx" // SfxContentHelper::Kill() 84cdf0e10cSrcweir 85cdf0e10cSrcweir using namespace ::vos; 86cdf0e10cSrcweir using namespace ::com::sun::star::uno; 87cdf0e10cSrcweir using namespace ::com::sun::star::util; 88cdf0e10cSrcweir using namespace ::com::sun::star::beans; 89cdf0e10cSrcweir using namespace ::com::sun::star::container; 90cdf0e10cSrcweir 91cdf0e10cSrcweir //=================================================================== 92cdf0e10cSrcweir 93cdf0e10cSrcweir SV_IMPL_PTRARR( SfxTbxCtrlFactArr_Impl, SfxTbxCtrlFactory* ); 94cdf0e10cSrcweir SV_IMPL_PTRARR( SfxStbCtrlFactArr_Impl, SfxStbCtrlFactory* ); 95cdf0e10cSrcweir SV_IMPL_PTRARR( SfxMenuCtrlFactArr_Impl, SfxMenuCtrlFactory* ); 96cdf0e10cSrcweir SV_IMPL_PTRARR( SfxChildWinFactArr_Impl, SfxChildWinFactory* ); 97cdf0e10cSrcweir SV_IMPL_PTRARR( SfxModuleArr_Impl, SfxModule* ); 98cdf0e10cSrcweir 99cdf0e10cSrcweir //=================================================================== 100cdf0e10cSrcweir 101cdf0e10cSrcweir #define SfxApplication 102cdf0e10cSrcweir #include "sfxslots.hxx" 103cdf0e10cSrcweir 104cdf0e10cSrcweir class SfxSpecialConfigError_Impl 105cdf0e10cSrcweir { 106cdf0e10cSrcweir String aError; 107cdf0e10cSrcweir 108cdf0e10cSrcweir public: 109cdf0e10cSrcweir 110cdf0e10cSrcweir SfxSpecialConfigError_Impl( const String& rStr ); 111cdf0e10cSrcweir DECL_LINK( TimerHdl, Timer*); 112cdf0e10cSrcweir }; 113cdf0e10cSrcweir 114cdf0e10cSrcweir 115cdf0e10cSrcweir SfxSpecialConfigError_Impl::SfxSpecialConfigError_Impl( const String& rStr ) : 116cdf0e10cSrcweir aError( rStr ) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir Timer *pTimer = new Timer; 119cdf0e10cSrcweir pTimer->SetTimeoutHdl( LINK(this, SfxSpecialConfigError_Impl, TimerHdl) ); 120cdf0e10cSrcweir pTimer->SetTimeout( 0 ); 121cdf0e10cSrcweir pTimer->Start(); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir IMPL_LINK( SfxSpecialConfigError_Impl, TimerHdl, Timer*, pTimer ) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir delete pTimer; 127cdf0e10cSrcweir ErrorBox( 0, WinBits( WB_OK ) , aError ).Execute(); 128cdf0e10cSrcweir delete this; 129cdf0e10cSrcweir SFX_APP()->GetAppDispatcher_Impl()->Execute( SID_QUITAPP ); 130cdf0e10cSrcweir return 0L; 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir //==================================================================== 134cdf0e10cSrcweir 135cdf0e10cSrcweir #define SFX_ITEMTYPE_STATBAR 4 136cdf0e10cSrcweir 137cdf0e10cSrcweir SFX_IMPL_INTERFACE(SfxApplication,SfxShell,SfxResId(RID_DESKTOP)) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir SFX_STATUSBAR_REGISTRATION(SfxResId(SFX_ITEMTYPE_STATBAR)); 140cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_0); 141cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_1); 142cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_2); 143cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_3); 144cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_4); 145cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_5); 146cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_6); 147cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_7); 148cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_8); 149cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_9); 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir //-------------------------------------------------------------------- 153cdf0e10cSrcweir SfxProgress* SfxApplication::GetProgress() const 154cdf0e10cSrcweir 155cdf0e10cSrcweir /* [Beschreibung] 156cdf0e10cSrcweir 157cdf0e10cSrcweir Liefert den f"ur die gesamte Applikation laufenden SfxProgress 158cdf0e10cSrcweir oder 0, falls keiner f"ur die gesamte Applikation l"auft. 159cdf0e10cSrcweir 160cdf0e10cSrcweir 161cdf0e10cSrcweir [Querverweise] 162cdf0e10cSrcweir 163cdf0e10cSrcweir <SfxProgress::GetActiveProgress(SfxViewFrame*)> 164cdf0e10cSrcweir <SfxViewFrame::GetProgress()const> 165cdf0e10cSrcweir */ 166cdf0e10cSrcweir 167cdf0e10cSrcweir { 168cdf0e10cSrcweir return pAppData_Impl->pProgress; 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir //------------------------------------------------------------------------ 172cdf0e10cSrcweir 173cdf0e10cSrcweir SvUShorts* SfxApplication::GetDisabledSlotList_Impl() 174cdf0e10cSrcweir { 175cdf0e10cSrcweir sal_Bool bError = sal_False; 176cdf0e10cSrcweir SvUShorts* pList = pAppData_Impl->pDisabledSlotList; 177cdf0e10cSrcweir if ( !pList ) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir // Gibt es eine Slotdatei ? 180cdf0e10cSrcweir INetURLObject aUserObj( SvtPathOptions().GetUserConfigPath() ); 181cdf0e10cSrcweir aUserObj.insertName( DEFINE_CONST_UNICODE( "slots.cfg" ) ); 182cdf0e10cSrcweir SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aUserObj.GetMainURL( INetURLObject::NO_DECODE ), STREAM_STD_READ ); 183cdf0e10cSrcweir if ( !pStream || pStream->GetError() == ERRCODE_IO_NOTEXISTS ) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir delete pStream; 186cdf0e10cSrcweir INetURLObject aObj( SvtPathOptions().GetConfigPath() ); 187cdf0e10cSrcweir aObj.insertName( DEFINE_CONST_UNICODE( "slots.cfg" ) ); 188cdf0e10cSrcweir pStream = ::utl::UcbStreamHelper::CreateStream( aObj.GetMainURL( INetURLObject::NO_DECODE ), STREAM_STD_READ ); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir 191cdf0e10cSrcweir sal_Bool bSlotsEnabled = SvtInternalOptions().SlotCFGEnabled(); 192cdf0e10cSrcweir sal_Bool bSlots = ( pStream && !pStream->GetError() ); 193cdf0e10cSrcweir if( bSlots && bSlotsEnabled ) 194cdf0e10cSrcweir { 195cdf0e10cSrcweir // SlotDatei einlesen 196cdf0e10cSrcweir String aTitle; 197cdf0e10cSrcweir pStream->ReadByteString(aTitle); 198cdf0e10cSrcweir if ( aTitle.CompareToAscii("SfxSlotFile" ) == COMPARE_EQUAL ) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir sal_uInt16 nCount; 201cdf0e10cSrcweir (*pStream) >> nCount; 202cdf0e10cSrcweir pList = pAppData_Impl->pDisabledSlotList = 203cdf0e10cSrcweir new SvUShorts( nCount < 255 ? (sal_Int8) nCount : 255, 255 ); 204cdf0e10cSrcweir 205cdf0e10cSrcweir sal_uInt16 nSlot; 206cdf0e10cSrcweir for ( sal_uInt16 n=0; n<nCount; n++ ) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir (*pStream) >> nSlot; 209cdf0e10cSrcweir pList->Insert( nSlot, n ); 210cdf0e10cSrcweir } 211cdf0e10cSrcweir 212cdf0e10cSrcweir pStream->ReadByteString(aTitle); 213cdf0e10cSrcweir if ( aTitle.CompareToAscii("END" ) != COMPARE_EQUAL || pStream->GetError() ) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir // Lesen schief gegangen 216cdf0e10cSrcweir DELETEZ( pList ); 217cdf0e10cSrcweir bError = sal_True; 218cdf0e10cSrcweir } 219cdf0e10cSrcweir } 220cdf0e10cSrcweir else 221cdf0e10cSrcweir { 222cdf0e10cSrcweir // Streamerkennung fehlgeschlagen 223cdf0e10cSrcweir bError = sal_True; 224cdf0e10cSrcweir } 225cdf0e10cSrcweir } 226cdf0e10cSrcweir else if ( bSlots != bSlotsEnabled ) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir // Wenn kein Slotlist-Eintrag, dann darf auch keine SlotDatei 229cdf0e10cSrcweir // vorhanden sein 230cdf0e10cSrcweir bError = sal_True; 231cdf0e10cSrcweir } 232cdf0e10cSrcweir 233cdf0e10cSrcweir delete pStream; 234cdf0e10cSrcweir } 235cdf0e10cSrcweir else if ( pList == (SvUShorts*) -1L ) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir return NULL; 238cdf0e10cSrcweir } 239cdf0e10cSrcweir 240cdf0e10cSrcweir if ( !pList ) 241cdf0e10cSrcweir pAppData_Impl->pDisabledSlotList = (SvUShorts*) -1L; 242cdf0e10cSrcweir 243cdf0e10cSrcweir if ( bError ) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir // Wenn ein Sloteintrag vorhanden ist, aber keine oder eine fehlerhafte 246cdf0e10cSrcweir // SlotDatei, oder aber eine Slotdatei, aber kein Sloteintrag, dann 247cdf0e10cSrcweir // gilt dies als fehlerhafte Konfiguration 248cdf0e10cSrcweir new SfxSpecialConfigError_Impl( String( SfxResId( RID_SPECIALCONFIG_ERROR ) ) ); 249cdf0e10cSrcweir } 250cdf0e10cSrcweir 251cdf0e10cSrcweir return pList; 252cdf0e10cSrcweir } 253cdf0e10cSrcweir 254cdf0e10cSrcweir 255cdf0e10cSrcweir SfxModule* SfxApplication::GetModule_Impl() 256cdf0e10cSrcweir { 257cdf0e10cSrcweir SfxModule* pModule = SfxModule::GetActiveModule(); 258cdf0e10cSrcweir if ( !pModule ) 259*46d2a04eSHerbert Dürr pModule = SfxModule::GetActiveModule( SfxViewFrame::GetFirst( NULL ) ); 260cdf0e10cSrcweir if( pModule ) 261cdf0e10cSrcweir return pModule; 262cdf0e10cSrcweir else 263cdf0e10cSrcweir { 264cdf0e10cSrcweir DBG_ERROR( "No module!" ); 265cdf0e10cSrcweir return NULL; 266cdf0e10cSrcweir } 267cdf0e10cSrcweir } 268cdf0e10cSrcweir 269cdf0e10cSrcweir ISfxTemplateCommon* SfxApplication::GetCurrentTemplateCommon( SfxBindings& rBindings ) 270cdf0e10cSrcweir { 271cdf0e10cSrcweir if( pAppData_Impl->pTemplateCommon ) 272cdf0e10cSrcweir return pAppData_Impl->pTemplateCommon; 273cdf0e10cSrcweir SfxChildWindow *pChild = rBindings.GetWorkWindow_Impl()->GetChildWindow_Impl( 274cdf0e10cSrcweir SfxTemplateDialogWrapper::GetChildWindowId() ); 275cdf0e10cSrcweir if ( pChild ) 276cdf0e10cSrcweir return ((SfxTemplateDialog*) pChild->GetWindow())->GetISfxTemplateCommon(); 277cdf0e10cSrcweir return 0; 278cdf0e10cSrcweir } 279cdf0e10cSrcweir 280cdf0e10cSrcweir SfxResourceManager& SfxApplication::GetResourceManager() const { return *pAppData_Impl->pResMgr; } 281cdf0e10cSrcweir sal_Bool SfxApplication::IsDowning() const { return pAppData_Impl->bDowning; } 282cdf0e10cSrcweir SfxDispatcher* SfxApplication::GetAppDispatcher_Impl() { return pAppData_Impl->pAppDispat; } 283cdf0e10cSrcweir SfxSlotPool& SfxApplication::GetAppSlotPool_Impl() const { return *pAppData_Impl->pSlotPool; } 284cdf0e10cSrcweir //SfxOptions& SfxApplication::GetOptions() { return *pAppData_Impl->pOptions; } 285cdf0e10cSrcweir //const SfxOptions& SfxApplication::GetOptions() const { return *pAppData_Impl->pOptions; } 286