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