bump product version to 4.2.0.1
[LibreOffice.git] / include / sfx2 / app.hxx
blob6827ce6c4b6a34dc534a20800674a27a72273560
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 .
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/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>
40 #include <vector>
42 class Timer;
43 class WorkWindow;
44 class ISfxTemplateCommon;
45 class BasicManager;
46 class DdeService;
47 class GenLink;
48 class PrinterDialog;
49 class Point;
50 class Rectangle;
51 class AppSettings;
52 struct SfxChildWinContextFactory;
53 class SfxAppData_Impl;
54 class SfxBindings;
55 class SfxChildWinFactArr_Impl;
56 class SfxChildWindow;
57 class SfxDispatcher;
58 class SfxEventConfiguration;
59 class SfxEventHint;
60 class SfxItemSet;
61 class SfxMedium;
62 class SfxMenuCtrlFactArr_Impl;
63 class SfxNewFileDialog;
64 class SfxObjectShell;
65 class SfxObjectShellArr_Impl;
66 class SfxProgress;
67 class SfxSlotPool;
68 class SfxStbCtrlFactArr_Impl;
69 class SfxTbxCtrlFactArr_Impl;
70 class SfxTemplateDialog;
71 class SfxViewFrame;
72 class SfxViewFrameArr_Impl;
73 class SfxViewShell;
74 class SfxViewShellArr_Impl;
75 class StarBASIC;
76 class SfxWorkWindow;
77 class SfxFilterMatcher;
78 class SfxModule;
79 class SfxModule;
80 typedef ::std::vector<SfxModule*> SfxModuleArr_Impl;
81 class Window;
82 struct SfxChildWinFactory;
83 struct SfxMenuCtrlFactory;
84 struct SfxStbCtrlFactory;
85 struct SfxTbxCtrlFactory;
86 class SimpleResMgr;
87 class ModalDialog;
88 class SbxArray;
89 class SbxValue;
91 typedef ::std::vector< SfxMedium* > SfxMediumList;
93 namespace sfx2
95 class SvLinkSource;
96 namespace sidebar {
97 class Theme;
101 //====================================================================
103 class SfxLinkItem : public SfxPoolItem
105 Link aLink;
106 public:
107 virtual SfxPoolItem* Clone( SfxItemPool* = 0 ) const
108 { return new SfxLinkItem( *this ); }
109 virtual int operator==( const SfxPoolItem& rL) const
110 { return ((SfxLinkItem&)rL).aLink == aLink; }
111 SfxLinkItem( sal_uInt16 nWhichId, const Link& rValue ) : SfxPoolItem( nWhichId )
112 { aLink = rValue; }
113 const Link& GetValue() const { return aLink; }
116 //TODO/CLEANUP
117 //is apparently used only in SfxPickList/SfxFrameLoader
118 DECL_OBJHINT( SfxStringHint, OUString );
120 #ifndef SFX_DECL_OBJECTSHELL_DEFINED
121 #define SFX_DECL_OBJECTSHELL_DEFINED
122 SV_DECL_REF(SfxObjectShell)
123 #endif
125 class SfxObjectShellLock;
127 class SFX2_DLLPUBLIC SfxApplication: public SfxShell
129 SAL_DLLPRIVATE static SfxApplication* pApp;
131 SfxAppData_Impl* pAppData_Impl;
133 DECL_DLLPRIVATE_LINK( GlobalBasicErrorHdl_Impl, StarBASIC* );
135 static SfxApplication* Create();
136 void Init();
137 void Exit();
138 void SettingsChange( sal_uInt16, const AppSettings & );
139 void Quit();
140 void Deinitialize();
142 public:
143 TYPEINFO();
144 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXAPP)
146 SfxApplication();
147 ~SfxApplication();
148 static SfxApplication* GetOrCreate();
150 // Resource Manager
151 ResMgr* GetSfxResManager();
152 static ResMgr* CreateResManager( const char *pPrefix );
154 // DDE
155 #if defined( WNT )
156 long DdeExecute( const OUString& rCmd );
157 #endif
158 sal_Bool InitializeDde();
159 const DdeService* GetDdeService() const;
160 DdeService* GetDdeService();
161 #if defined( WNT )
162 void AddDdeTopic( SfxObjectShell* );
163 #endif
164 void RemoveDdeTopic( SfxObjectShell* );
166 // "static" methods
168 * @param pArgs Takes ownership
170 sal_uIntPtr LoadTemplate( SfxObjectShellLock& xDoc, const OUString& rFileName, sal_Bool bCopy=sal_True, SfxItemSet* pArgs = 0 );
171 SfxTemplateDialog* GetTemplateDialog();
172 Window* GetTopWindow() const;
174 // TODO/CLEANUP: make currently selected family a view property and so we don't need to query the status from the "TemplateCommon"
175 ISfxTemplateCommon* GetCurrentTemplateCommon( SfxBindings& );
177 // members
178 SfxFilterMatcher& GetFilterMatcher();
179 SfxProgress* GetProgress() const;
180 const OUString& GetLastSaveDirectory() const;
181 sal_uInt16 GetFreeIndex();
182 void ReleaseIndex(sal_uInt16 i);
184 // Basic/Scripting
185 static sal_Bool IsXScriptURL( const OUString& rScriptURL );
186 static OUString ChooseScript();
187 static void MacroOrganizer( sal_Int16 nTabId );
188 static ErrCode CallBasic( const OUString&, BasicManager*, SbxArray *pArgs, SbxValue *pRet );
189 static ErrCode CallAppBasic( const OUString& i_macroName, SbxArray* i_args = NULL, SbxValue* i_ret = NULL )
190 { return CallBasic( i_macroName, SfxApplication::GetOrCreate()->GetBasicManager(), i_args, i_ret ); }
191 BasicManager* GetBasicManager();
192 com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer >
193 GetDialogContainer();
194 com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer >
195 GetBasicContainer();
196 StarBASIC* GetBasic();
197 sal_uInt16 SaveBasicAndDialogContainer() const;
199 // misc.
200 sal_Bool GetOptions(SfxItemSet &);
201 void SetOptions(const SfxItemSet &);
202 virtual void Invalidate(sal_uInt16 nId = 0);
203 void NotifyEvent(const SfxEventHint& rEvent, bool bSynchron = true );
204 sal_Bool IsDowning() const;
205 void ResetLastDir();
207 SAL_DLLPRIVATE static SfxApplication* Get() { return pApp;}
208 SAL_DLLPRIVATE SfxDispatcher* GetAppDispatcher_Impl();
209 SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl();
211 SAL_DLLPRIVATE sal_Bool QueryExit_Impl();
212 SAL_DLLPRIVATE void SetOptions_Impl(const SfxItemSet &);
213 SAL_DLLPRIVATE bool Initialize_Impl();
215 SAL_DLLPRIVATE SfxAppData_Impl* Get_Impl() const { return pAppData_Impl; }
217 // Object-Factories/global arrays
218 SAL_DLLPRIVATE void RegisterChildWindow_Impl(SfxModule*, SfxChildWinFactory*);
219 SAL_DLLPRIVATE void RegisterChildWindowContext_Impl(SfxModule*, sal_uInt16, SfxChildWinContextFactory*);
220 SAL_DLLPRIVATE void RegisterStatusBarControl_Impl(SfxModule*, SfxStbCtrlFactory*);
221 SAL_DLLPRIVATE void RegisterMenuControl_Impl(SfxModule*, SfxMenuCtrlFactory*);
222 SAL_DLLPRIVATE void RegisterToolBoxControl_Impl( SfxModule*, SfxTbxCtrlFactory*);
223 SAL_DLLPRIVATE SfxTbxCtrlFactArr_Impl& GetTbxCtrlFactories_Impl() const;
224 SAL_DLLPRIVATE SfxStbCtrlFactArr_Impl& GetStbCtrlFactories_Impl() const;
225 SAL_DLLPRIVATE SfxMenuCtrlFactArr_Impl& GetMenuCtrlFactories_Impl() const;
226 SAL_DLLPRIVATE SfxChildWinFactArr_Impl& GetChildWinFactories_Impl() const;
227 SAL_DLLPRIVATE SfxViewFrameArr_Impl& GetViewFrames_Impl() const;
228 SAL_DLLPRIVATE SfxViewShellArr_Impl& GetViewShells_Impl() const;
229 SAL_DLLPRIVATE SfxObjectShellArr_Impl& GetObjectShells_Impl() const;
230 SAL_DLLPRIVATE void SetViewFrame_Impl(SfxViewFrame *pViewFrame);
232 // Slot Methods
233 // TODO/CLEANUP: still needed?
234 SAL_DLLPRIVATE void NewDocDirectExec_Impl(SfxRequest &);
235 SAL_DLLPRIVATE void NewDocExec_Impl(SfxRequest &);
236 SAL_DLLPRIVATE void OpenDocExec_Impl(SfxRequest &);
237 SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &);
238 SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &);
239 SAL_DLLPRIVATE void PropExec_Impl(SfxRequest &);
240 SAL_DLLPRIVATE void PropState_Impl(SfxItemSet &);
241 SAL_DLLPRIVATE void INetExecute_Impl(SfxRequest &);
242 SAL_DLLPRIVATE void INetState_Impl(SfxItemSet &);
243 SAL_DLLPRIVATE void OfaExec_Impl(SfxRequest &);
244 SAL_DLLPRIVATE void OfaState_Impl(SfxItemSet &);
246 SAL_DLLPRIVATE void SetProgress_Impl(SfxProgress *);
247 SAL_DLLPRIVATE const OUString& GetLastDir_Impl() const;
248 SAL_DLLPRIVATE void SetLastDir_Impl( const OUString & );
250 SAL_DLLPRIVATE void Registrations_Impl();
251 SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl(const SfxViewFrame *pFrame=0) const;
253 // TODO/CLEANUP: still needed? -- unclear whether this comment
254 // refers to the GetDisabledSlotList_Impl() method which was
255 // already removed, or the below methods?
256 SAL_DLLPRIVATE SfxSlotPool& GetAppSlotPool_Impl() const;
257 SAL_DLLPRIVATE SfxModule* GetModule_Impl();
258 SAL_DLLPRIVATE ResMgr* GetOffResManager_Impl();
260 static bool loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWidth);
262 /** loads the application logo as used in the impress slideshow pause screen */
263 static BitmapEx GetApplicationLogo(long nWidth);
265 /** this Theme contains Images so must be deleted before DeInitVCL */
266 sfx2::sidebar::Theme & GetSidebarTheme();
269 #define SFX_APP() SfxGetpApp()
271 //--------------------------------------------------------------------
273 inline SfxApplication* SfxGetpApp()
275 return SfxApplication::GetOrCreate();
278 #endif
281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */