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 143 : 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 166 : SfxBasicManagerCreationListener::~SfxBasicManagerCreationListener()
70 : {
71 166 : }
72 :
73 1386 : void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager )
74 : {
75 1386 : if ( _rxForDocument == NULL )
76 71 : m_rAppData.OnApplicationBasicManagerCreated( _rBasicManager );
77 1386 : }
78 :
79 143 : SfxAppData_Impl::SfxAppData_Impl( SfxApplication* )
80 : : pDdeService( 0 )
81 : , pDocTopics( 0 )
82 : , pTriggerTopic(0)
83 : , pDdeService2(0)
84 : , pFactArr(0)
85 143 : , pTopFrames( new SfxFrameArr_Impl )
86 : , pMatcher( 0 )
87 : #ifndef DISABLE_SCRIPTING
88 : , pBasicResMgr( 0 )
89 : #endif
90 : , pSvtResMgr( 0 )
91 : , pAppDispatch(NULL)
92 : , pTemplates( 0 )
93 : , pPool(0)
94 : , pSaveOptions( 0 )
95 : , pHelpOptions( 0 )
96 : , pProgress(0)
97 : , pTemplateCommon( 0 )
98 : , nDocModalMode(0)
99 : , nAutoTabPageId(0)
100 : , nRescheduleLocks(0)
101 : , nInReschedule(0)
102 143 : , m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(comphelper::getProcessComponentContext()))
103 : , pTbxCtrlFac(0)
104 : , pStbCtrlFac(0)
105 : , pViewFrames(0)
106 : , pObjShells(0)
107 : , pSfxResManager(0)
108 : , pOfaResMgr(0)
109 143 : , pBasicManager( new SfxBasicManagerHolder )
110 143 : , pBasMgrListener( new SfxBasicManagerCreationListener( *this ) )
111 : , pViewFrame( 0 )
112 : , pSlotPool( 0 )
113 : , pAppDispat( 0 )
114 : , pInterfaces( 0 )
115 : , nDocNo(0)
116 : , nInterfaces( 0 )
117 : , bDowning( true )
118 : , bInQuit( false )
119 : , bInvalidateOnUnlock( false )
120 715 : , bODFVersionWarningLater( false )
121 :
122 : {
123 : #ifndef DISABLE_SCRIPTING
124 143 : BasicManagerRepository::registerCreationListener( *pBasMgrListener );
125 : #endif
126 143 : }
127 :
128 166 : SfxAppData_Impl::~SfxAppData_Impl()
129 : {
130 83 : DeInitDDE();
131 83 : delete pTopFrames;
132 83 : delete pBasicManager;
133 :
134 : #ifndef DISABLE_SCRIPTING
135 83 : BasicManagerRepository::revokeCreationListener( *pBasMgrListener );
136 83 : delete pBasMgrListener;
137 : #endif
138 83 : }
139 :
140 2 : SfxDocumentTemplates* SfxAppData_Impl::GetDocumentTemplates()
141 : {
142 2 : if ( !pTemplates )
143 2 : pTemplates = new SfxDocumentTemplates;
144 : else
145 0 : pTemplates->ReInitFromComponent();
146 2 : return pTemplates;
147 : }
148 :
149 71 : void SfxAppData_Impl::OnApplicationBasicManagerCreated( BasicManager& _rBasicManager )
150 : {
151 : #ifdef DISABLE_SCRIPTING
152 : (void) _rBasicManager;
153 : #else
154 71 : pBasicManager->reset( &_rBasicManager );
155 :
156 : // global constants, additionally to the ones already added by createApplicationBasicManager:
157 : // ThisComponent
158 71 : Reference< XInterface > xCurrentComponent = SfxObjectShell::GetCurrentComponent();
159 71 : _rBasicManager.SetGlobalUNOConstant( "ThisComponent", makeAny( xCurrentComponent ) );
160 : #endif
161 71 : }
162 :
163 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|