1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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
; }
42 class SfxAppData_Impl
;
47 class SfxObjectShellLock
;
53 class SfxFilterMatcher
;
55 struct SfxChildWinFactory
;
56 struct SfxStbCtrlFactory
;
57 struct SfxTbxCtrlFactory
;
68 enum class SfxToolsModule
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;
86 SfxLinkItem( sal_uInt16 nWhichId
, const Link
<SfxPoolItem
const *, void>& rValue
)
87 : SfxPoolItem( nWhichId
, SfxItemType::SfxLinkItemType
)
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();
111 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXAPP
)
114 /// SfxInterface initializer.
115 SAL_DLLPRIVATE
static void InitInterface_Impl();
116 SAL_DLLPRIVATE
SfxApplication();
119 SAL_DLLPRIVATE
virtual ~SfxApplication() override
;
120 static SfxApplication
* GetOrCreate();
121 static SfxApplication
* Get();
125 static bool DdeExecute( const OUString
& rCmd
);
127 SAL_DLLPRIVATE
bool InitializeDde();
128 SAL_DLLPRIVATE
const DdeService
* GetDdeService() const;
129 DdeService
* GetDdeService();
131 void AddDdeTopic( SfxObjectShell
* );
133 void RemoveDdeTopic( SfxObjectShell
const * );
137 * @param pArgs Takes ownership
139 ErrCodeMsg
LoadTemplate( SfxObjectShellLock
& xDoc
, const OUString
& rFileName
, std::unique_ptr
<SfxItemSet
> pArgs
);
140 weld::Window
* GetTopWindow() const;
143 SfxFilterMatcher
& GetFilterMatcher();
144 SAL_DLLPRIVATE SfxProgress
* GetProgress() const;
145 SAL_DLLPRIVATE sal_uInt16
GetFreeIndex();
146 SAL_DLLPRIVATE
void ReleaseIndex(sal_uInt16 i
);
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;
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;
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
);
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();
246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */