Replace workaround of resize to invalidate with an explicit SfxHint
[LibreOffice.git] / sw / inc / swmodule.hxx
blobc77fa3d0d7b7ed9c48c9e5ce92e28bd2df546a66
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_SWMODULE_HXX
20 #define INCLUDED_SW_INC_SWMODULE_HXX
22 #include <sal/config.h>
24 #include <cstddef>
26 #include <o3tl/deleter.hxx>
27 #include <tools/fldunit.hxx>
28 #include <svl/ctloptions.hxx>
29 #include <svl/lstner.hxx>
30 #include <unotools/options.hxx>
31 #include <sfx2/module.hxx>
32 #include <sfx2/app.hxx>
34 #include "swdllapi.h"
35 #include "shellid.hxx"
36 #include "fldupde.hxx"
38 class Color;
39 class SfxItemSet;
40 class SfxRequest;
41 class SfxErrorHandler;
42 class SwDBConfig;
43 class SwModuleOptions;
44 class SwMasterUsrPref;
45 class SwViewOption;
46 class SwView;
47 class SwWrtShell;
48 class SwPrintOptions;
49 class SwChapterNumRules;
50 class SwStdFontConfig;
51 class SwNavigationConfig;
52 class SwTransferable;
53 class SwToolbarConfigItem;
54 class SwAttrPool;
55 namespace svtools{ class ColorConfig;}
56 class SvtCTLOptions;
57 class SvtUserOptions;
58 enum class SwCompareMode;
59 struct SwDBData;
60 namespace tools { class JsonWriter; }
62 enum class SvViewOpt {
63 DestView,
64 DestText,
65 DestWeb,
66 DestViewOnly //ViewOptions are set only at View, not at the appl.
69 namespace com::sun::star::scanner { class XScannerManager2; }
70 namespace com::sun::star::linguistic2 { class XLanguageGuessing; }
71 namespace com::sun::star::linguistic2 { class XLinguServiceEventListener; }
72 namespace ooo::vba { class XSinkCaller; }
73 class SwLinguServiceEventListener;
75 class SAL_DLLPUBLIC_RTTI SwModule final : public SfxModule, public SfxListener, public utl::ConfigurationListener
77 OUString m_sActAuthor;
79 // ConfigItems
80 std::unique_ptr<SwModuleOptions, o3tl::default_delete<SwModuleOptions>> m_pModuleConfig;
81 std::unique_ptr<SwMasterUsrPref, o3tl::default_delete<SwMasterUsrPref>> m_pUsrPref;
82 std::unique_ptr<SwMasterUsrPref, o3tl::default_delete<SwMasterUsrPref>> m_pWebUsrPref;
83 std::unique_ptr<SwPrintOptions> m_pPrintOptions;
84 std::unique_ptr<SwPrintOptions> m_pWebPrintOptions;
85 std::unique_ptr<SwChapterNumRules> m_pChapterNumRules;
86 std::unique_ptr<SwStdFontConfig> m_pStdFontConfig;
87 std::unique_ptr<SwNavigationConfig> m_pNavigationConfig;
88 std::unique_ptr<SwToolbarConfigItem> m_pToolbarConfig; //For stacked toolbars. Which one was visible?
89 std::unique_ptr<SwToolbarConfigItem> m_pWebToolbarConfig;
90 std::unique_ptr<SwDBConfig> m_pDBConfig;
91 std::unique_ptr<svtools::ColorConfig> m_pColorConfig;
92 std::unique_ptr<SvtCTLOptions> m_pCTLOptions;
93 std::unique_ptr<SvtUserOptions> m_pUserOptions;
95 std::unique_ptr<SfxErrorHandler> m_pErrorHandler;
97 rtl::Reference<SwAttrPool> m_pAttrPool;
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.
102 SwView* m_pView;
104 // List of all Redline-authors.
105 std::vector<OUString> m_pAuthorNames;
107 // DictionaryList listener to trigger spellchecking or hyphenation
108 rtl::Reference< SwLinguServiceEventListener > m_xLinguServiceEventListener;
109 css::uno::Reference< css::scanner::XScannerManager2 > m_xScannerManager;
110 css::uno::Reference< css::linguistic2::XLanguageGuessing > m_xLanguageGuesser;
112 SvtCTLOptions::TextNumerals m_eCTLTextNumerals;
114 bool m_bAuthorInitialised : 1;
115 bool m_bEmbeddedLoadSave : 1;
117 // Catch hint for DocInfo.
118 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
120 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
122 // Envelopes, labels.
123 void InsertEnv(SfxRequest&);
124 void InsertLab(SfxRequest&, bool bLabel);
126 css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller;
128 public:
129 // public Data - used for internal Clipboard / Drag & Drop / XSelection
130 SwTransferable *m_pDragDrop, *m_pXSelection;
132 SFX_DECL_INTERFACE(SW_INTERFACE_MODULE)
134 private:
135 /// SfxInterface initializer.
136 static void InitInterface_Impl();
138 public:
139 // This Ctor only for SW-Dll.
140 SwModule( SfxObjectFactory* pFact,
141 SfxObjectFactory* pWebFact,
142 SfxObjectFactory* pGlobalFact );
144 virtual ~SwModule() override;
146 // Set view for internal use only. It is public only for technical reasons.
147 void SetView(SwView* pVw) { m_pView = pVw; }
148 SwView* GetView() { return m_pView; }
150 // Handler for slots.
151 void StateOther(SfxItemSet &);
153 SW_DLLPUBLIC void ExecOther(SfxRequest &); // Fields, formula...
155 // Modify user settings.
156 SW_DLLPUBLIC const SwMasterUsrPref *GetUsrPref(bool bWeb) const;
157 const SwViewOption* GetViewOption(bool bWeb);
158 SW_DLLPUBLIC void ApplyUsrPref(const SwViewOption &, SwView*,
159 SvViewOpt nDest = SvViewOpt::DestView );
160 void ApplyUserMetric( FieldUnit eMetric, bool bWeb );
161 void ApplyRulerMetric( FieldUnit eMetric, bool bHorizontal, bool bWeb );
162 SW_DLLPUBLIC void ApplyFieldUpdateFlags(SwFieldUpdateFlags eFieldFlags);
163 SW_DLLPUBLIC void ApplyLinkMode(sal_Int32 nNewLinkMode);
165 // Default page mode for text grid.
166 SW_DLLPUBLIC void ApplyDefaultPageMode(bool bIsSquaredPageMode);
168 void ApplyUserCharUnit(bool bApplyChar, bool bWeb); // apply_char_unit
170 // Create ConfigItems.
171 SwModuleOptions* GetModuleConfig() { return m_pModuleConfig.get();}
172 SwPrintOptions* GetPrtOptions(bool bWeb);
173 SW_DLLPUBLIC SwChapterNumRules* GetChapterNumRules();
174 SwStdFontConfig* GetStdFontConfig() { return m_pStdFontConfig.get(); }
175 SwNavigationConfig* GetNavigationConfig();
176 SwToolbarConfigItem*GetToolbarConfig() { return m_pToolbarConfig.get(); }
177 SwToolbarConfigItem*GetWebToolbarConfig() { return m_pWebToolbarConfig.get(); }
178 SW_DLLPUBLIC SwDBConfig* GetDBConfig();
179 SW_DLLPUBLIC svtools::ColorConfig& GetColorConfig();
180 SvtUserOptions& GetUserOptions();
182 // Iterate over views.
183 SAL_RET_MAYBENULL static SwView* GetFirstView();
184 SAL_RET_MAYBENULL static SwView* GetNextView(SwView const *);
186 bool IsEmbeddedLoadSave() const { return m_bEmbeddedLoadSave; }
187 void SetEmbeddedLoadSave( bool bFlag ) { m_bEmbeddedLoadSave = bFlag; }
189 SvtCTLOptions::TextNumerals GetCTLTextNumerals() const { return m_eCTLTextNumerals; }
191 static void ShowDBObj( SwView const & rView, const SwDBData& rData);
193 // Table modi.
194 bool IsInsTableFormatNum(bool bHTML) const;
195 bool IsInsTableChangeNumFormat(bool bHTML) const;
196 bool IsInsTableAlignNum(bool bHTML) const;
197 bool IsSplitVerticalByDefault(bool bHTML) const;
198 void SetSplitVerticalByDefault(bool bHTML, bool value);
200 // Redlining.
201 std::size_t GetRedlineAuthor();
202 SW_DLLPUBLIC OUString const & GetRedlineAuthor(std::size_t nPos);
203 SW_DLLPUBLIC void ClearRedlineAuthors();
204 /// See SwXTextDocument::getTrackedChangeAuthors().
205 void GetRedlineAuthorInfo(tools::JsonWriter& rJsonWriter);
206 std::size_t InsertRedlineAuthor(const OUString& rAuthor);
207 void SetRedlineAuthor(const OUString& rAuthor); // for unit tests
209 void GetInsertAuthorAttr(std::size_t nAuthor, SfxItemSet &rSet);
210 void GetDeletedAuthorAttr(std::size_t nAuthor, SfxItemSet &rSet);
211 void GetFormatAuthorAttr(std::size_t nAuthor, SfxItemSet &rSet);
213 sal_uInt16 GetRedlineMarkPos() const;
214 const Color& GetRedlineMarkColor() const;
216 SwCompareMode GetCompareMode() const;
217 bool IsUseRsid() const;
218 bool IsIgnorePieces() const;
219 sal_uInt16 GetPieceLen() const;
221 // Return defined DocStat - WordDelimiter.
222 OUString const & GetDocStatWordDelim() const;
224 // Pass metric of ModuleConfig (for HTML-export).
225 FieldUnit GetMetric( bool bWeb ) const;
227 // Pass update-statuses.
228 sal_uInt16 GetLinkUpdMode() const;
229 SwFieldUpdateFlags GetFieldUpdateFlags() const;
231 // Virtual methods for options dialog.
232 virtual std::optional<SfxItemSet> CreateItemSet( sal_uInt16 nId ) override;
233 virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) override;
234 virtual std::unique_ptr<SfxTabPage> CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) override;
235 SW_DLLPUBLIC virtual std::optional<SfxStyleFamilies> CreateStyleFamilies() override;
237 // Pool is created here and set at SfxShell.
238 void InitAttrPool();
239 // Delete pool before it is too late.
240 void RemoveAttrPool();
242 // Invalidates online spell-wrong-lists if necessary.
243 static void CheckSpellChanges( bool bOnlineSpelling,
244 bool bIsSpellWrongAgain, bool bIsSpellAllAgain, bool bSmartTags );
246 css::uno::Reference< css::scanner::XScannerManager2 > const &
247 GetScannerManager();
249 css::uno::Reference< css::linguistic2::XLanguageGuessing > const &
250 GetLanguageGuesser();
252 SW_DLLPUBLIC void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller);
253 void CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments);
255 // Access to SwModule
256 static auto get() { return static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule::Writer)); }
259 // Access to the View and the shell.
261 SAL_RET_MAYBENULL SW_DLLPUBLIC SwView* GetActiveView();
262 SAL_RET_MAYBENULL SW_DLLPUBLIC SwWrtShell* GetActiveWrtShell();
264 namespace sw
266 SW_DLLPUBLIC Color* GetActiveRetoucheColor();
269 extern bool g_bNoInterrupt;
271 #endif
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */