LibreOffice Module sfx2 (master) 1
app.hxx
Go to the documentation of this file.
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>
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>
32
33#include <sfx2/shell.hxx>
34
35namespace com::sun::star::frame { class XFrame; }
36namespace com::sun::star::script { class XLibraryContainer; }
37
38namespace weld { class Window; }
39
40class BasicManager;
41class DdeService;
42class SfxAppData_Impl;
43class SfxDispatcher;
44class SfxEventHint;
45class SfxItemSet;
46class SfxObjectShell;
48class SfxProgress;
49class SfxSlotPool;
50class SfxViewFrame;
51class StarBASIC;
52class SfxWorkWindow;
54class SfxModule;
58class SbxArray;
59class SbxValue;
60
61namespace sfx2
62{
63 namespace sidebar {
64 class Theme;
65 }
66}
67
69{
70 Math = 0,
71 Calc = 1,
72 Draw = 2,
73 Writer = 3,
74 Basic = 4,
75 LAST = Basic
76};
77
79{
81public:
82 SfxLinkItem( sal_uInt16 nWhichId, const Link<SfxPoolItem const *, void>& rValue ) : SfxPoolItem( nWhichId )
83 { aLink = rValue; }
84
85 virtual SfxLinkItem* Clone( SfxItemPool* = nullptr ) const override
86 { return new SfxLinkItem( *this ); }
87 virtual bool operator==( const SfxPoolItem& rL) const override
88 { return static_cast<const SfxLinkItem&>(rL).aLink == aLink; }
90 GetValue() const { return aLink; }
91};
92
93// This is a singleton class. Sad that there apparently is no other
94// way than a comment like this to indicate that to the code reader.
96{
97 std::unique_ptr<SfxAppData_Impl> pImpl;
98
99 DECL_DLLPRIVATE_STATIC_LINK( SfxApplication, GlobalBasicErrorHdl_Impl, StarBASIC*, bool );
100
101 void Deinitialize();
102
103public:
105
106private:
108 static void InitInterface_Impl();
110
111public:
112 virtual ~SfxApplication() override;
113 static SfxApplication* GetOrCreate();
114 static SfxApplication* Get();
115
116 // DDE
117#if defined(_WIN32)
118 static bool DdeExecute( const OUString& rCmd );
119#endif
120 bool InitializeDde();
121 const DdeService* GetDdeService() const;
122 DdeService* GetDdeService();
123#if defined(_WIN32)
124 void AddDdeTopic( SfxObjectShell* );
125#endif
126 void RemoveDdeTopic( SfxObjectShell const * );
127
128 // "static" methods
132 ErrCode LoadTemplate( SfxObjectShellLock& xDoc, const OUString& rFileName, std::unique_ptr<SfxItemSet> pArgs );
133 weld::Window* GetTopWindow() const;
134
135 // members
136 SfxFilterMatcher& GetFilterMatcher();
137 SfxProgress* GetProgress() const;
138 sal_uInt16 GetFreeIndex();
139 void ReleaseIndex(sal_uInt16 i);
140
141 // Basic/Scripting
142 static bool IsXScriptURL( const OUString& rScriptURL );
143 static OUString ChooseScript(weld::Window *pParent);
144 // if xDocFrame is present, then select that document in the macro organizer by default, otherwise it is typically "Application Macros"
145 // that is preselected
146 static void MacroOrganizer(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 nTabId);
147 static ErrCode CallBasic( const OUString&, BasicManager*, SbxArray *pArgs, SbxValue *pRet );
148 static ErrCode CallAppBasic( const OUString& i_macroName )
149 { return CallBasic( i_macroName, SfxApplication::GetBasicManager(), nullptr, nullptr ); }
150 static BasicManager* GetBasicManager();
151 css::script::XLibraryContainer * GetDialogContainer();
152 css::script::XLibraryContainer * GetBasicContainer();
153 static StarBASIC* GetBasic();
154 void SaveBasicAndDialogContainer() const;
155
156 // misc.
157 static void GetOptions(SfxItemSet &);
158 static void SetOptions(const SfxItemSet &);
159 virtual void Invalidate(sal_uInt16 nId = 0) override;
160 void NotifyEvent(const SfxEventHint& rEvent, bool bSynchron = true );
161 bool IsDowning() const;
162 void ResetLastDir();
163
164 SAL_DLLPRIVATE SfxDispatcher* GetAppDispatcher_Impl();
165 SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl();
166
167 SAL_DLLPRIVATE void Initialize_Impl();
168
169 SAL_DLLPRIVATE SfxAppData_Impl* Get_Impl() const { return pImpl.get(); }
170
171 // Object-Factories/global arrays
172 SAL_DLLPRIVATE void RegisterChildWindow_Impl(SfxModule*, const SfxChildWinFactory&);
173 SAL_DLLPRIVATE void RegisterStatusBarControl_Impl(SfxModule*, const SfxStbCtrlFactory&);
174 SAL_DLLPRIVATE void RegisterToolBoxControl_Impl( SfxModule*, const SfxTbxCtrlFactory&);
175 SAL_DLLPRIVATE SfxTbxCtrlFactory* GetTbxCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const;
176 SAL_DLLPRIVATE SfxStbCtrlFactory* GetStbCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const;
177 SAL_DLLPRIVATE SfxChildWinFactory* GetChildWinFactoryById(sal_uInt16 nId) const;
178 SAL_DLLPRIVATE std::vector<SfxViewFrame*>& GetViewFrames_Impl() const;
179 SAL_DLLPRIVATE std::vector<SfxViewShell*>& GetViewShells_Impl() const;
180 /* unordered_map<ModuleName+Language, acceleratorConfigurationClassInstance> */
181 SAL_DLLPRIVATE std::unordered_map<OUString, css::uno::Reference<css::ui::XAcceleratorConfiguration>>& GetAcceleratorConfs_Impl() const;
182 SAL_DLLPRIVATE std::vector<SfxObjectShell*>& GetObjectShells_Impl() const;
183 SAL_DLLPRIVATE void SetViewFrame_Impl(SfxViewFrame *pViewFrame);
184
185 // Slot Methods
186 // TODO/CLEANUP: still needed?
187 SAL_DLLPRIVATE void NewDocDirectExec_Impl(SfxRequest &);
188 SAL_DLLPRIVATE static void NewDocDirectState_Impl(SfxItemSet &);
189 SAL_DLLPRIVATE void NewDocExec_Impl(SfxRequest &);
190 SAL_DLLPRIVATE void OpenDocExec_Impl(SfxRequest &);
191 SAL_DLLPRIVATE void OpenRemoteExec_Impl(SfxRequest &);
192 SAL_DLLPRIVATE void SignPDFExec_Impl(SfxRequest&);
193 SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &);
194 SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &);
195 SAL_DLLPRIVATE static void PropExec_Impl(SfxRequest const &);
196 SAL_DLLPRIVATE static void PropState_Impl(SfxItemSet &);
197 SAL_DLLPRIVATE void OfaExec_Impl(SfxRequest &);
198 SAL_DLLPRIVATE static void OfaState_Impl(SfxItemSet &);
199
200 SAL_DLLPRIVATE void SetProgress_Impl(SfxProgress *);
201 SAL_DLLPRIVATE const OUString& GetLastDir_Impl() const;
202 SAL_DLLPRIVATE void SetLastDir_Impl( const OUString & );
203
204 SAL_DLLPRIVATE static void Registrations_Impl();
205 SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl(const SfxViewFrame *pFrame) const;
206
207 // TODO/CLEANUP: still needed? -- unclear whether this comment
208 // refers to the GetDisabledSlotList_Impl() method which was
209 // already removed, or the below methods?
210 SAL_DLLPRIVATE SfxSlotPool& GetAppSlotPool_Impl() const;
211 SAL_DLLPRIVATE static SfxModule* GetModule_Impl();
212
213 static void SetModule(SfxToolsModule nSharedLib, std::unique_ptr<SfxModule> pModule);
214 static SfxModule* GetModule(SfxToolsModule nSharedLib);
215
216 static bool loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWidth);
217
219 static BitmapEx GetApplicationLogo(tools::Long nWidth);
220
223 static bool IsHeadlessOrUITest();
224
225 static bool IsTipOfTheDayDue();
226
228 sfx2::sidebar::Theme & GetSidebarTheme();
229};
230
232{
233 return SfxApplication::Get();
234}
235
236#endif
237
238
239/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxApplication * SfxGetpApp()
Definition: app.hxx:231
SfxToolsModule
Definition: app.hxx:69
SAL_DLLPRIVATE SfxAppData_Impl * Get_Impl() const
Definition: app.hxx:169
DECL_DLLPRIVATE_STATIC_LINK(SfxApplication, GlobalBasicErrorHdl_Impl, StarBASIC *, bool)
std::unique_ptr< SfxAppData_Impl > pImpl
Definition: app.hxx:97
static SfxApplication * Get()
Definition: app.cxx:70
static BasicManager * GetBasicManager()
Definition: appbas.cxx:62
static ErrCode CallAppBasic(const OUString &i_macroName)
Definition: app.hxx:148
virtual SfxLinkItem * Clone(SfxItemPool *=nullptr) const override
Definition: app.hxx:85
virtual bool operator==(const SfxPoolItem &rL) const override
Definition: app.hxx:87
const Link< SfxPoolItem const *, void > & GetValue() const
Definition: app.hxx:90
Link< SfxPoolItem const *, void > aLink
Definition: app.hxx:80
SfxLinkItem(sal_uInt16 nWhichId, const Link< SfxPoolItem const *, void > &rValue)
Definition: app.hxx:82
The class SfxShell is the base class for all classes, which provide the functionality of the form <Sl...
Definition: shell.hxx:128
Simple collection of colors, gradients, fonts that define the look of the sidebar and its controls.
Definition: Theme.hxx:44
#define SFX2_DLLPUBLIC
Definition: dllapi.h:29
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
long Long
#define SFX_DECL_INTERFACE(nId)
Definition: shell.hxx:532
constexpr auto SFX_INTERFACE_SFXAPP
Definition: shell.hxx:61