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