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 <tools/fldunit.hxx>
27 #include <svl/lstner.hxx>
28 #include <unotools/options.hxx>
29 #include <sfx2/module.hxx>
32 #include "shellid.hxx"
33 #include <fldupde.hxx>
34 #include <com/sun/star/linguistic2/XLinguServiceEventListener.hpp>
35 #include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
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
;
61 enum class SvViewOpt
{
65 DestViewOnly
//ViewOptions are set only at View, not at the appl.
68 namespace com
{ namespace sun
{ namespace star
{ namespace scanner
{
69 class XScannerManager2
;
72 class SW_DLLPUBLIC SwModule
: public SfxModule
, public SfxListener
, public utl::ConfigurationListener
74 OUString m_sActAuthor
;
77 SwModuleOptions
* m_pModuleConfig
;
78 SwMasterUsrPref
* m_pUsrPref
;
79 SwMasterUsrPref
* m_pWebUsrPref
;
80 SwPrintOptions
* m_pPrintOptions
;
81 SwPrintOptions
* m_pWebPrintOptions
;
82 SwChapterNumRules
* m_pChapterNumRules
;
83 SwStdFontConfig
* m_pStdFontConfig
;
84 SwNavigationConfig
* m_pNavigationConfig
;
85 SwToolbarConfigItem
*m_pToolbarConfig
; //For stacked toolbars. Which one was visible?
86 SwToolbarConfigItem
*m_pWebToolbarConfig
;
87 SwDBConfig
* m_pDBConfig
;
88 svtools::ColorConfig
* m_pColorConfig
;
89 SvtAccessibilityOptions
* m_pAccessibilityOptions
;
90 SvtCTLOptions
* m_pCTLOptions
;
91 SvtUserOptions
* m_pUserOptions
;
93 SfxErrorHandler
* m_pErrorHandler
;
95 SwAttrPool
*m_pAttrPool
;
97 // Current view is held here in order to avoid one's being forced
98 // to work via GetActiveView.
99 // View is valid until destroyed in Activate or exchanged.
102 // List of all Redline-authors.
103 std::vector
<OUString
> m_pAuthorNames
;
105 // DictionaryList listener to trigger spellchecking or hyphenation
106 css::uno::Reference
< css::linguistic2::XLinguServiceEventListener
> m_xLinguServiceEventListener
;
107 css::uno::Reference
< css::scanner::XScannerManager2
> m_xScannerManager
;
108 css::uno::Reference
< css::linguistic2::XLanguageGuessing
> m_xLanguageGuesser
;
110 bool m_bAuthorInitialised
: 1;
111 bool m_bEmbeddedLoadSave
: 1;
113 // Catch hint for DocInfo.
114 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
116 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster
*, ConfigurationHints
) override
;
119 // Envelopes, labels.
120 void InsertEnv(SfxRequest
&);
121 void InsertLab(SfxRequest
&, bool bLabel
);
124 // public Data - used for internal Clipboard / Drag & Drop / XSelection
125 SwTransferable
*m_pDragDrop
, *m_pXSelection
;
127 SFX_DECL_INTERFACE(SW_INTERFACE_MODULE
)
130 /// SfxInterface initializer.
131 static void InitInterface_Impl();
134 // This Ctor only for SW-Dll.
135 SwModule( SfxObjectFactory
* pFact
,
136 SfxObjectFactory
* pWebFact
,
137 SfxObjectFactory
* pGlobalFact
);
139 virtual ~SwModule() override
;
141 // Set view for internal use only. It is public only for technical reasons.
142 void SetView(SwView
* pVw
) { m_pView
= pVw
; }
143 SwView
* GetView() { return m_pView
; }
145 // Handler for slots.
146 void StateOther(SfxItemSet
&);
148 void ExecOther(SfxRequest
&); // Fields, formula...
150 // Modify user settings.
151 const SwMasterUsrPref
*GetUsrPref(bool bWeb
) const;
152 const SwViewOption
* GetViewOption(bool bWeb
);
153 void ApplyUsrPref(const SwViewOption
&, SwView
*,
154 SvViewOpt nDest
= SvViewOpt::DestView
);
155 void ApplyUserMetric( FieldUnit eMetric
, bool bWeb
);
156 void ApplyRulerMetric( FieldUnit eMetric
, bool bHorizontal
, bool bWeb
);
157 void ApplyFieldUpdateFlags(SwFieldUpdateFlags eFieldFlags
);
158 void ApplyLinkMode(sal_Int32 nNewLinkMode
);
160 // Default page mode for text grid.
161 void ApplyDefaultPageMode(bool bIsSquaredPageMode
);
163 void ApplyUserCharUnit(bool bApplyChar
, bool bWeb
); // apply_char_unit
165 // Create ConfigItems.
166 SwModuleOptions
* GetModuleConfig() { return m_pModuleConfig
;}
167 SwPrintOptions
* GetPrtOptions(bool bWeb
);
168 SwChapterNumRules
* GetChapterNumRules();
169 SwStdFontConfig
* GetStdFontConfig() { return m_pStdFontConfig
; }
170 SwNavigationConfig
* GetNavigationConfig();
171 SwToolbarConfigItem
*GetToolbarConfig() { return m_pToolbarConfig
; }
172 SwToolbarConfigItem
*GetWebToolbarConfig() { return m_pWebToolbarConfig
; }
173 SwDBConfig
* GetDBConfig();
174 svtools::ColorConfig
& GetColorConfig();
175 SvtAccessibilityOptions
& GetAccessibilityOptions();
176 SvtCTLOptions
& GetCTLOptions();
177 SvtUserOptions
& GetUserOptions();
179 // Iterate over views.
180 static SwView
* GetFirstView();
181 static SwView
* GetNextView(SwView
*);
183 bool IsEmbeddedLoadSave() const { return m_bEmbeddedLoadSave
; }
184 void SetEmbeddedLoadSave( bool bFlag
) { m_bEmbeddedLoadSave
= bFlag
; }
186 static void ShowDBObj( SwView
& rView
, const SwDBData
& rData
);
189 bool IsInsTableFormatNum(bool bHTML
) const;
190 bool IsInsTableChangeNumFormat(bool bHTML
) const;
191 bool IsInsTableAlignNum(bool bHTML
) const;
194 std::size_t GetRedlineAuthor();
195 OUString
GetRedlineAuthor(std::size_t nPos
);
196 /// See SwXTextDocument::getTrackedChangeAuthors().
197 OUString
GetRedlineAuthorInfo();
198 std::size_t InsertRedlineAuthor(const OUString
& rAuthor
);
199 void SetRedlineAuthor(const OUString
& rAuthor
); // for unit tests
201 void GetInsertAuthorAttr(std::size_t nAuthor
, SfxItemSet
&rSet
);
202 void GetDeletedAuthorAttr(std::size_t nAuthor
, SfxItemSet
&rSet
);
203 void GetFormatAuthorAttr(std::size_t nAuthor
, SfxItemSet
&rSet
);
205 sal_uInt16
GetRedlineMarkPos();
206 const Color
& GetRedlineMarkColor();
208 SwCompareMode
GetCompareMode() const;
209 bool IsUseRsid() const;
210 bool IsIgnorePieces() const;
211 sal_uInt16
GetPieceLen() const;
213 // Return defined DocStat - WordDelimiter.
214 OUString
GetDocStatWordDelim() const;
216 // Pass metric of ModuleConfig (for HTML-export).
217 FieldUnit
GetMetric( bool bWeb
) const;
219 // Pass update-statuses.
220 sal_uInt16
GetLinkUpdMode() const;
221 SwFieldUpdateFlags
GetFieldUpdateFlags() const;
223 // Virtual methods for options dialog.
224 virtual SfxItemSet
* CreateItemSet( sal_uInt16 nId
) override
;
225 virtual void ApplyItemSet( sal_uInt16 nId
, const SfxItemSet
& rSet
) override
;
226 virtual VclPtr
<SfxTabPage
> CreateTabPage( sal_uInt16 nId
, vcl::Window
* pParent
, const SfxItemSet
& rSet
) override
;
227 virtual SfxStyleFamilies
* CreateStyleFamilies() override
;
229 // Pool is created here and set at SfxShell.
231 // Delete pool before it is too late.
232 void RemoveAttrPool();
234 // Invalidates online spell-wrong-lists if necessary.
235 static void CheckSpellChanges( bool bOnlineSpelling
,
236 bool bIsSpellWrongAgain
, bool bIsSpellAllAgain
, bool bSmartTags
);
238 inline const css::uno::Reference
< css::linguistic2::XLinguServiceEventListener
>&
239 GetLngSvcEvtListener();
240 void CreateLngSvcEvtListener();
242 css::uno::Reference
< css::scanner::XScannerManager2
> const &
245 css::uno::Reference
< css::linguistic2::XLanguageGuessing
> const &
246 GetLanguageGuesser();
249 inline const css::uno::Reference
< css::linguistic2::XLinguServiceEventListener
>&
250 SwModule::GetLngSvcEvtListener()
252 return m_xLinguServiceEventListener
;
255 // Access to SwModule, the View and the shell.
257 #define SW_MOD() ( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule::Writer)))
259 SW_DLLPUBLIC SwView
* GetActiveView();
260 SW_DLLPUBLIC SwWrtShell
* GetActiveWrtShell();
264 SW_DLLPUBLIC Color
* GetActiveRetoucheColor();
267 extern bool g_bNoInterrupt
;
271 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */