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 <config_features.h>
22 #include <appdata.hxx>
23 #include <sfxpicklist.hxx>
24 #include <sfx2/dispatch.hxx>
25 #include <sfx2/doctempl.hxx>
26 #include <sfx2/fcontnr.hxx>
27 #include <sfx2/module.hxx>
28 #include <sfx2/msgpool.hxx>
29 #include <sfx2/sidebar/Theme.hxx>
30 #include <sfx2/objsh.hxx>
31 #include <appbaslib.hxx>
32 #include <childwinimpl.hxx>
33 #include <ctrlfactoryimpl.hxx>
34 #include <shellimpl.hxx>
35 #include <unoctitm.hxx>
36 #include <svl/svdde.hxx>
38 #include <basic/basicmanagerrepository.hxx>
39 #include <basic/basmgr.hxx>
40 #include <basic/basrdll.hxx>
42 using ::basic::BasicManagerRepository
;
43 using ::basic::BasicManagerCreationListener
;
44 using ::com::sun::star::uno::Reference
;
45 using ::com::sun::star::frame::XModel
;
46 using ::com::sun::star::uno::XInterface
;
48 static BasicDLL
* pBasic
= nullptr;
50 class SfxBasicManagerCreationListener
: public ::basic::BasicManagerCreationListener
53 SfxAppData_Impl
& m_rAppData
;
56 explicit SfxBasicManagerCreationListener(SfxAppData_Impl
& _rAppData
)
57 : m_rAppData(_rAppData
)
61 virtual ~SfxBasicManagerCreationListener();
63 virtual void onBasicManagerCreated( const Reference
< XModel
>& _rxForDocument
, BasicManager
& _rBasicManager
) override
;
66 SfxBasicManagerCreationListener::~SfxBasicManagerCreationListener()
70 void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference
< XModel
>& _rxForDocument
, BasicManager
& _rBasicManager
)
72 if ( _rxForDocument
== nullptr )
73 m_rAppData
.OnApplicationBasicManagerCreated( _rBasicManager
);
76 SfxAppData_Impl::SfxAppData_Impl()
81 , pBasicManager( new SfxBasicManagerHolder
)
82 , pBasMgrListener( new SfxBasicManagerCreationListener( *this ) )
83 , pViewFrame( nullptr )
88 pBasic
= new BasicDLL
;
90 #if HAVE_FEATURE_SCRIPTING
91 BasicManagerRepository::registerCreationListener( *pBasMgrListener
);
95 SfxAppData_Impl::~SfxAppData_Impl()
98 pBasicManager
.reset();
100 #if HAVE_FEATURE_SCRIPTING
101 BasicManagerRepository::revokeCreationListener( *pBasMgrListener
);
102 pBasMgrListener
.reset();
108 SfxDocumentTemplates
* SfxAppData_Impl::GetDocumentTemplates()
111 pTemplates
.reset(new SfxDocumentTemplates
);
113 pTemplates
->ReInitFromComponent();
114 return pTemplates
.get();
117 void SfxAppData_Impl::OnApplicationBasicManagerCreated( BasicManager
& _rBasicManager
)
119 #if !HAVE_FEATURE_SCRIPTING
120 (void) _rBasicManager
;
122 pBasicManager
->reset( &_rBasicManager
);
124 // global constants, additionally to the ones already added by createApplicationBasicManager:
126 Reference
< XInterface
> xCurrentComponent
= SfxObjectShell::GetCurrentComponent();
127 _rBasicManager
.SetGlobalUNOConstant( "ThisComponent", makeAny( xCurrentComponent
) );
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */