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 .
21 #include <tools/string.hxx>
22 #include <tools/fldunit.hxx>
23 #include <svl/lstner.hxx>
24 #include <unotools/options.hxx>
25 #include <sfx2/module.hxx>
27 #include <tools/shl.hxx>
29 #include "shellid.hxx"
30 #include <fldupde.hxx>
31 #include <com/sun/star/linguistic2/XLinguServiceEventListener.hpp>
32 #include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
33 #include <editeng/svxenum.hxx>
38 class SfxErrorHandler
;
40 class SwModuleOptions
;
41 class SwMasterUsrPref
;
46 class SwChapterNumRules
;
47 class SwStdFontConfig
;
48 class SwNavigationConfig
;
50 class SwToolbarConfigItem
;
52 namespace svtools
{ class ColorConfig
;}
53 class SvtAccessibilityOptions
;
58 #define VIEWOPT_DEST_VIEW 0
59 #define VIEWOPT_DEST_TEXT 1
60 #define VIEWOPT_DEST_WEB 2
61 #define VIEWOPT_DEST_VIEW_ONLY 3 //ViewOptions are set only at ::com::sun::star::sdbcx::View, not at the appl.
63 namespace com
{ namespace sun
{ namespace star
{ namespace scanner
{
64 class XScannerManager2
;
67 class SW_DLLPUBLIC SwModule
: public SfxModule
, public SfxListener
, public utl::ConfigurationListener
72 SwModuleOptions
* pModuleConfig
;
73 SwMasterUsrPref
* pUsrPref
;
74 SwMasterUsrPref
* pWebUsrPref
;
75 SwPrintOptions
* pPrtOpt
;
76 SwPrintOptions
* pWebPrtOpt
;
77 SwChapterNumRules
* pChapterNumRules
;
78 SwStdFontConfig
* pStdFontConfig
;
79 SwNavigationConfig
* pNavigationConfig
;
80 SwToolbarConfigItem
*pToolbarConfig
; //For stacked toolbars. Which one was visible?
81 SwToolbarConfigItem
*pWebToolbarConfig
;
82 SwDBConfig
* pDBConfig
;
83 svtools::ColorConfig
* pColorConfig
;
84 SvtAccessibilityOptions
* pAccessibilityOptions
;
85 SvtCTLOptions
* pCTLOptions
;
86 SvtUserOptions
* pUserOptions
;
88 SfxErrorHandler
* pErrorHdl
;
90 SwAttrPool
*pAttrPool
;
92 // Current view is held here in order to avoid one's being forced
93 // to work via GetActiveView.
94 // View is valid until destroyed in Activate or exchanged.
97 // List of all Redline-authors.
98 std::vector
<String
>* pAuthorNames
;
100 // DictionaryList listener to trigger spellchecking or hyphenation
101 ::com::sun::star::uno::Reference
<
102 ::com::sun::star::linguistic2::XLinguServiceEventListener
> xLngSvcEvtListener
;
103 ::com::sun::star::uno::Reference
<
104 ::com::sun::star::scanner::XScannerManager2
> m_xScannerManager
;
105 ::com::sun::star::uno::Reference
<
106 ::com::sun::star::linguistic2::XLanguageGuessing
> m_xLanguageGuesser
;
108 sal_Bool bAuthorInitialised
: 1;
109 sal_Bool bEmbeddedLoadSave
: 1;
111 // Catch hint for DocInfo.
112 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
114 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster
*, sal_uInt32
);
117 // Envelopes, labels.
118 void InsertEnv(SfxRequest
&);
119 void InsertLab(SfxRequest
&, sal_Bool bLabel
);
122 // public Data - used for internal Clipboard / Drag & Drop / XSelection
123 SwTransferable
*pDragDrop
, *pXSelection
;
126 SFX_DECL_INTERFACE(SW_INTERFACE_MODULE
)
128 // This Ctor only for SW-Dll.
129 SwModule( SfxObjectFactory
* pFact
,
130 SfxObjectFactory
* pWebFact
,
131 SfxObjectFactory
* pGlobalFact
);
135 // Set view for internal use only. It is public only for technical reasons.
136 inline void SetView(SwView
* pVw
) { pView
= pVw
; }
137 inline SwView
* GetView() { return pView
; }
139 // Handler for slots.
140 void StateOther(SfxItemSet
&);
142 void ExecOther(SfxRequest
&); // Fields, formula...
144 // Modify user settings.
145 const SwMasterUsrPref
*GetUsrPref(sal_Bool bWeb
) const;
146 const SwViewOption
* GetViewOption(sal_Bool bWeb
);
147 void ApplyUsrPref(const SwViewOption
&, SwView
*,
148 sal_uInt16 nDest
= VIEWOPT_DEST_VIEW
);
149 void ApplyUserMetric( FieldUnit eMetric
, sal_Bool bWeb
);
150 void ApplyRulerMetric( FieldUnit eMetric
, sal_Bool bHorizontal
, sal_Bool bWeb
);
151 void ApplyFldUpdateFlags(SwFldUpdateFlags eFldFlags
);
152 void ApplyLinkMode(sal_Int32 nNewLinkMode
);
154 // Default page mode for text grid.
155 void ApplyDefaultPageMode(sal_Bool bIsSquaredPageMode
);
157 void ApplyUserCharUnit(sal_Bool bApplyChar
, sal_Bool bWeb
); // apply_char_unit
159 // Create ConfigItems.
160 SwModuleOptions
* GetModuleConfig() { return pModuleConfig
;}
161 SwPrintOptions
* GetPrtOptions(sal_Bool bWeb
);
162 SwChapterNumRules
* GetChapterNumRules();
163 SwStdFontConfig
* GetStdFontConfig() { return pStdFontConfig
; }
164 SwNavigationConfig
* GetNavigationConfig();
165 SwToolbarConfigItem
*GetToolbarConfig() { return pToolbarConfig
; }
166 SwToolbarConfigItem
*GetWebToolbarConfig() { return pWebToolbarConfig
; }
167 SwDBConfig
* GetDBConfig();
168 svtools::ColorConfig
& GetColorConfig();
169 SvtAccessibilityOptions
& GetAccessibilityOptions();
170 SvtCTLOptions
& GetCTLOptions();
171 SvtUserOptions
& GetUserOptions();
173 // Iterate over views.
174 static SwView
* GetFirstView();
175 static SwView
* GetNextView(SwView
*);
177 sal_Bool
IsEmbeddedLoadSave() const { return bEmbeddedLoadSave
; }
178 void SetEmbeddedLoadSave( sal_Bool bFlag
) { bEmbeddedLoadSave
= bFlag
; }
180 void ShowDBObj( SwView
& rView
, const SwDBData
& rData
, sal_Bool bOnlyIfAvailable
= sal_False
);
183 sal_Bool
IsInsTblFormatNum(sal_Bool bHTML
) const;
184 sal_Bool
IsInsTblChangeNumFormat(sal_Bool bHTML
) const;
185 sal_Bool
IsInsTblAlignNum(sal_Bool bHTML
) const;
188 sal_uInt16
GetRedlineAuthor();
189 const String
& GetRedlineAuthor(sal_uInt16 nPos
);
190 sal_uInt16
InsertRedlineAuthor(const String
& rAuthor
);
191 void SetRedlineAuthor(const String
& rAuthor
); // for unit tests
193 void GetInsertAuthorAttr(sal_uInt16 nAuthor
, SfxItemSet
&rSet
);
194 void GetDeletedAuthorAttr(sal_uInt16 nAuthor
, SfxItemSet
&rSet
);
195 void GetFormatAuthorAttr(sal_uInt16 nAuthor
, SfxItemSet
&rSet
);
197 sal_uInt16
GetRedlineMarkPos();
198 const Color
& GetRedlineMarkColor();
200 SvxCompareMode
GetCompareMode() const;
201 sal_Bool
IsUseRsid() const;
202 sal_Bool
IsIgnorePieces() const;
203 sal_uInt16
GetPieceLen() const;
205 // Return defined DocStat - WordDelimiter.
206 const String
& GetDocStatWordDelim() const;
208 // Pass metric of ModuleConfig (for HTML-export).
209 sal_uInt16
GetMetric( sal_Bool bWeb
) const;
211 // Pass update-statuses.
212 sal_uInt16
GetLinkUpdMode( sal_Bool bWeb
) const;
213 SwFldUpdateFlags
GetFldUpdateFlags( sal_Bool bWeb
) const;
215 // Virtual methods for options dialog.
216 virtual SfxItemSet
* CreateItemSet( sal_uInt16 nId
);
217 virtual void ApplyItemSet( sal_uInt16 nId
, const SfxItemSet
& rSet
);
218 virtual SfxTabPage
* CreateTabPage( sal_uInt16 nId
, Window
* pParent
, const SfxItemSet
& rSet
);
220 // Pool is created here and set at SfxShell.
222 // Delete pool before it is too late.
223 void RemoveAttrPool();
225 // Invalidates online spell-wrong-lists if necessary.
226 void CheckSpellChanges( bool bOnlineSpelling
,
227 bool bIsSpellWrongAgain
, bool bIsSpellAllAgain
, bool bSmartTags
);
229 inline ::com::sun::star::uno::Reference
<
230 ::com::sun::star::linguistic2::XLinguServiceEventListener
>
231 GetLngSvcEvtListener();
232 inline void SetLngSvcEvtListener( ::com::sun::star::uno::Reference
<
233 ::com::sun::star::linguistic2::XLinguServiceEventListener
> & xLstnr
);
234 void CreateLngSvcEvtListener();
236 ::com::sun::star::uno::Reference
<
237 ::com::sun::star::scanner::XScannerManager2
>
240 ::com::sun::star::uno::Reference
<
241 ::com::sun::star::linguistic2::XLanguageGuessing
>
242 GetLanguageGuesser();
246 inline ::com::sun::star::uno::Reference
<
247 ::com::sun::star::linguistic2::XLinguServiceEventListener
>
248 SwModule::GetLngSvcEvtListener()
250 return xLngSvcEvtListener
;
253 inline void SwModule::SetLngSvcEvtListener(
254 ::com::sun::star::uno::Reference
<
255 ::com::sun::star::linguistic2::XLinguServiceEventListener
> & xLstnr
)
257 xLngSvcEvtListener
= xLstnr
;
261 // Access to SwModule, the ::com::sun::star::sdbcx::View and the shell.
263 #define SW_MOD() ( *(SwModule**) GetAppData(SHL_WRITER))
265 SW_DLLPUBLIC SwView
* GetActiveView();
266 SW_DLLPUBLIC SwWrtShell
* GetActiveWrtShell();
270 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */