1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sfx2.hxx" 30 #include <tools/cachestr.hxx> 31 #include <tools/config.hxx> 32 #ifndef _INETSTRM_HXX //autogen 33 #include <svl/inetstrm.hxx> 34 #endif 35 #include <svl/stritem.hxx> 36 37 #define _SVSTDARR_STRINGS 38 #include <svl/svstdarr.hxx> 39 #include <vos/mutex.hxx> 40 41 #include <vcl/menu.hxx> 42 #include <vcl/msgbox.hxx> 43 #include <svl/dateitem.hxx> 44 #include <vcl/menu.hxx> 45 #include <vcl/wrkwin.hxx> 46 #include "comphelper/processfactory.hxx" 47 48 #include <sfx2/viewfrm.hxx> 49 #include "appdata.hxx" 50 #include <sfx2/dispatch.hxx> 51 #include <sfx2/event.hxx> 52 #include "sfxtypes.hxx" 53 #include <sfx2/doctempl.hxx> 54 #include "arrdecl.hxx" 55 #include <sfx2/docfac.hxx> 56 #include <sfx2/docfile.hxx> 57 #include <sfx2/request.hxx> 58 #include "referers.hxx" 59 #include "app.hrc" 60 #include "sfx2/sfxresid.hxx" 61 #include "objshimp.hxx" 62 #include <sfx2/appuno.hxx> 63 #include "imestatuswindow.hxx" 64 #include "appbaslib.hxx" 65 66 #include <basic/basicmanagerrepository.hxx> 67 #include <basic/basmgr.hxx> 68 69 using ::basic::BasicManagerRepository; 70 using ::basic::BasicManagerCreationListener; 71 using ::com::sun::star::uno::Reference; 72 using ::com::sun::star::frame::XModel; 73 using ::com::sun::star::uno::XInterface; 74 75 class SfxBasicManagerCreationListener : public ::basic::BasicManagerCreationListener 76 { 77 private: 78 SfxAppData_Impl& m_rAppData; 79 80 public: 81 SfxBasicManagerCreationListener( SfxAppData_Impl& _rAppData ) :m_rAppData( _rAppData ) { } 82 83 virtual void onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager ); 84 }; 85 86 void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager ) 87 { 88 if ( _rxForDocument == NULL ) 89 m_rAppData.OnApplicationBasicManagerCreated( _rBasicManager ); 90 } 91 92 SfxAppData_Impl::SfxAppData_Impl( SfxApplication* ) : 93 pDdeService( 0 ), 94 pDocTopics( 0 ), 95 pTriggerTopic(0), 96 pDdeService2(0), 97 pFactArr(0), 98 pTopFrames( new SfxFrameArr_Impl ), 99 pInitLinkList(0), 100 pMatcher( 0 ), 101 pBasicResMgr( 0 ), 102 pSvtResMgr( 0 ), 103 pAppDispatch(NULL), 104 pTemplates( 0 ), 105 pPool(0), 106 pDisabledSlotList( 0 ), 107 pSecureURLs(0), 108 pSaveOptions( 0 ), 109 pUndoOptions( 0 ), 110 pHelpOptions( 0 ), 111 pProgress(0), 112 pTemplateCommon( 0 ), 113 nDocModalMode(0), 114 nAutoTabPageId(0), 115 nRescheduleLocks(0), 116 nInReschedule(0), 117 nAsynchronCalls(0), 118 m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(comphelper::getProcessServiceFactory())) 119 , pTbxCtrlFac(0) 120 , pStbCtrlFac(0) 121 , pViewFrames(0) 122 , pObjShells(0) 123 , pSfxResManager(0) 124 , pOfaResMgr(0) 125 , pSimpleResManager(0) 126 , pBasicManager( new SfxBasicManagerHolder ) 127 , pBasMgrListener( new SfxBasicManagerCreationListener( *this ) ) 128 , pViewFrame( 0 ) 129 , pSlotPool( 0 ) 130 , pResMgr( 0 ) 131 , pAppDispat( 0 ) 132 , pInterfaces( 0 ) 133 , nDocNo(0) 134 , nInterfaces( 0 ) 135 , bDowning( sal_True ) 136 , bInQuit( sal_False ) 137 , bInvalidateOnUnlock( sal_False ) 138 , bODFVersionWarningLater( sal_False ) 139 140 { 141 BasicManagerRepository::registerCreationListener( *pBasMgrListener ); 142 } 143 144 SfxAppData_Impl::~SfxAppData_Impl() 145 { 146 DeInitDDE(); 147 delete pTopFrames; 148 delete pSecureURLs; 149 delete pBasicManager; 150 151 BasicManagerRepository::revokeCreationListener( *pBasMgrListener ); 152 delete pBasMgrListener; 153 } 154 155 void SfxAppData_Impl::UpdateApplicationSettings( sal_Bool bDontHide ) 156 { 157 AllSettings aAllSet = Application::GetSettings(); 158 StyleSettings aStyleSet = aAllSet.GetStyleSettings(); 159 sal_uInt32 nStyleOptions = aStyleSet.GetOptions(); 160 if ( bDontHide ) 161 nStyleOptions &= ~STYLE_OPTION_HIDEDISABLED; 162 else 163 nStyleOptions |= STYLE_OPTION_HIDEDISABLED; 164 aStyleSet.SetOptions( nStyleOptions ); 165 aAllSet.SetStyleSettings( aStyleSet ); 166 Application::SetSettings( aAllSet ); 167 } 168 169 SfxDocumentTemplates* SfxAppData_Impl::GetDocumentTemplates() 170 { 171 if ( !pTemplates ) 172 pTemplates = new SfxDocumentTemplates; 173 else 174 pTemplates->ReInitFromComponent(); 175 return pTemplates; 176 } 177 178 void SfxAppData_Impl::OnApplicationBasicManagerCreated( BasicManager& _rBasicManager ) 179 { 180 pBasicManager->reset( &_rBasicManager ); 181 182 // global constants, additionally to the ones already added by createApplicationBasicManager: 183 // ThisComponent 184 Reference< XInterface > xCurrentComponent = SfxObjectShell::GetCurrentComponent(); 185 _rBasicManager.SetGlobalUNOConstant( "ThisComponent", makeAny( xCurrentComponent ) ); 186 } 187