LibreOffice Module sc (master)  1
scmod.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SC_INC_SCMOD_HXX
21 #define INCLUDED_SC_INC_SCMOD_HXX
22 
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>
34 
35 #include <vector>
36 #include <map>
37 #include <memory>
38 
39 class KeyEvent;
40 class EditView;
41 class SfxErrorHandler;
43 class SvtCTLOptions;
44 class SvtUserOptions;
45 
46 namespace svtools { class ColorConfig; }
47 namespace ooo::vba { class XSinkCaller; }
48 namespace com::sun::star::uno { class Any; }
49 namespace com::sun::star::uno { template <typename > class Sequence; }
50 
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;
76 class ScFormEditData;
77 class ScMarkData;
78 struct ScDragData;
80 
81 class SAL_DLLPUBLIC_RTTI ScModule final : public SfxModule, public SfxListener, public utl::ConfigurationListener
82 {
85  std::unique_ptr<ScDragData> m_pDragData;
88  // there is no global InputHandler anymore, each View has its own
90  std::unique_ptr<ScViewCfg, o3tl::default_delete<ScViewCfg>> m_pViewCfg;
91  std::unique_ptr<ScDocCfg, o3tl::default_delete<ScDocCfg>> m_pDocCfg;
92  std::unique_ptr<ScAppCfg, o3tl::default_delete<ScAppCfg>> m_pAppCfg;
93  std::unique_ptr<ScDefaultsCfg> m_pDefaultsCfg;
94  std::unique_ptr<ScFormulaCfg> m_pFormulaCfg;
95  std::unique_ptr<ScInputCfg> m_pInputCfg;
96  std::unique_ptr<ScPrintCfg> m_pPrintCfg;
97  std::unique_ptr<ScNavipiCfg> m_pNavipiCfg;
98  std::unique_ptr<ScAddInCfg> m_pAddInCfg;
99  std::unique_ptr<svtools::ColorConfig> m_pColorConfig;
100  std::unique_ptr<SvtAccessibilityOptions> m_pAccessOptions;
101  std::unique_ptr<SvtCTLOptions> m_pCTLOptions;
102  std::unique_ptr<SvtUserOptions> m_pUserOptions;
103  std::unique_ptr<SfxErrorHandler> m_pErrorHdl;
104  sal_uInt16 m_nCurRefDlgId;
105  bool m_bIsWaterCan:1;
106  bool m_bIsInEditCommand:1;
107  bool m_bIsInExecuteDrop:1;
108  bool m_bIsInSharedDocLoading:1;
109  bool m_bIsInSharedDocSaving:1;
110 
111  // a way to find existing Dialogs for a given parent Window of the slot type
112  std::map<sal_uInt16, std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>>> m_mapRefController;
113 
114  css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller;
115 
116 public:
118 
119 private:
121  static void InitInterface_Impl();
122 
123 public:
124  ScModule( SfxObjectFactory* pFact );
125  virtual ~ScModule() override;
126 
127  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
128  virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
129  void DeleteCfg();
130 
131  // moved by the application
132 
133  DECL_LINK( IdleHandler, Timer*, void ); // Timer instead of idle
134  DECL_LINK( SpellTimerHdl, Timer*, void );
135  DECL_LINK( CalcFieldValueHdl, EditFieldInfo*, void );
136 
137  void Execute( SfxRequest& rReq );
138  void GetState( SfxItemSet& rSet );
139  static void HideDisabledSlots( SfxItemSet& rSet );
140 
141  void AnythingChanged();
142 
143  // Drag & Drop:
144  const ScDragData& GetDragData() const { return *m_pDragData;}
145  void SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
146  void ResetDragObject();
147  void SetDragLink(
148  const OUString& rDoc, const OUString& rTab, const OUString& rArea );
149  void SetDragJump(
150  ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText );
151 
152  static ScDocument* GetClipDoc(); // called from document - should be removed later
153 
154  // X selection:
155  ScSelectionTransferObj* GetSelectionTransfer() const { return m_pSelTransfer; }
156  void SetSelectionTransfer( ScSelectionTransferObj* pNew );
157 
158  void SetWaterCan( bool bNew ) { m_bIsWaterCan = bNew; }
159  bool GetIsWaterCan() const { return m_bIsWaterCan; }
160 
161  void SetInEditCommand( bool bNew ) { m_bIsInEditCommand = bNew; }
162 
163  void SetInExecuteDrop( bool bNew ) { m_bIsInExecuteDrop = bNew; }
164  bool IsInExecuteDrop() const { return m_bIsInExecuteDrop; }
165 
166  // Options:
167  const ScViewOptions& GetViewOptions ();
168  SC_DLLPUBLIC const ScDocOptions& GetDocOptions ();
169  SC_DLLPUBLIC const ScAppOptions& GetAppOptions ();
170  SC_DLLPUBLIC const ScDefaultsOptions& GetDefaultsOptions ();
171  SC_DLLPUBLIC const ScFormulaOptions& GetFormulaOptions ();
172  SC_DLLPUBLIC const ScInputOptions& GetInputOptions ();
173  SC_DLLPUBLIC const ScPrintOptions& GetPrintOptions ();
174  void SetViewOptions ( const ScViewOptions& rOpt );
175  SC_DLLPUBLIC void SetDocOptions ( const ScDocOptions& rOpt );
176  SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rOpt );
177  void SetDefaultsOptions ( const ScDefaultsOptions& rOpt );
178  SC_DLLPUBLIC void SetFormulaOptions ( const ScFormulaOptions& rOpt );
179  SC_DLLPUBLIC void SetInputOptions ( const ScInputOptions& rOpt );
180  void SetPrintOptions ( const ScPrintOptions& rOpt );
181  void InsertEntryToLRUList(sal_uInt16 nFIndex);
182 
183  static void GetSpellSettings( LanguageType& rDefLang, LanguageType& rCjkLang, LanguageType& rCtlLang,
184  bool& rAutoSpell );
185  static void SetAutoSpellProperty( bool bSet );
186  static bool HasThesaurusLanguage( LanguageType nLang );
187 
188  LanguageType GetOptDigitLanguage(); // from CTL options
189 
190  ScNavipiCfg& GetNavipiCfg();
191  ScAddInCfg& GetAddInCfg();
192  svtools::ColorConfig& GetColorConfig();
193  SvtAccessibilityOptions& GetAccessOptions();
194  SvtCTLOptions& GetCTLOptions();
195  SC_DLLPUBLIC SvtUserOptions& GetUserOptions();
196 
197  void ModifyOptions( const SfxItemSet& rOptSet );
198 
199  // InputHandler:
200  bool IsEditMode(); // not for SC_INPUT_TYPE
201  bool IsInputMode(); // also for SC_INPUT_TYPE
202  void SetInputMode( ScInputMode eMode, const OUString* pInitText = nullptr );
203  bool InputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit = false );
204  SC_DLLPUBLIC void InputEnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL );
205  void InputCancelHandler();
206  void InputSelection( const EditView* pView );
207  void InputChanged( const EditView* pView );
208  ScInputHandler* GetInputHdl( ScTabViewShell* pViewSh = nullptr, bool bUseRef = true );
209  void SetRefInputHdl( ScInputHandler* pNew );
210  ScInputHandler* GetRefInputHdl() { return m_pRefInputHandler;}
211 
212  void ViewShellGone(const ScTabViewShell* pViewSh);
213  void ViewShellChanged(bool bStopEditing);
214  // communication with function-autopilot
215  void InputGetSelection( sal_Int32& rStart, sal_Int32& rEnd );
216  void InputSetSelection( sal_Int32 nStart, sal_Int32 nEnd );
217  void InputReplaceSelection( const OUString& rStr );
218  void InputTurnOffWinEngine();
219  void ActivateInputWindow( const OUString* pStr = nullptr,
220  bool bMatrix = false );
221 
222  // input of reference:
223  SC_DLLPUBLIC void SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm = nullptr );
224  bool IsModalMode(SfxObjectShell* pDocSh = nullptr);
225  bool IsFormulaMode();
226  bool IsRefDialogOpen();
227  bool IsTableLocked();
228  void SetReference( const ScRange& rRef, ScDocument& rDoc,
229  const ScMarkData* pMarkData = nullptr );
230  void AddRefEntry();
231  void EndReference();
232  sal_uInt16 GetCurRefDlgId() const { return m_nCurRefDlgId; }
233 
234  // virtual methods for the options dialog
235  virtual std::unique_ptr<SfxItemSet> CreateItemSet( sal_uInt16 nId ) override;
236  virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) override;
237  virtual std::unique_ptr<SfxTabPage> CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) override;
238  virtual std::unique_ptr<SfxStyleFamilies> CreateStyleFamilies() override;
239 
240  void SetInSharedDocLoading( bool bNew ) { m_bIsInSharedDocLoading = bNew; }
241  bool IsInSharedDocLoading() const { return m_bIsInSharedDocLoading; }
242  void SetInSharedDocSaving( bool bNew ) { m_bIsInSharedDocSaving = bNew; }
243  bool IsInSharedDocSaving() const { return m_bIsInSharedDocSaving; }
244 
245  SC_DLLPUBLIC void RegisterRefController(sal_uInt16 nSlotId, std::shared_ptr<SfxDialogController>& rWnd, weld::Window* pWndAncestor);
246  SC_DLLPUBLIC void UnregisterRefController(sal_uInt16 nSlotId, const std::shared_ptr<SfxDialogController>& rWnd);
247  SC_DLLPUBLIC std::shared_ptr<SfxDialogController> Find1RefWindow(sal_uInt16 nSlotId, const weld::Window *pWndAncestor);
248 
249  SC_DLLPUBLIC void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller);
250  SC_DLLPUBLIC void CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments);
251 };
252 
253 #define SC_MOD() ( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule::Calc)) )
254 
255 void global_InitAppOptions();
256 
257 #endif
258 
259 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetIsWaterCan() const
Definition: scmod.hxx:159
std::unique_ptr< SvtUserOptions > m_pUserOptions
Definition: scmod.hxx:102
ConfigurationHints
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
std::unique_ptr< ScFormulaCfg > m_pFormulaCfg
Definition: scmod.hxx:94
std::map< sal_uInt16, std::vector< std::pair< std::shared_ptr< SfxDialogController >, weld::Window * > > > m_mapRefController
Definition: scmod.hxx:112
std::unique_ptr< ScNavipiCfg > m_pNavipiCfg
Definition: scmod.hxx:97
void SetInSharedDocSaving(bool bNew)
Definition: scmod.hxx:242
Idle m_aSpellIdle
Definition: scmod.hxx:84
std::unique_ptr< SvtCTLOptions > m_pCTLOptions
Definition: scmod.hxx:101
std::unique_ptr< ScDefaultsCfg > m_pDefaultsCfg
Definition: scmod.hxx:93
virtual std::unique_ptr< SfxStyleFamilies > CreateStyleFamilies()
std::unique_ptr< ScInputCfg > m_pInputCfg
Definition: scmod.hxx:95
std::unique_ptr< ScAppCfg, o3tl::default_delete< ScAppCfg > > m_pAppCfg
Definition: scmod.hxx:92
ScMessagePool * m_pMessagePool
Definition: scmod.hxx:87
css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller
Definition: scmod.hxx:114
sal_uInt16 m_nCurRefDlgId
Definition: scmod.hxx:104
void SetInEditCommand(bool bNew)
Definition: scmod.hxx:161
std::unique_ptr< ScDocCfg, o3tl::default_delete< ScDocCfg > > m_pDocCfg
Definition: scmod.hxx:91
void SetInExecuteDrop(bool bNew)
Definition: scmod.hxx:163
ScSelectionTransferObj * m_pSelTransfer
Definition: scmod.hxx:86
sal_uInt16 GetCurRefDlgId() const
Definition: scmod.hxx:232
void SetInSharedDocLoading(bool bNew)
Definition: scmod.hxx:240
void Notify(ScModelObj &rModelObj, const ScRangeList &rChangeRanges, const OUString &rType=OUString("cell-change"), const css::uno::Sequence< css::beans::PropertyValue > &rProperties=css::uno::Sequence< css::beans::PropertyValue >())
Definition: docsh.hxx:477
std::unique_ptr< SvtAccessibilityOptions > m_pAccessOptions
Definition: scmod.hxx:100
std::unique_ptr< ScDragData > m_pDragData
Definition: scmod.hxx:85
Timer m_aIdleTimer
Definition: scmod.hxx:83
std::unique_ptr< svtools::ColorConfig > m_pColorConfig
Definition: scmod.hxx:99
ScSelectionTransferObj * GetSelectionTransfer() const
Definition: scmod.hxx:155
std::unique_ptr< ScViewCfg, o3tl::default_delete< ScViewCfg > > m_pViewCfg
Definition: scmod.hxx:90
bool IsInSharedDocSaving() const
Definition: scmod.hxx:243
ScInputHandler * m_pRefInputHandler
Definition: scmod.hxx:89
bool IsInExecuteDrop() const
Definition: scmod.hxx:164
void SetWaterCan(bool bNew)
Definition: scmod.hxx:158
std::unique_ptr< ScAddInCfg > m_pAddInCfg
Definition: scmod.hxx:98
virtual std::unique_ptr< SfxItemSet > CreateItemSet(sal_uInt16 nId)
virtual void ApplyItemSet(sal_uInt16 nId, const SfxItemSet &rSet)
ScEnterMode
Definition: global.hxx:229
ScInputHandler * GetRefInputHdl()
Definition: scmod.hxx:210
std::unique_ptr< ScPrintCfg > m_pPrintCfg
Definition: scmod.hxx:96
virtual std::unique_ptr< SfxTabPage > CreateTabPage(sal_uInt16 nId, weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
ScInputMode
Definition: global.hxx:368
#define SC_DLLPUBLIC
Definition: scdllapi.h:28
void global_InitAppOptions()
Definition: scmod.cxx:727
std::unique_ptr< SfxErrorHandler > m_pErrorHdl
Definition: scmod.hxx:103
#define SCID_APP
Definition: shellids.hxx:24
bool IsInSharedDocLoading() const
Definition: scmod.hxx:241
#define SFX_DECL_INTERFACE(nId)