Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/inc/swmodule.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
#ifndef INCLUDED_SW_INC_SWMODULE_HXX
20
#define INCLUDED_SW_INC_SWMODULE_HXX
21
22
#include <sal/config.h>
23
24
#include <cstddef>
25
26
#include <o3tl/deleter.hxx>
27
#include <rtl/ref.hxx>
28
#include <tools/fldunit.hxx>
29
#include <svl/ctloptions.hxx>
30
#include <svl/lstner.hxx>
31
#include <unotools/options.hxx>
32
#include <sfx2/module.hxx>
33
#include <sfx2/app.hxx>
34
35
#include "swdllapi.h"
36
#include "shellid.hxx"
37
#include "fldupde.hxx"
38
39
class Color;
40
class ItemInfoPackage;
41
class SfxItemSet;
42
class SfxRequest;
43
class SfxErrorHandler;
44
class SwDBConfig;
45
class SwModuleOptions;
46
class SwMasterUsrPref;
47
class SwViewOption;
48
class SwView;
49
class SwWrtShell;
50
class SwPrintOptions;
51
class SwChapterNumRules;
52
class SwStdFontConfig;
53
class SwNavigationConfig;
54
class SwTransferable;
55
class SwToolbarConfigItem;
56
namespace svtools{ class ColorConfig;}
57
class SvtUserOptions;
58
enum class SwCompareMode;
59
struct SwDBData;
60
namespace tools { class JsonWriter; }
61
62
enum class SvViewOpt {
63
    DestView,
64
    DestText,
65
    DestWeb,
66
    DestViewOnly   //ViewOptions are set only at View, not at the appl.
67
};
68
69
namespace com::sun::star::scanner { class XScannerManager2; }
70
namespace com::sun::star::linguistic2 { class XLanguageGuessing; }
71
namespace ooo::vba { class XSinkCaller; }
72
class SwLinguServiceEventListener;
73
class SwTableAutoFormatTable;
74
enum class SwRedlineRenderMode;
75
76
class SAL_DLLPUBLIC_RTTI SwModule final : public SfxModule, public SfxListener, public utl::ConfigurationListener
77
{
78
    OUString            m_sActAuthor;
79
80
    // ConfigItems
81
    std::unique_ptr<SwModuleOptions, o3tl::default_delete<SwModuleOptions>> m_pModuleConfig;
82
    std::unique_ptr<SwMasterUsrPref, o3tl::default_delete<SwMasterUsrPref>> m_pUsrPref;
83
    std::unique_ptr<SwMasterUsrPref, o3tl::default_delete<SwMasterUsrPref>> m_pWebUsrPref;
84
    std::unique_ptr<SwPrintOptions>      m_pPrintOptions;
85
    std::unique_ptr<SwPrintOptions>      m_pWebPrintOptions;
86
    std::unique_ptr<SwChapterNumRules>   m_pChapterNumRules;
87
    std::unique_ptr<SwStdFontConfig>     m_pStdFontConfig;
88
    std::unique_ptr<SwNavigationConfig>  m_pNavigationConfig;
89
    std::unique_ptr<SwToolbarConfigItem> m_pToolbarConfig;     //For stacked toolbars. Which one was visible?
90
    std::unique_ptr<SwToolbarConfigItem> m_pWebToolbarConfig;
91
    std::unique_ptr<SwDBConfig>          m_pDBConfig;
92
    std::unique_ptr<svtools::ColorConfig>   m_pColorConfig;
93
    std::unique_ptr<SvtCTLOptions>       m_pCTLOptions;
94
    std::unique_ptr<SvtUserOptions>      m_pUserOptions;
95
96
    std::unique_ptr<SfxErrorHandler> m_pErrorHandler;
97
98
    std::unique_ptr<SwTableAutoFormatTable> m_xTableAutoFormatTable;
99
100
    std::unique_ptr<ItemInfoPackage> m_xItemInfoPackageSwAttributes;
101
102
    // Current view is held here in order to avoid one's being forced
103
    // to work via GetActiveView.
104
    // View is valid until destroyed in Activate or exchanged.
105
    SwView*             m_pView;
106
107
    // List of all Redline-authors.
108
    std::vector<OUString> m_pAuthorNames;
109
110
    // DictionaryList listener to trigger spellchecking or hyphenation
111
    rtl::Reference< SwLinguServiceEventListener > m_xLinguServiceEventListener;
112
    css::uno::Reference< css::scanner::XScannerManager2 >    m_xScannerManager;
113
    css::uno::Reference< css::linguistic2::XLanguageGuessing >  m_xLanguageGuesser;
114
115
    SvtCTLOptions::TextNumerals m_eCTLTextNumerals;
116
117
    bool                m_bAuthorInitialised : 1;
118
    bool                m_bEmbeddedLoadSave : 1;
119
120
    // Catch hint for DocInfo.
121
    virtual void        Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
122
123
    virtual void        ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
124
125
    // Envelopes, labels.
126
    void                InsertEnv(SfxRequest&);
127
    void                InsertLab(SfxRequest&, bool bLabel);
128
129
    css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller;
130
131
public:
132
    // public Data - used for internal Clipboard / Drag & Drop / XSelection
133
    SwTransferable  *m_pDragDrop, *m_pXSelection;
134
135
    SFX_DECL_INTERFACE(SW_INTERFACE_MODULE)
136
137
private:
138
    /// SfxInterface initializer.
139
    static void InitInterface_Impl();
140
141
public:
142
    // This Ctor only for SW-Dll.
143
    SwModule( SfxObjectFactory* pFact,
144
                SfxObjectFactory* pWebFact,
145
                    SfxObjectFactory* pGlobalFact );
146
147
    virtual ~SwModule() override;
148
149
    // Set view for internal use only. It is public only for technical reasons.
150
12.4k
    void        SetView(SwView* pVw) { m_pView = pVw; }
151
4.14k
    SwView*     GetView() { return m_pView; }
152
153
    // Handler for slots.
154
    void                StateOther(SfxItemSet &);
155
156
    SW_DLLPUBLIC void ExecOther(SfxRequest &);    // Fields, formula...
157
158
    // Modify user settings.
159
    SW_DLLPUBLIC const SwMasterUsrPref *GetUsrPref(bool bWeb) const;
160
    const SwViewOption* GetViewOption(bool bWeb);
161
    SW_DLLPUBLIC void ApplyUsrPref(const SwViewOption &, SwView*,
162
                                     SvViewOpt nDest = SvViewOpt::DestView );
163
    void ApplyUserMetric( FieldUnit eMetric, bool bWeb );
164
    void ApplyRulerMetric( FieldUnit eMetric, bool bHorizontal, bool bWeb );
165
    SW_DLLPUBLIC void ApplyFieldUpdateFlags(SwFieldUpdateFlags eFieldFlags);
166
    SW_DLLPUBLIC void ApplyLinkMode(sal_Int32 nNewLinkMode);
167
168
    // Default page mode for text grid.
169
    SW_DLLPUBLIC void ApplyDefaultPageMode(bool bIsSquaredPageMode);
170
171
    void ApplyUserCharUnit(bool bApplyChar, bool bWeb);  // apply_char_unit
172
173
    // Create ConfigItems.
174
87.8k
    SwModuleOptions*    GetModuleConfig()       { return m_pModuleConfig.get();}
175
    SwPrintOptions*     GetPrtOptions(bool bWeb);
176
    SW_DLLPUBLIC SwChapterNumRules*  GetChapterNumRules();
177
69.9k
    SwStdFontConfig*    GetStdFontConfig()      { return m_pStdFontConfig.get(); }
178
    SwNavigationConfig* GetNavigationConfig();
179
4.14k
    SwToolbarConfigItem*GetToolbarConfig()      { return m_pToolbarConfig.get();    }
180
0
    SwToolbarConfigItem*GetWebToolbarConfig()   { return m_pWebToolbarConfig.get(); }
181
    SW_DLLPUBLIC SwDBConfig* GetDBConfig();
182
    SW_DLLPUBLIC svtools::ColorConfig& GetColorConfig();
183
    SvtUserOptions&     GetUserOptions();
184
185
    // Iterate over views.
186
    SAL_RET_MAYBENULL static SwView*      GetFirstView();
187
    SAL_RET_MAYBENULL static SwView*      GetNextView(SwView const *);
188
189
1.99M
    bool IsEmbeddedLoadSave() const         { return m_bEmbeddedLoadSave; }
190
0
    void SetEmbeddedLoadSave( bool bFlag )  { m_bEmbeddedLoadSave = bFlag; }
191
192
1.66M
    SvtCTLOptions::TextNumerals GetCTLTextNumerals() const { return m_eCTLTextNumerals; }
193
194
    static void ShowDBObj( SwView const & rView, const SwDBData& rData);
195
196
    // Table modi.
197
    bool            IsInsTableFormatNum(bool bHTML) const;
198
    bool            IsInsTableChangeNumFormat(bool bHTML) const;
199
    bool            IsInsTableAlignNum(bool bHTML) const;
200
    bool            IsSplitVerticalByDefault(bool bHTML) const;
201
    void            SetSplitVerticalByDefault(bool bHTML, bool value);
202
203
    // Redlining.
204
    std::size_t         GetRedlineAuthor();
205
    SW_DLLPUBLIC OUString const & GetRedlineAuthor(std::size_t nPos);
206
    SW_DLLPUBLIC void ClearRedlineAuthors();
207
    /// See SwXTextDocument::getTrackedChangeAuthors().
208
    void                GetRedlineAuthorInfo(tools::JsonWriter& rJsonWriter);
209
    std::size_t         InsertRedlineAuthor(const OUString& rAuthor);
210
    SW_DLLPUBLIC void   SetRedlineAuthor(const OUString& rAuthor); // for unit tests
211
212
    void                GetInsertAuthorAttr(std::size_t nAuthor, SfxItemSet &rSet, SwRedlineRenderMode eMode);
213
    void                GetDeletedAuthorAttr(std::size_t nAuthor, SfxItemSet &rSet, SwRedlineRenderMode eMode);
214
    void                GetFormatAuthorAttr(std::size_t nAuthor, SfxItemSet &rSet);
215
216
    sal_uInt16              GetRedlineMarkPos() const;
217
    const Color&            GetRedlineMarkColor() const;
218
219
    SwCompareMode      GetCompareMode() const;
220
    bool            IsUseRsid() const;
221
    bool            IsIgnorePieces() const;
222
    sal_uInt16          GetPieceLen() const;
223
224
    // Return defined DocStat - WordDelimiter.
225
    OUString const & GetDocStatWordDelim() const;
226
227
    // Pass metric of ModuleConfig (for HTML-export).
228
    FieldUnit GetMetric( bool bWeb ) const;
229
230
    // Pass update-statuses.
231
    sal_uInt16 GetLinkUpdMode() const;
232
    SwFieldUpdateFlags GetFieldUpdateFlags() const;
233
234
    // Virtual methods for options dialog.
235
    virtual std::optional<SfxItemSet> CreateItemSet( sal_uInt16 nId ) override;
236
    virtual void         ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) override;
237
    virtual std::unique_ptr<SfxTabPage> CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) override;
238
    SW_DLLPUBLIC virtual SfxStyleFamilies CreateStyleFamilies() override;
239
240
    void    InitItemInfoPackageSwAttributes();
241
    void    RemoveItemInfoPackageSwAttributes();
242
243
    ItemInfoPackage& getItemInfoPackageSwAttributes();
244
245
    // Invalidates online spell-wrong-lists if necessary.
246
    static void  CheckSpellChanges( bool bOnlineSpelling,
247
                    bool bIsSpellWrongAgain, bool bIsSpellAllAgain, bool bSmartTags );
248
249
    css::uno::Reference< css::scanner::XScannerManager2 > const &
250
            GetScannerManager();
251
252
    css::uno::Reference< css::linguistic2::XLanguageGuessing > const &
253
            GetLanguageGuesser();
254
255
    SW_DLLPUBLIC void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller);
256
    void CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments);
257
258
    SW_DLLPUBLIC const SwTableAutoFormatTable& GetAutoFormatTable();
259
260
//    Access to SwModule
261
13.9M
    static auto get() { return static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule::Writer)); }
262
};
263
264
//    Access to the View and the shell.
265
266
SAL_RET_MAYBENULL SW_DLLPUBLIC SwView*    GetActiveView();
267
SAL_RET_MAYBENULL SW_DLLPUBLIC SwWrtShell* GetActiveWrtShell();
268
269
namespace sw
270
{
271
SW_DLLPUBLIC Color* GetActiveRetoucheColor();
272
}
273
274
extern bool g_bNoInterrupt;
275
276
#endif
277
278
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */