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 <tools/config.hxx>
23 #include <svl/stritem.hxx>
25 #include <vcl/menu.hxx>
26 #include <vcl/wrkwin.hxx>
27 #include <comphelper/processfactory.hxx>
29 #include <sfx2/viewfrm.hxx>
30 #include <appdata.hxx>
31 #include <sfx2/dispatch.hxx>
32 #include <sfx2/event.hxx>
33 #include <sfxpicklist.hxx>
34 #include <sfxtypes.hxx>
35 #include <sfx2/doctempl.hxx>
36 #include <arrdecl.hxx>
37 #include <sfx2/docfac.hxx>
38 #include <sfx2/docfile.hxx>
39 #include <sfx2/request.hxx>
40 #include <sfx2/sidebar/Theme.hxx>
41 #include <sfx2/unoctitm.hxx>
42 #include <objshimp.hxx>
43 #include "imestatuswindow.hxx"
44 #include <appbaslib.hxx>
45 #include <childwinimpl.hxx>
46 #include <svl/svdde.hxx>
48 #include <basic/basicmanagerrepository.hxx>
49 #include <basic/basmgr.hxx>
51 using ::basic::BasicManagerRepository
;
52 using ::basic::BasicManagerCreationListener
;
53 using ::com::sun::star::uno::Reference
;
54 using ::com::sun::star::frame::XModel
;
55 using ::com::sun::star::uno::XInterface
;
57 class SfxBasicManagerCreationListener
: public ::basic::BasicManagerCreationListener
60 SfxAppData_Impl
& m_rAppData
;
63 explicit SfxBasicManagerCreationListener(SfxAppData_Impl
& _rAppData
)
64 : m_rAppData(_rAppData
)
68 virtual ~SfxBasicManagerCreationListener();
70 virtual void onBasicManagerCreated( const Reference
< XModel
>& _rxForDocument
, BasicManager
& _rBasicManager
) override
;
73 SfxBasicManagerCreationListener::~SfxBasicManagerCreationListener()
77 void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference
< XModel
>& _rxForDocument
, BasicManager
& _rBasicManager
)
79 if ( _rxForDocument
== nullptr )
80 m_rAppData
.OnApplicationBasicManagerCreated( _rBasicManager
);
83 SfxAppData_Impl::SfxAppData_Impl()
84 : pDdeService( nullptr )
85 , pDocTopics( nullptr )
86 , pTriggerTopic(nullptr)
87 , pDdeService2(nullptr)
90 , m_pToolsErrorHdl(nullptr)
91 , m_pSoErrorHdl(nullptr)
92 #if HAVE_FEATURE_SCRIPTING
93 , m_pSbxErrorHdl(nullptr)
95 , pTemplates( nullptr )
101 , m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(comphelper::getProcessComponentContext()))
102 , pTbxCtrlFac(nullptr)
103 , pStbCtrlFac(nullptr)
104 , pViewFrames(nullptr)
105 , pViewShells(nullptr)
106 , pObjShells(nullptr)
107 , pBasicManager( new SfxBasicManagerHolder
)
108 , pBasMgrListener( new SfxBasicManagerCreationListener( *this ) )
109 , pViewFrame( nullptr )
110 , pSlotPool( nullptr )
111 , pAppDispat( nullptr )
116 #if HAVE_FEATURE_SCRIPTING
117 BasicManagerRepository::registerCreationListener( *pBasMgrListener
);
121 SfxAppData_Impl::~SfxAppData_Impl()
124 pBasicManager
.reset();
126 #if HAVE_FEATURE_SCRIPTING
127 BasicManagerRepository::revokeCreationListener( *pBasMgrListener
);
128 pBasMgrListener
.reset();
132 SfxDocumentTemplates
* SfxAppData_Impl::GetDocumentTemplates()
135 pTemplates
= new SfxDocumentTemplates
;
137 pTemplates
->ReInitFromComponent();
141 void SfxAppData_Impl::OnApplicationBasicManagerCreated( BasicManager
& _rBasicManager
)
143 #if !HAVE_FEATURE_SCRIPTING
144 (void) _rBasicManager
;
146 pBasicManager
->reset( &_rBasicManager
);
148 // global constants, additionally to the ones already added by createApplicationBasicManager:
150 Reference
< XInterface
> xCurrentComponent
= SfxObjectShell::GetCurrentComponent();
151 _rBasicManager
.SetGlobalUNOConstant( "ThisComponent", makeAny( xCurrentComponent
) );
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */