Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/inc/scmod.hxx
Line
Count
Source
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 <svtools/colorcfg.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;
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;
73
class ScSelectionTransferObj;
74
class ScMarkData;
75
struct ScDragData;
76
class SfxDialogController;
77
78
class SAL_DLLPUBLIC_RTTI ScModule final : public SfxModule, public SfxListener, public utl::ConfigurationListener
79
{
80
    Timer               m_aIdleTimer;
81
    std::unique_ptr<ScDragData> m_pDragData;
82
    ScSelectionTransferObj* m_pSelTransfer;
83
    rtl::Reference<ScMessagePool> m_pMessagePool;
84
    // there is no global InputHandler anymore, each View has its own
85
    ScInputHandler*     m_pRefInputHandler;
86
    std::unique_ptr<ScViewCfg, o3tl::default_delete<ScViewCfg>> m_pViewCfg;
87
    std::unique_ptr<ScDocCfg, o3tl::default_delete<ScDocCfg>> m_pDocCfg;
88
    std::unique_ptr<ScAppCfg, o3tl::default_delete<ScAppCfg>> m_pAppCfg;
89
    std::unique_ptr<ScDefaultsCfg>    m_pDefaultsCfg;
90
    std::unique_ptr<ScFormulaCfg>     m_pFormulaCfg;
91
    std::unique_ptr<ScInputCfg>       m_pInputCfg;
92
    std::unique_ptr<ScPrintCfg>       m_pPrintCfg;
93
    std::unique_ptr<ScNavipiCfg>      m_pNavipiCfg;
94
    std::unique_ptr<ScAddInCfg>       m_pAddInCfg;
95
    std::unique_ptr<svtools::ColorConfig>    m_pColorConfig;
96
    std::unique_ptr<SvtCTLOptions>           m_pCTLOptions;
97
    std::unique_ptr<SvtUserOptions>          m_pUserOptions;
98
    std::unique_ptr<SfxErrorHandler>  m_pErrorHdl;
99
    sal_uInt16          m_nCurRefDlgId;
100
    bool                m_bIsWaterCan:1;
101
    bool                m_bIsInEditCommand:1;
102
    bool                m_bIsInExecuteDrop:1;
103
    bool                m_bIsInSharedDocLoading:1;
104
    bool                m_bIsInSharedDocSaving:1;
105
106
    // a way to find existing Dialogs for a given parent Window of the slot type
107
    std::map<sal_uInt16, std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>>> m_mapRefController;
108
109
    css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller;
110
111
public:
112
                    SFX_DECL_INTERFACE(SCID_APP)
113
114
private:
115
    /// SfxInterface initializer.
116
    static void InitInterface_Impl();
117
118
public:
119
                        ScModule( SfxObjectFactory* pFact );
120
    virtual            ~ScModule() override;
121
122
    virtual void        Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
123
    virtual void        ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
124
    void                DeleteCfg();
125
126
                        // moved by the application
127
128
    DECL_DLLPRIVATE_LINK( IdleHandler, Timer*, void ); // Timer instead of idle
129
    DECL_DLLPRIVATE_LINK( CalcFieldValueHdl, EditFieldInfo*, void );
130
131
    void                Execute( SfxRequest& rReq );
132
    void                GetState( SfxItemSet& rSet );
133
    static void         HideDisabledSlots( SfxItemSet& rSet );
134
135
    void                EnsureIdleUpdate();
136
137
    //  Drag & Drop:
138
    const ScDragData*   GetDragData() const;
139
    void                SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj );
140
    void                ResetDragObject();
141
    void                SetDragLink(
142
        const OUString& rDoc, const OUString& rTab, const OUString& rArea );
143
    void                SetDragJump(
144
        ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText );
145
146
    static ScDocument*  GetClipDoc();       // called from document - should be removed later
147
148
    //  X selection:
149
0
    ScSelectionTransferObj* GetSelectionTransfer() const    { return m_pSelTransfer; }
150
    void                SetSelectionTransfer( ScSelectionTransferObj* pNew );
151
152
0
    void                SetWaterCan( bool bNew )    { m_bIsWaterCan = bNew; }
153
0
    bool                GetIsWaterCan() const       { return m_bIsWaterCan; }
154
155
0
    void                SetInEditCommand( bool bNew )   { m_bIsInEditCommand = bNew; }
156
157
0
    void                SetInExecuteDrop( bool bNew )   { m_bIsInExecuteDrop = bNew; }
158
0
    bool                IsInExecuteDrop() const         { return m_bIsInExecuteDrop; }
159
160
    // Options:
161
    const ScViewOptions&    GetViewOptions  ();
162
    SC_DLLPUBLIC const ScDocOptions&        GetDocOptions   ();
163
    SC_DLLPUBLIC const ScAppOptions&        GetAppOptions   ();
164
    SC_DLLPUBLIC const ScDefaultsOptions&   GetDefaultsOptions ();
165
    SC_DLLPUBLIC const ScFormulaOptions&    GetFormulaOptions ();
166
    SC_DLLPUBLIC const ScInputOptions&      GetInputOptions ();
167
    SC_DLLPUBLIC const ScPrintOptions&      GetPrintOptions ();
168
    void                SetViewOptions  ( const ScViewOptions& rOpt );
