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