Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sc / inc / scmod.hxx
blobb2b21114007150f2f751a8ab89929b9f02223eee
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 "scdll.hxx"
25 #include <vcl/timer.hxx>
26 #include <vcl/idle.hxx>
27 #include <svl/lstner.hxx>
28 #include "global.hxx"
29 #include "shellids.hxx"
30 #include <unotools/options.hxx>
32 #include <com/sun/star/datatransfer/XTransferable2.hpp>
34 #include <algorithm>
35 #include <vector>
36 #include <map>
37 #include <memory>
38 #include <stack>
40 class KeyEvent;
41 class EditView;
42 class SfxErrorHandler;
43 class SvtAccessibilityOptions;
44 class SvtCTLOptions;
45 class SvtUserOptions;
47 namespace svtools { class ColorConfig; }
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;
78 class ScModule: public SfxModule, public SfxListener, public utl::ConfigurationListener
80 Timer m_aIdleTimer;
81 Idle m_aSpellIdle;
82 ScDragData* m_pDragData;
83 ScSelectionTransferObj* m_pSelTransfer;
84 ScMessagePool* m_pMessagePool;
85 // there is no global InputHandler anymore, each View has it's own
86 ScInputHandler* m_pRefInputHandler;
87 ScViewCfg* m_pViewCfg;
88 ScDocCfg* m_pDocCfg;
89 ScAppCfg* m_pAppCfg;
90 ScDefaultsCfg* m_pDefaultsCfg;
91 ScFormulaCfg* m_pFormulaCfg;
92 ScInputCfg* m_pInputCfg;
93 ScPrintCfg* m_pPrintCfg;
94 ScNavipiCfg* m_pNavipiCfg;
95 ScAddInCfg* m_pAddInCfg;
96 svtools::ColorConfig* m_pColorConfig;
97 SvtAccessibilityOptions* m_pAccessOptions;
98 SvtCTLOptions* m_pCTLOptions;
99 SvtUserOptions* m_pUserOptions;
100 SfxErrorHandler* m_pErrorHdl;
101 ScFormEditData* m_pFormEditData;
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 std::map<sal_uInt16, std::vector<VclPtr<vcl::Window> > > m_mapRefWindow;
110 public:
111 SFX_DECL_INTERFACE(SCID_APP)
113 private:
114 /// SfxInterface initializer.
115 static void InitInterface_Impl();
117 public:
118 ScModule( SfxObjectFactory* pFact );
119 virtual ~ScModule() override;
121 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
122 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
123 void DeleteCfg();
125 // moved by the application
127 DECL_LINK( IdleHandler, Timer*, void ); // Timer instead of idle
128 DECL_LINK( SpellTimerHdl, Timer*, void );
129 DECL_LINK( CalcFieldValueHdl, EditFieldInfo*, void );
131 void Execute( SfxRequest& rReq );
132 void GetState( SfxItemSet& rSet );
133 static void HideDisabledSlots( SfxItemSet& rSet );
135 void AnythingChanged();
137 // Drag & Drop:
138 const ScDragData& GetDragData() const { return *m_pDragData;}
139 void SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
140 void ResetDragObject();
141 void SetDragLink(
142 const OUString& rDoc, const OUString& rTab, const OUString& rArea );
143 void SetDragJump(
144 ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText );
146 // X selection:
147 ScSelectionTransferObj* GetSelectionTransfer() const { return m_pSelTransfer; }
148 void SetSelectionTransfer( ScSelectionTransferObj* pNew );
150 void SetWaterCan( bool bNew ) { m_bIsWaterCan = bNew; }
151 bool GetIsWaterCan() const { return m_bIsWaterCan; }
153 void SetInEditCommand( bool bNew ) { m_bIsInEditCommand = bNew; }
155 void SetInExecuteDrop( bool bNew ) { m_bIsInExecuteDrop = bNew; }
156 bool IsInExecuteDrop() const { return m_bIsInExecuteDrop; }
158 // Options:
159 const ScViewOptions& GetViewOptions ();
160 SC_DLLPUBLIC const ScDocOptions& GetDocOptions ();
161 SC_DLLPUBLIC const ScAppOptions& GetAppOptions ();
162 SC_DLLPUBLIC const ScDefaultsOptions& GetDefaultsOptions ();
163 SC_DLLPUBLIC const ScFormulaOptions& GetFormulaOptions ();
164 SC_DLLPUBLIC const ScInputOptions& GetInputOptions ();
165 SC_DLLPUBLIC const ScPrintOptions& GetPrintOptions ();
166 void SetViewOptions ( const ScViewOptions& rOpt );
167 SC_DLLPUBLIC void SetDocOptions ( const ScDocOptions& rOpt );
168 SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rOpt );
169 void SetDefaultsOptions ( const ScDefaultsOptions& rOpt );
170 SC_DLLPUBLIC void SetFormulaOptions ( const ScFormulaOptions& rOpt );
171 SC_DLLPUBLIC void SetInputOptions ( const ScInputOptions& rOpt );
172 void SetPrintOptions ( const ScPrintOptions& rOpt );
173 void InsertEntryToLRUList(sal_uInt16 nFIndex);
175 static void GetSpellSettings( LanguageType& rDefLang, LanguageType& rCjkLang, LanguageType& rCtlLang,
176 bool& rAutoSpell );
177 static void SetAutoSpellProperty( bool bSet );
178 static bool HasThesaurusLanguage( LanguageType nLang );
180 LanguageType GetOptDigitLanguage(); // from CTL options
182 ScNavipiCfg& GetNavipiCfg();
183 ScAddInCfg& GetAddInCfg();
184 svtools::ColorConfig& GetColorConfig();
185 SvtAccessibilityOptions& GetAccessOptions();
186 SvtCTLOptions& GetCTLOptions();
187 SC_DLLPUBLIC SvtUserOptions& GetUserOptions();
189 void ModifyOptions( const SfxItemSet& rOptSet );
191 // InputHandler:
192 bool IsEditMode(); // not for SC_INPUT_TYPE
193 bool IsInputMode(); // also for SC_INPUT_TYPE
194 void SetInputMode( ScInputMode eMode, const OUString* pInitText = nullptr );
195 bool InputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit = false );
196 SC_DLLPUBLIC void InputEnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL );
197 void InputCancelHandler();
198 void InputSelection( const EditView* pView );
199 void InputChanged( const EditView* pView );
200 ScInputHandler* GetInputHdl( ScTabViewShell* pViewSh = nullptr, bool bUseRef = true );
202 void SetRefInputHdl( ScInputHandler* pNew );
203 ScInputHandler* GetRefInputHdl() { return m_pRefInputHandler;}
205 void ViewShellGone(const ScTabViewShell* pViewSh);
206 void ViewShellChanged(bool bStopEditing);
207 // communication with function-autopilot
208 void InputGetSelection( sal_Int32& rStart, sal_Int32& rEnd );
209 void InputSetSelection( sal_Int32 nStart, sal_Int32 nEnd );
210 void InputReplaceSelection( const OUString& rStr );
211 void InputTurnOffWinEngine();
212 OUString InputGetFormulaStr();
213 void ActivateInputWindow( const OUString* pStr = nullptr,
214 bool bMatrix = false );
216 void InitFormEditData();
217 void ClearFormEditData();
218 ScFormEditData* GetFormEditData() { return m_pFormEditData; }
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 VclPtr<SfxTabPage> CreateTabPage( sal_uInt16 nId, TabPageParent pParent, const SfxItemSet& rSet ) override;
236 virtual 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 RegisterRefWindow( sal_uInt16 nSlotId, vcl::Window *pWnd );
244 SC_DLLPUBLIC void UnregisterRefWindow( sal_uInt16 nSlotId, vcl::Window *pWnd );
245 SC_DLLPUBLIC vcl::Window * Find1RefWindow( sal_uInt16 nSlotId, vcl::Window *pWndAncestor );
248 #define SC_MOD() ( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule::Calc)) )
250 void global_InitAppOptions();
252 #endif
254 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */