xref: /AOO41X/main/sw/inc/swmodule.hxx (revision 1d2dbeb0b7301723c6d13094e87a8714ef81a328)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SWMODULE_HXX
24 #define _SWMODULE_HXX
25 #include <tools/link.hxx>
26 #include <tools/string.hxx>
27 #include <tools/fldunit.hxx>
28 #include <svl/lstner.hxx>
29 #include <unotools/options.hxx>
30 #include <sfx2/module.hxx>
31 
32 #include <tools/shl.hxx>
33 #include <svl/lstner.hxx>
34 #include "swdllapi.h"
35 #include "shellid.hxx"
36 #include <fldupde.hxx>
37 #include <com/sun/star/linguistic2/XLinguServiceEventListener.hpp>
38 #include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
39 
40 class SvStringsDtor;
41 class Color;
42 class SfxItemSet;
43 class SfxRequest;
44 class SfxErrorHandler;
45 class SwDBConfig;
46 class SwModuleOptions;
47 class SwMasterUsrPref;
48 class SwViewOption;
49 class SwView;
50 class SwWrtShell;
51 class SwPrintOptions;
52 class SwChapterNumRules;
53 class SwStdFontConfig;
54 class SwNavigationConfig;
55 class SwTransferable;
56 class SwToolbarConfigItem;
57 class SwAttrPool;
58 namespace svtools{ class ColorConfig;}
59 class SvtAccessibilityOptions;
60 class SvtCTLOptions;
61 class SvtUserOptions;
62 class SvtUndoOptions;
63 
64 struct SwDBData;
65 #define VIEWOPT_DEST_VIEW       0
66 #define VIEWOPT_DEST_TEXT       1
67 #define VIEWOPT_DEST_WEB        2
68 #define VIEWOPT_DEST_VIEW_ONLY  3 //ViewOptions werden nur an der ::com::sun::star::sdbcx::View, nicht an der Appl. gesetzt
69 
70 namespace com{ namespace sun{ namespace star{ namespace scanner{
71     class XScannerManager;
72 }}}}
73 
74 class SW_DLLPUBLIC SwModule: public SfxModule, public SfxListener, public utl::ConfigurationListener
75 {
76     String              sActAuthor;
77 
78     // ConfigItems
79     SwModuleOptions*    pModuleConfig;
80     SwMasterUsrPref*    pUsrPref;
81     SwMasterUsrPref*    pWebUsrPref;
82     SwPrintOptions*     pPrtOpt;
83     SwPrintOptions*     pWebPrtOpt;
84     SwChapterNumRules*  pChapterNumRules;
85     SwStdFontConfig*    pStdFontConfig;
86     SwNavigationConfig* pNavigationConfig;
87     SwToolbarConfigItem*pToolbarConfig;     //fuer gestackte Toolbars, welche
88     SwToolbarConfigItem*pWebToolbarConfig;  //war sichtbar?
89     SwDBConfig*         pDBConfig;
90     svtools::ColorConfig*   pColorConfig;
91     SvtAccessibilityOptions* pAccessibilityOptions;
92     SvtCTLOptions*      pCTLOptions;
93     SvtUserOptions*     pUserOptions;
94     SvtUndoOptions*     pUndoOptions;
95 
96     SfxErrorHandler*    pErrorHdl;
97 
98     SwAttrPool          *pAttrPool;
99 
100     // Die aktuelle View wird hier gehalten um nicht ueber
101     // GetActiveView arbeiten zu muessen
102     // Die View ist solange gueltig bis Sie im Activate
103     // zerstoert oder ausgetauscht wird
104     SwView*             pView;
105 
106     // Liste aller Redline-Autoren
107     SvStringsDtor*      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::XScannerManager >    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     // Hint abfangen fuer DocInfo
121     virtual void        Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
122 
123     virtual void        ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
124 
125 protected:
126     // Briefumschlaege, Etiketten
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     SFX_DECL_INTERFACE(SW_INTERFACE_MODULE)
136 
137     // dieser Ctor nur fuer SW-Dll
138     SwModule( SfxObjectFactory* pFact,
139                 SfxObjectFactory* pWebFact,
140                     SfxObjectFactory* pGlobalFact );
141 
142     ~SwModule();
143 
144     // View setzen nur fuer internen Gebrauch,
145     // aus techn. Gruenden public
146     //
SetView(SwView * pVw)147     inline  void        SetView(SwView* pVw) { pView = pVw; }
GetView()148     inline  SwView*     GetView() { return pView; }
149 
150     //Die Handler fuer die Slots
151     void                StateOther(SfxItemSet &);   // andere
152 
153     void                ExecOther(SfxRequest &);    // Felder, Formel ..
154 
155     // Benutzereinstellungen modifizieren
156     const SwMasterUsrPref *GetUsrPref(sal_Bool bWeb) const;
157     const SwViewOption* GetViewOption(sal_Bool bWeb);
158     void                ApplyUsrPref(const SwViewOption &, SwView*,
159                                      sal_uInt16 nDest = VIEWOPT_DEST_VIEW );
160     void ApplyUserMetric( FieldUnit eMetric, sal_Bool bWeb );
161     void ApplyRulerMetric( FieldUnit eMetric, sal_Bool bHorizontal, sal_Bool bWeb );
162     void ApplyFldUpdateFlags(SwFldUpdateFlags eFldFlags);
163     void ApplyLinkMode(sal_Int32 nNewLinkMode);
164 
165     //default page mode for text grid
166     void ApplyDefaultPageMode(sal_Bool bIsSquaredPageMode);
167 
168     // ConfigItems erzeugen
GetModuleConfig()169     SwModuleOptions*    GetModuleConfig()       { return pModuleConfig;}
170     SwPrintOptions*     GetPrtOptions(sal_Bool bWeb);
171     SwChapterNumRules*  GetChapterNumRules();
GetStdFontConfig()172     SwStdFontConfig*    GetStdFontConfig()      { return pStdFontConfig; }
173     SwNavigationConfig* GetNavigationConfig();
GetToolbarConfig()174     SwToolbarConfigItem*GetToolbarConfig()      { return pToolbarConfig;    }
GetWebToolbarConfig()175     SwToolbarConfigItem*GetWebToolbarConfig()   { return pWebToolbarConfig; }
176     SwDBConfig*         GetDBConfig();
177     svtools::ColorConfig&   GetColorConfig();
178     SvtAccessibilityOptions&    GetAccessibilityOptions();
179     SvtCTLOptions&      GetCTLOptions();
180     SvtUserOptions&     GetUserOptions();
181     SvtUndoOptions&     GetUndoOptions();
182 
183     // Ueber Sichten iterieren
184     static SwView*      GetFirstView();
185     static SwView*      GetNextView(SwView*);
186 
IsEmbeddedLoadSave() const187     sal_Bool IsEmbeddedLoadSave() const         { return bEmbeddedLoadSave; }
SetEmbeddedLoadSave(sal_Bool bFlag)188     void SetEmbeddedLoadSave( sal_Bool bFlag )  { bEmbeddedLoadSave = bFlag; }
189 
190     void ShowDBObj( SwView& rView, const SwDBData& rData, sal_Bool bOnlyIfAvailable = sal_False);
191 
192     // Tabellenmodi
193     sal_Bool            IsInsTblFormatNum(sal_Bool bHTML) const;
194     sal_Bool            IsInsTblChangeNumFormat(sal_Bool bHTML) const;
195     sal_Bool            IsInsTblAlignNum(sal_Bool bHTML) const;
196 
197     // Redlining
198     sal_uInt16          GetRedlineAuthor();
199     const String&       GetRedlineAuthor(sal_uInt16 nPos);
200     sal_uInt16          InsertRedlineAuthor(const String& rAuthor);
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     // returne den definierten DocStat - WordDelimiter
210     const String&       GetDocStatWordDelim() const;
211 
212     // Durchreichen der Metric von der ModuleConfig (fuer HTML-Export)
213     sal_uInt16 GetMetric( sal_Bool bWeb ) const;
214 
215     // Update-Stati durchreichen
216     sal_uInt16 GetLinkUpdMode( sal_Bool bWeb ) const;
217     SwFldUpdateFlags GetFldUpdateFlags( sal_Bool bWeb ) const;
218 
219     //virtuelle Methoden fuer den Optionendialog
220     virtual SfxItemSet*  CreateItemSet( sal_uInt16 nId );
221     virtual void         ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet );
222     virtual SfxTabPage*  CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet );
223 
224     //hier wird der Pool angelegt und an der SfxShell gesetzt
225     void    InitAttrPool();
226     //Pool loeschen bevor es zu spaet ist
227     void    RemoveAttrPool();
228 
229     // Invalidiert ggf. OnlineSpell-WrongListen
230     void    CheckSpellChanges( sal_Bool bOnlineSpelling,
231                     sal_Bool bIsSpellWrongAgain, sal_Bool bIsSpellAllAgain, sal_Bool bSmartTags );
232 
233     inline ::com::sun::star::uno::Reference<
234         ::com::sun::star::linguistic2::XLinguServiceEventListener >
235             GetLngSvcEvtListener();
236     inline void SetLngSvcEvtListener( ::com::sun::star::uno::Reference<
237         ::com::sun::star::linguistic2::XLinguServiceEventListener > & xLstnr);
238     void    CreateLngSvcEvtListener();
239 
240     ::com::sun::star::uno::Reference<
241         ::com::sun::star::scanner::XScannerManager >
242             GetScannerManager();
243 
244     ::com::sun::star::uno::Reference<
245         ::com::sun::star::linguistic2::XLanguageGuessing >
246             GetLanguageGuesser();
247 };
248 
249 
250 inline ::com::sun::star::uno::Reference<
251     ::com::sun::star::linguistic2::XLinguServiceEventListener >
GetLngSvcEvtListener()252         SwModule::GetLngSvcEvtListener()
253 {
254     return xLngSvcEvtListener;
255 }
256 
SetLngSvcEvtListener(::com::sun::star::uno::Reference<::com::sun::star::linguistic2::XLinguServiceEventListener> & xLstnr)257 inline void SwModule::SetLngSvcEvtListener(
258     ::com::sun::star::uno::Reference<
259        ::com::sun::star::linguistic2::XLinguServiceEventListener > & xLstnr)
260 {
261     xLngSvcEvtListener = xLstnr;
262 }
263 
264 
265 /*-----------------08.07.97 10.33-------------------
266     Zugriff auf das SwModule, die ::com::sun::star::sdbcx::View und die Shell
267 --------------------------------------------------*/
268 
269 #define SW_MOD() ( *(SwModule**) GetAppData(SHL_WRITER))
270 
271 SW_DLLPUBLIC SwView*    GetActiveView();
272 SW_DLLPUBLIC SwWrtShell* GetActiveWrtShell();
273 
274 #endif
275