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 <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>
33 
34 #include <vector>
35 #include <map>
36 #include <memory>
37 
38 class KeyEvent;
39 class EditView;
40 class SfxErrorHandler;
42 class SvtCTLOptions;
43 class SvtUserOptions;
44 
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; }
49 
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;
75 class ScFormEditData;
76 class ScMarkData;
77 struct ScDragData;
79 
80 class SAL_DLLPUBLIC_RTTI ScModule final : public SfxModule, public SfxListener, public utl::ConfigurationListener
81 {
83  std::unique_ptr<ScDragData> m_pDragData;
86  // there is no global InputHandler anymore, each View has its own
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;
108 
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;
111 
112  css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller;
113 
114 public:
116 
117 private:
119  static void InitInterface_Impl();
120 
121 public:
122  ScModule( SfxObjectFactory* pFact );
123  virtual ~ScModule() override;
124 
125  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
126  virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
127  void DeleteCfg();
128 
129  // moved by the application
130 
131  DECL_LINK( IdleHandler, Timer*, void ); // Timer instead of idle
132  DECL_LINK( CalcFieldValueHdl, EditFieldInfo*, void );
133 
134  void Execute( SfxRequest& rReq );
135  void GetState( SfxItemSet& rSet );
136  static void HideDisabledSlots( SfxItemSet& rSet );
137 
138  void AnythingChanged();
139 
140  // Drag & Drop:
141  const ScDragData& GetDragData() const { return *m_pDragData;}
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 );
148 
149  static ScDocument* GetClipDoc(); // called from document - should be removed later
150 
151  // X selection:
152  ScSelectionTransferObj* GetSelectionTransfer() const { return m_pSelTransfer; }
153  void SetSelectionTransfer( ScSelectionTransferObj* pNew );
154 
155  void SetWaterCan( bool bNew ) { m_bIsWaterCan = bNew; }
156  bool GetIsWaterCan() const { return m_bIsWaterCan; }
157 
158  void SetInEditCommand( bool bNew ) { m_bIsInEditCommand = bNew; }
159 
160  void SetInExecuteDrop( bool bNew ) { m_bIsInExecuteDrop = bNew; }
161  bool IsInExecuteDrop() const { return m_bIsInExecuteDrop; }
162 
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);
179 
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 );
184 
185  LanguageType GetOptDigitLanguage(); // from CTL options
186 
187  ScNavipiCfg& GetNavipiCfg();
188  ScAddInCfg& GetAddInCfg();
189  svtools::ColorConfig& GetColorConfig();
190  SvtAccessibilityOptions& GetAccessOptions();
191  SvtCTLOptions& GetCTLOptions();
192  SC_DLLPUBLIC SvtUserOptions& GetUserOptions();
193 
194  void ModifyOptions( const SfxItemSet& rOptSet );
195 
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 );
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;}
208 
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 );
218 
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; }
230 
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;
236 
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; }
241 
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);
245 
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);
248 };
249 
250 #define SC_MOD() ( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule::Calc)) )
251 
252 void global_InitAppOptions();
253 
254 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetIsWaterCan() const
Definition: scmod.hxx:156
std::unique_ptr< SvtUserOptions > m_pUserOptions
Definition: scmod.hxx:100
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:92
std::map< sal_uInt16, std::vector< std::pair< std::shared_ptr< SfxDialogController >, weld::Window * > > > m_mapRefController
Definition: scmod.hxx:110
std::unique_ptr< ScNavipiCfg > m_pNavipiCfg
Definition: scmod.hxx:95
void SetInSharedDocSaving(bool bNew)
Definition: scmod.hxx:239
std::unique_ptr< SvtCTLOptions > m_pCTLOptions
Definition: scmod.hxx:99
std::unique_ptr< ScDefaultsCfg > m_pDefaultsCfg
Definition: scmod.hxx:91
std::unique_ptr< ScInputCfg > m_pInputCfg
Definition: scmod.hxx:93
std::unique_ptr< ScAppCfg, o3tl::default_delete< ScAppCfg > > m_pAppCfg
Definition: scmod.hxx:90
virtual std::optional< SfxStyleFamilies > CreateStyleFamilies()
css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller
Definition: scmod.hxx:112
sal_uInt16 m_nCurRefDlgId
Definition: scmod.hxx:102
void SetInEditCommand(bool bNew)
Definition: scmod.hxx:158
std::unique_ptr< ScDocCfg, o3tl::default_delete< ScDocCfg > > m_pDocCfg
Definition: scmod.hxx:89
void SetInExecuteDrop(bool bNew)
Definition: scmod.hxx:160
ScSelectionTransferObj * m_pSelTransfer
Definition: scmod.hxx:84
rtl::Reference< ScMessagePool > m_pMessagePool
Definition: scmod.hxx:85
sal_uInt16 GetCurRefDlgId() const
Definition: scmod.hxx:229
void SetInSharedDocLoading(bool bNew)
Definition: scmod.hxx:237
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:98
std::unique_ptr< ScDragData > m_pDragData
Definition: scmod.hxx:83
Timer m_aIdleTimer
Definition: scmod.hxx:82
std::unique_ptr< svtools::ColorConfig > m_pColorConfig
Definition: scmod.hxx:97
ScSelectionTransferObj * GetSelectionTransfer() const
Definition: scmod.hxx:152
std::unique_ptr< ScViewCfg, o3tl::default_delete< ScViewCfg > > m_pViewCfg
Definition: scmod.hxx:88
bool IsInSharedDocSaving() const
Definition: scmod.hxx:240
ScInputHandler * m_pRefInputHandler
Definition: scmod.hxx:87
bool IsInExecuteDrop() const
Definition: scmod.hxx:161
void SetWaterCan(bool bNew)
Definition: scmod.hxx:155
std::unique_ptr< ScAddInCfg > m_pAddInCfg
Definition: scmod.hxx:96
virtual void ApplyItemSet(sal_uInt16 nId, const SfxItemSet &rSet)
ScEnterMode
Definition: global.hxx:228
ScInputHandler * GetRefInputHdl()
Definition: scmod.hxx:207
std::unique_ptr< ScPrintCfg > m_pPrintCfg
Definition: scmod.hxx:94
virtual std::unique_ptr< SfxTabPage > CreateTabPage(sal_uInt16 nId, weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
ScInputMode
Definition: global.hxx:368
virtual std::optional< SfxItemSet > CreateItemSet(sal_uInt16 nId)
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
void global_InitAppOptions()
Definition: scmod.cxx:722
std::unique_ptr< SfxErrorHandler > m_pErrorHdl
Definition: scmod.hxx:101
#define SCID_APP
Definition: shellids.hxx:23
bool IsInSharedDocLoading() const
Definition: scmod.hxx:238
#define SFX_DECL_INTERFACE(nId)