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