bump product version to 4.2.0.1
[LibreOffice.git] / sfx2 / source / appl / appdata.cxx
blobccc9eb1574ec9d876bb15ada00a7335c4232cf33
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/config.hxx>
21 #include <svl/stritem.hxx>
23 #include <osl/mutex.hxx>
25 #include <vcl/menu.hxx>
26 #include <vcl/msgbox.hxx>
27 #include <svl/dateitem.hxx>
28 #include <vcl/wrkwin.hxx>
29 #include <comphelper/processfactory.hxx>
31 #include <sfx2/viewfrm.hxx>
32 #include "appdata.hxx"
33 #include <sfx2/dispatch.hxx>
34 #include <sfx2/event.hxx>
35 #include "sfxtypes.hxx"
36 #include <sfx2/doctempl.hxx>
37 #include "arrdecl.hxx"
38 #include <sfx2/docfac.hxx>
39 #include <sfx2/docfile.hxx>
40 #include <sfx2/request.hxx>
41 #include <sfx2/sidebar/Theme.hxx>
42 #include "app.hrc"
43 #include <sfx2/sfxresid.hxx>
44 #include "objshimp.hxx"
45 #include <sfx2/appuno.hxx>
46 #include "imestatuswindow.hxx"
47 #include "appbaslib.hxx"
49 #include <basic/basicmanagerrepository.hxx>
50 #include <basic/basmgr.hxx>
52 using ::basic::BasicManagerRepository;
53 using ::basic::BasicManagerCreationListener;
54 using ::com::sun::star::uno::Reference;
55 using ::com::sun::star::frame::XModel;
56 using ::com::sun::star::uno::XInterface;
58 class SfxBasicManagerCreationListener : public ::basic::BasicManagerCreationListener
60 private:
61 SfxAppData_Impl& m_rAppData;
63 public:
64 SfxBasicManagerCreationListener( SfxAppData_Impl& _rAppData ) :m_rAppData( _rAppData ) { }
66 virtual ~SfxBasicManagerCreationListener();
68 virtual void onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager );
71 SfxBasicManagerCreationListener::~SfxBasicManagerCreationListener()
75 void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager )
77 if ( _rxForDocument == NULL )
78 m_rAppData.OnApplicationBasicManagerCreated( _rBasicManager );
81 SfxAppData_Impl::SfxAppData_Impl( SfxApplication* )
82 : pDdeService( 0 )
83 , pDocTopics( 0 )
84 , pTriggerTopic(0)
85 , pDdeService2(0)
86 , pFactArr(0)
87 , pTopFrames( new SfxFrameArr_Impl )
88 , pMatcher( 0 )
89 #ifndef DISABLE_SCRIPTING
90 , pBasicResMgr( 0 )
91 #endif
92 , pSvtResMgr( 0 )
93 , pAppDispatch(NULL)
94 , pTemplates( 0 )
95 , pPool(0)
96 , pSaveOptions( 0 )
97 , pHelpOptions( 0 )
98 , pProgress(0)
99 , pTemplateCommon( 0 )
100 , nDocModalMode(0)
101 , nAutoTabPageId(0)
102 , nRescheduleLocks(0)
103 , nInReschedule(0)
104 , m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(comphelper::getProcessComponentContext()))
105 , pTbxCtrlFac(0)
106 , pStbCtrlFac(0)
107 , pViewFrames(0)
108 , pObjShells(0)
109 , pSfxResManager(0)
110 , pOfaResMgr(0)
111 , pBasicManager( new SfxBasicManagerHolder )
112 , pBasMgrListener( new SfxBasicManagerCreationListener( *this ) )
113 , pViewFrame( 0 )
114 , pSlotPool( 0 )
115 , pAppDispat( 0 )
116 , pInterfaces( 0 )
117 , nDocNo(0)
118 , nInterfaces( 0 )
119 , bDowning( sal_True )
120 , bInQuit( sal_False )
121 , bInvalidateOnUnlock( sal_False )
122 , bODFVersionWarningLater( sal_False )
125 #ifndef DISABLE_SCRIPTING
126 BasicManagerRepository::registerCreationListener( *pBasMgrListener );
127 #endif
130 SfxAppData_Impl::~SfxAppData_Impl()
132 DeInitDDE();
133 delete pTopFrames;
134 delete pBasicManager;
136 #ifndef DISABLE_SCRIPTING
137 BasicManagerRepository::revokeCreationListener( *pBasMgrListener );
138 delete pBasMgrListener;
139 #endif
142 SfxDocumentTemplates* SfxAppData_Impl::GetDocumentTemplates()
144 if ( !pTemplates )
145 pTemplates = new SfxDocumentTemplates;
146 else
147 pTemplates->ReInitFromComponent();
148 return pTemplates;
151 void SfxAppData_Impl::OnApplicationBasicManagerCreated( BasicManager& _rBasicManager )
153 #ifdef DISABLE_SCRIPTING
154 (void) _rBasicManager;
155 #else
156 pBasicManager->reset( &_rBasicManager );
158 // global constants, additionally to the ones already added by createApplicationBasicManager:
159 // ThisComponent
160 Reference< XInterface > xCurrentComponent = SfxObjectShell::GetCurrentComponent();
161 _rBasicManager.SetGlobalUNOConstant( "ThisComponent", makeAny( xCurrentComponent ) );
162 #endif
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */