tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / sfx2 / source / appl / appdata.cxx
blob70be138696890c502ec7829a512f6ca391349f4a
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 <config_features.h>
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>
28 #include <sfx2/sidebar/Theme.hxx>
29 #include <sfx2/objsh.hxx>
30 #include <appbaslib.hxx>
31 #include <unoctitm.hxx>
32 #include <svl/svdde.hxx>
34 #include <basic/basicmanagerrepository.hxx>
35 #include <basic/basmgr.hxx>
36 #include <basic/basrdll.hxx>
38 using ::basic::BasicManagerRepository;
39 using ::basic::BasicManagerCreationListener;
40 using ::com::sun::star::uno::Reference;
41 using ::com::sun::star::frame::XModel;
42 using ::com::sun::star::uno::XInterface;
44 static BasicDLL* pBasic = nullptr;
46 class SfxBasicManagerCreationListener : public ::basic::BasicManagerCreationListener
48 private:
49 SfxAppData_Impl& m_rAppData;
51 public:
52 explicit SfxBasicManagerCreationListener(SfxAppData_Impl& _rAppData)
53 : m_rAppData(_rAppData)
57 virtual ~SfxBasicManagerCreationListener();
59 virtual void onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager ) override;
62 SfxBasicManagerCreationListener::~SfxBasicManagerCreationListener()
66 void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager )
68 if ( _rxForDocument == nullptr )
69 m_rAppData.OnApplicationBasicManagerCreated( _rBasicManager );
72 SfxAppData_Impl::SfxAppData_Impl()
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 , bClosingDocs( false )
85 pBasic = new BasicDLL;
87 #if HAVE_FEATURE_SCRIPTING
88 BasicManagerRepository::registerCreationListener( *pBasMgrListener );
89 #endif
92 SfxAppData_Impl::~SfxAppData_Impl()
94 DeInitDDE();
95 pBasicManager.reset();
97 #if HAVE_FEATURE_SCRIPTING
98 BasicManagerRepository::revokeCreationListener( *pBasMgrListener );
99 pBasMgrListener.reset();
100 #endif
102 delete pBasic;
105 SfxDocumentTemplates* SfxAppData_Impl::GetDocumentTemplates()
107 if ( !pTemplates )
108 pTemplates.emplace();
109 else
110 pTemplates->ReInitFromComponent();
111 return &*pTemplates;
114 void SfxAppData_Impl::OnApplicationBasicManagerCreated( BasicManager& _rBasicManager )
116 #if !HAVE_FEATURE_SCRIPTING
117 (void) _rBasicManager;
118 #else
119 pBasicManager->reset( &_rBasicManager );
121 // global constants, additionally to the ones already added by createApplicationBasicManager:
122 // ThisComponent
123 Reference< XInterface > xCurrentComponent = SfxObjectShell::GetCurrentComponent();
124 _rBasicManager.SetGlobalUNOConstant( u"ThisComponent"_ustr, css::uno::Any( xCurrentComponent ) );
125 #endif
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */