Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _SWMODULE_HXX
29 : : #define _SWMODULE_HXX
30 : : #include <tools/string.hxx>
31 : : #include <tools/fldunit.hxx>
32 : : #include <svl/lstner.hxx>
33 : : #include <unotools/options.hxx>
34 : : #include <sfx2/module.hxx>
35 : :
36 : : #include <tools/shl.hxx>
37 : : #include "swdllapi.h"
38 : : #include "shellid.hxx"
39 : : #include <fldupde.hxx>
40 : : #include <com/sun/star/linguistic2/XLinguServiceEventListener.hpp>
41 : : #include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
42 : : #include <editeng/svxenum.hxx>
43 : :
44 : : class Color;
45 : : class SfxItemSet;
46 : : class SfxRequest;
47 : : class SfxErrorHandler;
48 : : class SwDBConfig;
49 : : class SwModuleOptions;
50 : : class SwMasterUsrPref;
51 : : class SwViewOption;
52 : : class SwView;
53 : : class SwWrtShell;
54 : : class SwPrintOptions;
55 : : class SwChapterNumRules;
56 : : class SwStdFontConfig;
57 : : class SwNavigationConfig;
58 : : class SwTransferable;
59 : : class SwToolbarConfigItem;
60 : : class SwAttrPool;
61 : : namespace svtools{ class ColorConfig;}
62 : : class SvtAccessibilityOptions;
63 : : class SvtCTLOptions;
64 : : class SvtUserOptions;
65 : :
66 : : struct SwDBData;
67 : : #define VIEWOPT_DEST_VIEW 0
68 : : #define VIEWOPT_DEST_TEXT 1
69 : : #define VIEWOPT_DEST_WEB 2
70 : : #define VIEWOPT_DEST_VIEW_ONLY 3 //ViewOptions are set only at ::com::sun::star::sdbcx::View, not at the appl.
71 : :
72 : : namespace com{ namespace sun{ namespace star{ namespace scanner{
73 : : class XScannerManager2;
74 : : }}}}
75 : :
76 : : class SW_DLLPUBLIC SwModule: public SfxModule, public SfxListener, public utl::ConfigurationListener
77 : : {
78 : : String sActAuthor;
79 : :
80 : : // ConfigItems
81 : : SwModuleOptions* pModuleConfig;
82 : : SwMasterUsrPref* pUsrPref;
83 : : SwMasterUsrPref* pWebUsrPref;
84 : : SwPrintOptions* pPrtOpt;
85 : : SwPrintOptions* pWebPrtOpt;
86 : : SwChapterNumRules* pChapterNumRules;
87 : : SwStdFontConfig* pStdFontConfig;
88 : : SwNavigationConfig* pNavigationConfig;
89 : : SwToolbarConfigItem*pToolbarConfig; //For stacked toolbars. Which one was visible?
90 : : SwToolbarConfigItem*pWebToolbarConfig;
91 : : SwDBConfig* pDBConfig;
92 : : svtools::ColorConfig* pColorConfig;
93 : : SvtAccessibilityOptions* pAccessibilityOptions;
94 : : SvtCTLOptions* pCTLOptions;
95 : : SvtUserOptions* pUserOptions;
96 : :
97 : : SfxErrorHandler* pErrorHdl;
98 : :
99 : : SwAttrPool *pAttrPool;
100 : :
101 : : // Current view is held here in order to avoid one's being forced
102 : : // to work via GetActiveView.
103 : : // View is valid until destroyed in Activate or exchanged.
104 : : SwView* pView;
105 : :
106 : : // List of all Redline-authors.
107 : : std::vector<String>* pAuthorNames;
108 : :
109 : : // DictionaryList listener to trigger spellchecking or hyphenation
110 : : ::com::sun::star::uno::Reference<
111 : : ::com::sun::star::linguistic2::XLinguServiceEventListener > xLngSvcEvtListener;
112 : : ::com::sun::star::uno::Reference<
113 : : ::com::sun::star::scanner::XScannerManager2 > m_xScannerManager;
114 : : ::com::sun::star::uno::Reference<
115 : : ::com::sun::star::linguistic2::XLanguageGuessing > m_xLanguageGuesser;
116 : :
117 : : sal_Bool bAuthorInitialised : 1;
118 : : sal_Bool bEmbeddedLoadSave : 1;
119 : :
120 : : // Catch hint for DocInfo.
121 : : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
122 : :
123 : : virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
124 : :
125 : : protected:
126 : : // Envelopes, labels.
127 : : void InsertEnv(SfxRequest&);
128 : : void InsertLab(SfxRequest&, sal_Bool bLabel);
129 : :
130 : : public:
131 : : // public Data - used for internal Clipboard / Drag & Drop / XSelection
132 : : SwTransferable *pDragDrop, *pXSelection;
133 : :
134 : : TYPEINFO();
135 : 73 : SFX_DECL_INTERFACE(SW_INTERFACE_MODULE)
136 : :
137 : : // This Ctor only for SW-Dll.
138 : : SwModule( SfxObjectFactory* pFact,
139 : : SfxObjectFactory* pWebFact,
140 : : SfxObjectFactory* pGlobalFact );
141 : :
142 : : ~SwModule();
143 : :
144 : : // Set view for internal use only. It is public only for technical reasons.
145 : 3823 : inline void SetView(SwView* pVw) { pView = pVw; }
146 : 1231 : inline SwView* GetView() { return 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(sal_Bool bWeb) const;
155 : : const SwViewOption* GetViewOption(sal_Bool bWeb);
156 : : void ApplyUsrPref(const SwViewOption &, SwView*,
157 : : sal_uInt16 nDest = VIEWOPT_DEST_VIEW );
158 : : void ApplyUserMetric( FieldUnit eMetric, sal_Bool bWeb );
159 : : void ApplyRulerMetric( FieldUnit eMetric, sal_Bool bHorizontal, sal_Bool bWeb );
160 : : void ApplyFldUpdateFlags(SwFldUpdateFlags eFldFlags);
161 : : void ApplyLinkMode(sal_Int32 nNewLinkMode);
162 : :
163 : : // Default page mode for text grid.
164 : : void ApplyDefaultPageMode(sal_Bool bIsSquaredPageMode);
165 : :
166 : : void ApplyUserCharUnit(sal_Bool bApplyChar, sal_Bool bWeb); // apply_char_unit
167 : :
168 : : // Create ConfigItems.
169 : 270 : SwModuleOptions* GetModuleConfig() { return pModuleConfig;}
170 : : SwPrintOptions* GetPrtOptions(sal_Bool bWeb);
171 : : SwChapterNumRules* GetChapterNumRules();
172 : 1484 : SwStdFontConfig* GetStdFontConfig() { return pStdFontConfig; }
173 : : SwNavigationConfig* GetNavigationConfig();
174 : 1310 : SwToolbarConfigItem*GetToolbarConfig() { return pToolbarConfig; }
175 : 4 : SwToolbarConfigItem*GetWebToolbarConfig() { return pWebToolbarConfig; }
176 : : SwDBConfig* GetDBConfig();
177 : : svtools::ColorConfig& GetColorConfig();
178 : : SvtAccessibilityOptions& GetAccessibilityOptions();
179 : : SvtCTLOptions& GetCTLOptions();
180 : : SvtUserOptions& GetUserOptions();
181 : :
182 : : // Iterate over views.
183 : : static SwView* GetFirstView();
184 : : static SwView* GetNextView(SwView*);
185 : :
186 : 1220 : sal_Bool IsEmbeddedLoadSave() const { return bEmbeddedLoadSave; }
187 : 379 : void SetEmbeddedLoadSave( sal_Bool bFlag ) { bEmbeddedLoadSave = bFlag; }
188 : :
189 : : void ShowDBObj( SwView& rView, const SwDBData& rData, sal_Bool bOnlyIfAvailable = sal_False);
190 : :
191 : : // Table modi.
192 : : sal_Bool IsInsTblFormatNum(sal_Bool bHTML) const;
193 : : sal_Bool IsInsTblChangeNumFormat(sal_Bool bHTML) const;
194 : : sal_Bool IsInsTblAlignNum(sal_Bool bHTML) const;
195 : :
196 : : // Redlining.
197 : : sal_uInt16 GetRedlineAuthor();
198 : : const String& GetRedlineAuthor(sal_uInt16 nPos);
199 : : sal_uInt16 InsertRedlineAuthor(const String& rAuthor);
200 : : void SetRedlineAuthor(const String& rAuthor); // for unit tests
201 : :
202 : : void GetInsertAuthorAttr(sal_uInt16 nAuthor, SfxItemSet &rSet);
203 : : void GetDeletedAuthorAttr(sal_uInt16 nAuthor, SfxItemSet &rSet);
204 : : void GetFormatAuthorAttr(sal_uInt16 nAuthor, SfxItemSet &rSet);
205 : :
206 : : sal_uInt16 GetRedlineMarkPos();
207 : : const Color& GetRedlineMarkColor();
208 : :
209 : : SvxCompareMode GetCompareMode() const;
210 : : sal_Bool IsUseRsid() const;
211 : : sal_Bool IsIgnorePieces() const;
212 : : sal_uInt16 GetPieceLen() const;
213 : :
214 : : // Return defined DocStat - WordDelimiter.
215 : : const String& GetDocStatWordDelim() const;
216 : :
217 : : // Pass metric of ModuleConfig (for HTML-export).
218 : : sal_uInt16 GetMetric( sal_Bool bWeb ) const;
219 : :
220 : : // Pass update-statuses.
221 : : sal_uInt16 GetLinkUpdMode( sal_Bool bWeb ) const;
222 : : SwFldUpdateFlags GetFldUpdateFlags( sal_Bool bWeb ) const;
223 : :
224 : : // Virtual methods for options dialog.
225 : : virtual SfxItemSet* CreateItemSet( sal_uInt16 nId );
226 : : virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet );
227 : : virtual SfxTabPage* CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet );
228 : :
229 : : // Pool is created here and set at SfxShell.
230 : : void InitAttrPool();
231 : : // Delete pool before it is too late.
232 : : void RemoveAttrPool();
233 : :
234 : : // Invalidates online spell-wrong-lists if necessary.
235 : : void CheckSpellChanges( sal_Bool bOnlineSpelling,
236 : : sal_Bool bIsSpellWrongAgain, sal_Bool bIsSpellAllAgain, sal_Bool bSmartTags );
237 : :
238 : : inline ::com::sun::star::uno::Reference<
239 : : ::com::sun::star::linguistic2::XLinguServiceEventListener >
240 : : GetLngSvcEvtListener();
241 : : inline void SetLngSvcEvtListener( ::com::sun::star::uno::Reference<
242 : : ::com::sun::star::linguistic2::XLinguServiceEventListener > & xLstnr);
243 : : void CreateLngSvcEvtListener();
244 : :
245 : : ::com::sun::star::uno::Reference<
246 : : ::com::sun::star::scanner::XScannerManager2 >
247 : : GetScannerManager();
248 : :
249 : : ::com::sun::star::uno::Reference<
250 : : ::com::sun::star::linguistic2::XLanguageGuessing >
251 : : GetLanguageGuesser();
252 : : };
253 : :
254 : :
255 : : inline ::com::sun::star::uno::Reference<
256 : : ::com::sun::star::linguistic2::XLinguServiceEventListener >
257 : 44666 : SwModule::GetLngSvcEvtListener()
258 : : {
259 : 44666 : return xLngSvcEvtListener;
260 : : }
261 : :
262 : : inline void SwModule::SetLngSvcEvtListener(
263 : : ::com::sun::star::uno::Reference<
264 : : ::com::sun::star::linguistic2::XLinguServiceEventListener > & xLstnr)
265 : : {
266 : : xLngSvcEvtListener = xLstnr;
267 : : }
268 : :
269 : :
270 : : // Access to SwModule, the ::com::sun::star::sdbcx::View and the shell.
271 : :
272 : : #define SW_MOD() ( *(SwModule**) GetAppData(SHL_WRITER))
273 : :
274 : : SW_DLLPUBLIC SwView* GetActiveView();
275 : : SW_DLLPUBLIC SwWrtShell* GetActiveWrtShell();
276 : :
277 : : #endif
278 : :
279 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|