xref: /trunk/main/sw/inc/swmodule.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _SWMODULE_HXX
28 #define _SWMODULE_HXX
29 #include <tools/link.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 <svl/lstner.hxx>
38 #include "swdllapi.h"
39 #include "shellid.hxx"
40 #include <fldupde.hxx>
41 #include <com/sun/star/linguistic2/XLinguServiceEventListener.hpp>
42 #include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
43 
44 class SvStringsDtor;
45 class Color;
46 class SfxItemSet;
47 class SfxRequest;
48 class SfxErrorHandler;
49 class SwDBConfig;
50 class SwModuleOptions;
51 class SwMasterUsrPref;
52 class SwViewOption;
53 class SwView;
54 class SwWrtShell;
55 class SwPrintOptions;
56 class SwChapterNumRules;
57 class SwStdFontConfig;
58 class SwNavigationConfig;
59 class SwTransferable;
60 class SwToolbarConfigItem;
61 class SwAttrPool;
62 namespace svtools{ class ColorConfig;}
63 class SvtAccessibilityOptions;
64 class SvtCTLOptions;
65 class SvtUserOptions;
66 class SvtUndoOptions;
67 
68 struct SwDBData;
69 #define VIEWOPT_DEST_VIEW       0
70 #define VIEWOPT_DEST_TEXT       1
71 #define VIEWOPT_DEST_WEB        2
72 #define VIEWOPT_DEST_VIEW_ONLY  3 //ViewOptions werden nur an der ::com::sun::star::sdbcx::View, nicht an der Appl. gesetzt
73 
74 namespace com{ namespace sun{ namespace star{ namespace scanner{
75     class XScannerManager;
76 }}}}
77 
78 class SW_DLLPUBLIC SwModule: public SfxModule, public SfxListener, public utl::ConfigurationListener
79 {
80     String              sActAuthor;
81 
82     // ConfigItems
83     SwModuleOptions*    pModuleConfig;
84     SwMasterUsrPref*    pUsrPref;
85     SwMasterUsrPref*    pWebUsrPref;
86     SwPrintOptions*     pPrtOpt;
87     SwPrintOptions*     pWebPrtOpt;
88     SwChapterNumRules*  pChapterNumRules;
89     SwStdFontConfig*    pStdFontConfig;
90     SwNavigationConfig* pNavigationConfig;
91     SwToolbarConfigItem*pToolbarConfig;     //fuer gestackte Toolbars, welche
92     SwToolbarConfigItem*pWebToolbarConfig;  //war sichtbar?
93     SwDBConfig*         pDBConfig;
94     svtools::ColorConfig*   pColorConfig;
95     SvtAccessibilityOptions* pAccessibilityOptions;
96     SvtCTLOptions*      pCTLOptions;
97     SvtUserOptions*     pUserOptions;
98     SvtUndoOptions*     pUndoOptions;
99 
100     SfxErrorHandler*    pErrorHdl;
101 
102     SwAttrPool          *pAttrPool;
103 
104     // Die aktuelle View wird hier gehalten um nicht ueber
105     // GetActiveView arbeiten zu muessen
106     // Die View ist solange gueltig bis Sie im Activate
107     // zerstoert oder ausgetauscht wird
108     SwView*             pView;
109 
110     // Liste aller Redline-Autoren
111     SvStringsDtor*      pAuthorNames;
112 
113     // DictionaryList listener to trigger spellchecking or hyphenation
114     ::com::sun::star::uno::Reference<
115         ::com::sun::star::linguistic2::XLinguServiceEventListener > xLngSvcEvtListener;
116     ::com::sun::star::uno::Reference<
117         ::com::sun::star::scanner::XScannerManager >    m_xScannerManager;
118     ::com::sun::star::uno::Reference<
119         ::com::sun::star::linguistic2::XLanguageGuessing >  m_xLanguageGuesser;
120 
121     sal_Bool                bAuthorInitialised : 1;
122     sal_Bool                bEmbeddedLoadSave : 1;
123 
124     // Hint abfangen fuer DocInfo
125     virtual void        Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
126 
127     virtual void        ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
128 
129 protected:
130     // Briefumschlaege, Etiketten
131     void                InsertEnv(SfxRequest&);
132     void                InsertLab(SfxRequest&, sal_Bool bLabel);
133 
134 public:
135     // public Data - used for internal Clipboard / Drag & Drop / XSelection
136     SwTransferable  *pDragDrop, *pXSelection;
137 
138     TYPEINFO();
139     SFX_DECL_INTERFACE(SW_INTERFACE_MODULE)
140 
141     // dieser Ctor nur fuer SW-Dll
142     SwModule( SfxObjectFactory* pFact,
143                 SfxObjectFactory* pWebFact,
144                     SfxObjectFactory* pGlobalFact );
145 
146     ~SwModule();
147 
148     // View setzen nur fuer internen Gebrauch,
149     // aus techn. Gruenden public
150     //
151     inline  void        SetView(SwView* pVw) { pView = pVw; }
152     inline  SwView*     GetView() { return pView; }
153 
154     //Die Handler fuer die Slots
155     void                StateOther(SfxItemSet &);   // andere
156 
157     void                ExecOther(SfxRequest &);    // Felder, Formel ..
158 
159     // Benutzereinstellungen modifizieren
160     const SwMasterUsrPref *GetUsrPref(sal_Bool bWeb) const;
161     const SwViewOption* GetViewOption(sal_Bool bWeb);
162     void                ApplyUsrPref(const SwViewOption &, SwView*,
163                                      sal_uInt16 nDest = VIEWOPT_DEST_VIEW );
164     void ApplyUserMetric( FieldUnit eMetric, sal_Bool bWeb );
165     void ApplyRulerMetric( FieldUnit eMetric, sal_Bool bHorizontal, sal_Bool bWeb );
166     void ApplyFldUpdateFlags(SwFldUpdateFlags eFldFlags);
167     void ApplyLinkMode(sal_Int32 nNewLinkMode);
168 
169     //default page mode for text grid
170     void ApplyDefaultPageMode(sal_Bool bIsSquaredPageMode);
171 
172     // ConfigItems erzeugen
173     SwModuleOptions*    GetModuleConfig()       { return pModuleConfig;}
174     SwPrintOptions*     GetPrtOptions(sal_Bool bWeb);
175     SwChapterNumRules*  GetChapterNumRules();
176     SwStdFontConfig*    GetStdFontConfig()      { return pStdFontConfig; }
177     SwNavigationConfig* GetNavigationConfig();
178     SwToolbarConfigItem*GetToolbarConfig()      { return pToolbarConfig;    }
179     SwToolbarConfigItem*GetWebToolbarConfig()   { return pWebToolbarConfig; }
180     SwDBConfig*         GetDBConfig();
181     svtools::ColorConfig&   GetColorConfig();
182     SvtAccessibilityOptions&    GetAccessibilityOptions();
183     SvtCTLOptions&      GetCTLOptions();
184     SvtUserOptions&     GetUserOptions();
185     SvtUndoOptions&     GetUndoOptions();
186 
187     // Ueber Sichten iterieren
188     static SwView*      GetFirstView();
189     static SwView*      GetNextView(SwView*);
190 
191     sal_Bool IsEmbeddedLoadSave() const         { return bEmbeddedLoadSave; }
192     void SetEmbeddedLoadSave( sal_Bool bFlag )  { bEmbeddedLoadSave = bFlag; }
193 
194     void ShowDBObj( SwView& rView, const SwDBData& rData, sal_Bool bOnlyIfAvailable = sal_False);
195 
196     // Tabellenmodi
197     sal_Bool            IsInsTblFormatNum(sal_Bool bHTML) const;
198     sal_Bool            IsInsTblChangeNumFormat(sal_Bool bHTML) const;
199     sal_Bool            IsInsTblAlignNum(sal_Bool bHTML) const;
200 
201     // Redlining
202     sal_uInt16          GetRedlineAuthor();
203     const String&       GetRedlineAuthor(sal_uInt16 nPos);
204     sal_uInt16          InsertRedlineAuthor(const String& rAuthor);
205 
206     void                GetInsertAuthorAttr(sal_uInt16 nAuthor, SfxItemSet &rSet);
207     void                GetDeletedAuthorAttr(sal_uInt16 nAuthor, SfxItemSet &rSet);
208     void                GetFormatAuthorAttr(sal_uInt16 nAuthor, SfxItemSet &rSet);
209 
210     sal_uInt16              GetRedlineMarkPos();
211     const Color&            GetRedlineMarkColor();
212 
213     // returne den definierten DocStat - WordDelimiter
214     const String&       GetDocStatWordDelim() const;
215 
216     // Durchreichen der Metric von der ModuleConfig (fuer HTML-Export)
217     sal_uInt16 GetMetric( sal_Bool bWeb ) const;
218 
219     // Update-Stati durchreichen
220     sal_uInt16 GetLinkUpdMode( sal_Bool bWeb ) const;
221     SwFldUpdateFlags GetFldUpdateFlags( sal_Bool bWeb ) const;
222 
223     //virtuelle Methoden fuer den Optionendialog
224     virtual SfxItemSet*  CreateItemSet( sal_uInt16 nId );
225     virtual void         ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet );
226     virtual SfxTabPage*  CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet );
227 
228     //hier wird der Pool angelegt und an der SfxShell gesetzt
229     void    InitAttrPool();
230     //Pool loeschen bevor es zu spaet ist
231     void    RemoveAttrPool();
232 
233     // Invalidiert ggf. OnlineSpell-WrongListen
234     void    CheckSpellChanges( sal_Bool bOnlineSpelling,
235                     sal_Bool bIsSpellWrongAgain, sal_Bool bIsSpellAllAgain, sal_Bool bSmartTags );
236 
237     inline ::com::sun::star::uno::Reference<
238         ::com::sun::star::linguistic2::XLinguServiceEventListener >
239             GetLngSvcEvtListener();
240     inline void SetLngSvcEvtListener( ::com::sun::star::uno::Reference<
241         ::com::sun::star::linguistic2::XLinguServiceEventListener > & xLstnr);
242     void    CreateLngSvcEvtListener();
243 
244     ::com::sun::star::uno::Reference<
245         ::com::sun::star::scanner::XScannerManager >
246             GetScannerManager();
247 
248     ::com::sun::star::uno::Reference<
249         ::com::sun::star::linguistic2::XLanguageGuessing >
250             GetLanguageGuesser();
251 };
252 
253 
254 inline ::com::sun::star::uno::Reference<
255     ::com::sun::star::linguistic2::XLinguServiceEventListener >
256         SwModule::GetLngSvcEvtListener()
257 {
258     return xLngSvcEvtListener;
259 }
260 
261 inline void SwModule::SetLngSvcEvtListener(
262     ::com::sun::star::uno::Reference<
263        ::com::sun::star::linguistic2::XLinguServiceEventListener > & xLstnr)
264 {
265     xLngSvcEvtListener = xLstnr;
266 }
267 
268 
269 /*-----------------08.07.97 10.33-------------------
270     Zugriff auf das SwModule, die ::com::sun::star::sdbcx::View und die Shell
271 --------------------------------------------------*/
272 
273 #define SW_MOD() ( *(SwModule**) GetAppData(SHL_WRITER))
274 
275 SW_DLLPUBLIC SwView*    GetActiveView();
276 SW_DLLPUBLIC SwWrtShell* GetActiveWrtShell();
277 
278 #endif
279