lok: calc - send other views our selection in their co-ordinates.
[LibreOffice.git] / include / sfx2 / app.hxx
blobf08855ee8d18fed2f4295df47b38b7e2b8ddb77f
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 <vcl/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::script { class XLibraryContainer; }
35 namespace weld { class Window; }
37 class BasicManager;
38 class DdeService;
39 struct SfxChildWinContextFactory;
40 class SfxAppData_Impl;
41 class SfxChildWinFactArr_Impl;
42 class SfxDispatcher;
43 class SfxEventHint;
44 class SfxItemSet;
45 class SfxObjectShell;
46 class SfxObjectShellArr_Impl;
47 class SfxObjectShellLock;
48 class SfxProgress;
49 class SfxSlotPool;
50 class SfxStbCtrlFactArr_Impl;
51 class SfxTbxCtrlFactArr_Impl;
52 class SfxViewFrame;
53 class SfxViewFrameArr_Impl;
54 class SfxViewShellArr_Impl;
55 class StarBASIC;
56 class SfxWorkWindow;
57 class SfxFilterMatcher;
58 class SfxModule;
59 namespace vcl { class Window; }
60 struct SfxChildWinFactory;
61 struct SfxStbCtrlFactory;
62 struct SfxTbxCtrlFactory;
63 class SbxArray;
64 class SbxValue;
66 namespace sfx2
68 namespace sidebar {
69 class Theme;
73 enum class SfxToolsModule
75 Math = 0,
76 Calc = 1,
77 Draw = 2,
78 Writer = 3,
79 Basic = 4,
80 LAST = Basic
83 class SFX2_DLLPUBLIC SfxLinkItem final : public SfxPoolItem
85 Link<SfxPoolItem const *, void> aLink;
86 public:
87 SfxLinkItem( sal_uInt16 nWhichId, const Link<SfxPoolItem const *, void>& rValue ) : SfxPoolItem( nWhichId )
88 { aLink = rValue; }
90 virtual SfxLinkItem* Clone( SfxItemPool* = nullptr ) const override
91 { return new SfxLinkItem( *this ); }
92 virtual bool operator==( const SfxPoolItem& rL) const override
93 { return static_cast<const SfxLinkItem&>(rL).aLink == aLink; }
94 const Link<SfxPoolItem const *, void>&
95 GetValue() const { return aLink; }
98 // This is a singleton class. Sad that there apparently is no other
99 // way than a comment like this to indicate that to the code reader.
100 class SFX2_DLLPUBLIC SfxApplication final : public SfxShell
102 std::unique_ptr<SfxAppData_Impl> pImpl;
104 DECL_DLLPRIVATE_STATIC_LINK( SfxApplication, GlobalBasicErrorHdl_Impl, StarBASIC*, bool );
106 void Deinitialize();
108 public:
109 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXAPP)
111 private:
112 /// SfxInterface initializer.
113 static void InitInterface_Impl();
114 SfxApplication();
116 public:
117 virtual ~SfxApplication() override;
118 static SfxApplication* GetOrCreate();
119 static SfxApplication* Get();
121 // DDE
122 #if defined(_WIN32)
123 static long DdeExecute( const OUString& rCmd );
124 #endif
125 bool InitializeDde();
126 const DdeService* GetDdeService() const;
127 DdeService* GetDdeService();
128 #if defined(_WIN32)
129 void AddDdeTopic( SfxObjectShell* );
130 #endif
131 void RemoveDdeTopic( SfxObjectShell const * );
133 // "static" methods
135 * @param pArgs Takes ownership
137 ErrCode LoadTemplate( SfxObjectShellLock& xDoc, const OUString& rFileName, std::unique_ptr<SfxItemSet> pArgs );
138 vcl::Window* GetTopWindow() const;
140 // members
141 SfxFilterMatcher& GetFilterMatcher();
142 SfxProgress* GetProgress() const;
143 sal_uInt16 GetFreeIndex();
144 void ReleaseIndex(sal_uInt16 i);
146 // Basic/Scripting
147 static bool IsXScriptURL( const OUString& rScriptURL );
148 static OUString ChooseScript(weld::Window *pParent);
149 static void MacroOrganizer(weld::Window* pParent, sal_Int16 nTabId);
150 static ErrCode CallBasic( const OUString&, BasicManager*, SbxArray *pArgs, SbxValue *pRet );
151 static ErrCode CallAppBasic( const OUString& i_macroName )
152 { return CallBasic( i_macroName, SfxApplication::GetBasicManager(), nullptr, nullptr ); }
153 static BasicManager* GetBasicManager();
154 css::script::XLibraryContainer * GetDialogContainer();
155 css::script::XLibraryContainer * GetBasicContainer();
156 static StarBASIC* GetBasic();
157 void SaveBasicAndDialogContainer() const;
159 // misc.
160 void GetOptions(SfxItemSet &);
161 void SetOptions(const SfxItemSet &);
162 virtual void Invalidate(sal_uInt16 nId = 0) override;
163 void NotifyEvent(const SfxEventHint& rEvent, bool bSynchron = true );
164 bool IsDowning() const;
165 void ResetLastDir();
167 SAL_DLLPRIVATE SfxDispatcher* GetAppDispatcher_Impl();
168 SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl();
170 SAL_DLLPRIVATE void SetOptions_Impl(const SfxItemSet &);
171 SAL_DLLPRIVATE void Initialize_Impl();
173 SAL_DLLPRIVATE SfxAppData_Impl* Get_Impl() const { return pImpl.get(); }
175 // Object-Factories/global arrays
176 SAL_DLLPRIVATE void RegisterChildWindow_Impl(SfxModule*, std::unique_ptr<SfxChildWinFactory>);
177 SAL_DLLPRIVATE void RegisterChildWindowContext_Impl(SfxModule*, sal_uInt16, std::unique_ptr<SfxChildWinContextFactory>);
178 SAL_DLLPRIVATE void RegisterStatusBarControl_Impl(SfxModule*, const SfxStbCtrlFactory&);
179 SAL_DLLPRIVATE void RegisterToolBoxControl_Impl( SfxModule*, const SfxTbxCtrlFactory&);
180 SAL_DLLPRIVATE SfxTbxCtrlFactArr_Impl& GetTbxCtrlFactories_Impl() const;
181 SAL_DLLPRIVATE SfxStbCtrlFactArr_Impl& GetStbCtrlFactories_Impl() const;
182 SAL_DLLPRIVATE SfxChildWinFactArr_Impl& GetChildWinFactories_Impl() const;
183 SAL_DLLPRIVATE SfxViewFrameArr_Impl& GetViewFrames_Impl() const;
184 SAL_DLLPRIVATE SfxViewShellArr_Impl& GetViewShells_Impl() const;
185 SAL_DLLPRIVATE SfxObjectShellArr_Impl& GetObjectShells_Impl() const;
186 SAL_DLLPRIVATE void SetViewFrame_Impl(SfxViewFrame *pViewFrame);
188 // Slot Methods
189 // TODO/CLEANUP: still needed?
190 SAL_DLLPRIVATE void NewDocDirectExec_Impl(SfxRequest &);
191 SAL_DLLPRIVATE void NewDocExec_Impl(SfxRequest &);
192 SAL_DLLPRIVATE void OpenDocExec_Impl(SfxRequest &);
193 SAL_DLLPRIVATE void OpenRemoteExec_Impl(SfxRequest &);
194 SAL_DLLPRIVATE void SignPDFExec_Impl(SfxRequest&);
195 SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &);
196 SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &);
197 SAL_DLLPRIVATE static void PropExec_Impl(SfxRequest const &);
198 SAL_DLLPRIVATE static void PropState_Impl(SfxItemSet &);
199 SAL_DLLPRIVATE void OfaExec_Impl(SfxRequest &);
200 SAL_DLLPRIVATE static void OfaState_Impl(SfxItemSet &);
202 SAL_DLLPRIVATE void SetProgress_Impl(SfxProgress *);
203 SAL_DLLPRIVATE const OUString& GetLastDir_Impl() const;
204 SAL_DLLPRIVATE void SetLastDir_Impl( const OUString & );
206 SAL_DLLPRIVATE static void Registrations_Impl();
207 SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl(const SfxViewFrame *pFrame) const;
209 // TODO/CLEANUP: still needed? -- unclear whether this comment
210 // refers to the GetDisabledSlotList_Impl() method which was
211 // already removed, or the below methods?
212 SAL_DLLPRIVATE SfxSlotPool& GetAppSlotPool_Impl() const;
213 SAL_DLLPRIVATE static SfxModule* GetModule_Impl();
215 static void SetModule(SfxToolsModule nSharedLib, std::unique_ptr<SfxModule> pModule);
216 static SfxModule* GetModule(SfxToolsModule nSharedLib);
218 static bool loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWidth);
220 /** loads the application logo as used in the impress slideshow pause screen */
221 static BitmapEx GetApplicationLogo(long nWidth);
223 /** this Theme contains Images so must be deleted before DeInitVCL */
224 sfx2::sidebar::Theme & GetSidebarTheme();
227 inline SfxApplication* SfxGetpApp()
229 return SfxApplication::Get();
232 #endif
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */