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 #pragma once
21 
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>
32 
33 #include <vector>
34 #include <map>
35 #include <memory>
36 
37 class KeyEvent;
38 class EditView;
39 class SfxErrorHandler;
41 class SvtCTLOptions;
42 class SvtUserOptions;
43 
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; }
48 
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;
74 class ScFormEditData;
75 class ScMarkData;
76 struct ScDragData;
78 
79 class SAL_DLLPUBLIC_RTTI ScModule final : public SfxModule, public SfxListener, public utl::ConfigurationListener
80 {
82  std::unique_ptr<ScDragData> m_pDragData;
85  // there is no global InputHandler anymore, each View has its own
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;
107 
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;
110 
111  css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller;
112 
113 public:
115 
116 private:
118  static void InitInterface_Impl();
119 
120 public:
121  ScModule( SfxObjectFactory* pFact );
122  virtual ~ScModule() override;
123 
124  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
125  virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
126  void DeleteCfg();
127 
128  // moved by the application
129 
130  DECL_LINK( IdleHandler, Timer*, void ); // Timer instead of idle
131  DECL_LINK( CalcFieldValueHdl, EditFieldInfo*, void );
132 
133  void Execute( SfxRequest& rReq );
134  void GetState( SfxItemSet& rSet );
135  static void HideDisabledSlots( SfxItemSet& rSet );
136 
137  void AnythingChanged();
138 
139  // Drag & Drop:
140  const ScDragData& GetDragData() const { return *m_pDragData;}
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 );
147 
148  static ScDocument* GetClipDoc(); // called from document - should be removed later
149 
150  // X selection:
151  ScSelectionTransferObj* GetSelectionTransfer() const { return m_pSelTransfer; }
152  void SetSelectionTransfer( ScSelectionTransferObj* pNew );
153 
154  void SetWaterCan( bool bNew ) { m_bIsWaterCan = bNew; }
155  bool GetIsWaterCan() const { return m_bIsWaterCan; }
156 
157  void SetInEditCommand( bool bNew ) { m_bIsInEditCommand = bNew; }
158 
159  void SetInExecuteDrop( bool bNew ) { m_bIsInExecuteDrop = bNew; }
160  bool IsInExecuteDrop() const { return m_bIsInExecuteDrop; }
161 
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);
178 
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 );
183 
184  LanguageType GetOptDigitLanguage(); // from CTL options
185 
186  ScNavipiCfg& GetNavipiCfg();
187  ScAddInCfg& GetAddInCfg();
188  svtools::ColorConfig& GetColorConfig();
189  SvtAccessibilityOptions& GetAccessOptions();
190  SvtCTLOptions& GetCTLOptions();
191  SC_DLLPUBLIC SvtUserOptions& GetUserOptions();
192 
193  void ModifyOptions( const SfxItemSet& rOptSet );
194 
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 );
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;}
207 
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( const OUString& rStr );
214  void InputTurnOffWinEngine();
215  void ActivateInputWindow( const OUString* pStr = nullptr,
216  bool bMatrix = false );
217 
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; }
229 
230  // virtual methods for the options dialog
231  virtual std::unique_ptr<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::unique_ptr<SfxStyleFamilies> CreateStyleFamilies() override;
235 
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; }
240 
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);
244 
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);
247 };
248 
249 #define SC_MOD() ( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule::Calc)) )
250 
251 void global_InitAppOptions();
252 
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetIsWaterCan() const
Definition: scmod.hxx:155
std::unique_ptr< SvtUserOptions > m_pUserOptions
Definition: scmod.hxx:99
ConfigurationHints
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:42
std::unique_ptr< ScFormulaCfg > m_pFormulaCfg
Definition: scmod.hxx:91
std::map< sal_uInt16, std::vector< std::pair< std::shared_ptr< SfxDialogController >, weld::Window * > > > m_mapRefController
Definition: scmod.hxx:109
std::unique_ptr< ScNavipiCfg > m_pNavipiCfg
Definition: scmod.hxx:94
void SetInSharedDocSaving(bool bNew)
Definition: scmod.hxx:238
std::unique_ptr< SvtCTLOptions > m_pCTLOptions
Definition: scmod.hxx:98
std::unique_ptr< ScDefaultsCfg > m_pDefaultsCfg
Definition: scmod.hxx:90
virtual std::unique_ptr< SfxStyleFamilies > CreateStyleFamilies()
std::unique_ptr< ScInputCfg > m_pInputCfg
Definition: scmod.hxx:92
std::unique_ptr< ScAppCfg, o3tl::default_delete< ScAppCfg > > m_pAppCfg
Definition: scmod.hxx:89
ScMessagePool * m_pMessagePool
Definition: scmod.hxx:84
css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller
Definition: scmod.hxx:111
sal_uInt16 m_nCurRefDlgId
Definition: scmod.hxx:101
void SetInEditCommand(bool bNew)
Definition: scmod.hxx:157
std::unique_ptr< ScDocCfg, o3tl::default_delete< ScDocCfg > > m_pDocCfg
Definition: scmod.hxx:88
void SetInExecuteDrop(bool bNew)
Definition: scmod.hxx:159
ScSelectionTransferObj * m_pSelTransfer
Definition: scmod.hxx:83
sal_uInt16 GetCurRefDlgId() const
Definition: scmod.hxx:228
void SetInSharedDocLoading(bool bNew)
Definition: scmod.hxx:236
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:478
std::unique_ptr< SvtAccessibilityOptions > m_pAccessOptions
Definition: scmod.hxx:97
std::unique_ptr< ScDragData > m_pDragData
Definition: scmod.hxx:82
Timer m_aIdleTimer
Definition: scmod.hxx:81
std::unique_ptr< svtools::ColorConfig > m_pColorConfig
Definition: scmod.hxx:96
ScSelectionTransferObj * GetSelectionTransfer() const
Definition: scmod.hxx:151
std::unique_ptr< ScViewCfg, o3tl::default_delete< ScViewCfg > > m_pViewCfg
Definition: scmod.hxx:87
bool IsInSharedDocSaving() const
Definition: scmod.hxx:239
ScInputHandler * m_pRefInputHandler
Definition: scmod.hxx:86
bool IsInExecuteDrop() const
Definition: scmod.hxx:160
void SetWaterCan(bool bNew)
Definition: scmod.hxx:154
std::unique_ptr< ScAddInCfg > m_pAddInCfg
Definition: scmod.hxx:95
virtual std::unique_ptr< SfxItemSet > CreateItemSet(sal_uInt16 nId)
virtual void ApplyItemSet(sal_uInt16 nId, const SfxItemSet &rSet)
ScEnterMode
Definition: global.hxx:228
ScInputHandler * GetRefInputHdl()
Definition: scmod.hxx:206
std::unique_ptr< ScPrintCfg > m_pPrintCfg
Definition: scmod.hxx:93
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:27
void global_InitAppOptions()
Definition: scmod.cxx:723
std::unique_ptr< SfxErrorHandler > m_pErrorHdl
Definition: scmod.hxx:100
#define SCID_APP
Definition: shellids.hxx:23
bool IsInSharedDocLoading() const
Definition: scmod.hxx:237
#define SFX_DECL_INTERFACE(nId)