1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
19 #ifndef INCLUDED_SFX2_APP_HXX
20 #define INCLUDED_SFX2_APP_HXX
22 #include <sal/config.h>
23 #include <sfx2/dllapi.h>
24 #include <sal/types.h>
25 #include <tools/errcode.hxx>
26 #include <svl/smplhint.hxx>
27 #include <svl/poolitem.hxx>
28 #include <vcl/image.hxx>
29 #include <tools/ref.hxx>
30 #include <com/sun/star/uno/Reference.hxx>
31 #include <com/sun/star/script/XLibraryContainer.hpp>
32 #include <com/sun/star/task/XStatusIndicator.hpp>
34 // too many files including sfx2/app.hxx use VCL Application class but don't include the
35 // header file because in former times SfxApplication was derived from it
36 #include <vcl/svapp.hxx>
38 #include <sfx2/shell.hxx>
42 class ISfxTemplateCommon
;
50 struct SfxChildWinContextFactory
;
51 class SfxAppData_Impl
;
53 class SfxChildWinFactArr_Impl
;
56 class SfxEventConfiguration
;
60 class SfxMenuCtrlFactArr_Impl
;
61 class SfxNewFileDialog
;
63 class SfxObjectShellArr_Impl
;
66 class SfxStbCtrlFactArr_Impl
;
67 class SfxTbxCtrlFactArr_Impl
;
69 class SfxViewFrameArr_Impl
;
71 class SfxViewShellArr_Impl
;
74 class SfxFilterMatcher
;
77 namespace vcl
{ class Window
; }
78 struct SfxChildWinFactory
;
79 struct SfxMenuCtrlFactory
;
80 struct SfxStbCtrlFactory
;
81 struct SfxTbxCtrlFactory
;
95 class SfxLinkItem
: public SfxPoolItem
99 virtual SfxPoolItem
* Clone( SfxItemPool
* = 0 ) const SAL_OVERRIDE
100 { return new SfxLinkItem( *this ); }
101 virtual bool operator==( const SfxPoolItem
& rL
) const SAL_OVERRIDE
102 { return static_cast<const SfxLinkItem
&>(rL
).aLink
== aLink
; }
103 SfxLinkItem( sal_uInt16 nWhichId
, const Link
<>& rValue
) : SfxPoolItem( nWhichId
)
105 const Link
<>& GetValue() const { return aLink
; }
108 #ifndef SFX_DECL_OBJECTSHELL_DEFINED
109 #define SFX_DECL_OBJECTSHELL_DEFINED
110 typedef tools::SvRef
<SfxObjectShell
> SfxObjectShellRef
;
113 class SfxObjectShellLock
;
115 class SFX2_DLLPUBLIC SfxApplication
: public SfxShell
117 SAL_DLLPRIVATE
static SfxApplication
* pApp
;
119 SfxAppData_Impl
* pAppData_Impl
;
121 DECL_DLLPRIVATE_LINK_TYPED( GlobalBasicErrorHdl_Impl
, StarBASIC
*, bool );
123 static SfxApplication
* Create();
124 void SettingsChange( sal_uInt16
, const AppSettings
& );
130 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXAPP
)
133 /// SfxInterface initializer.
134 static void InitInterface_Impl();
139 virtual ~SfxApplication();
140 static SfxApplication
* GetOrCreate();
141 static SfxApplication
* Get() { return pApp
;}
144 static ResMgr
* GetSfxResManager();
148 long DdeExecute( const OUString
& rCmd
);
150 bool InitializeDde();
151 const DdeService
* GetDdeService() const;
152 DdeService
* GetDdeService();
154 void AddDdeTopic( SfxObjectShell
* );
156 void RemoveDdeTopic( SfxObjectShell
* );
160 * @param pArgs Takes ownership
162 sal_uIntPtr
LoadTemplate( SfxObjectShellLock
& xDoc
, const OUString
& rFileName
, bool bCopy
=true, SfxItemSet
* pArgs
= 0 );
163 vcl::Window
* GetTopWindow() const;
166 SfxFilterMatcher
& GetFilterMatcher();
167 SfxProgress
* GetProgress() const;
168 const OUString
& GetLastSaveDirectory() const;
169 sal_uInt16
GetFreeIndex();
170 void ReleaseIndex(sal_uInt16 i
);
173 static bool IsXScriptURL( const OUString
& rScriptURL
);
174 static OUString
ChooseScript();
175 static void MacroOrganizer( sal_Int16 nTabId
);
176 static ErrCode
CallBasic( const OUString
&, BasicManager
*, SbxArray
*pArgs
, SbxValue
*pRet
);
177 static ErrCode
CallAppBasic( const OUString
& i_macroName
, SbxArray
* i_args
= NULL
, SbxValue
* i_ret
= NULL
)
178 { return CallBasic( i_macroName
, SfxApplication::GetBasicManager(), i_args
, i_ret
); }
179 static BasicManager
* GetBasicManager();
180 com::sun::star::script::XLibraryContainer
* GetDialogContainer();
181 com::sun::star::script::XLibraryContainer
* GetBasicContainer();
182 static StarBASIC
* GetBasic();
183 sal_uInt16
SaveBasicAndDialogContainer() const;
186 bool GetOptions(SfxItemSet
&);
187 void SetOptions(const SfxItemSet
&);
188 virtual void Invalidate(sal_uInt16 nId
= 0) SAL_OVERRIDE
;
189 void NotifyEvent(const SfxEventHint
& rEvent
, bool bSynchron
= true );
190 bool IsDowning() const;
193 SAL_DLLPRIVATE SfxDispatcher
* GetAppDispatcher_Impl();
194 SAL_DLLPRIVATE SfxDispatcher
* GetDispatcher_Impl();
196 SAL_DLLPRIVATE
void SetOptions_Impl(const SfxItemSet
&);
197 SAL_DLLPRIVATE
bool Initialize_Impl();
199 SAL_DLLPRIVATE SfxAppData_Impl
* Get_Impl() const { return pAppData_Impl
; }
201 // Object-Factories/global arrays
202 SAL_DLLPRIVATE
void RegisterChildWindow_Impl(SfxModule
*, SfxChildWinFactory
*);
203 SAL_DLLPRIVATE
void RegisterChildWindowContext_Impl(SfxModule
*, sal_uInt16
, SfxChildWinContextFactory
*);
204 SAL_DLLPRIVATE
void RegisterStatusBarControl_Impl(SfxModule
*, SfxStbCtrlFactory
*);
205 SAL_DLLPRIVATE
void RegisterMenuControl_Impl(SfxModule
*, SfxMenuCtrlFactory
*);
206 SAL_DLLPRIVATE
void RegisterToolBoxControl_Impl( SfxModule
*, SfxTbxCtrlFactory
*);
207 SAL_DLLPRIVATE SfxTbxCtrlFactArr_Impl
& GetTbxCtrlFactories_Impl() const;
208 SAL_DLLPRIVATE SfxStbCtrlFactArr_Impl
& GetStbCtrlFactories_Impl() const;
209 SAL_DLLPRIVATE SfxMenuCtrlFactArr_Impl
& GetMenuCtrlFactories_Impl() const;
210 SAL_DLLPRIVATE SfxChildWinFactArr_Impl
& GetChildWinFactories_Impl() const;
211 SAL_DLLPRIVATE SfxViewFrameArr_Impl
& GetViewFrames_Impl() const;
212 SAL_DLLPRIVATE SfxViewShellArr_Impl
& GetViewShells_Impl() const;
213 SAL_DLLPRIVATE SfxObjectShellArr_Impl
& GetObjectShells_Impl() const;
214 SAL_DLLPRIVATE
void SetViewFrame_Impl(SfxViewFrame
*pViewFrame
);
217 // TODO/CLEANUP: still needed?
218 SAL_DLLPRIVATE
void NewDocDirectExec_Impl(SfxRequest
&);
219 SAL_DLLPRIVATE
void NewDocExec_Impl(SfxRequest
&);
220 SAL_DLLPRIVATE
void OpenDocExec_Impl(SfxRequest
&);
221 SAL_DLLPRIVATE
void MiscExec_Impl(SfxRequest
&);
222 SAL_DLLPRIVATE
void MiscState_Impl(SfxItemSet
&);
223 SAL_DLLPRIVATE
void PropExec_Impl(SfxRequest
&);
224 SAL_DLLPRIVATE
void PropState_Impl(SfxItemSet
&);
225 SAL_DLLPRIVATE
void INetExecute_Impl(SfxRequest
&);
226 SAL_DLLPRIVATE
void INetState_Impl(SfxItemSet
&);
227 SAL_DLLPRIVATE
void OfaExec_Impl(SfxRequest
&);
228 SAL_DLLPRIVATE
void OfaState_Impl(SfxItemSet
&);
230 SAL_DLLPRIVATE
void SetProgress_Impl(SfxProgress
*);
231 SAL_DLLPRIVATE
const OUString
& GetLastDir_Impl() const;
232 SAL_DLLPRIVATE
void SetLastDir_Impl( const OUString
& );
234 SAL_DLLPRIVATE
void Registrations_Impl();
235 SAL_DLLPRIVATE SfxWorkWindow
* GetWorkWindow_Impl(const SfxViewFrame
*pFrame
=0) const;
237 // TODO/CLEANUP: still needed? -- unclear whether this comment
238 // refers to the GetDisabledSlotList_Impl() method which was
239 // already removed, or the below methods?
240 SAL_DLLPRIVATE SfxSlotPool
& GetAppSlotPool_Impl() const;
241 SAL_DLLPRIVATE SfxModule
* GetModule_Impl();
243 static bool loadBrandSvg(const char *pName
, BitmapEx
&rBitmap
, int nWidth
);
245 /** loads the application logo as used in the impress slideshow pause screen */
246 static BitmapEx
GetApplicationLogo(long nWidth
);
248 /** this Theme contains Images so must be deleted before DeInitVCL */
249 sfx2::sidebar::Theme
& GetSidebarTheme();
252 inline SfxApplication
* SfxGetpApp()
254 return SfxApplication::GetOrCreate();
260 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */