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