xref: /aoo42x/main/sfx2/source/appl/appdata.cxx (revision d119d52d)
1*d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d119d52dSAndrew Rist  * distributed with this work for additional information
6*d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9*d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*d119d52dSAndrew Rist  *
11*d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*d119d52dSAndrew Rist  *
13*d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15*d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*d119d52dSAndrew Rist  * specific language governing permissions and limitations
18*d119d52dSAndrew Rist  * under the License.
19*d119d52dSAndrew Rist  *
20*d119d52dSAndrew Rist  *************************************************************/
21*d119d52dSAndrew Rist 
22*d119d52dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir #include <tools/cachestr.hxx>
27cdf0e10cSrcweir #include <tools/config.hxx>
28cdf0e10cSrcweir #ifndef _INETSTRM_HXX //autogen
29cdf0e10cSrcweir #include <svl/inetstrm.hxx>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir #include <svl/stritem.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #define _SVSTDARR_STRINGS
34cdf0e10cSrcweir #include <svl/svstdarr.hxx>
35cdf0e10cSrcweir #include <vos/mutex.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <vcl/menu.hxx>
38cdf0e10cSrcweir #include <vcl/msgbox.hxx>
39cdf0e10cSrcweir #include <svl/dateitem.hxx>
40cdf0e10cSrcweir #include <vcl/menu.hxx>
41cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
42cdf0e10cSrcweir #include "comphelper/processfactory.hxx"
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
45cdf0e10cSrcweir #include "appdata.hxx"
46cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
47cdf0e10cSrcweir #include <sfx2/event.hxx>
48cdf0e10cSrcweir #include "sfxtypes.hxx"
49cdf0e10cSrcweir #include <sfx2/doctempl.hxx>
50cdf0e10cSrcweir #include "arrdecl.hxx"
51cdf0e10cSrcweir #include <sfx2/docfac.hxx>
52cdf0e10cSrcweir #include <sfx2/docfile.hxx>
53cdf0e10cSrcweir #include <sfx2/request.hxx>
54cdf0e10cSrcweir #include "referers.hxx"
55cdf0e10cSrcweir #include "app.hrc"
56cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
57cdf0e10cSrcweir #include "objshimp.hxx"
58cdf0e10cSrcweir #include <sfx2/appuno.hxx>
59cdf0e10cSrcweir #include "imestatuswindow.hxx"
60cdf0e10cSrcweir #include "appbaslib.hxx"
61cdf0e10cSrcweir 
62cdf0e10cSrcweir #include <basic/basicmanagerrepository.hxx>
63cdf0e10cSrcweir #include <basic/basmgr.hxx>
64cdf0e10cSrcweir 
65cdf0e10cSrcweir using ::basic::BasicManagerRepository;
66cdf0e10cSrcweir using ::basic::BasicManagerCreationListener;
67cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
68cdf0e10cSrcweir using ::com::sun::star::frame::XModel;
69cdf0e10cSrcweir using ::com::sun::star::uno::XInterface;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir class SfxBasicManagerCreationListener : public ::basic::BasicManagerCreationListener
72cdf0e10cSrcweir {
73cdf0e10cSrcweir private:
74cdf0e10cSrcweir     SfxAppData_Impl& m_rAppData;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir public:
SfxBasicManagerCreationListener(SfxAppData_Impl & _rAppData)77cdf0e10cSrcweir     SfxBasicManagerCreationListener( SfxAppData_Impl& _rAppData ) :m_rAppData( _rAppData ) { }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     virtual void onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager );
80cdf0e10cSrcweir };
81cdf0e10cSrcweir 
onBasicManagerCreated(const Reference<XModel> & _rxForDocument,BasicManager & _rBasicManager)82cdf0e10cSrcweir void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir     if ( _rxForDocument == NULL )
85cdf0e10cSrcweir         m_rAppData.OnApplicationBasicManagerCreated( _rBasicManager );
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
SfxAppData_Impl(SfxApplication *)88cdf0e10cSrcweir SfxAppData_Impl::SfxAppData_Impl( SfxApplication* ) :
89cdf0e10cSrcweir 		pDdeService( 0 ),
90cdf0e10cSrcweir 		pDocTopics( 0 ),
91cdf0e10cSrcweir 		pTriggerTopic(0),
92cdf0e10cSrcweir 		pDdeService2(0),
93cdf0e10cSrcweir 		pFactArr(0),
94cdf0e10cSrcweir 		pTopFrames( new SfxFrameArr_Impl ),
95cdf0e10cSrcweir 		pInitLinkList(0),
96cdf0e10cSrcweir 		pMatcher( 0 ),
97cdf0e10cSrcweir 		pBasicResMgr( 0 ),
98cdf0e10cSrcweir 		pSvtResMgr( 0 ),
99cdf0e10cSrcweir 		pAppDispatch(NULL),
100cdf0e10cSrcweir         pTemplates( 0 ),
101cdf0e10cSrcweir 		pPool(0),
102cdf0e10cSrcweir 		pDisabledSlotList( 0 ),
103cdf0e10cSrcweir 		pSecureURLs(0),
104cdf0e10cSrcweir         pSaveOptions( 0 ),
105cdf0e10cSrcweir         pUndoOptions( 0 ),
106cdf0e10cSrcweir         pHelpOptions( 0 ),
107cdf0e10cSrcweir 		pProgress(0),
108cdf0e10cSrcweir 		pTemplateCommon( 0 ),
109cdf0e10cSrcweir 		nDocModalMode(0),
110cdf0e10cSrcweir 		nAutoTabPageId(0),
111cdf0e10cSrcweir         nRescheduleLocks(0),
112cdf0e10cSrcweir         nInReschedule(0),
113cdf0e10cSrcweir         nAsynchronCalls(0),
114cdf0e10cSrcweir         m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(comphelper::getProcessServiceFactory()))
115cdf0e10cSrcweir     , pTbxCtrlFac(0)
116cdf0e10cSrcweir     , pStbCtrlFac(0)
117cdf0e10cSrcweir     , pViewFrames(0)
118cdf0e10cSrcweir     , pObjShells(0)
119cdf0e10cSrcweir     , pSfxResManager(0)
120cdf0e10cSrcweir     , pOfaResMgr(0)
121cdf0e10cSrcweir     , pSimpleResManager(0)
122cdf0e10cSrcweir     , pBasicManager( new SfxBasicManagerHolder )
123cdf0e10cSrcweir     , pBasMgrListener( new SfxBasicManagerCreationListener( *this ) )
124cdf0e10cSrcweir 	, pViewFrame( 0 )
125cdf0e10cSrcweir     , pSlotPool( 0 )
126cdf0e10cSrcweir 	, pResMgr( 0 )
127cdf0e10cSrcweir 	, pAppDispat( 0 )
128cdf0e10cSrcweir 	, pInterfaces( 0 )
129cdf0e10cSrcweir     , nDocNo(0)
130cdf0e10cSrcweir 	, nInterfaces( 0 )
131cdf0e10cSrcweir     , bDowning( sal_True )
132cdf0e10cSrcweir     , bInQuit( sal_False )
133cdf0e10cSrcweir     , bInvalidateOnUnlock( sal_False )
134cdf0e10cSrcweir     , bODFVersionWarningLater( sal_False )
135cdf0e10cSrcweir 
136cdf0e10cSrcweir {
137cdf0e10cSrcweir     BasicManagerRepository::registerCreationListener( *pBasMgrListener );
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
~SfxAppData_Impl()140cdf0e10cSrcweir SfxAppData_Impl::~SfxAppData_Impl()
141cdf0e10cSrcweir {
142cdf0e10cSrcweir     DeInitDDE();
143cdf0e10cSrcweir 	delete pTopFrames;
144cdf0e10cSrcweir 	delete pSecureURLs;
145cdf0e10cSrcweir     delete pBasicManager;
146cdf0e10cSrcweir 
147cdf0e10cSrcweir     BasicManagerRepository::revokeCreationListener( *pBasMgrListener );
148cdf0e10cSrcweir     delete pBasMgrListener;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
UpdateApplicationSettings(sal_Bool bDontHide)151cdf0e10cSrcweir void SfxAppData_Impl::UpdateApplicationSettings( sal_Bool bDontHide )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir 	AllSettings aAllSet = Application::GetSettings();
154cdf0e10cSrcweir 	StyleSettings aStyleSet = aAllSet.GetStyleSettings();
155cdf0e10cSrcweir 	sal_uInt32 nStyleOptions = aStyleSet.GetOptions();
156cdf0e10cSrcweir 	if ( bDontHide )
157cdf0e10cSrcweir 		nStyleOptions &= ~STYLE_OPTION_HIDEDISABLED;
158cdf0e10cSrcweir 	else
159cdf0e10cSrcweir 		nStyleOptions |= STYLE_OPTION_HIDEDISABLED;
160cdf0e10cSrcweir 	aStyleSet.SetOptions( nStyleOptions );
161cdf0e10cSrcweir 	aAllSet.SetStyleSettings( aStyleSet );
162cdf0e10cSrcweir 	Application::SetSettings( aAllSet );
163cdf0e10cSrcweir }
164cdf0e10cSrcweir 
GetDocumentTemplates()165cdf0e10cSrcweir SfxDocumentTemplates* SfxAppData_Impl::GetDocumentTemplates()
166cdf0e10cSrcweir {
167cdf0e10cSrcweir     if ( !pTemplates )
168cdf0e10cSrcweir         pTemplates = new SfxDocumentTemplates;
169cdf0e10cSrcweir     else
170cdf0e10cSrcweir         pTemplates->ReInitFromComponent();
171cdf0e10cSrcweir     return pTemplates;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir 
OnApplicationBasicManagerCreated(BasicManager & _rBasicManager)174cdf0e10cSrcweir void SfxAppData_Impl::OnApplicationBasicManagerCreated( BasicManager& _rBasicManager )
175cdf0e10cSrcweir {
176cdf0e10cSrcweir     pBasicManager->reset( &_rBasicManager );
177cdf0e10cSrcweir 
178cdf0e10cSrcweir     // global constants, additionally to the ones already added by createApplicationBasicManager:
179cdf0e10cSrcweir     // ThisComponent
180cdf0e10cSrcweir     Reference< XInterface > xCurrentComponent = SfxObjectShell::GetCurrentComponent();
181cdf0e10cSrcweir     _rBasicManager.SetGlobalUNOConstant( "ThisComponent", makeAny( xCurrentComponent ) );
182cdf0e10cSrcweir }
183