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>
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
; }
40 class SfxAppData_Impl
;
45 class SfxObjectShellLock
;
51 class SfxFilterMatcher
;
53 struct SfxChildWinFactory
;
54 struct SfxStbCtrlFactory
;
55 struct SfxTbxCtrlFactory
;
66 enum class SfxToolsModule
76 class SFX2_DLLPUBLIC SfxLinkItem final
: public SfxPoolItem
78 Link
<SfxPoolItem
const *, void> aLink
;
80 SfxLinkItem( sal_uInt16 nWhichId
, const Link
<SfxPoolItem
const *, void>& rValue
) : SfxPoolItem( nWhichId
)
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 );
102 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXAPP
)
105 /// SfxInterface initializer.
106 static void InitInterface_Impl();
110 virtual ~SfxApplication() override
;
111 static SfxApplication
* GetOrCreate();
112 static SfxApplication
* Get();
116 static bool DdeExecute( const OUString
& rCmd
);
118 bool InitializeDde();
119 const DdeService
* GetDdeService() const;
120 DdeService
* GetDdeService();
122 void AddDdeTopic( SfxObjectShell
* );
124 void RemoveDdeTopic( SfxObjectShell
const * );
128 * @param pArgs Takes ownership
130 ErrCode
LoadTemplate( SfxObjectShellLock
& xDoc
, const OUString
& rFileName
, std::unique_ptr
<SfxItemSet
> pArgs
);
131 weld::Window
* GetTopWindow() const;
134 SfxFilterMatcher
& GetFilterMatcher();
135 SfxProgress
* GetProgress() const;
136 sal_uInt16
GetFreeIndex();
137 void ReleaseIndex(sal_uInt16 i
);
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;
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;
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
);
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();
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */