/src/libreoffice/include/sfx2/app.hxx
Line | Count | Source |
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 <memory> |
23 | | #include <sal/config.h> |
24 | | #include <sfx2/dllapi.h> |
25 | | #include <sal/types.h> |
26 | | #include <comphelper/errcode.hxx> |
27 | | #include <svl/poolitem.hxx> |
28 | | #include <vcl/bitmap.hxx> |
29 | | #include <tools/link.hxx> |
30 | | #include <com/sun/star/ui/XAcceleratorConfiguration.hpp> |
31 | | #include <unordered_map> |
32 | | |
33 | | #include <sfx2/shell.hxx> |
34 | | |
35 | | namespace com::sun::star::frame { class XFrame; } |
36 | | namespace com::sun::star::script { class XStorageBasedLibraryContainer; } |
37 | | |
38 | | namespace weld { class Window; } |
39 | | |
40 | | class BasicManager; |
41 | | class DdeService; |
42 | | class SfxAppData_Impl; |
43 | | class SfxDispatcher; |
44 | | class SfxEventHint; |
45 | | class SfxItemSet; |
46 | | class SfxObjectShell; |
47 | | class SfxObjectShellLock; |
48 | | class SfxProgress; |
49 | | class SfxSlotPool; |
50 | | class SfxViewFrame; |
51 | | class StarBASIC; |
52 | | class SfxWorkWindow; |
53 | | class SfxFilterMatcher; |
54 | | class SfxModule; |
55 | | struct SfxChildWinFactory; |
56 | | struct SfxStbCtrlFactory; |
57 | | struct SfxTbxCtrlFactory; |
58 | | class SbxArray; |
59 | | class SbxValue; |
60 | | |
61 | | namespace sfx2 |
62 | | { |
63 | | namespace sidebar { |
64 | | class Theme; |
65 | | } |
66 | | } |
67 | | |
68 | | enum class SfxToolsModule |
69 | | { |
70 | | Math = 0, |
71 | | Calc = 1, |
72 | | Draw = 2, |
73 | | Writer = 3, |
74 | | Basic = 4, |
75 | | LAST = Basic |
76 | | }; |
77 | | |
78 | | class SFX2_DLLPUBLIC SfxLinkItem final : public SfxPoolItem |
79 | | { |
80 | | Link<SfxPoolItem const *, void> aLink; |
81 | | |
82 | 0 | SfxLinkItem(SfxLinkItem const &) = default; |
83 | | void operator =(SfxLinkItem const &) = delete; |
84 | | |
85 | | public: |
86 | | DECLARE_ITEM_TYPE_FUNCTION(SfxLinkItem) |
87 | | SfxLinkItem( sal_uInt16 nWhichId, const Link<SfxPoolItem const *, void>& rValue ) |
88 | | : SfxPoolItem( nWhichId ) |
89 | 0 | { aLink = rValue; } |
90 | | |
91 | | virtual ~SfxLinkItem() override; |
92 | | |
93 | | virtual SfxLinkItem* Clone( SfxItemPool* = nullptr ) const override |
94 | 0 | { return new SfxLinkItem( *this ); } |
95 | | virtual bool operator==( const SfxPoolItem& rL) const override |
96 | 0 | { return static_cast<const SfxLinkItem&>(rL).aLink == aLink; } |
97 | | const Link<SfxPoolItem const *, void>& |
98 | 0 | GetValue() const { return aLink; } |
99 | | }; |
100 | | |
101 | | // This is a singleton class. Sad that there apparently is no other |
102 | | // way than a comment like this to indicate that to the code reader. |
103 | | class SFX2_DLLPUBLIC SfxApplication final : public SfxShell |
104 | | { |
105 | | std::unique_ptr<SfxAppData_Impl> pImpl; |
106 | | |
107 | | DECL_DLLPRIVATE_STATIC_LINK( SfxApplication, GlobalBasicErrorHdl_Impl, StarBASIC*, bool ); |
108 | | |
109 | | SAL_DLLPRIVATE void Deinitialize(); |
110 | | |
111 | | public: |
112 | | SFX_DECL_INTERFACE(SFX_INTERFACE_SFXAPP) |
113 | | |
114 | | private: |
115 | | /// SfxInterface initializer. |
116 | | SAL_DLLPRIVATE static void InitInterface_Impl(); |
117 | | SAL_DLLPRIVATE SfxApplication(); |
118 | | |
119 | | public: |
120 | | SAL_DLLPRIVATE virtual ~SfxApplication() override; |
121 | | static SfxApplication* GetOrCreate(); |
122 | | static SfxApplication* Get(); |
123 | | |
124 | | // DDE |
125 | | #if defined(_WIN32) |
126 | | static bool DdeExecute( const OUString& rCmd ); |
127 | | #endif |
128 | | SAL_DLLPRIVATE bool InitializeDde(); |
129 | | SAL_DLLPRIVATE const DdeService* GetDdeService() const; |
130 | | DdeService* GetDdeService(); |
131 | | #if defined(_WIN32) |
132 | | void AddDdeTopic( SfxObjectShell* ); |
133 | | #endif |
134 | | void RemoveDdeTopic( SfxObjectShell const * ); |
135 | | |
136 | | // "static" methods |
137 | | /** |
138 | | * @param pArgs Takes ownership |
139 | | */ |
140 | | ErrCodeMsg LoadTemplate( SfxObjectShellLock& xDoc, const OUString& rFileName, std::unique_ptr<SfxItemSet> pArgs ); |
141 | | weld::Window* GetTopWindow() const; |
142 | | |
143 | | // members |
144 | | SfxFilterMatcher& GetFilterMatcher(); |
145 | | SAL_DLLPRIVATE SfxProgress* GetProgress() const; |
146 | | SAL_DLLPRIVATE sal_uInt16 GetFreeIndex(); |
147 | | SAL_DLLPRIVATE void ReleaseIndex(sal_uInt16 i); |
148 | | |
149 | | // Basic/Scripting |
150 | | static bool IsXScriptURL( const OUString& rScriptURL ); |
151 | | static OUString ChooseScript(weld::Window *pParent); |
152 | | // if xDocFrame is present, then select that document in the macro organizer by default, otherwise it is typically "Application Macros" |
153 | | // that is preselected |
154 | | SAL_DLLPRIVATE static void MacroOrganizer(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 nTabId); |
155 | | static ErrCode CallBasic( const OUString&, BasicManager*, SbxArray *pArgs, SbxValue *pRet ); |
156 | | static ErrCode CallAppBasic( const OUString& i_macroName ) |
157 | 0 | { return CallBasic( i_macroName, SfxApplication::GetBasicManager(), nullptr, nullptr ); } |
158 | | static BasicManager* GetBasicManager(); |
159 | | css::script::XStorageBasedLibraryContainer* GetDialogContainer(); |
160 | | css::script::XStorageBasedLibraryContainer* GetBasicContainer(); |
161 | | static StarBASIC* GetBasic(); |
162 | | void SaveBasicAndDialogContainer() const; |
163 | | |
164 | | // misc. |
165 | | static void GetOptions(SfxItemSet &); |
166 | | static void SetOptions(const SfxItemSet &); |
167 | | SAL_DLLPRIVATE virtual void Invalidate(sal_uInt16 nId = 0) override; |
168 | | void NotifyEvent(const SfxEventHint& rEvent, bool bSynchron = true ); |
169 | | bool IsDowning() const; |
170 | | |
171 | | SAL_DLLPRIVATE SfxDispatcher* GetAppDispatcher_Impl(); |
172 | | SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl(); |
173 | | |
174 | | SAL_DLLPRIVATE void Initialize_Impl(); |
175 | | |
176 | 17.6M | SAL_DLLPRIVATE SfxAppData_Impl* Get_Impl() const { return pImpl.get(); } |
177 | | |
178 | | // Object-Factories/global arrays |
179 | | SAL_DLLPRIVATE void RegisterChildWindow_Impl(SfxModule*, const SfxChildWinFactory&); |
180 | | SAL_DLLPRIVATE void RegisterStatusBarControl_Impl(SfxModule*, const SfxStbCtrlFactory&); |
181 | | SAL_DLLPRIVATE void RegisterToolBoxControl_Impl( SfxModule*, const SfxTbxCtrlFactory&); |
182 | | SAL_DLLPRIVATE SfxTbxCtrlFactory* GetTbxCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const; |
183 | | SAL_DLLPRIVATE SfxStbCtrlFactory* GetStbCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const; |
184 | | SAL_DLLPRIVATE SfxChildWinFactory* GetChildWinFactoryById(sal_uInt16 nId) const; |
185 | | SAL_DLLPRIVATE std::vector<SfxViewFrame*>& GetViewFrames_Impl() const; |
186 | | SAL_DLLPRIVATE std::vector<SfxViewShell*>& GetViewShells_Impl() const; |
187 | | /* unordered_map<ModuleName+Language, acceleratorConfigurationClassInstance> */ |
188 | | SAL_DLLPRIVATE std::unordered_map<OUString, css::uno::Reference<css::ui::XAcceleratorConfiguration>>& GetAcceleratorConfs_Impl() const; |
189 | | SAL_DLLPRIVATE std::vector<SfxObjectShell*>& GetObjectShells_Impl() const; |
190 | | SAL_DLLPRIVATE void SetViewFrame_Impl(SfxViewFrame *pViewFrame); |
191 | | |
192 | | // Slot Methods |
193 | | // TODO/CLEANUP: still needed? |
194 | | SAL_DLLPRIVATE void NewDocDirectExec_Impl(SfxRequest &); |
195 | | SAL_DLLPRIVATE static void NewDocDirectState_Impl(SfxItemSet &); |
196 | | SAL_DLLPRIVATE void NewDocExec_Impl(SfxRequest &); |
197 | | SAL_DLLPRIVATE void OpenDocExec_Impl(SfxRequest &); |
198 | | SAL_DLLPRIVATE void OpenRemoteExec_Impl(SfxRequest &); |
199 | | SAL_DLLPRIVATE void SignPDFExec_Impl(SfxRequest&); |
200 | | SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &); |
201 | | SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &); |
202 | | SAL_DLLPRIVATE static void PropExec_Impl(SfxRequest const &); |
203 | | SAL_DLLPRIVATE static void PropState_Impl(SfxItemSet &); |
204 | | SAL_DLLPRIVATE void OfaExec_Impl(SfxRequest &); |
205 | | SAL_DLLPRIVATE static void OfaState_Impl(SfxItemSet &); |
206 | | |
207 | | SAL_DLLPRIVATE void SetProgress_Impl(SfxProgress *); |
208 | | |
209 | | SAL_DLLPRIVATE static void Registrations_Impl(); |
210 | | SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl(const SfxViewFrame *pFrame) const; |
211 | | |
212 | | // TODO/CLEANUP: still needed? -- unclear whether this comment |
213 | | // refers to the GetDisabledSlotList_Impl() method which was |
214 | | // already removed, or the below methods? |
215 | | SAL_DLLPRIVATE SfxSlotPool& GetAppSlotPool_Impl() const; |
216 | | SAL_DLLPRIVATE static SfxModule* GetModule_Impl(); |
217 | | |
218 | | static void SetModule(SfxToolsModule nSharedLib, std::unique_ptr<SfxModule> pModule); |
219 | | static SfxModule* GetModule(SfxToolsModule nSharedLib); |
220 | | |
221 | | static bool loadBrandSvg(const char *pName, Bitmap& rBitmap, int nWidth); |
222 | | |
223 | | /** loads the application logo as used in the impress slideshow pause screen */ |
224 | | static Bitmap GetApplicationLogo(tools::Long nWidth); |
225 | | |
226 | | /** if true then dialog/infobar notifications like the tip of the day or |
227 | | version change infobar should be suppressed */ |
228 | | static bool IsHeadlessOrUITest(); |
229 | | |
230 | | static bool IsTipOfTheDayDue(); |
231 | | |
232 | | /** this Theme contains Images so must be deleted before DeInitVCL */ |
233 | | SAL_DLLPRIVATE sfx2::sidebar::Theme & GetSidebarTheme(); |
234 | | }; |
235 | | |
236 | | inline SfxApplication* SfxGetpApp() |
237 | 12.0M | { |
238 | 12.0M | return SfxApplication::Get(); |
239 | 12.0M | } |
240 | | |
241 | | #endif |
242 | | |
243 | | |
244 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |