Branch libreoffice-5-0-4
[LibreOffice.git] / sfx2 / source / appl / appdata.cxx
blob4e988409f1c9ddc8a4d3fa5fc163ae08b18b89b7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <config_features.h>
22 #include <tools/config.hxx>
23 #include <svl/stritem.hxx>
25 #include <osl/mutex.hxx>
27 #include <vcl/menu.hxx>
28 #include <vcl/msgbox.hxx>
29 #include <vcl/wrkwin.hxx>
30 #include <comphelper/processfactory.hxx>
32 #include <sfx2/viewfrm.hxx>
33 #include "appdata.hxx"
34 #include <sfx2/dispatch.hxx>
35 #include <sfx2/event.hxx>
36 #include "sfxtypes.hxx"
37 #include <sfx2/doctempl.hxx>
38 #include "arrdecl.hxx"
39 #include <sfx2/docfac.hxx>
40 #include <sfx2/docfile.hxx>
41 #include <sfx2/request.hxx>
42 #include <sfx2/sidebar/Theme.hxx>
43 #include "app.hrc"
44 #include <sfx2/sfxresid.hxx>
45 #include "objshimp.hxx"
46 #include "imestatuswindow.hxx"
47 #include "appbaslib.hxx"
48 #include <childwinimpl.hxx>
50 #include <basic/basicmanagerrepository.hxx>
51 #include <basic/basmgr.hxx>
53 using ::basic::BasicManagerRepository;
54 using ::basic::BasicManagerCreationListener;
55 using ::com::sun::star::uno::Reference;
56 using ::com::sun::star::frame::XModel;
57 using ::com::sun::star::uno::XInterface;
59 class SfxBasicManagerCreationListener : public ::basic::BasicManagerCreationListener
61 private:
62 SfxAppData_Impl& m_rAppData;
64 public:
65 SfxBasicManagerCreationListener( SfxAppData_Impl& _rAppData ) :m_rAppData( _rAppData ) { }
67 virtual ~SfxBasicManagerCreationListener();
69 virtual void onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager ) SAL_OVERRIDE;
72 SfxBasicManagerCreationListener::~SfxBasicManagerCreationListener()
76 void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager )
78 if ( _rxForDocument == NULL )
79 m_rAppData.OnApplicationBasicManagerCreated( _rBasicManager );
82 SfxAppData_Impl::SfxAppData_Impl( SfxApplication* )
83 : pDdeService( 0 )
84 , pDocTopics( 0 )
85 , pTriggerTopic(0)
86 , pDdeService2(0)
87 , pFactArr(0)
88 , pTopFrames( new SfxFrameArr_Impl )
89 , pMatcher( 0 )
90 #if HAVE_FEATURE_SCRIPTING
91 , pBasicResMgr( 0 )
92 #endif
93 , pSvtResMgr( 0 )
94 , m_pToolsErrorHdl(0)
95 , m_pSoErrorHdl(0)
96 #if HAVE_FEATURE_SCRIPTING
97 , m_pSbxErrorHdl(0)
98 #endif
99 , pAppDispatch(NULL)
100 , pTemplates( 0 )
101 , pPool(0)
102 , pSaveOptions( 0 )
103 , pHelpOptions( 0 )
104 , pProgress(0)
105 , nDocModalMode(0)
106 , nAutoTabPageId(0)
107 , nRescheduleLocks(0)
108 , nInReschedule(0)
109 , m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(comphelper::getProcessComponentContext()))
110 , pTbxCtrlFac(0)
111 , pStbCtrlFac(0)
112 , pMenuCtrlFac(0)
113 , pViewFrames(0)
114 , pViewShells(0)
115 , pObjShells(0)
116 , pSfxResManager(0)
117 , pBasicManager( new SfxBasicManagerHolder )
118 , pBasMgrListener( new SfxBasicManagerCreationListener( *this ) )
119 , pViewFrame( 0 )
120 , pSlotPool( 0 )
121 , pAppDispat( 0 )
122 , pInterfaces( 0 )
123 , nDocNo(0)
124 , nInterfaces( 0 )
125 , bDispatcherLocked( false )
126 , bDowning( true )
127 , bInQuit( false )
128 , bInvalidateOnUnlock( false )
129 , bODFVersionWarningLater( false )
132 #if HAVE_FEATURE_SCRIPTING
133 BasicManagerRepository::registerCreationListener( *pBasMgrListener );
134 #endif
137 SfxAppData_Impl::~SfxAppData_Impl()
139 DeInitDDE();
140 delete pTopFrames;
141 delete pBasicManager;
143 #if HAVE_FEATURE_SCRIPTING
144 BasicManagerRepository::revokeCreationListener( *pBasMgrListener );
145 delete pBasMgrListener;
146 #endif
149 SfxDocumentTemplates* SfxAppData_Impl::GetDocumentTemplates()
151 if ( !pTemplates )
152 pTemplates = new SfxDocumentTemplates;
153 else
154 pTemplates->ReInitFromComponent();
155 return pTemplates;
158 void SfxAppData_Impl::OnApplicationBasicManagerCreated( BasicManager& _rBasicManager )
160 #if !HAVE_FEATURE_SCRIPTING
161 (void) _rBasicManager;
162 #else
163 pBasicManager->reset( &_rBasicManager );
165 // global constants, additionally to the ones already added by createApplicationBasicManager:
166 // ThisComponent
167 Reference< XInterface > xCurrentComponent = SfxObjectShell::GetCurrentComponent();
168 _rBasicManager.SetGlobalUNOConstant( "ThisComponent", makeAny( xCurrentComponent ) );
169 #endif
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */