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
37class KeyEvent;
38class EditView;
39class SfxErrorHandler;
41class SvtCTLOptions;
42class SvtUserOptions;
43
44namespace svtools { class ColorConfig; }
45namespace ooo::vba { class XSinkCaller; }
46namespace com::sun::star::uno { class Any; }
47namespace com::sun::star::uno { template <typename > class Sequence; }
48
49class ScRange;
50class ScDocument;
51class ScViewCfg;
52class ScDocCfg;
53class ScAppCfg;
54class ScDefaultsCfg;
55class ScFormulaCfg;
56class ScInputCfg;
57class ScPrintCfg;
58class ScViewOptions;
59class ScDocOptions;
60class ScAppOptions;
63class ScInputOptions;
64class ScPrintOptions;
65class ScInputHandler;
66class ScTabViewShell;
67class ScMessagePool;
68class EditFieldInfo;
69class ScNavipiCfg;
70class ScAddInCfg;
71class ScTransferObj;
74class ScFormEditData;
75class ScMarkData;
76struct ScDragData;
78
79class 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;
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
113public:
115
116private:
118 static void InitInterface_Impl();
119
120public:
121 ScModule( SfxObjectFactory* pFact );
122 virtual ~ScModule() override;
123
124 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
126 void DeleteCfg();
127
128 // moved by the application
129
130 DECL_DLLPRIVATE_LINK( IdleHandler, Timer*, void ); // Timer instead of idle
131 DECL_DLLPRIVATE_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;
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 static LanguageType GetOptDigitLanguage(); // from CTL options
185
186 ScNavipiCfg& GetNavipiCfg();
187 ScAddInCfg& GetAddInCfg();
188 svtools::ColorConfig& GetColorConfig();
189 SC_DLLPUBLIC SvtUserOptions& GetUserOptions();
190
191 void ModifyOptions( const SfxItemSet& rOptSet );
192
193 // InputHandler:
194 bool IsEditMode(); // not for SC_INPUT_TYPE
195 bool IsInputMode(); // also for SC_INPUT_TYPE
196 void SetInputMode( ScInputMode eMode, const OUString* pInitText = nullptr );
197 bool InputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit = false );
198 SC_DLLPUBLIC void InputEnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL, bool bBeforeSavingInLOK = false );
199 void InputCancelHandler();
200 void InputSelection( const EditView* pView );
201 void InputChanged( const EditView* pView );
202 ScInputHandler* GetInputHdl( ScTabViewShell* pViewSh = nullptr, bool bUseRef = true );
203 void SetRefInputHdl( ScInputHandler* pNew );
204 ScInputHandler* GetRefInputHdl() { return m_pRefInputHandler;}
205
206 void ViewShellGone(const ScTabViewShell* pViewSh);
207 void ViewShellChanged(bool bStopEditing);
208 // communication with function-autopilot
209 void InputGetSelection( sal_Int32& rStart, sal_Int32& rEnd );
210 void InputSetSelection( sal_Int32 nStart, sal_Int32 nEnd );
211 void InputReplaceSelection( std::u16string_view aStr );
212 void InputTurnOffWinEngine();
213 void ActivateInputWindow( const OUString* pStr = nullptr,
214 bool bMatrix = false );
215
216 // input of reference:
217 SC_DLLPUBLIC void SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm = nullptr );
218 bool IsModalMode(SfxObjectShell* pDocSh = nullptr);
219 bool IsFormulaMode();
220 bool IsRefDialogOpen();
221 bool IsTableLocked();
222 void SetReference( const ScRange& rRef, ScDocument& rDoc,
223 const ScMarkData* pMarkData = nullptr );
224 void AddRefEntry();
225 void EndReference();
226 sal_uInt16 GetCurRefDlgId() const { return m_nCurRefDlgId; }
227
228 // virtual methods for the options dialog
229 virtual std::optional<SfxItemSet> CreateItemSet( sal_uInt16 nId ) override;
230 virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) override;
231 virtual std::unique_ptr<SfxTabPage> CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) override;
232 virtual std::optional<SfxStyleFamilies> CreateStyleFamilies() override;
233
234 void SetInSharedDocLoading( bool bNew ) { m_bIsInSharedDocLoading = bNew; }
235 bool IsInSharedDocLoading() const { return m_bIsInSharedDocLoading; }
236 void SetInSharedDocSaving( bool bNew ) { m_bIsInSharedDocSaving = bNew; }
237 bool IsInSharedDocSaving() const { return m_bIsInSharedDocSaving; }
238
239 SC_DLLPUBLIC void RegisterRefController(sal_uInt16 nSlotId, std::shared_ptr<SfxDialogController>& rWnd, weld::Window* pWndAncestor);
240 SC_DLLPUBLIC void UnregisterRefController(sal_uInt16 nSlotId, const std::shared_ptr<SfxDialogController>& rWnd);
241 SC_DLLPUBLIC std::shared_ptr<SfxDialogController> Find1RefWindow(sal_uInt16 nSlotId, const weld::Window *pWndAncestor);
242
243 SC_DLLPUBLIC void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller);
244 SC_DLLPUBLIC void CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments);
245};
246
247#define SC_MOD() ( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule::Calc)) )
248
250
251/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
sal_uInt16 m_nCurRefDlgId
Definition: scmod.hxx:101
std::unique_ptr< ScNavipiCfg > m_pNavipiCfg
Definition: scmod.hxx:94
Timer m_aIdleTimer
Definition: scmod.hxx:81
void SetInSharedDocLoading(bool bNew)
Definition: scmod.hxx:234
css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller
Definition: scmod.hxx:111
bool IsInSharedDocSaving() const
Definition: scmod.hxx:237
ScInputHandler * GetRefInputHdl()
Definition: scmod.hxx:204
std::map< sal_uInt16, std::vector< std::pair< std::shared_ptr< SfxDialogController >, weld::Window * > > > m_mapRefController
Definition: scmod.hxx:109
std::unique_ptr< svtools::ColorConfig > m_pColorConfig
Definition: scmod.hxx:96
void SetWaterCan(bool bNew)
Definition: scmod.hxx:154
std::unique_ptr< SvtCTLOptions > m_pCTLOptions
Definition: scmod.hxx:98
bool GetIsWaterCan() const
Definition: scmod.hxx:155
std::unique_ptr< ScInputCfg > m_pInputCfg
Definition: scmod.hxx:92
std::unique_ptr< SvtUserOptions > m_pUserOptions
Definition: scmod.hxx:99
bool m_bIsWaterCan
Definition: scmod.hxx:102
ScSelectionTransferObj * m_pSelTransfer
Definition: scmod.hxx:83
std::unique_ptr< ScFormulaCfg > m_pFormulaCfg
Definition: scmod.hxx:91
std::unique_ptr< ScViewCfg, o3tl::default_delete< ScViewCfg > > m_pViewCfg
Definition: scmod.hxx:87
void SetInExecuteDrop(bool bNew)
Definition: scmod.hxx:159
sal_uInt16 GetCurRefDlgId() const
Definition: scmod.hxx:226
DECL_DLLPRIVATE_LINK(IdleHandler, Timer *, void)
rtl::Reference< ScMessagePool > m_pMessagePool
Definition: scmod.hxx:84
bool IsInSharedDocLoading() const
Definition: scmod.hxx:235
std::unique_ptr< SvtAccessibilityOptions > m_pAccessOptions
Definition: scmod.hxx:97
ScInputHandler * m_pRefInputHandler
Definition: scmod.hxx:86
void SetInEditCommand(bool bNew)
Definition: scmod.hxx:157
std::unique_ptr< SfxErrorHandler > m_pErrorHdl
Definition: scmod.hxx:100
bool m_bIsInExecuteDrop
Definition: scmod.hxx:104
std::unique_ptr< ScDefaultsCfg > m_pDefaultsCfg
Definition: scmod.hxx:90
void SetInSharedDocSaving(bool bNew)
Definition: scmod.hxx:236
std::unique_ptr< ScDragData > m_pDragData
Definition: scmod.hxx:82
std::unique_ptr< ScAppCfg, o3tl::default_delete< ScAppCfg > > m_pAppCfg
Definition: scmod.hxx:89
bool m_bIsInSharedDocLoading
Definition: scmod.hxx:105
bool m_bIsInEditCommand
Definition: scmod.hxx:103
std::unique_ptr< ScPrintCfg > m_pPrintCfg
Definition: scmod.hxx:93
bool m_bIsInSharedDocSaving
Definition: scmod.hxx:106
std::unique_ptr< ScDocCfg, o3tl::default_delete< ScDocCfg > > m_pDocCfg
Definition: scmod.hxx:88
bool IsInExecuteDrop() const
Definition: scmod.hxx:160
ScSelectionTransferObj * GetSelectionTransfer() const
Definition: scmod.hxx:151
std::unique_ptr< ScAddInCfg > m_pAddInCfg
Definition: scmod.hxx:95
DECL_DLLPRIVATE_LINK(CalcFieldValueHdl, EditFieldInfo *, void)
static void InitInterface_Impl()
virtual std::optional< SfxStyleFamilies > CreateStyleFamilies()
virtual std::unique_ptr< SfxTabPage > CreateTabPage(sal_uInt16 nId, weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
virtual void ApplyItemSet(sal_uInt16 nId, const SfxItemSet &rSet)
virtual std::optional< SfxItemSet > CreateItemSet(sal_uInt16 nId)
virtual void ConfigurationChanged(ConfigurationBroadcaster *p, ConfigurationHints nHint)=0
ScInputMode
Definition: global.hxx:360
ScEnterMode
Definition: global.hxx:219
@ ColorConfig
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:498
const ::avmedia::MediaItem * Execute(const SdrMarkView *pSdrView, SfxRequest const &rReq)
void GetState(const SdrMarkView *pSdrView, SfxItemSet &rSet)
ConfigurationHints
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
void global_InitAppOptions()
Definition: scmod.cxx:794
#define SFX_DECL_INTERFACE(nId)
#define SCID_APP
Definition: shellids.hxx:23