169
    SC_DLLPUBLIC void   SetDocOptions   ( const ScDocOptions& rOpt );
170
    SC_DLLPUBLIC void   SetAppOptions   ( const ScAppOptions& rOpt );
171
    SC_DLLPUBLIC void   SetDefaultsOptions ( const ScDefaultsOptions& rOpt );
172
    SC_DLLPUBLIC void   SetFormulaOptions ( const ScFormulaOptions& rOpt );
173
    SC_DLLPUBLIC void   SetInputOptions ( const ScInputOptions& rOpt );
174
    void                SetPrintOptions ( const ScPrintOptions& rOpt );
175
    void                InsertEntryToLRUList(sal_uInt16 nFIndex);
176
    void                InsertOrEraseFavouritesListEntry(sal_uInt16 nFIndex, bool bInsert);
177
178
    static void         GetSpellSettings( LanguageType& rDefLang, LanguageType& rCjkLang, LanguageType& rCtlLang );
179
    static void         SetAutoSpellProperty( bool bSet );
180
    static bool         GetAutoSpellProperty();
181
    static bool         HasThesaurusLanguage( LanguageType nLang );
182
183
    static LanguageType GetOptDigitLanguage();      // from CTL options
184
185
    ScNavipiCfg&        GetNavipiCfg();
186
    ScAddInCfg&         GetAddInCfg();
187
    svtools::ColorConfig&   GetColorConfig();
188
    static bool         IsLOKViewInDarkMode();
189
    SC_DLLPUBLIC SvtUserOptions& GetUserOptions();
190
    SC_DLLPUBLIC FieldUnit GetMetric();
191
192
    void                ModifyOptions( const SfxItemSet& rOptSet );
193
194
    // InputHandler:
195
    bool                IsEditMode();   // not for SC_INPUT_TYPE
196
    bool                IsInputMode();  // also for SC_INPUT_TYPE
197
    void                SetInputMode( ScInputMode eMode, const OUString* pInitText = nullptr );
198
    bool                InputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit = false );
199
    SC_DLLPUBLIC void   InputEnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL, bool bBeforeSavingInLOK = false );
200
    void                InputCancelHandler();
201
    void                InputSelection( const EditView* pView );
202
    void                InputChanged( const EditView* pView );
203
    ScInputHandler*     GetInputHdl( ScTabViewShell* pViewSh = nullptr, bool bUseRef = true );
204
    void                SetRefInputHdl( ScInputHandler* pNew );
205
0
    ScInputHandler*     GetRefInputHdl() { return m_pRefInputHandler;}
206
207
    void                ViewShellGone(const ScTabViewShell* pViewSh);
208
    void                ViewShellChanged(bool bStopEditing);
209
    // communication with function-autopilot
210
    void                InputGetSelection( sal_Int32& rStart, sal_Int32& rEnd );
211
    void                InputSetSelection( sal_Int32 nStart, sal_Int32 nEnd );
212
    void                InputReplaceSelection( std::u16string_view aStr );
213
    void                InputTurnOffWinEngine();
214
    void                ActivateInputWindow( const OUString* pStr = nullptr,
215
                                                bool bMatrix = false );
216
217
    // input of reference:
218
    SC_DLLPUBLIC void   SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm = nullptr );
219
    bool                IsModalMode(SfxObjectShell* pDocSh = nullptr);
220
    bool                IsFormulaMode();
221
    bool                IsRefDialogOpen();
222
    bool                IsTableLocked();
223
    void                SetReference( const ScRange& rRef, ScDocument& rDoc,
224
                                        const ScMarkData* pMarkData = nullptr );
225
    void                AddRefEntry();
226
    void                EndReference();
227
0
    sal_uInt16          GetCurRefDlgId() const                  { return m_nCurRefDlgId; }
228
229
    // virtual methods for the options dialog
230
    virtual std::optional<SfxItemSet> CreateItemSet( sal_uInt16 nId ) override;
231
    virtual void         ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) override;
232
    virtual std::unique_ptr<SfxTabPage> CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) override;
233
    virtual SfxStyleFamilies CreateStyleFamilies() override;
234
235
0
    void                SetInSharedDocLoading( bool bNew )  { m_bIsInSharedDocLoading = bNew; }
236
0
    bool                IsInSharedDocLoading() const        { return m_bIsInSharedDocLoading; }
237
0
    void                SetInSharedDocSaving( bool bNew )   { m_bIsInSharedDocSaving = bNew; }
238
0
    bool                IsInSharedDocSaving() const         { return m_bIsInSharedDocSaving; }
239
240
    SC_DLLPUBLIC void   RegisterRefController(sal_uInt16 nSlotId, std::shared_ptr<SfxDialogController>& rWnd, weld::Window* pWndAncestor);
241
    SC_DLLPUBLIC void   UnregisterRefController(sal_uInt16 nSlotId, const std::shared_ptr<SfxDialogController>& rWnd);
242
    SC_DLLPUBLIC std::shared_ptr<SfxDialogController> Find1RefWindow(sal_uInt16 nSlotId, const weld::Window *pWndAncestor);
243
244
    SC_DLLPUBLIC void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller);
245
    SC_DLLPUBLIC void CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments);
246
247
5.59M
    static auto get() { return static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule::Calc)); }
248
};
249
250
void global_InitAppOptions();
251
252
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */