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 .
22 #include "sal/config.h"
23 #include "sfx2/dllapi.h"
24 #include "sal/types.h"
25 #include <tools/solar.h>
26 #include <tools/errcode.hxx>
27 #include <svl/smplhint.hxx>
28 #include <svl/poolitem.hxx>
29 #include <vcl/image.hxx>
30 #include <tools/ref.hxx>
31 #include <com/sun/star/uno/Reference.hxx>
32 #include <com/sun/star/script/XLibraryContainer.hpp>
33 #include <com/sun/star/task/XStatusIndicator.hpp>
35 // too many files including sfx2/app.hxx use VCL Application class but don't include the
36 // header file because in former times SfxApplication was derived from it
37 #include <vcl/svapp.hxx>
39 #include <sfx2/shell.hxx>
44 class ISfxTemplateCommon
;
52 struct SfxChildWinContextFactory
;
53 class SfxAppData_Impl
;
55 class SfxChildWinFactArr_Impl
;
58 class SfxEventConfiguration
;
62 class SfxMenuCtrlFactArr_Impl
;
63 class SfxNewFileDialog
;
65 class SfxObjectShellArr_Impl
;
68 class SfxStbCtrlFactArr_Impl
;
69 class SfxTbxCtrlFactArr_Impl
;
70 class SfxTemplateDialog
;
72 class SfxViewFrameArr_Impl
;
74 class SfxViewShellArr_Impl
;
77 class SfxFilterMatcher
;
80 typedef ::std::vector
<SfxModule
*> SfxModuleArr_Impl
;
83 struct SfxChildWinFactory
;
84 struct SfxMenuCtrlFactory
;
85 struct SfxStbCtrlFactory
;
86 struct SfxTbxCtrlFactory
;
92 typedef ::std::vector
< SfxMedium
* > SfxMediumList
;
99 //====================================================================
101 class SfxLinkItem
: public SfxPoolItem
105 virtual SfxPoolItem
* Clone( SfxItemPool
* = 0 ) const
106 { return new SfxLinkItem( *this ); }
107 virtual int operator==( const SfxPoolItem
& rL
) const
108 { return ((SfxLinkItem
&)rL
).aLink
== aLink
; }
109 SfxLinkItem( sal_uInt16 nWhichId
, const Link
& rValue
) : SfxPoolItem( nWhichId
)
111 const Link
& GetValue() const { return aLink
; }
115 //is apparently used only in SfxPickList/SfxFrameLoader
116 DECL_OBJHINT( SfxStringHint
, String
);
118 #ifndef SFX_DECL_OBJECTSHELL_DEFINED
119 #define SFX_DECL_OBJECTSHELL_DEFINED
120 SV_DECL_REF(SfxObjectShell
)
123 class SfxObjectShellLock
;
125 class SFX2_DLLPUBLIC SfxApplication
: public SfxShell
127 SAL_DLLPRIVATE
static SfxApplication
* pApp
;
129 SfxAppData_Impl
* pAppData_Impl
;
131 DECL_DLLPRIVATE_LINK( GlobalBasicErrorHdl_Impl
, StarBASIC
* );
133 static SfxApplication
* Create();
136 void SettingsChange( sal_uInt16
, const AppSettings
& );
142 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXAPP
)
146 static SfxApplication
* GetOrCreate();
149 ResMgr
* GetSfxResManager();
150 static ResMgr
* CreateResManager( const char *pPrefix
);
154 long DdeExecute( const String
& rCmd
);
156 sal_Bool
InitializeDde();
157 const DdeService
* GetDdeService() const;
158 DdeService
* GetDdeService();
160 void AddDdeTopic( SfxObjectShell
* );
162 void RemoveDdeTopic( SfxObjectShell
* );
166 * @param pArgs Takes ownership
168 sal_uIntPtr
LoadTemplate( SfxObjectShellLock
& xDoc
, const String
& rFileName
, sal_Bool bCopy
=sal_True
, SfxItemSet
* pArgs
= 0 );
169 SfxTemplateDialog
* GetTemplateDialog();
170 Window
* GetTopWindow() const;
172 // TODO/CLEANUP: make currently selected family a view property and so we don't need to query the status from the "TemplateCommon"
173 ISfxTemplateCommon
* GetCurrentTemplateCommon( SfxBindings
& );
176 SfxFilterMatcher
& GetFilterMatcher();
177 SfxProgress
* GetProgress() const;
178 const String
& GetLastSaveDirectory() const;
179 sal_uInt16
GetFreeIndex();
180 void ReleaseIndex(sal_uInt16 i
);
183 static sal_Bool
IsXScriptURL( const String
& rScriptURL
);
184 static OUString
ChooseScript();
185 static void MacroOrganizer( sal_Int16 nTabId
);
186 static ErrCode
CallBasic( const String
&, BasicManager
*, SbxArray
*pArgs
, SbxValue
*pRet
);
187 static ErrCode
CallAppBasic( const String
& i_macroName
, SbxArray
* i_args
= NULL
, SbxValue
* i_ret
= NULL
)
188 { return CallBasic( i_macroName
, SfxApplication::GetOrCreate()->GetBasicManager(), i_args
, i_ret
); }
189 BasicManager
* GetBasicManager();
190 com::sun::star::uno::Reference
< com::sun::star::script::XLibraryContainer
>
191 GetDialogContainer();
192 com::sun::star::uno::Reference
< com::sun::star::script::XLibraryContainer
>
194 StarBASIC
* GetBasic();
195 sal_uInt16
SaveBasicAndDialogContainer() const;
198 sal_Bool
GetOptions(SfxItemSet
&);
199 void SetOptions(const SfxItemSet
&);
200 virtual void Invalidate(sal_uInt16 nId
= 0);
201 void NotifyEvent(const SfxEventHint
& rEvent
, bool bSynchron
= true );
202 sal_Bool
IsDowning() const;
203 sal_Bool
IsSecureURL( const INetURLObject
&rURL
, const String
*pReferer
) const;
206 SAL_DLLPRIVATE
static SfxApplication
* Get() { return pApp
;}
207 SAL_DLLPRIVATE SfxDispatcher
* GetAppDispatcher_Impl();
208 SAL_DLLPRIVATE SfxDispatcher
* GetDispatcher_Impl();
210 SAL_DLLPRIVATE sal_Bool
QueryExit_Impl();
211 SAL_DLLPRIVATE
void SetOptions_Impl(const SfxItemSet
&);
212 SAL_DLLPRIVATE
bool Initialize_Impl();
214 SAL_DLLPRIVATE SfxAppData_Impl
* Get_Impl() const { return pAppData_Impl
; }
216 // Object-Factories/global arrays
217 SAL_DLLPRIVATE
void RegisterChildWindow_Impl(SfxModule
*, SfxChildWinFactory
*);
218 SAL_DLLPRIVATE
void RegisterChildWindowContext_Impl(SfxModule
*, sal_uInt16
, SfxChildWinContextFactory
*);
219 SAL_DLLPRIVATE
void RegisterStatusBarControl_Impl(SfxModule
*, SfxStbCtrlFactory
*);
220 SAL_DLLPRIVATE
void RegisterMenuControl_Impl(SfxModule
*, SfxMenuCtrlFactory
*);
221 SAL_DLLPRIVATE
void RegisterToolBoxControl_Impl( SfxModule
*, SfxTbxCtrlFactory
*);
222 SAL_DLLPRIVATE SfxTbxCtrlFactArr_Impl
& GetTbxCtrlFactories_Impl() const;
223 SAL_DLLPRIVATE SfxStbCtrlFactArr_Impl
& GetStbCtrlFactories_Impl() const;
224 SAL_DLLPRIVATE SfxMenuCtrlFactArr_Impl
& GetMenuCtrlFactories_Impl() const;
225 SAL_DLLPRIVATE SfxChildWinFactArr_Impl
& GetChildWinFactories_Impl() const;
226 SAL_DLLPRIVATE SfxViewFrameArr_Impl
& GetViewFrames_Impl() const;
227 SAL_DLLPRIVATE SfxViewShellArr_Impl
& GetViewShells_Impl() const;
228 SAL_DLLPRIVATE SfxObjectShellArr_Impl
& GetObjectShells_Impl() const;
229 SAL_DLLPRIVATE
void SetViewFrame_Impl(SfxViewFrame
*pViewFrame
);
232 // TODO/CLEANUP: still needed?
233 SAL_DLLPRIVATE
void NewDocDirectExec_Impl(SfxRequest
&);
234 SAL_DLLPRIVATE
void NewDocExec_Impl(SfxRequest
&);
235 SAL_DLLPRIVATE
void OpenDocExec_Impl(SfxRequest
&);
236 SAL_DLLPRIVATE
void MiscExec_Impl(SfxRequest
&);
237 SAL_DLLPRIVATE
void MiscState_Impl(SfxItemSet
&);
238 SAL_DLLPRIVATE
void PropExec_Impl(SfxRequest
&);
239 SAL_DLLPRIVATE
void PropState_Impl(SfxItemSet
&);
240 SAL_DLLPRIVATE
void INetExecute_Impl(SfxRequest
&);
241 SAL_DLLPRIVATE
void INetState_Impl(SfxItemSet
&);
242 SAL_DLLPRIVATE
void OfaExec_Impl(SfxRequest
&);
243 SAL_DLLPRIVATE
void OfaState_Impl(SfxItemSet
&);
245 SAL_DLLPRIVATE
void SetProgress_Impl(SfxProgress
*);
246 SAL_DLLPRIVATE
const String
& GetLastDir_Impl() const;
247 SAL_DLLPRIVATE
void SetLastDir_Impl( const String
& );
249 SAL_DLLPRIVATE
void Registrations_Impl();
250 SAL_DLLPRIVATE SfxWorkWindow
* GetWorkWindow_Impl(const SfxViewFrame
*pFrame
=0) const;
252 // TODO/CLEANUP: still needed? -- unclear whether this comment
253 // refers to the GetDisabledSlotList_Impl() method which was
254 // already removed, or the below methods?
255 SAL_DLLPRIVATE SfxSlotPool
& GetAppSlotPool_Impl() const;
256 SAL_DLLPRIVATE SfxModule
* GetModule_Impl();
257 SAL_DLLPRIVATE ResMgr
* GetOffResManager_Impl();
259 static bool loadBrandSvg(const char *pName
, BitmapEx
&rBitmap
, int nWidth
);
261 /** loads the application logo as used in the impress slideshow pause screen */
262 static BitmapEx
GetApplicationLogo(long nWidth
);
265 #define SFX_APP() SfxGetpApp()
267 //--------------------------------------------------------------------
269 inline SfxApplication
* SfxGetpApp()
271 return SfxApplication::GetOrCreate();
277 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */