Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/sc/inc/scmod.hxx
Line
Count
Source (jump to first uncovered line)
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;
40
class SvtCTLOptions;
41
class SvtUserOptions;
42
43
namespace svtools { class ColorConfig; }
44
namespace ooo::vba { class XSinkCaller; }
45
namespace com::sun::star::uno { class Any; }
46
namespace com::sun::star::uno { template <typename > class Sequence; }
47
48
class ScRange;
49
class ScDocument;
50
class ScViewCfg;
51
class ScDocCfg;
52
class ScAppCfg;
53
class ScDefaultsCfg;
54
class ScFormulaCfg;
55
class ScInputCfg;
56
class ScPrintCfg;
57
class ScViewOptions;
58
class ScDocOptions;
59
class ScAppOptions;
60
class ScDefaultsOptions;
61
class ScFormulaOptions;
62
class ScInputOptions;
63
class ScPrintOptions;
64
class ScInputHandler;
65
class ScTabViewShell;
66
class ScMessagePool;
67
class EditFieldInfo;
68
class ScNavipiCfg;
69
class ScAddInCfg;
70
class ScTransferObj;
71
class ScDrawTransferObj;
72
class ScSelectionTransferObj;
73
class ScMarkData;
74
struct ScDragData;
75
class SfxDialogController;
76
77
class SAL_DLLPUBLIC_RTTI ScModule final : public SfxModule, public SfxListener, public utl::ConfigurationListener
78
{
79
    Timer               m_aIdleTimer;
80
    std::unique_ptr<ScDragData> m_pDragData;
81
    ScSelectionTransferObj* m_pSelTransfer;
82
    rtl::Reference<ScMessagePool> m_pMessagePool;
83
    // there is no global InputHandler anymore, each View has its own
84
    ScInputHandler*     m_pRefInputHandler;
85
    std::unique_ptr<ScViewCfg, o3tl::default_delete<ScViewCfg>> m_pViewCfg;
86
    std::unique_ptr<ScDocCfg, o3tl::default_delete<ScDocCfg>> m_pDocCfg;
87
    std::unique_ptr<ScAppCfg, o3tl::default_delete<ScAppCfg>> m_pAppCfg;
88
    std::unique_ptr<ScDefaultsCfg>    m_pDefaultsCfg;
89
    std::unique_ptr<ScFormulaCfg>     m_pFormulaCfg;
90
    std::unique_ptr<ScInputCfg>       m_pInputCfg;
91
    std::unique_ptr<ScPrintCfg>       m_pPrintCfg;
92
    std::unique_ptr<ScNavipiCfg>      m_pNavipiCfg;
93
    std::unique_ptr<ScAddInCfg>       m_pAddInCfg;
94
    std::unique_ptr<svtools::ColorConfig>    m_pColorConfig;
95
    std::unique_ptr<SvtCTLOptions>           m_pCTLOptions;
96
    std::unique_ptr<SvtUserOptions>          m_pUserOptions;
97
    std::unique_ptr<SfxErrorHandler>  m_pErrorHdl;
98
    sal_uInt16          m_nCurRefDlgId;
99
    bool                m_bIsWaterCan:1;
100
    bool                m_bIsInEditCommand:1;
101
    bool                m_bIsInExecuteDrop:1;
102
    bool                m_bIsInSharedDocLoading:1;
103
    bool                m_bIsInSharedDocSaving:1;
104
105
    // a way to find existing Dialogs for a given parent Window of the slot type
106
    std::map<sal_uInt16, std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>>> m_mapRefController;
107
108
    css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller;
109
110
public:
111
                    SFX_DECL_INTERFACE(SCID_APP)
112
113
private:
114
    /// SfxInterface initializer.
115
    static void InitInterface_Impl();
116
117
public:
118
                        ScModule( SfxObjectFactory* pFact );
119
    virtual            ~ScModule() override;
120
121
    virtual void        Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
122
    virtual void        ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
123
    void                DeleteCfg();
124
125
                        // moved by the application
126
127
    DECL_DLLPRIVATE_LINK( IdleHandler, Timer*, void ); // Timer instead of idle
128
    DECL_DLLPRIVATE_LINK( CalcFieldValueHdl, EditFieldInfo*, void );
129
130
    void                Execute( SfxRequest& rReq );
131
    void                GetState( SfxItemSet& rSet );
132
    static void         HideDisabledSlots( SfxItemSet& rSet );
133
134
    void                AnythingChanged();
135
136
    //  Drag & Drop:
137
    const ScDragData*   GetDragData() const;
138
    void                SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
139
    void                ResetDragObject();
140
    void                SetDragLink(
141
        const OUString& rDoc, const OUString& rTab, const OUString& rArea );
142
    void                SetDragJump(
143
        ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText );
144
145
    static ScDocument*  GetClipDoc();       // called from document - should be removed later
146
147
    //  X selection:
148
0
    ScSelectionTransferObj* GetSelectionTransfer() const    { return m_pSelTransfer; }
149
    void                SetSelectionTransfer( ScSelectionTransferObj* pNew );
150
151
0
    void                SetWaterCan( bool bNew )    { m_bIsWaterCan = bNew; }
152
0
    bool                GetIsWaterCan() const       { return m_bIsWaterCan; }
153
154
0
    void                SetInEditCommand( bool bNew )   { m_bIsInEditCommand = bNew; }
155
156
0
    void                SetInExecuteDrop( bool bNew )   { m_bIsInExecuteDrop = bNew; }
157
0
    bool                IsInExecuteDrop() const         { return m_bIsInExecuteDrop; }
158
159
    // Options:
160
    const ScViewOptions&    GetViewOptions  ();
161
    SC_DLLPUBLIC const ScDocOptions&        GetDocOptions   ();
162
    SC_DLLPUBLIC const ScAppOptions&        GetAppOptions   ();
163
    SC_DLLPUBLIC const ScDefaultsOptions&   GetDefaultsOptions ();
164
    SC_DLLPUBLIC const ScFormulaOptions&    GetFormulaOptions ();
165
    SC_DLLPUBLIC const ScInputOptions&      GetInputOptions ();
166
    SC_DLLPUBLIC const ScPrintOptions&      GetPrintOptions ();
167
    void                SetViewOptions  ( const ScViewOptions& rOpt );
168
    SC_DLLPUBLIC void   SetDocOptions   ( const ScDocOptions& rOpt );
169
    SC_DLLPUBLIC void   SetAppOptions   ( const ScAppOptions& rOpt );
170
    SC_DLLPUBLIC void   SetDefaultsOptions ( const ScDefaultsOptions& rOpt );
171
    SC_DLLPUBLIC void   SetFormulaOptions ( const ScFormulaOptions& rOpt );
172
    SC_DLLPUBLIC void   SetInputOptions ( const ScInputOptions& rOpt );
173
    void                SetPrintOptions ( const ScPrintOptions& rOpt );
174
    void                InsertEntryToLRUList(sal_uInt16 nFIndex);
175
    void                InsertOrEraseFavouritesListEntry(sal_uInt16 nFIndex, bool bInsert);
176
177
    static void         GetSpellSettings( LanguageType& rDefLang, LanguageType& rCjkLang, LanguageType& rCtlLang );
178
    static void         SetAutoSpellProperty( bool bSet );
179
    static bool         GetAutoSpellProperty();
180
    static bool         HasThesaurusLanguage( LanguageType nLang );
181
182
    static LanguageType GetOptDigitLanguage();      // from CTL options
183
184
    ScNavipiCfg&        GetNavipiCfg();
185
    ScAddInCfg&         GetAddInCfg();
186
    svtools::ColorConfig&   GetColorConfig();
187
    static bool         IsLOKViewInDarkMode();
188
    SC_DLLPUBLIC SvtUserOptions& GetUserOptions();
189
    SC_DLLPUBLIC FieldUnit GetMetric();
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
0
    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
0
    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 SfxStyleFamilies CreateStyleFamilies() override;
233
234
0
    void                SetInSharedDocLoading( bool bNew )  { m_bIsInSharedDocLoading = bNew; }
235
0
    bool                IsInSharedDocLoading() const        { return m_bIsInSharedDocLoading; }
236
0
    void                SetInSharedDocSaving( bool bNew )   { m_bIsInSharedDocSaving = bNew; }
237
0
    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
4.17M
    static auto get() { return static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule::Calc)); }
247
};
248
249
void global_InitAppOptions();
250
251
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */