Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef _SFXAPP_HXX
20 : #define _SFXAPP_HXX
21 :
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>
34 :
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>
38 :
39 : #include <sfx2/shell.hxx>
40 : #include <vector>
41 :
42 : class Timer;
43 : class ApplicationEvent;
44 : class WorkWindow;
45 : class ISfxTemplateCommon;
46 : class BasicManager;
47 : class DdeService;
48 : class GenLink;
49 : class PrinterDialog;
50 : class Point;
51 : class Rectangle;
52 : class AppSettings;
53 : struct SfxChildWinContextFactory;
54 : class SfxAppData_Impl;
55 : class SfxBindings;
56 : class SfxChildWinFactArr_Impl;
57 : class SfxChildWindow;
58 : class SfxDispatcher;
59 : class SfxEventConfiguration;
60 : class SfxEventHint;
61 : class SfxItemSet;
62 : class SfxMedium;
63 : class SfxMenuCtrlFactArr_Impl;
64 : class SfxNewFileDialog;
65 : class SfxObjectShell;
66 : class SfxObjectShellArr_Impl;
67 : class SfxProgress;
68 : class SfxResourceManager;
69 : class SfxSlotPool;
70 : class SfxStbCtrlFactArr_Impl;
71 : class SfxTbxCtrlFactArr_Impl;
72 : class SfxTemplateDialog;
73 : class SfxViewFrame;
74 : class SfxViewFrameArr_Impl;
75 : class SfxViewShell;
76 : class SfxViewShellArr_Impl;
77 : class StarBASIC;
78 : class SfxWorkWindow;
79 : class SfxFilterMatcher;
80 : class SfxModule;
81 : class SfxModule;
82 : typedef ::std::vector<SfxModule*> SfxModuleArr_Impl;
83 : class Window;
84 : class INetURLObject;
85 : struct SfxChildWinFactory;
86 : struct SfxMenuCtrlFactory;
87 : struct SfxStbCtrlFactory;
88 : struct SfxTbxCtrlFactory;
89 : class SimpleResMgr;
90 : class ModalDialog;
91 : class SbxArray;
92 : class SbxValue;
93 :
94 : typedef ::std::vector< SfxMedium* > SfxMediumList;
95 :
96 : namespace sfx2
97 : {
98 : class SvLinkSource;
99 : }
100 :
101 : //====================================================================
102 :
103 0 : class SfxLinkItem : public SfxPoolItem
104 : {
105 : Link aLink;
106 : public:
107 0 : virtual SfxPoolItem* Clone( SfxItemPool* = 0 ) const
108 0 : { return new SfxLinkItem( *this ); }
109 0 : virtual int operator==( const SfxPoolItem& rL) const
110 0 : { return ((SfxLinkItem&)rL).aLink == aLink; }
111 0 : SfxLinkItem( sal_uInt16 nWhichId, const Link& rValue ) : SfxPoolItem( nWhichId )
112 0 : { aLink = rValue; }
113 0 : const Link& GetValue() const { return aLink; }
114 : };
115 :
116 : //TODO/CLEANUP
117 : //is apparently used only in SfxPickList/SfxFrameLoader
118 : DECL_OBJHINT( SfxStringHint, String );
119 :
120 : #ifndef SFX_DECL_OBJECTSHELL_DEFINED
121 : #define SFX_DECL_OBJECTSHELL_DEFINED
122 0 : SV_DECL_REF(SfxObjectShell)
123 : #endif
124 :
125 : class SfxObjectShellLock;
126 :
127 : class SFX2_DLLPUBLIC SfxApplication: public SfxShell
128 : {
129 : SAL_DLLPRIVATE static SfxApplication* pApp;
130 :
131 : SfxAppData_Impl* pAppData_Impl;
132 :
133 : DECL_DLLPRIVATE_LINK( GlobalBasicErrorHdl_Impl, StarBASIC* );
134 :
135 : static SfxApplication* Create();
136 : void Init();
137 : void Exit();
138 : void SettingsChange( sal_uInt16, const AppSettings & );
139 : void Quit();
140 : void Deinitialize();
141 :
142 : public:
143 : TYPEINFO();
144 : SFX_DECL_INTERFACE(SFX_INTERFACE_SFXAPP)
145 :
146 : SfxApplication();
147 : ~SfxApplication();
148 : static SfxApplication* GetOrCreate();
149 :
150 : // Resource Manager
151 : ResMgr* GetSfxResManager();
152 : static ResMgr* CreateResManager( const char *pPrefix );
153 :
154 : // DDE
155 : #if defined( WNT )
156 : long DdeExecute( const String& 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* );
165 :
166 : // "static" methods
167 : sal_uIntPtr LoadTemplate( SfxObjectShellLock& xDoc, const String& rFileName, sal_Bool bCopy=sal_True, SfxItemSet* pArgs = 0 );
168 : SfxTemplateDialog* GetTemplateDialog();
169 : Window* GetTopWindow() const;
170 :
171 : // TODO/CLEANUP: make currently selected family a view property and so we don't need to query the status from the "TemplateCommon"
172 : ISfxTemplateCommon* GetCurrentTemplateCommon( SfxBindings& );
173 :
174 : // members
175 : SfxFilterMatcher& GetFilterMatcher();
176 : SfxProgress* GetProgress() const;
177 : const String& GetLastSaveDirectory() const;
178 : sal_uInt16 GetFreeIndex();
179 : void ReleaseIndex(sal_uInt16 i);
180 :
181 : // Basic/Scripting
182 : static sal_Bool IsXScriptURL( const String& rScriptURL );
183 : static ::rtl::OUString ChooseScript();
184 : static void MacroOrganizer( sal_Int16 nTabId );
185 : static ErrCode CallBasic( const String&, BasicManager*, SbxArray *pArgs, SbxValue *pRet );
186 0 : static ErrCode CallAppBasic( const String& i_macroName, SbxArray* i_args = NULL, SbxValue* i_ret = NULL )
187 0 : { return CallBasic( i_macroName, SfxApplication::GetOrCreate()->GetBasicManager(), i_args, i_ret ); }
188 : BasicManager* GetBasicManager();
189 : com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer >
190 : GetDialogContainer();
191 : com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer >
192 : GetBasicContainer();
193 : StarBASIC* GetBasic();
194 : sal_uInt16 SaveBasicAndDialogContainer() const;
195 :
196 : // misc.
197 : sal_Bool GetOptions(SfxItemSet &);
198 : void SetOptions(const SfxItemSet &);
199 : virtual void Invalidate(sal_uInt16 nId = 0);
200 : void NotifyEvent(const SfxEventHint& rEvent, bool bSynchron = true );
201 : sal_Bool IsDowning() const;
202 : sal_Bool IsSecureURL( const INetURLObject &rURL, const String *pReferer ) const;
203 : static SfxObjectShellRef DocAlreadyLoaded( const String &rName,
204 : sal_Bool bSilent,
205 : sal_Bool bActivate,
206 : sal_Bool bForbidVisible = sal_False,
207 : const String* pPostStr = 0);
208 : void ResetLastDir();
209 :
210 : SAL_DLLPRIVATE static SfxApplication* Get() { return pApp;}
211 : SAL_DLLPRIVATE SfxDispatcher* GetAppDispatcher_Impl();
212 : SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl();
213 :
214 : SAL_DLLPRIVATE sal_Bool QueryExit_Impl();
215 : SAL_DLLPRIVATE void SetOptions_Impl(const SfxItemSet &);
216 : SAL_DLLPRIVATE bool Initialize_Impl();
217 :
218 : SAL_DLLPRIVATE SfxAppData_Impl* Get_Impl() const { return pAppData_Impl; }
219 :
220 : // Object-Factories/global arrays
221 : SAL_DLLPRIVATE void RegisterChildWindow_Impl(SfxModule*, SfxChildWinFactory*);
222 : SAL_DLLPRIVATE void RegisterChildWindowContext_Impl(SfxModule*, sal_uInt16, SfxChildWinContextFactory*);
223 : SAL_DLLPRIVATE void RegisterStatusBarControl_Impl(SfxModule*, SfxStbCtrlFactory*);
224 : SAL_DLLPRIVATE void RegisterMenuControl_Impl(SfxModule*, SfxMenuCtrlFactory*);
225 : SAL_DLLPRIVATE void RegisterToolBoxControl_Impl( SfxModule*, SfxTbxCtrlFactory*);
226 : SAL_DLLPRIVATE SfxTbxCtrlFactArr_Impl& GetTbxCtrlFactories_Impl() const;
227 : SAL_DLLPRIVATE SfxStbCtrlFactArr_Impl& GetStbCtrlFactories_Impl() const;
228 : SAL_DLLPRIVATE SfxMenuCtrlFactArr_Impl& GetMenuCtrlFactories_Impl() const;
229 : SAL_DLLPRIVATE SfxChildWinFactArr_Impl& GetChildWinFactories_Impl() const;
230 : SAL_DLLPRIVATE SfxViewFrameArr_Impl& GetViewFrames_Impl() const;
231 : SAL_DLLPRIVATE SfxViewShellArr_Impl& GetViewShells_Impl() const;
232 : SAL_DLLPRIVATE SfxObjectShellArr_Impl& GetObjectShells_Impl() const;
233 : SAL_DLLPRIVATE void SetViewFrame_Impl(SfxViewFrame *pViewFrame);
234 :
235 : // Slot Methods
236 : // TODO/CLEANUP: still needed?
237 : SAL_DLLPRIVATE void NewDocDirectExec_Impl(SfxRequest &);
238 : SAL_DLLPRIVATE void NewDocExec_Impl(SfxRequest &);
239 : SAL_DLLPRIVATE void OpenDocExec_Impl(SfxRequest &);
240 : SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &);
241 : SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &);
242 : SAL_DLLPRIVATE void PropExec_Impl(SfxRequest &);
243 : SAL_DLLPRIVATE void PropState_Impl(SfxItemSet &);
244 : SAL_DLLPRIVATE void INetExecute_Impl(SfxRequest &);
245 : SAL_DLLPRIVATE void INetState_Impl(SfxItemSet &);
246 : SAL_DLLPRIVATE void OfaExec_Impl(SfxRequest &);
247 : SAL_DLLPRIVATE void OfaState_Impl(SfxItemSet &);
248 :
249 : SAL_DLLPRIVATE void SetProgress_Impl(SfxProgress *);
250 : SAL_DLLPRIVATE const String& GetLastDir_Impl() const;
251 : SAL_DLLPRIVATE void SetLastDir_Impl( const String & );
252 :
253 : SAL_DLLPRIVATE void Registrations_Impl();
254 : SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl(const SfxViewFrame *pFrame=0) const;
255 :
256 : // TODO/CLEANUP: still needed?
257 : SAL_DLLPRIVATE std::vector<sal_uInt16>* GetDisabledSlotList_Impl();
258 : SAL_DLLPRIVATE SfxSlotPool& GetAppSlotPool_Impl() const;
259 : SAL_DLLPRIVATE SfxModule* GetModule_Impl();
260 : SAL_DLLPRIVATE ResMgr* GetOffResManager_Impl();
261 :
262 : /* loads a branded bitmap - that can be overridden per locale */
263 : static bool LoadBrandBitmap (const char* pName, BitmapEx &rBitmap);
264 : /** loads the application logo as used in the about dialog and impress slideshow pause screen */
265 : static Image GetApplicationLogo();
266 : };
267 :
268 : #define SFX_APP() SfxGetpApp()
269 :
270 : //--------------------------------------------------------------------
271 :
272 903 : inline SfxApplication* SfxGetpApp()
273 : {
274 903 : return SfxApplication::GetOrCreate();
275 : }
276 :
277 : #endif
278 :
279 :
280 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|