xref: /AOO41X/main/sfx2/source/appl/appdata.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
30*cdf0e10cSrcweir #include <tools/cachestr.hxx>
31*cdf0e10cSrcweir #include <tools/config.hxx>
32*cdf0e10cSrcweir #ifndef _INETSTRM_HXX //autogen
33*cdf0e10cSrcweir #include <svl/inetstrm.hxx>
34*cdf0e10cSrcweir #endif
35*cdf0e10cSrcweir #include <svl/stritem.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #define _SVSTDARR_STRINGS
38*cdf0e10cSrcweir #include <svl/svstdarr.hxx>
39*cdf0e10cSrcweir #include <vos/mutex.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include <vcl/menu.hxx>
42*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
43*cdf0e10cSrcweir #include <svl/dateitem.hxx>
44*cdf0e10cSrcweir #include <vcl/menu.hxx>
45*cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
46*cdf0e10cSrcweir #include "comphelper/processfactory.hxx"
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
49*cdf0e10cSrcweir #include "appdata.hxx"
50*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
51*cdf0e10cSrcweir #include <sfx2/event.hxx>
52*cdf0e10cSrcweir #include "sfxtypes.hxx"
53*cdf0e10cSrcweir #include <sfx2/doctempl.hxx>
54*cdf0e10cSrcweir #include "arrdecl.hxx"
55*cdf0e10cSrcweir #include <sfx2/docfac.hxx>
56*cdf0e10cSrcweir #include <sfx2/docfile.hxx>
57*cdf0e10cSrcweir #include <sfx2/request.hxx>
58*cdf0e10cSrcweir #include "referers.hxx"
59*cdf0e10cSrcweir #include "app.hrc"
60*cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
61*cdf0e10cSrcweir #include "objshimp.hxx"
62*cdf0e10cSrcweir #include <sfx2/appuno.hxx>
63*cdf0e10cSrcweir #include "imestatuswindow.hxx"
64*cdf0e10cSrcweir #include "appbaslib.hxx"
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir #include <basic/basicmanagerrepository.hxx>
67*cdf0e10cSrcweir #include <basic/basmgr.hxx>
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir using ::basic::BasicManagerRepository;
70*cdf0e10cSrcweir using ::basic::BasicManagerCreationListener;
71*cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
72*cdf0e10cSrcweir using ::com::sun::star::frame::XModel;
73*cdf0e10cSrcweir using ::com::sun::star::uno::XInterface;
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir class SfxBasicManagerCreationListener : public ::basic::BasicManagerCreationListener
76*cdf0e10cSrcweir {
77*cdf0e10cSrcweir private:
78*cdf0e10cSrcweir     SfxAppData_Impl& m_rAppData;
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir public:
81*cdf0e10cSrcweir     SfxBasicManagerCreationListener( SfxAppData_Impl& _rAppData ) :m_rAppData( _rAppData ) { }
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir     virtual void onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager );
84*cdf0e10cSrcweir };
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager )
87*cdf0e10cSrcweir {
88*cdf0e10cSrcweir     if ( _rxForDocument == NULL )
89*cdf0e10cSrcweir         m_rAppData.OnApplicationBasicManagerCreated( _rBasicManager );
90*cdf0e10cSrcweir }
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir SfxAppData_Impl::SfxAppData_Impl( SfxApplication* ) :
93*cdf0e10cSrcweir 		pDdeService( 0 ),
94*cdf0e10cSrcweir 		pDocTopics( 0 ),
95*cdf0e10cSrcweir 		pTriggerTopic(0),
96*cdf0e10cSrcweir 		pDdeService2(0),
97*cdf0e10cSrcweir 		pFactArr(0),
98*cdf0e10cSrcweir 		pTopFrames( new SfxFrameArr_Impl ),
99*cdf0e10cSrcweir 		pInitLinkList(0),
100*cdf0e10cSrcweir 		pMatcher( 0 ),
101*cdf0e10cSrcweir 		pBasicResMgr( 0 ),
102*cdf0e10cSrcweir 		pSvtResMgr( 0 ),
103*cdf0e10cSrcweir 		pAppDispatch(NULL),
104*cdf0e10cSrcweir         pTemplates( 0 ),
105*cdf0e10cSrcweir 		pPool(0),
106*cdf0e10cSrcweir 		pDisabledSlotList( 0 ),
107*cdf0e10cSrcweir 		pSecureURLs(0),
108*cdf0e10cSrcweir         pSaveOptions( 0 ),
109*cdf0e10cSrcweir         pUndoOptions( 0 ),
110*cdf0e10cSrcweir         pHelpOptions( 0 ),
111*cdf0e10cSrcweir 		pProgress(0),
112*cdf0e10cSrcweir 		pTemplateCommon( 0 ),
113*cdf0e10cSrcweir 		nDocModalMode(0),
114*cdf0e10cSrcweir 		nAutoTabPageId(0),
115*cdf0e10cSrcweir         nRescheduleLocks(0),
116*cdf0e10cSrcweir         nInReschedule(0),
117*cdf0e10cSrcweir         nAsynchronCalls(0),
118*cdf0e10cSrcweir         m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(comphelper::getProcessServiceFactory()))
119*cdf0e10cSrcweir     , pTbxCtrlFac(0)
120*cdf0e10cSrcweir     , pStbCtrlFac(0)
121*cdf0e10cSrcweir     , pViewFrames(0)
122*cdf0e10cSrcweir     , pObjShells(0)
123*cdf0e10cSrcweir     , pSfxResManager(0)
124*cdf0e10cSrcweir     , pOfaResMgr(0)
125*cdf0e10cSrcweir     , pSimpleResManager(0)
126*cdf0e10cSrcweir     , pBasicManager( new SfxBasicManagerHolder )
127*cdf0e10cSrcweir     , pBasMgrListener( new SfxBasicManagerCreationListener( *this ) )
128*cdf0e10cSrcweir 	, pViewFrame( 0 )
129*cdf0e10cSrcweir     , pSlotPool( 0 )
130*cdf0e10cSrcweir 	, pResMgr( 0 )
131*cdf0e10cSrcweir 	, pAppDispat( 0 )
132*cdf0e10cSrcweir 	, pInterfaces( 0 )
133*cdf0e10cSrcweir     , nDocNo(0)
134*cdf0e10cSrcweir 	, nInterfaces( 0 )
135*cdf0e10cSrcweir     , bDowning( sal_True )
136*cdf0e10cSrcweir     , bInQuit( sal_False )
137*cdf0e10cSrcweir     , bInvalidateOnUnlock( sal_False )
138*cdf0e10cSrcweir     , bODFVersionWarningLater( sal_False )
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir {
141*cdf0e10cSrcweir     BasicManagerRepository::registerCreationListener( *pBasMgrListener );
142*cdf0e10cSrcweir }
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir SfxAppData_Impl::~SfxAppData_Impl()
145*cdf0e10cSrcweir {
146*cdf0e10cSrcweir     DeInitDDE();
147*cdf0e10cSrcweir 	delete pTopFrames;
148*cdf0e10cSrcweir 	delete pSecureURLs;
149*cdf0e10cSrcweir     delete pBasicManager;
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir     BasicManagerRepository::revokeCreationListener( *pBasMgrListener );
152*cdf0e10cSrcweir     delete pBasMgrListener;
153*cdf0e10cSrcweir }
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir void SfxAppData_Impl::UpdateApplicationSettings( sal_Bool bDontHide )
156*cdf0e10cSrcweir {
157*cdf0e10cSrcweir 	AllSettings aAllSet = Application::GetSettings();
158*cdf0e10cSrcweir 	StyleSettings aStyleSet = aAllSet.GetStyleSettings();
159*cdf0e10cSrcweir 	sal_uInt32 nStyleOptions = aStyleSet.GetOptions();
160*cdf0e10cSrcweir 	if ( bDontHide )
161*cdf0e10cSrcweir 		nStyleOptions &= ~STYLE_OPTION_HIDEDISABLED;
162*cdf0e10cSrcweir 	else
163*cdf0e10cSrcweir 		nStyleOptions |= STYLE_OPTION_HIDEDISABLED;
164*cdf0e10cSrcweir 	aStyleSet.SetOptions( nStyleOptions );
165*cdf0e10cSrcweir 	aAllSet.SetStyleSettings( aStyleSet );
166*cdf0e10cSrcweir 	Application::SetSettings( aAllSet );
167*cdf0e10cSrcweir }
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir SfxDocumentTemplates* SfxAppData_Impl::GetDocumentTemplates()
170*cdf0e10cSrcweir {
171*cdf0e10cSrcweir     if ( !pTemplates )
172*cdf0e10cSrcweir         pTemplates = new SfxDocumentTemplates;
173*cdf0e10cSrcweir     else
174*cdf0e10cSrcweir         pTemplates->ReInitFromComponent();
175*cdf0e10cSrcweir     return pTemplates;
176*cdf0e10cSrcweir }
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir void SfxAppData_Impl::OnApplicationBasicManagerCreated( BasicManager& _rBasicManager )
179*cdf0e10cSrcweir {
180*cdf0e10cSrcweir     pBasicManager->reset( &_rBasicManager );
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir     // global constants, additionally to the ones already added by createApplicationBasicManager:
183*cdf0e10cSrcweir     // ThisComponent
184*cdf0e10cSrcweir     Reference< XInterface > xCurrentComponent = SfxObjectShell::GetCurrentComponent();
185*cdf0e10cSrcweir     _rBasicManager.SetGlobalUNOConstant( "ThisComponent", makeAny( xCurrentComponent ) );
186*cdf0e10cSrcweir }
187