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