Line data Source code
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 <tools/config.hxx>
23 : #include <svl/stritem.hxx>
24 :
25 : #include <osl/mutex.hxx>
26 :
27 : #include <vcl/menu.hxx>
28 : #include <vcl/msgbox.hxx>
29 : #include <vcl/wrkwin.hxx>
30 : #include <comphelper/processfactory.hxx>
31 :
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>
43 : #include "app.hrc"
44 : #include <sfx2/sfxresid.hxx>
45 : #include "objshimp.hxx"
46 : #include "imestatuswindow.hxx"
47 : #include "appbaslib.hxx"
48 : #include <childwinimpl.hxx>
49 :
50 : #include <basic/basicmanagerrepository.hxx>
51 : #include <basic/basmgr.hxx>
52 :
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;
58 :
59 : class SfxBasicManagerCreationListener : public ::basic::BasicManagerCreationListener
60 : {
61 : private:
62 : SfxAppData_Impl& m_rAppData;
63 :
64 : public:
65 208 : SfxBasicManagerCreationListener( SfxAppData_Impl& _rAppData ) :m_rAppData( _rAppData ) { }
66 :
67 : virtual ~SfxBasicManagerCreationListener();
68 :
69 : virtual void onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager ) SAL_OVERRIDE;
70 : };
71 :
72 238 : SfxBasicManagerCreationListener::~SfxBasicManagerCreationListener()
73 : {
74 238 : }
75 :
76 2117 : void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager )
77 : {
78 2117 : if ( _rxForDocument == NULL )
79 111 : m_rAppData.OnApplicationBasicManagerCreated( _rBasicManager );
80 2117 : }
81 :
82 208 : SfxAppData_Impl::SfxAppData_Impl( SfxApplication* )
83 : : pDdeService( 0 )
84 : , pDocTopics( 0 )
85 : , pTriggerTopic(0)
86 : , pDdeService2(0)
87 : , pFactArr(0)
88 208 : , pTopFrames( new SfxFrameArr_Impl )
89 : , pMatcher( 0 )
90 : #if HAVE_FEATURE_SCRIPTING
91 : , pBasicResMgr( 0 )
92 : #endif
93 : , pSvtResMgr( 0 )
94 : , m_pToolsErrorHdl(0)
95 : , m_pSoErrorHdl(0)
96 : #if HAVE_FEATURE_SCRIPTING
97 : , m_pSbxErrorHdl(0)
98 : #endif
99 : , pAppDispatch(NULL)
100 : , pTemplates( 0 )
101 : , pPool(0)
102 : , pSaveOptions( 0 )
103 : , pHelpOptions( 0 )
104 : , pProgress(0)
105 : , nDocModalMode(0)
106 : , nAutoTabPageId(0)
107 : , nRescheduleLocks(0)
108 : , nInReschedule(0)
109 208 : , m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(comphelper::getProcessComponentContext()))
110 : , pTbxCtrlFac(0)
111 : , pStbCtrlFac(0)
112 : , pMenuCtrlFac(0)
113 : , pViewFrames(0)
114 : , pViewShells(0)
115 : , pObjShells(0)
116 : , pSfxResManager(0)
117 208 : , pBasicManager( new SfxBasicManagerHolder )
118 208 : , pBasMgrListener( new SfxBasicManagerCreationListener( *this ) )
119 : , pViewFrame( 0 )
120 : , pSlotPool( 0 )
121 : , pAppDispat( 0 )
122 : , pInterfaces( 0 )
123 : , nDocNo(0)
124 : , nInterfaces( 0 )
125 : , bDispatcherLocked( false )
126 : , bDowning( true )
127 : , bInQuit( false )
128 : , bInvalidateOnUnlock( false )
129 1040 : , bODFVersionWarningLater( false )
130 :
131 : {
132 : #if HAVE_FEATURE_SCRIPTING
133 208 : BasicManagerRepository::registerCreationListener( *pBasMgrListener );
134 : #endif
135 208 : }
136 :
137 238 : SfxAppData_Impl::~SfxAppData_Impl()
138 : {
139 119 : DeInitDDE();
140 119 : delete pTopFrames;
141 119 : delete pBasicManager;
142 :
143 : #if HAVE_FEATURE_SCRIPTING
144 119 : BasicManagerRepository::revokeCreationListener( *pBasMgrListener );
145 119 : delete pBasMgrListener;
146 : #endif
147 119 : }
148 :
149 4 : SfxDocumentTemplates* SfxAppData_Impl::GetDocumentTemplates()
150 : {
151 4 : if ( !pTemplates )
152 3 : pTemplates = new SfxDocumentTemplates;
153 : else
154 1 : pTemplates->ReInitFromComponent();
155 4 : return pTemplates;
156 : }
157 :
158 111 : void SfxAppData_Impl::OnApplicationBasicManagerCreated( BasicManager& _rBasicManager )
159 : {
160 : #if !HAVE_FEATURE_SCRIPTING
161 : (void) _rBasicManager;
162 : #else
163 111 : pBasicManager->reset( &_rBasicManager );
164 :
165 : // global constants, additionally to the ones already added by createApplicationBasicManager:
166 : // ThisComponent
167 111 : Reference< XInterface > xCurrentComponent = SfxObjectShell::GetCurrentComponent();
168 111 : _rBasicManager.SetGlobalUNOConstant( "ThisComponent", makeAny( xCurrentComponent ) );
169 : #endif
170 111 : }
171 :
172 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|