android: Update app-specific/MIME type icons
[LibreOffice.git] / sc / inc / scmod.hxx
blob89c52478477639d22e8219381488fc9eff3aa5e8
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 .
20 #pragma once
22 #include "scdllapi.h"
23 #include <o3tl/deleter.hxx>
24 #include <vcl/timer.hxx>
25 #include <svl/lstner.hxx>
26 #include <sfx2/app.hxx>
27 #include <sfx2/module.hxx>
28 #include "global.hxx"
29 #include "shellids.hxx"
30 #include <unotools/options.hxx>
31 #include <com/sun/star/uno/Reference.h>
33 #include <vector>
34 #include <map>
35 #include <memory>
37 class KeyEvent;
38 class EditView;
39 class SfxErrorHandler;
40 class SvtAccessibilityOptions;
41 class SvtCTLOptions;
42 class SvtUserOptions;
44 namespace svtools { class ColorConfig; }
45 namespace ooo::vba { class XSinkCaller; }
46 namespace com::sun::star::uno { class Any; }
47 namespace com::sun::star::uno { template <typename > class Sequence; }
49 class ScRange;
50 class ScDocument;
51 class ScViewCfg;
52 class ScDocCfg;
53 class ScAppCfg;
54 class ScDefaultsCfg;
55 class ScFormulaCfg;
56 class ScInputCfg;
57 class ScPrintCfg;
58 class ScViewOptions;
59 class ScDocOptions;
60 class ScAppOptions;
61 class ScDefaultsOptions;
62 class ScFormulaOptions;
63 class ScInputOptions;
64 class ScPrintOptions;
65 class ScInputHandler;
66 class ScTabViewShell;
67 class ScMessagePool;
68 class EditFieldInfo;
69 class ScNavipiCfg;
70 class ScAddInCfg;
71 class ScTransferObj;
72 class ScDrawTransferObj;
73 class ScSelectionTransferObj;
74 class ScFormEditData;
75 class ScMarkData;
76 struct ScDragData;
77 class SfxDialogController;
79 class SAL_DLLPUBLIC_RTTI ScModule final : public SfxModule, public SfxListener, public utl::ConfigurationListener
81 Timer m_aIdleTimer;
82 std::unique_ptr<ScDragData> m_pDragData;
83 ScSelectionTransferObj* m_pSelTransfer;
84 rtl::Reference<ScMessagePool> m_pMessagePool;
85 // there is no global InputHandler anymore, each View has its own
86 ScInputHandler* m_pRefInputHandler;
87 std::unique_ptr<ScViewCfg, o3tl::default_delete<ScViewCfg>> m_pViewCfg;
88 std::unique_ptr<ScDocCfg, o3tl::default_delete<ScDocCfg>> m_pDocCfg;
89 std::unique_ptr<ScAppCfg, o3tl::default_delete<ScAppCfg>> m_pAppCfg;
90 std::unique_ptr<ScDefaultsCfg> m_pDefaultsCfg;
91 std::unique_ptr<ScFormulaCfg> m_pFormulaCfg;
92 std::unique_ptr<ScInputCfg> m_pInputCfg;
93 std::unique_ptr<ScPrintCfg> m_pPrintCfg;
94 std::unique_ptr<ScNavipiCfg> m_pNavipiCfg;
95 std::unique_ptr<ScAddInCfg> m_pAddInCfg;
96 std::unique_ptr<svtools::ColorConfig> m_pColorConfig;
97 std::unique_ptr<SvtAccessibilityOptions> m_pAccessOptions;
98 std::unique_ptr<SvtCTLOptions> m_pCTLOptions;
99 std::unique_ptr<SvtUserOptions> m_pUserOptions;
100 std::unique_ptr<SfxErrorHandler> m_pErrorHdl;
101 sal_uInt16 m_nCurRefDlgId;
102 bool m_bIsWaterCan:1;
103 bool m_bIsInEditCommand:1;
104 bool m_bIsInExecuteDrop:1;
105 bool m_bIsInSharedDocLoading:1;
106 bool m_bIsInSharedDocSaving:1;
108 // a way to find existing Dialogs for a given parent Window of the slot type
109 std::map<sal_uInt16, std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>>> m_mapRefController;
111 css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller;
113 public:
114 SFX_DECL_INTERFACE(SCID_APP)
116 private:
117 /// SfxInterface initializer.
118 static void InitInterface_Impl();
120 public:
121 ScModule( SfxObjectFactory* pFact );
122 virtual ~ScModule() override;
124 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
125 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
126 void DeleteCfg();
128 // moved by the application
130 DECL_DLLPRIVATE_LINK( IdleHandler, Timer*, void ); // Timer instead of idle
131 DECL_DLLPRIVATE_LINK( CalcFieldValueHdl, EditFieldInfo*, void );
133 void Execute( SfxRequest& rReq );
134 void GetState( SfxItemSet& rSet );
135 static void HideDisabledSlots( SfxItemSet& rSet );
137 void AnythingChanged();
139 // Drag & Drop:
140 const ScDragData& GetDragData() const;
141 void SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
142 void ResetDragObject();
143 void SetDragLink(
144 const OUString& rDoc, const OUString& rTab, const OUString& rArea );
145 void SetDragJump(
146 ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText );
148 static ScDocument* GetClipDoc(); // called from document - should be removed later
150 // X selection:
151 ScSelectionTransferObj* GetSelectionTransfer() const { return m_pSelTransfer; }
152 void SetSelectionTransfer( ScSelectionTransferObj* pNew );
154 void SetWaterCan( bool bNew ) { m_bIsWaterCan = bNew; }
155 bool GetIsWaterCan() const { return m_bIsWaterCan; }
157 void SetInEditCommand( bool bNew ) { m_bIsInEditCommand = bNew; }
159 void SetInExecuteDrop( bool bNew ) { m_bIsInExecuteDrop = bNew; }
160 bool IsInExecuteDrop() const { return m_bIsInExecuteDrop; }
162 // Options:
163 const ScViewOptions& GetViewOptions ();
164 SC_DLLPUBLIC const ScDocOptions& GetDocOptions ();
165 SC_DLLPUBLIC const ScAppOptions& GetAppOptions ();
166 SC_DLLPUBLIC const ScDefaultsOptions& GetDefaultsOptions ();
167 SC_DLLPUBLIC const ScFormulaOptions& GetFormulaOptions ();
168 SC_DLLPUBLIC const ScInputOptions& GetInputOptions ();
169 SC_DLLPUBLIC const ScPrintOptions& GetPrintOptions ();
170 void SetViewOptions ( const ScViewOptions& rOpt );
171 SC_DLLPUBLIC void SetDocOptions ( const ScDocOptions& rOpt );
172 SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rOpt );
173 SC_DLLPUBLIC void SetDefaultsOptions ( const ScDefaultsOptions& rOpt );
174 SC_DLLPUBLIC void SetFormulaOptions ( const ScFormulaOptions& rOpt );
175 SC_DLLPUBLIC void SetInputOptions ( const ScInputOptions& rOpt );
176 void SetPrintOptions ( const ScPrintOptions& rOpt );
177 void InsertEntryToLRUList(sal_uInt16 nFIndex);
179 static void GetSpellSettings( LanguageType& rDefLang, LanguageType& rCjkLang, LanguageType& rCtlLang,
180 bool& rAutoSpell );
181 static void SetAutoSpellProperty( bool bSet );
182 static bool HasThesaurusLanguage( LanguageType nLang );
184 static LanguageType GetOptDigitLanguage(); // from CTL options
186 ScNavipiCfg& GetNavipiCfg();
187 ScAddInCfg& GetAddInCfg();
188 svtools::ColorConfig& GetColorConfig();
189 SvtAccessibilityOptions& GetAccessOptions();
190 SvtCTLOptions& GetCTLOptions();
191 SC_DLLPUBLIC SvtUserOptions& GetUserOptions();
193 void ModifyOptions( const SfxItemSet& rOptSet );
195 // InputHandler:
196 bool IsEditMode(); // not for SC_INPUT_TYPE
197 bool IsInputMode(); // also for SC_INPUT_TYPE
198 void SetInputMode( ScInputMode eMode, const OUString* pInitText = nullptr );
199 bool InputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit = false );
200 SC_DLLPUBLIC void InputEnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL, bool bBeforeSavingInLOK = false );
201 void InputCancelHandler();
202 void InputSelection( const EditView* pView );
203 void InputChanged( const EditView* pView );
204 ScInputHandler* GetInputHdl( ScTabViewShell* pViewSh = nullptr, bool bUseRef = true );
205 void SetRefInputHdl( ScInputHandler* pNew );
206 ScInputHandler* GetRefInputHdl() { return m_pRefInputHandler;}
208 void ViewShellGone(const ScTabViewShell* pViewSh);
209 void ViewShellChanged(bool bStopEditing);
210 // communication with function-autopilot
211 void InputGetSelection( sal_Int32& rStart, sal_Int32& rEnd );
212 void InputSetSelection( sal_Int32 nStart, sal_Int32 nEnd );
213 void InputReplaceSelection( std::u16string_view aStr );
214 void InputTurnOffWinEngine();
215 void ActivateInputWindow( const OUString* pStr = nullptr,
216 bool bMatrix = false );
218 // input of reference:
219 SC_DLLPUBLIC void SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm = nullptr );
220 bool IsModalMode(SfxObjectShell* pDocSh = nullptr);
221 bool IsFormulaMode();
222 bool IsRefDialogOpen();
223 bool IsTableLocked();
224 void SetReference( const ScRange& rRef, ScDocument& rDoc,
225 const ScMarkData* pMarkData = nullptr );
226 void AddRefEntry();
227 void EndReference();
228 sal_uInt16 GetCurRefDlgId() const { return m_nCurRefDlgId; }
230 // virtual methods for the options dialog
231 virtual std::optional<SfxItemSet> CreateItemSet( sal_uInt16 nId ) override;
232 virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) override;
233 virtual std::unique_ptr<SfxTabPage> CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) override;
234 virtual std::optional<SfxStyleFamilies> CreateStyleFamilies() override;
236 void SetInSharedDocLoading( bool bNew ) { m_bIsInSharedDocLoading = bNew; }
237 bool IsInSharedDocLoading() const { return m_bIsInSharedDocLoading; }
238 void SetInSharedDocSaving( bool bNew ) { m_bIsInSharedDocSaving = bNew; }
239 bool IsInSharedDocSaving() const { return m_bIsInSharedDocSaving; }
241 SC_DLLPUBLIC void RegisterRefController(sal_uInt16 nSlotId, std::shared_ptr<SfxDialogController>& rWnd, weld::Window* pWndAncestor);
242 SC_DLLPUBLIC void UnregisterRefController(sal_uInt16 nSlotId, const std::shared_ptr<SfxDialogController>& rWnd);
243 SC_DLLPUBLIC std::shared_ptr<SfxDialogController> Find1RefWindow(sal_uInt16 nSlotId, const weld::Window *pWndAncestor);
245 SC_DLLPUBLIC void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller);
246 SC_DLLPUBLIC void CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments);
249 #define SC_MOD() ( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule::Calc)) )
251 void global_InitAppOptions();
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */