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