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 <osl/mutex.hxx>
27 #include <vcl/menu.hxx>
28 #include <vcl/msgbox.hxx>
29 #include <vcl/wrkwin.hxx>
30 #include <comphelper/processfactory.hxx>
32 #include <sfx2/viewfrm.hxx>
33 #include "appdata.hxx"
34 #include <sfx2/dispatch.hxx>
35 #include <sfx2/event.hxx>
36 #include "sfxtypes.hxx"
37 #include <sfx2/doctempl.hxx>
38 #include "arrdecl.hxx"
39 #include <sfx2/docfac.hxx>
40 #include <sfx2/docfile.hxx>
41 #include <sfx2/request.hxx>
42 #include <sfx2/sidebar/Theme.hxx>
44 #include <sfx2/sfxresid.hxx>
45 #include "objshimp.hxx"
46 #include "imestatuswindow.hxx"
47 #include "appbaslib.hxx"
48 #include <childwinimpl.hxx>
50 #include <basic/basicmanagerrepository.hxx>
51 #include <basic/basmgr.hxx>
53 using ::basic::BasicManagerRepository
;
54 using ::basic::BasicManagerCreationListener
;
55 using ::com::sun::star::uno::Reference
;
56 using ::com::sun::star::frame::XModel
;
57 using ::com::sun::star::uno::XInterface
;
59 class SfxBasicManagerCreationListener
: public ::basic::BasicManagerCreationListener
62 SfxAppData_Impl
& m_rAppData
;
65 SfxBasicManagerCreationListener( SfxAppData_Impl
& _rAppData
) :m_rAppData( _rAppData
) { }
67 virtual ~SfxBasicManagerCreationListener();
69 virtual void onBasicManagerCreated( const Reference
< XModel
>& _rxForDocument
, BasicManager
& _rBasicManager
) SAL_OVERRIDE
;
72 SfxBasicManagerCreationListener::~SfxBasicManagerCreationListener()
76 void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference
< XModel
>& _rxForDocument
, BasicManager
& _rBasicManager
)
78 if ( _rxForDocument
== NULL
)
79 m_rAppData
.OnApplicationBasicManagerCreated( _rBasicManager
);
82 SfxAppData_Impl::SfxAppData_Impl( SfxApplication
* )
88 , pTopFrames( new SfxFrameArr_Impl
)
90 #if HAVE_FEATURE_SCRIPTING
96 #if HAVE_FEATURE_SCRIPTING
107 , nRescheduleLocks(0)
109 , m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(comphelper::getProcessComponentContext()))
117 , pBasicManager( new SfxBasicManagerHolder
)
118 , pBasMgrListener( new SfxBasicManagerCreationListener( *this ) )
125 , bDispatcherLocked( false )
128 , bInvalidateOnUnlock( false )
129 , bODFVersionWarningLater( false )
132 #if HAVE_FEATURE_SCRIPTING
133 BasicManagerRepository::registerCreationListener( *pBasMgrListener
);
137 SfxAppData_Impl::~SfxAppData_Impl()
141 delete pBasicManager
;
143 #if HAVE_FEATURE_SCRIPTING
144 BasicManagerRepository::revokeCreationListener( *pBasMgrListener
);
145 delete pBasMgrListener
;
149 SfxDocumentTemplates
* SfxAppData_Impl::GetDocumentTemplates()
152 pTemplates
= new SfxDocumentTemplates
;
154 pTemplates
->ReInitFromComponent();
158 void SfxAppData_Impl::OnApplicationBasicManagerCreated( BasicManager
& _rBasicManager
)
160 #if !HAVE_FEATURE_SCRIPTING
161 (void) _rBasicManager
;
163 pBasicManager
->reset( &_rBasicManager
);
165 // global constants, additionally to the ones already added by createApplicationBasicManager:
167 Reference
< XInterface
> xCurrentComponent
= SfxObjectShell::GetCurrentComponent();
168 _rBasicManager
.SetGlobalUNOConstant( "ThisComponent", makeAny( xCurrentComponent
) );
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */