Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / sfx2 / source / appl / appdata.cxx
blob571797055c63edd20cc2128e5cb54d623dc434ba
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <tools/config.hxx>
30 #include <svl/stritem.hxx>
32 #include <osl/mutex.hxx>
34 #include <vcl/menu.hxx>
35 #include <vcl/msgbox.hxx>
36 #include <svl/dateitem.hxx>
37 #include <vcl/wrkwin.hxx>
38 #include "comphelper/processfactory.hxx"
40 #include <sfx2/viewfrm.hxx>
41 #include "appdata.hxx"
42 #include <sfx2/dispatch.hxx>
43 #include <sfx2/event.hxx>
44 #include "sfxtypes.hxx"
45 #include <sfx2/doctempl.hxx>
46 #include "arrdecl.hxx"
47 #include <sfx2/docfac.hxx>
48 #include <sfx2/docfile.hxx>
49 #include <sfx2/request.hxx>
50 #include "referers.hxx"
51 #include "app.hrc"
52 #include "sfx2/sfxresid.hxx"
53 #include "objshimp.hxx"
54 #include <sfx2/appuno.hxx>
55 #include "imestatuswindow.hxx"
56 #include "appbaslib.hxx"
58 #include <basic/basicmanagerrepository.hxx>
59 #include <basic/basmgr.hxx>
61 using ::basic::BasicManagerRepository;
62 using ::basic::BasicManagerCreationListener;
63 using ::com::sun::star::uno::Reference;
64 using ::com::sun::star::frame::XModel;
65 using ::com::sun::star::uno::XInterface;
67 class SfxBasicManagerCreationListener : public ::basic::BasicManagerCreationListener
69 private:
70 SfxAppData_Impl& m_rAppData;
72 public:
73 SfxBasicManagerCreationListener( SfxAppData_Impl& _rAppData ) :m_rAppData( _rAppData ) { }
75 virtual ~SfxBasicManagerCreationListener();
77 virtual void onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager );
80 SfxBasicManagerCreationListener::~SfxBasicManagerCreationListener()
84 void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager )
86 if ( _rxForDocument == NULL )
87 m_rAppData.OnApplicationBasicManagerCreated( _rBasicManager );
90 SfxAppData_Impl::SfxAppData_Impl( SfxApplication* )
91 : pDdeService( 0 )
92 , pDocTopics( 0 )
93 , pTriggerTopic(0)
94 , pDdeService2(0)
95 , pFactArr(0)
96 , pTopFrames( new SfxFrameArr_Impl )
97 , pMatcher( 0 )
98 , pBasicResMgr( 0 )
99 , pSvtResMgr( 0 )
100 , pAppDispatch(NULL)
101 , pTemplates( 0 )
102 , pPool(0)
103 , pDisabledSlotList( 0 )
104 , pSaveOptions( 0 )
105 , pHelpOptions( 0 )
106 , pProgress(0)
107 , pTemplateCommon( 0 )
108 , nDocModalMode(0)
109 , nAutoTabPageId(0)
110 , nRescheduleLocks(0)
111 , nInReschedule(0)
112 , m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(comphelper::getProcessServiceFactory()))
113 , pTbxCtrlFac(0)
114 , pStbCtrlFac(0)
115 , pViewFrames(0)
116 , pObjShells(0)
117 , pSfxResManager(0)
118 , pOfaResMgr(0)
119 , pBasicManager( new SfxBasicManagerHolder )
120 , pBasMgrListener( new SfxBasicManagerCreationListener( *this ) )
121 , pViewFrame( 0 )
122 , pSlotPool( 0 )
123 , pResMgr( 0 )
124 , pAppDispat( 0 )
125 , pInterfaces( 0 )
126 , nDocNo(0)
127 , nInterfaces( 0 )
128 , bDowning( sal_True )
129 , bInQuit( sal_False )
130 , bInvalidateOnUnlock( sal_False )
131 , bODFVersionWarningLater( sal_False )
134 #ifndef DISABLE_SCRIPTING
135 BasicManagerRepository::registerCreationListener( *pBasMgrListener );
136 #endif
139 SfxAppData_Impl::~SfxAppData_Impl()
141 DeInitDDE();
142 delete pTopFrames;
143 delete pBasicManager;
145 #ifndef DISABLE_SCRIPTING
146 BasicManagerRepository::revokeCreationListener( *pBasMgrListener );
147 delete pBasMgrListener;
148 #endif
151 SfxDocumentTemplates* SfxAppData_Impl::GetDocumentTemplates()
153 if ( !pTemplates )
154 pTemplates = new SfxDocumentTemplates;
155 else
156 pTemplates->ReInitFromComponent();
157 return pTemplates;
160 void SfxAppData_Impl::OnApplicationBasicManagerCreated( BasicManager& _rBasicManager )
162 #ifdef DISABLE_SCRIPTING
163 (void) _rBasicManager;
164 #else
165 pBasicManager->reset( &_rBasicManager );
167 // global constants, additionally to the ones already added by createApplicationBasicManager:
168 // ThisComponent
169 Reference< XInterface > xCurrentComponent = SfxObjectShell::GetCurrentComponent();
170 _rBasicManager.SetGlobalUNOConstant( "ThisComponent", makeAny( xCurrentComponent ) );
171 #endif
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */