1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <tools/config.hxx>
30 #include <svl/stritem.hxx>
32 #include <osl/mutex.hxx>
34 #include <vcl/menu.hxx>
35 #include <vcl/msgbox.hxx>
36 #include <svl/dateitem.hxx>
37 #include <vcl/wrkwin.hxx>
38 #include "comphelper/processfactory.hxx"
40 #include <sfx2/viewfrm.hxx>
41 #include "appdata.hxx"
42 #include <sfx2/dispatch.hxx>
43 #include <sfx2/event.hxx>
44 #include "sfxtypes.hxx"
45 #include <sfx2/doctempl.hxx>
46 #include "arrdecl.hxx"
47 #include <sfx2/docfac.hxx>
48 #include <sfx2/docfile.hxx>
49 #include <sfx2/request.hxx>
50 #include "referers.hxx"
52 #include "sfx2/sfxresid.hxx"
53 #include "objshimp.hxx"
54 #include <sfx2/appuno.hxx>
55 #include "imestatuswindow.hxx"
56 #include "appbaslib.hxx"
58 #include <basic/basicmanagerrepository.hxx>
59 #include <basic/basmgr.hxx>
61 using ::basic::BasicManagerRepository
;
62 using ::basic::BasicManagerCreationListener
;
63 using ::com::sun::star::uno::Reference
;
64 using ::com::sun::star::frame::XModel
;
65 using ::com::sun::star::uno::XInterface
;
67 class SfxBasicManagerCreationListener
: public ::basic::BasicManagerCreationListener
70 SfxAppData_Impl
& m_rAppData
;
73 SfxBasicManagerCreationListener( SfxAppData_Impl
& _rAppData
) :m_rAppData( _rAppData
) { }
75 virtual ~SfxBasicManagerCreationListener();
77 virtual void onBasicManagerCreated( const Reference
< XModel
>& _rxForDocument
, BasicManager
& _rBasicManager
);
80 SfxBasicManagerCreationListener::~SfxBasicManagerCreationListener()
84 void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference
< XModel
>& _rxForDocument
, BasicManager
& _rBasicManager
)
86 if ( _rxForDocument
== NULL
)
87 m_rAppData
.OnApplicationBasicManagerCreated( _rBasicManager
);
90 SfxAppData_Impl::SfxAppData_Impl( SfxApplication
* )
96 , pTopFrames( new SfxFrameArr_Impl
)
103 , pDisabledSlotList( 0 )
107 , pTemplateCommon( 0 )
110 , nRescheduleLocks(0)
112 , m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(comphelper::getProcessServiceFactory()))
119 , pBasicManager( new SfxBasicManagerHolder
)
120 , pBasMgrListener( new SfxBasicManagerCreationListener( *this ) )
128 , bDowning( sal_True
)
129 , bInQuit( sal_False
)
130 , bInvalidateOnUnlock( sal_False
)
131 , bODFVersionWarningLater( sal_False
)
134 #ifndef DISABLE_SCRIPTING
135 BasicManagerRepository::registerCreationListener( *pBasMgrListener
);
139 SfxAppData_Impl::~SfxAppData_Impl()
143 delete pBasicManager
;
145 #ifndef DISABLE_SCRIPTING
146 BasicManagerRepository::revokeCreationListener( *pBasMgrListener
);
147 delete pBasMgrListener
;
151 SfxDocumentTemplates
* SfxAppData_Impl::GetDocumentTemplates()
154 pTemplates
= new SfxDocumentTemplates
;
156 pTemplates
->ReInitFromComponent();
160 void SfxAppData_Impl::OnApplicationBasicManagerCreated( BasicManager
& _rBasicManager
)
162 #ifdef DISABLE_SCRIPTING
163 (void) _rBasicManager
;
165 pBasicManager
->reset( &_rBasicManager
);
167 // global constants, additionally to the ones already added by createApplicationBasicManager:
169 Reference
< XInterface
> xCurrentComponent
= SfxObjectShell::GetCurrentComponent();
170 _rBasicManager
.SetGlobalUNOConstant( "ThisComponent", makeAny( xCurrentComponent
) );
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */