1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
61 SfxAppData_Impl
& m_rAppData
;
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
* )
87 , pTopFrames( new SfxFrameArr_Impl
)
89 #ifndef DISABLE_SCRIPTING
99 , pTemplateCommon( 0 )
102 , nRescheduleLocks(0)
104 , m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(comphelper::getProcessComponentContext()))
111 , pBasicManager( new SfxBasicManagerHolder
)
112 , pBasMgrListener( new SfxBasicManagerCreationListener( *this ) )
119 , bDowning( sal_True
)
120 , bInQuit( sal_False
)
121 , bInvalidateOnUnlock( sal_False
)
122 , bODFVersionWarningLater( sal_False
)
125 #ifndef DISABLE_SCRIPTING
126 BasicManagerRepository::registerCreationListener( *pBasMgrListener
);
130 SfxAppData_Impl::~SfxAppData_Impl()
134 delete pBasicManager
;
136 #ifndef DISABLE_SCRIPTING
137 BasicManagerRepository::revokeCreationListener( *pBasMgrListener
);
138 delete pBasMgrListener
;
142 SfxDocumentTemplates
* SfxAppData_Impl::GetDocumentTemplates()
145 pTemplates
= new SfxDocumentTemplates
;
147 pTemplates
->ReInitFromComponent();
151 void SfxAppData_Impl::OnApplicationBasicManagerCreated( BasicManager
& _rBasicManager
)
153 #ifdef DISABLE_SCRIPTING
154 (void) _rBasicManager
;
156 pBasicManager
->reset( &_rBasicManager
);
158 // global constants, additionally to the ones already added by createApplicationBasicManager:
160 Reference
< XInterface
> xCurrentComponent
= SfxObjectShell::GetCurrentComponent();
161 _rBasicManager
.SetGlobalUNOConstant( "ThisComponent", makeAny( xCurrentComponent
) );
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */