Move setting of LD_LIBRARY_PATH closer to invocation of cppunittester
[LibreOffice.git] / include / sfx2 / app.hxx
blobd8c1ca98949656dd61a9bc37054dd0b5e80d21ed
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>
30 #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
31 #include <unordered_map>
33 #include <sfx2/shell.hxx>
35 namespace com::sun::star::frame { class XFrame; }
36 namespace com::sun::star::script { class XLibraryContainer; }
38 namespace weld { class Window; }
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;
61 namespace sfx2
63 namespace sidebar {
64 class Theme;
68 enum class SfxToolsModule
70 Math = 0,
71 Calc = 1,
72 Draw = 2,
73 Writer = 3,
74 Basic = 4,
75 LAST = Basic
78 class SFX2_DLLPUBLIC SfxLinkItem final : public SfxPoolItem
80 Link<SfxPoolItem const *, void> aLink;
82 SfxLinkItem(SfxLinkItem const &) = default;
83 void operator =(SfxLinkItem const &) = delete;
85 public:
86 SfxLinkItem( sal_uInt16 nWhichId, const Link<SfxPoolItem const *, void>& rValue )
87 : SfxPoolItem( nWhichId, SfxItemType::SfxLinkItemType )
88 { aLink = rValue; }
90 virtual ~SfxLinkItem() override;
92 virtual SfxLinkItem* Clone( SfxItemPool* = nullptr ) const override
93 { return new SfxLinkItem( *this ); }
94 virtual bool operator==( const SfxPoolItem& rL) const override
95 { return static_cast<const SfxLinkItem&>(rL).aLink == aLink; }
96 const Link<SfxPoolItem const *, void>&
97 GetValue() const { return aLink; }
100 // This is a singleton class. Sad that there apparently is no other
101 // way than a comment like this to indicate that to the code reader.
102 class SFX2_DLLPUBLIC SfxApplication final : public SfxShell
104 std::unique_ptr<SfxAppData_Impl> pImpl;
106 DECL_DLLPRIVATE_STATIC_LINK( SfxApplication, GlobalBasicErrorHdl_Impl, StarBASIC*, bool );
108 SAL_DLLPRIVATE void Deinitialize();
110 public:
111 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXAPP)
113 private:
114 /// SfxInterface initializer.
115 SAL_DLLPRIVATE static void InitInterface_Impl();
116 SAL_DLLPRIVATE SfxApplication();
118 public:
119 SAL_DLLPRIVATE virtual ~SfxApplication() override;
120 static SfxApplication* GetOrCreate();
121 static SfxApplication* Get();
123 // DDE
124 #if defined(_WIN32)
125 static bool DdeExecute( const OUString& rCmd );
126 #endif
127 SAL_DLLPRIVATE bool InitializeDde();
128 SAL_DLLPRIVATE const DdeService* GetDdeService() const;
129 DdeService* GetDdeService();
130 #if defined(_WIN32)
131 void AddDdeTopic( SfxObjectShell* );
132 #endif
133 void RemoveDdeTopic( SfxObjectShell const * );
135 // "static" methods
137 * @param pArgs Takes ownership
139 ErrCodeMsg LoadTemplate( SfxObjectShellLock& xDoc, const OUString& rFileName, std::unique_ptr<SfxItemSet> pArgs );
140 weld::Window* GetTopWindow() const;
142 // members
143 SfxFilterMatcher& GetFilterMatcher();
144 SAL_DLLPRIVATE SfxProgress* GetProgress() const;
145 SAL_DLLPRIVATE sal_uInt16 GetFreeIndex();
146 SAL_DLLPRIVATE void ReleaseIndex(sal_uInt16 i);
148 // Basic/Scripting
149 static bool IsXScriptURL( const OUString& rScriptURL );
150 static OUString ChooseScript(weld::Window *pParent);
151 // if xDocFrame is present, then select that document in the macro organizer by default, otherwise it is typically "Application Macros"
152 // that is preselected
153 SAL_DLLPRIVATE static void MacroOrganizer(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 nTabId);
154 static ErrCode CallBasic( const OUString&, BasicManager*, SbxArray *pArgs, SbxValue *pRet );
155 static ErrCode CallAppBasic( const OUString& i_macroName )
156 { return CallBasic( i_macroName, SfxApplication::GetBasicManager(), nullptr, nullptr ); }
157 static BasicManager* GetBasicManager();
158 css::script::XLibraryContainer * GetDialogContainer();
159 css::script::XLibraryContainer * GetBasicContainer();
160 static StarBASIC* GetBasic();
161 void SaveBasicAndDialogContainer() const;
163 // misc.
164 static void GetOptions(SfxItemSet &);
165 static void SetOptions(const SfxItemSet &);
166 SAL_DLLPRIVATE virtual void Invalidate(sal_uInt16 nId = 0) override;
167 void NotifyEvent(const SfxEventHint& rEvent, bool bSynchron = true );
168 bool IsDowning() const;
169 void ResetLastDir();
171 SAL_DLLPRIVATE SfxDispatcher* GetAppDispatcher_Impl();
172 SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl();
174 SAL_DLLPRIVATE void Initialize_Impl();
176 SAL_DLLPRIVATE SfxAppData_Impl* Get_Impl() const { return pImpl.get(); }
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);
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 &);
207 SAL_DLLPRIVATE void SetProgress_Impl(SfxProgress *);
208 SAL_DLLPRIVATE const OUString& GetLastDir_Impl() const;
209 SAL_DLLPRIVATE void SetLastDir_Impl( const OUString & );
211 SAL_DLLPRIVATE static void Registrations_Impl();
212 SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl(const SfxViewFrame *pFrame) const;
214 // TODO/CLEANUP: still needed? -- unclear whether this comment
215 // refers to the GetDisabledSlotList_Impl() method which was
216 // already removed, or the below methods?
217 SAL_DLLPRIVATE SfxSlotPool& GetAppSlotPool_Impl() const;
218 SAL_DLLPRIVATE static SfxModule* GetModule_Impl();
220 static void SetModule(SfxToolsModule nSharedLib, std::unique_ptr<SfxModule> pModule);
221 static SfxModule* GetModule(SfxToolsModule nSharedLib);
223 static bool loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWidth);
225 /** loads the application logo as used in the impress slideshow pause screen */
226 static BitmapEx GetApplicationLogo(tools::Long nWidth);
228 /** if true then dialog/infobar notifications like the tip of the day or
229 version change infobar should be suppressed */
230 static bool IsHeadlessOrUITest();
232 static bool IsTipOfTheDayDue();
234 /** this Theme contains Images so must be deleted before DeInitVCL */
235 SAL_DLLPRIVATE sfx2::sidebar::Theme & GetSidebarTheme();
238 inline SfxApplication* SfxGetpApp()
240 return SfxApplication::Get();
243 #endif
246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */