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