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