LibreOffice Module sfx2 (master) 1
appdata.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <config_features.h>
21
22#include <appdata.hxx>
23#include <sfx2/tbxctrl.hxx>
24#include <sfx2/stbitem.hxx>
25#include <sfx2/childwin.hxx>
26#include <sfx2/doctempl.hxx>
27#include <sfx2/module.hxx>
29#include <sfx2/objsh.hxx>
30#include <appbaslib.hxx>
31#include <unoctitm.hxx>
32#include <svl/svdde.hxx>
33
35#include <basic/basmgr.hxx>
36#include <basic/basrdll.hxx>
37
38using ::basic::BasicManagerRepository;
39using ::basic::BasicManagerCreationListener;
40using ::com::sun::star::uno::Reference;
41using ::com::sun::star::frame::XModel;
42using ::com::sun::star::uno::XInterface;
43
44static BasicDLL* pBasic = nullptr;
45
47{
48private:
50
51public:
53 : m_rAppData(_rAppData)
54 {
55 }
56
58
59 virtual void onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager ) override;
60};
61
63{
64}
65
66void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager )
67{
68 if ( _rxForDocument == nullptr )
70}
71
73 : pPool(nullptr)
74 , pProgress(nullptr)
75 , nDocModalMode(0)
76 , nRescheduleLocks(0)
77 , pBasicManager( new SfxBasicManagerHolder )
78 , pBasMgrListener( new SfxBasicManagerCreationListener( *this ) )
79 , pViewFrame( nullptr )
80 , bDowning( true )
81 , bInQuit( false )
82
83{
84 pBasic = new BasicDLL;
85
86#if HAVE_FEATURE_SCRIPTING
87 BasicManagerRepository::registerCreationListener( *pBasMgrListener );
88#endif
89}
90
92{
93 DeInitDDE();
94 pBasicManager.reset();
95
96#if HAVE_FEATURE_SCRIPTING
97 BasicManagerRepository::revokeCreationListener( *pBasMgrListener );
98 pBasMgrListener.reset();
99#endif
100
101 delete pBasic;
102}
103
105{
106 if ( !pTemplates )
107 pTemplates.emplace();
108 else
109 pTemplates->ReInitFromComponent();
110 return &*pTemplates;
111}
112
114{
115#if !HAVE_FEATURE_SCRIPTING
116 (void) _rBasicManager;
117#else
118 pBasicManager->reset( &_rBasicManager );
119
120 // global constants, additionally to the ones already added by createApplicationBasicManager:
121 // ThisComponent
122 Reference< XInterface > xCurrentComponent = SfxObjectShell::GetCurrentComponent();
123 _rBasicManager.SetGlobalUNOConstant( "ThisComponent", css::uno::Any( xCurrentComponent ) );
124#endif
125}
126
127/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static BasicDLL * pBasic
Definition: appdata.cxx:44
void SetGlobalUNOConstant(const OUString &rName, const css::uno::Any &_rValue, css::uno::Any *pOldValue=nullptr)
void DeInitDDE()
Definition: appdde.cxx:435
void OnApplicationBasicManagerCreated(BasicManager &_rManager)
called when the Application's BasicManager has been created.
Definition: appdata.cxx:113
std::optional< SfxDocumentTemplates > pTemplates
Definition: appdata.hxx:85
SfxDocumentTemplates * GetDocumentTemplates()
Definition: appdata.cxx:104
std::unique_ptr< SfxBasicManagerHolder > pBasicManager
Definition: appdata.hxx:106
std::unique_ptr< SfxBasicManagerCreationListener > pBasMgrListener
Definition: appdata.hxx:108
virtual ~SfxBasicManagerCreationListener()
Definition: appdata.cxx:62
SfxBasicManagerCreationListener(SfxAppData_Impl &_rAppData)
Definition: appdata.cxx:52
SfxAppData_Impl & m_rAppData
Definition: appdata.cxx:49
virtual void onBasicManagerCreated(const Reference< XModel > &_rxForDocument, BasicManager &_rBasicManager) override
Definition: appdata.cxx:66
helper class which holds and manipulates a BasicManager
Definition: appbaslib.hxx:35
static css::uno::Reference< css::uno::XInterface > GetCurrentComponent()
Definition: objxtor.cxx:915