1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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>
34 #include "shellid.hxx"
35 #include "fldupde.hxx"
40 class SfxErrorHandler
;
42 class SwModuleOptions
;
43 class SwMasterUsrPref
;
48 class SwChapterNumRules
;
49 class SwStdFontConfig
;
50 class SwNavigationConfig
;
52 class SwToolbarConfigItem
;
54 namespace svtools
{ class ColorConfig
;}
55 class SvtAccessibilityOptions
;
58 enum class SwCompareMode
;
60 namespace tools
{ class JsonWriter
; }
62 enum class SvViewOpt
{
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
; }
74 class SW_DLLPUBLIC SwModule final
: public SfxModule
, public SfxListener
, public utl::ConfigurationListener
76 OUString m_sActAuthor
;
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
;
95 std::unique_ptr
<SfxErrorHandler
> m_pErrorHandler
;
97 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.
104 // List of all Redline-authors.
105 std::vector
<OUString
> m_pAuthorNames
;
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
;
112 bool m_bAuthorInitialised
: 1;
113 bool m_bEmbeddedLoadSave
: 1;
115 // Catch hint for DocInfo.
116 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
118 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster
*, ConfigurationHints
) override
;
120 // Envelopes, labels.
121 void InsertEnv(SfxRequest
&);
122 void InsertLab(SfxRequest
&, bool bLabel
);
124 css::uno::Reference
< ooo::vba::XSinkCaller
> mxAutomationApplicationEventsCaller
;
127 // public Data - used for internal Clipboard / Drag & Drop / XSelection
128 SwTransferable
*m_pDragDrop
, *m_pXSelection
;
130 SFX_DECL_INTERFACE(SW_INTERFACE_MODULE
)
133 /// SfxInterface initializer.
134 static void InitInterface_Impl();
137 // This Ctor only for SW-Dll.
138 SwModule( SfxObjectFactory
* pFact
,
139 SfxObjectFactory
* pWebFact
,
140 SfxObjectFactory
* pGlobalFact
);
142 virtual ~SwModule() override
;
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
; }
148 // Handler for slots.
149 void StateOther(SfxItemSet
&);
151 void ExecOther(SfxRequest
&); // Fields, formula...
153 // Modify user settings.
154 const SwMasterUsrPref
*GetUsrPref(bool bWeb
) const;
155 const SwViewOption
* GetViewOption(bool bWeb
);
156 void ApplyUsrPref(const SwViewOption
&, SwView
*,
157 SvViewOpt nDest
= SvViewOpt::DestView
);
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
);
163 // Default page mode for text grid.
164 void ApplyDefaultPageMode(bool bIsSquaredPageMode
);
166 void ApplyUserCharUnit(bool bApplyChar
, bool bWeb
); // apply_char_unit
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 SvtAccessibilityOptions
& GetAccessibilityOptions();
179 SvtCTLOptions
& GetCTLOptions();
180 SvtUserOptions
& GetUserOptions();
182 // Iterate over views.
183 static SwView
* GetFirstView();
184 static SwView
* GetNextView(SwView
const *);
186 bool IsEmbeddedLoadSave() const { return m_bEmbeddedLoadSave
; }
187 void SetEmbeddedLoadSave( bool bFlag
) { m_bEmbeddedLoadSave
= bFlag
; }
189 static void ShowDBObj( SwView
const & rView
, const SwDBData
& rData
);
192 bool IsInsTableFormatNum(bool bHTML
) const;
193 bool IsInsTableChangeNumFormat(bool bHTML
) const;
194 bool IsInsTableAlignNum(bool bHTML
) const;
195 bool IsSplitVerticalByDefault(bool bHTML
) const;
196 void SetSplitVerticalByDefault(bool bHTML
, bool value
);
199 std::size_t GetRedlineAuthor();
200 OUString
const & GetRedlineAuthor(std::size_t nPos
);
201 /// See SwXTextDocument::getTrackedChangeAuthors().
202 void GetRedlineAuthorInfo(tools::JsonWriter
& rJsonWriter
);
203 std::size_t InsertRedlineAuthor(const OUString
& rAuthor
);
204 void SetRedlineAuthor(const OUString
& rAuthor
); // for unit tests
206 void GetInsertAuthorAttr(std::size_t nAuthor
, SfxItemSet
&rSet
);
207 void GetDeletedAuthorAttr(std::size_t nAuthor
, SfxItemSet
&rSet
);
208 void GetFormatAuthorAttr(std::size_t nAuthor
, SfxItemSet
&rSet
);
210 sal_uInt16
GetRedlineMarkPos() const;
211 const Color
& GetRedlineMarkColor() const;
213 SwCompareMode
GetCompareMode() const;
214 bool IsUseRsid() const;
215 bool IsIgnorePieces() const;
216 sal_uInt16
GetPieceLen() const;
218 // Return defined DocStat - WordDelimiter.
219 OUString
const & GetDocStatWordDelim() const;
221 // Pass metric of ModuleConfig (for HTML-export).
222 FieldUnit
GetMetric( bool bWeb
) const;
224 // Pass update-statuses.
225 sal_uInt16
GetLinkUpdMode() const;
226 SwFieldUpdateFlags
GetFieldUpdateFlags() const;
228 // Virtual methods for options dialog.
229 virtual std::unique_ptr
<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 std::unique_ptr
<SfxStyleFamilies
> CreateStyleFamilies() override
;
234 // Pool is created here and set at SfxShell.
236 // Delete pool before it is too late.
237 void RemoveAttrPool();
239 // Invalidates online spell-wrong-lists if necessary.
240 static void CheckSpellChanges( bool bOnlineSpelling
,
241 bool bIsSpellWrongAgain
, bool bIsSpellAllAgain
, bool bSmartTags
);
243 css::uno::Reference
< css::scanner::XScannerManager2
> const &
246 css::uno::Reference
< css::linguistic2::XLanguageGuessing
> const &
247 GetLanguageGuesser();
249 void RegisterAutomationApplicationEventsCaller(css::uno::Reference
< ooo::vba::XSinkCaller
> const& xCaller
);
250 void CallAutomationApplicationEventSinks(const OUString
& Method
, css::uno::Sequence
< css::uno::Any
>& Arguments
);
253 // Access to SwModule, the View and the shell.
255 #define SW_MOD() ( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule::Writer)))
257 SW_DLLPUBLIC SwView
* GetActiveView();
258 SW_DLLPUBLIC SwWrtShell
* GetActiveWrtShell();
262 SW_DLLPUBLIC Color
* GetActiveRetoucheColor();
265 extern bool g_bNoInterrupt
;
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */