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