xref: /trunk/main/sw/source/ui/app/swmodule.cxx (revision ffd38472365e95f6a578737bc9a5eb0fac624a86)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_sw.hxx"
24 
25 #include <hintids.hxx>
26 #ifndef _SWERROR_H
27 #include <swerror.h>
28 #endif
29 #include <vcl/wrkwin.hxx>
30 #include <vcl/graph.hxx>
31 #include <svx/galbrws.hxx>
32 #include <svx/svdobj.hxx>
33 #include <svtools/ehdl.hxx>
34 #include <svx/fntszctl.hxx>
35 #include <svx/fntctl.hxx>
36 #include <svx/SmartTagCtl.hxx>
37 #include <svx/pszctrl.hxx>
38 #include <svx/insctrl.hxx>
39 #include <svx/selctrl.hxx>
40 #include <svx/linectrl.hxx>
41 #include <svx/tbxctl.hxx>           //z-Zt falscher includeschutz!
42 #include <svx/fillctrl.hxx>
43 #include <svx/tbcontrl.hxx>
44 #include <svx/verttexttbxctrl.hxx>
45 #include <svx/formatpaintbrushctrl.hxx>
46 #include <svx/contdlg.hxx>
47 #include <svx/layctrl.hxx>
48 #include <svx/fontwork.hxx>
49 #include <SwSpellDialogChildWindow.hxx>
50 #include <svx/tbxalign.hxx>
51 #include <svx/grafctrl.hxx>
52 #include <svx/tbxcolor.hxx>
53 #include <svx/clipboardctl.hxx>
54 #include <svx/lboxctrl.hxx>
55 #include <svx/hyprlink.hxx>
56 #include <svx/tbxcustomshapes.hxx>
57 #include <svx/imapdlg.hxx>
58 #include <svx/srchdlg.hxx>
59 #include <svx/hyperdlg.hxx>
60 #include <svx/extrusioncolorcontrol.hxx>
61 #include <svx/fontworkgallery.hxx>
62 #include <com/sun/star/scanner/XScannerManager.hpp>
63 #include <com/sun/star/container/XSet.hpp>
64 #include <comphelper/processfactory.hxx>
65 #ifndef _DOCSH_HXX
66 #include <docsh.hxx>
67 #endif
68 #include <swmodule.hxx>
69 #include <swevent.hxx>
70 #include <swacorr.hxx>
71 #ifndef _CMDID_H
72 #include <cmdid.h>
73 #endif
74 #include <dobjfac.hxx>
75 #include <init.hxx>
76 #include <pview.hxx>
77 #include <wview.hxx>
78 #include <wdocsh.hxx>
79 #include <globdoc.hxx>
80 #ifndef _SRCVIEW_HXX //autogen
81 #include <srcview.hxx>
82 #endif
83 #include <glshell.hxx>
84 #include <tabsh.hxx>
85 #include <listsh.hxx>
86 #include <grfsh.hxx>
87 #include <mediash.hxx>
88 #include <olesh.hxx>
89 #include <drawsh.hxx>
90 #include <wformsh.hxx>
91 #include <drwtxtsh.hxx>
92 #include <beziersh.hxx>
93 #include <wtextsh.hxx>
94 #include <wfrmsh.hxx>
95 #ifndef _DRFORMSH_HXX
96 #include <drformsh.hxx>
97 #endif
98 #ifndef _WGRFSH_HXX
99 #include <wgrfsh.hxx>
100 #endif
101 #ifndef _WOLESH_HXX
102 #include <wolesh.hxx>
103 #endif
104 #ifndef _WLISTSH_HXX
105 #include <wlistsh.hxx>
106 #endif
107 #ifndef _WTABSH_HXX
108 #include <wtabsh.hxx>
109 #endif
110 #include <navipi.hxx>
111 #include <chartins.hxx>
112 #include <inputwin.hxx>
113 #include <usrpref.hxx>
114 #include <uinums.hxx>
115 #include <prtopt.hxx>
116 #include <bookctrl.hxx>
117 #include <tmplctrl.hxx>
118 #include <viewlayoutctrl.hxx>
119 #include <svx/zoomsliderctrl.hxx>
120 #include <tblctrl.hxx>
121 #include <zoomctrl.hxx>
122 #include <workctrl.hxx>
123 #include <tbxanchr.hxx>
124 #include <fldwrap.hxx>
125 #ifndef _REDLNDLG_HXX
126 #include <redlndlg.hxx>
127 #endif
128 #ifndef _SYNCBTN_HXX
129 #include <syncbtn.hxx>
130 #endif
131 #include <mailmergechildwindow.hxx>
132 #include <modcfg.hxx>
133 #include <fontcfg.hxx>
134 #include <sfx2/sidebar/SidebarChildWindow.hxx>
135 #include <sfx2/evntconf.hxx>
136 #include <sfx2/appuno.hxx>
137 #include <swatrset.hxx>
138 #include <idxmrk.hxx>
139 #include <dlelstnr.hxx>
140 #ifndef _BARCFG_HXX
141 #include <barcfg.hxx>
142 #endif
143 #include <svx/rubydialog.hxx>
144 // OD 14.02.2003 #107424#
145 #include <svtools/colorcfg.hxx>
146 
147 #include <editeng/acorrcfg.hxx>
148 #include <unotools/moduleoptions.hxx>
149 
150 #ifndef _AVMEDIA_MEDIAPPLAYER_HXX
151 #include <avmedia/mediaplayer.hxx>
152 #endif
153 #include <avmedia/mediatoolbox.hxx>
154 
155 #include <annotsh.hxx>
156 
157 #include <app.hrc>
158 #include <svx/xmlsecctrl.hxx>
159 ResMgr *pSwResMgr = 0;
160 sal_Bool    bNoInterrupt    = sal_False;
161 
162 #include <sfx2/app.hxx>
163 
164 #include <svx/svxerr.hxx>
165 
166 #include <unomid.h>
167 
168 using namespace com::sun::star;
169 
170 
171 TYPEINIT1( SwModule, SfxModule );
172 
173 using namespace ::com::sun::star;
174 using namespace ::com::sun::star::uno;
175 
176 //************************************************************************
177 
178 SwModule::SwModule( SfxObjectFactory* pWebFact,
179                     SfxObjectFactory* pFact,
180                     SfxObjectFactory* pGlobalFact )
181     : SfxModule( SfxApplication::CreateResManager( "sw" ), sal_False, pWebFact,
182                      pFact, pGlobalFact, NULL ),
183     pModuleConfig(0),
184     pUsrPref(0),
185     pWebUsrPref(0),
186     pPrtOpt(0),
187     pWebPrtOpt(0),
188     pChapterNumRules(0),
189     pStdFontConfig(0),
190     pNavigationConfig(0),
191     pToolbarConfig(0),
192     pWebToolbarConfig(0),
193     pDBConfig(0),
194     pColorConfig(0),
195     pAccessibilityOptions(0),
196     pCTLOptions(0),
197     pUserOptions(0),
198     pUndoOptions(0),
199     pAttrPool(0),
200     pView(0),
201     bAuthorInitialised(sal_False),
202     bEmbeddedLoadSave( sal_False ),
203     pDragDrop( 0 ),
204     pXSelection( 0 )
205 {
206     SetName( String::CreateFromAscii("StarWriter") );
207     pSwResMgr = GetResMgr();
208     SvxErrorHandler::Get();
209     pErrorHdl = new SfxErrorHandler( RID_SW_ERRHDL,
210                                      ERRCODE_AREA_SW,
211                                      ERRCODE_AREA_SW_END,
212                                      pSwResMgr );
213 
214     pModuleConfig = new SwModuleOptions;
215 
216     // Die brauchen wir sowieso
217     pToolbarConfig = new SwToolbarConfigItem( sal_False );
218     pWebToolbarConfig = new SwToolbarConfigItem( sal_True );
219 
220     pStdFontConfig = new SwStdFontConfig;
221 
222     pAuthorNames = new SvStringsDtor(5, 1); // Alle Redlining-Autoren
223 
224     // JP 18.10.96: SvxAutocorrect gegen die SwAutocorrect austauschen
225     SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get();
226     if( pACfg )
227     {
228         const SvxAutoCorrect* pOld = pACfg->GetAutoCorrect();
229         pACfg->SetAutoCorrect(new SwAutoCorrect( *pOld ));
230     }
231 
232     StartListening( *SFX_APP() );
233 
234     // OD 14.02.2003 #107424# - init color configuration
235     // member <pColorConfig> is created and the color configuration is applied
236     // at the view options.
237     GetColorConfig();
238 }
239 
240 //************************************************************************
241 
242 uno::Reference< scanner::XScannerManager >
243 SwModule::GetScannerManager()
244 {
245     if (!m_xScannerManager.is())
246     {
247         uno::Reference< lang::XMultiServiceFactory > xMgr (
248             comphelper::getProcessServiceFactory() );
249         if( xMgr.is() )
250         {
251             m_xScannerManager =
252                 uno::Reference< scanner::XScannerManager >(
253                     xMgr->createInstance(
254                         rtl::OUString::createFromAscii(
255                             "com.sun.star.scanner.ScannerManager" ) ),
256                     uno::UNO_QUERY );
257         }
258     }
259     return m_xScannerManager;
260 }
261 
262 uno::Reference< linguistic2::XLanguageGuessing > SwModule::GetLanguageGuesser()
263 {
264     if (!m_xLanguageGuesser.is())
265     {
266         uno::Reference< lang::XMultiServiceFactory > xMgr ( comphelper::getProcessServiceFactory() );
267         if (xMgr.is())
268         {
269             m_xLanguageGuesser = uno::Reference< linguistic2::XLanguageGuessing >(
270                     xMgr->createInstance(
271                         rtl::OUString::createFromAscii( "com.sun.star.linguistic2.LanguageGuessing" ) ),
272                         uno::UNO_QUERY );
273         }
274     }
275     return m_xLanguageGuesser;
276 }
277 
278 //************************************************************************
279 
280 SwModule::~SwModule()
281 {
282     SetPool(0);
283     SfxItemPool::Free(pAttrPool);
284     delete pErrorHdl;
285     EndListening( *SFX_APP() );
286 }
287 
288 //************************************************************************
289 
290 void SwModule::CreateLngSvcEvtListener()
291 {
292     if (!xLngSvcEvtListener.is())
293         xLngSvcEvtListener = new SwLinguServiceEventListener;
294 }
295 
296 //************************************************************************
297 
298 void SwDLL::RegisterFactories()
299 {
300     // Diese Id's duerfen nicht geaendert werden. Mittels der Id's wird vom
301     // Sfx die View (Dokumentansicht wiederherstellen) erzeugt.
302     if ( SvtModuleOptions().IsWriter() )
303         SwView::RegisterFactory     ( 2 );
304 
305     SwWebView::RegisterFactory      ( 5 );
306 
307     if ( SvtModuleOptions().IsWriter() )
308     {
309         SwSrcView::RegisterFactory      ( 6 );
310         SwPagePreView::RegisterFactory  ( 7 );
311     }
312 }
313 
314 //************************************************************************
315 
316 void SwDLL::RegisterInterfaces()
317 {
318     SwModule* pMod = SW_MOD();
319     SwModule::RegisterInterface( pMod );
320     SwDocShell::RegisterInterface( pMod );
321     SwWebDocShell::RegisterInterface( pMod );
322     SwGlosDocShell::RegisterInterface( pMod );
323     SwWebGlosDocShell::RegisterInterface( pMod );
324     SwView::RegisterInterface( pMod );
325     SwWebView::RegisterInterface( pMod );
326     SwPagePreView::RegisterInterface( pMod );
327     SwSrcView::RegisterInterface( pMod );
328 
329 
330     SwBaseShell::RegisterInterface(pMod);
331     SwTextShell::RegisterInterface(pMod);
332     SwTableShell::RegisterInterface(pMod);
333     SwListShell::RegisterInterface(pMod);
334     SwFrameShell::RegisterInterface(pMod);
335     SwDrawBaseShell::RegisterInterface(pMod);
336     SwDrawShell::RegisterInterface(pMod);
337     SwDrawFormShell::RegisterInterface(pMod);
338     SwDrawTextShell::RegisterInterface(pMod);
339     SwBezierShell::RegisterInterface(pMod);
340     SwGrfShell::RegisterInterface(pMod);
341     SwOleShell::RegisterInterface(pMod);
342     SwWebTextShell::RegisterInterface(pMod);
343     SwWebFrameShell::RegisterInterface(pMod);
344     SwWebGrfShell::RegisterInterface(pMod);
345     SwWebListShell::RegisterInterface(pMod);
346     SwWebTableShell::RegisterInterface(pMod);
347     SwWebDrawFormShell::RegisterInterface(pMod);
348     SwWebOleShell::RegisterInterface(pMod);
349     SwMediaShell::RegisterInterface(pMod);
350     SwAnnotationShell::RegisterInterface(pMod);
351 }
352 
353 //************************************************************************
354 
355 void SwDLL::RegisterControls()
356 {
357     SwModule* pMod = SW_MOD();
358     SvxTbxCtlDraw::RegisterControl(SID_INSERT_DRAW, pMod );
359     SvxTbxCtlAlign::RegisterControl(SID_OBJECT_ALIGN, pMod );
360     SwTbxAnchor::RegisterControl(FN_TOOL_ANCHOR, pMod );
361     SwTbxInsertCtrl::RegisterControl(FN_INSERT_CTRL, pMod );
362     SwTbxInsertCtrl::RegisterControl(FN_INSERT_OBJ_CTRL, pMod );
363     SwTbxAutoTextCtrl::RegisterControl(FN_INSERT_FIELD_CTRL, pMod );
364     SwTbxAutoTextCtrl::RegisterControl(FN_GLOSSARY_DLG, pMod );
365 
366     SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_BASIC, pMod );
367     SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_SYMBOL, pMod );
368     SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_ARROW, pMod );
369     SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_FLOWCHART, pMod );
370     SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_CALLOUT, pMod );
371     SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_STAR, pMod );
372 
373     svx::ExtrusionColorControl::RegisterControl( SID_EXTRUSION_3D_COLOR, pMod );
374     svx::FontWorkShapeTypeControl::RegisterControl( SID_FONTWORK_SHAPE_TYPE, pMod );
375 
376     SvxClipBoardControl::RegisterControl(SID_PASTE, pMod );
377     SvxUndoRedoControl::RegisterControl(SID_UNDO, pMod );
378     SvxUndoRedoControl::RegisterControl(SID_REDO, pMod );
379     svx::FormatPaintBrushToolBoxControl::RegisterControl(SID_FORMATPAINTBRUSH, pMod );
380 
381     SvxFillToolBoxControl::RegisterControl(SID_ATTR_FILL_STYLE, pMod );
382     SvxLineStyleToolBoxControl::RegisterControl(SID_ATTR_LINE_STYLE, pMod );
383     SvxLineWidthToolBoxControl::RegisterControl(SID_ATTR_LINE_WIDTH, pMod );
384     SvxLineColorToolBoxControl::RegisterControl(SID_ATTR_LINE_COLOR, pMod );
385     SvxLineEndToolBoxControl::RegisterControl(SID_ATTR_LINEEND_STYLE, pMod );
386 
387     SvxFontNameToolBoxControl::RegisterControl(SID_ATTR_CHAR_FONT, pMod );
388 //  SvxFontHeightToolBoxControl::RegisterControl(SID_ATTR_CHAR_FONTHEIGHT, pMod );
389     SvxFontColorToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR, pMod );
390     SvxFontColorExtToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR2, pMod );
391     SvxFontColorExtToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR_BACKGROUND, pMod );
392     SvxStyleToolBoxControl::RegisterControl(SID_STYLE_APPLY, pMod );
393     SvxColorToolBoxControl::RegisterControl(SID_BACKGROUND_COLOR, pMod );
394     SvxFrameToolBoxControl::RegisterControl(SID_ATTR_BORDER, pMod );
395     SvxFrameLineStyleToolBoxControl::RegisterControl(SID_FRAME_LINESTYLE, pMod );
396     SvxFrameLineColorToolBoxControl::RegisterControl(SID_FRAME_LINECOLOR, pMod );
397 
398     SvxColumnsToolBoxControl::RegisterControl(FN_INSERT_FRAME_INTERACT, pMod );
399     SvxColumnsToolBoxControl::RegisterControl(FN_INSERT_FRAME, pMod );
400     SvxColumnsToolBoxControl::RegisterControl(FN_INSERT_REGION, pMod );
401     SvxTableToolBoxControl::RegisterControl(FN_INSERT_TABLE, pMod );
402     SvxTableToolBoxControl::RegisterControl(FN_SHOW_MULTIPLE_PAGES, pMod );
403 
404     SvxFontMenuControl::RegisterControl(SID_ATTR_CHAR_FONT, pMod );
405     SvxFontSizeMenuControl::RegisterControl(SID_ATTR_CHAR_FONTHEIGHT, pMod );
406 
407     SwZoomControl::RegisterControl(SID_ATTR_ZOOM, pMod );
408     SwPreviewZoomControl::RegisterControl(FN_PREVIEW_ZOOM, pMod);
409     SvxPosSizeStatusBarControl::RegisterControl(0, pMod );
410     SvxInsertStatusBarControl::RegisterControl(SID_ATTR_INSERT, pMod );
411     SvxSelectionModeControl::RegisterControl(FN_STAT_SELMODE, pMod );
412     XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pMod );
413 
414     SwBookmarkControl::RegisterControl(FN_STAT_PAGE, pMod );
415     SwTemplateControl::RegisterControl(FN_STAT_TEMPLATE, pMod );
416     SwViewLayoutControl::RegisterControl( SID_ATTR_VIEWLAYOUT, pMod );
417     SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER, pMod );
418 
419     SwTableOptimizeCtrl::RegisterControl(FN_OPTIMIZE_TABLE, pMod);
420 
421     SvxIMapDlgChildWindow::RegisterChildWindow( sal_False, pMod );
422     SvxSearchDialogWrapper::RegisterChildWindow( sal_False, pMod );
423     SvxHlinkDlgWrapper::RegisterChildWindow( sal_False, pMod );
424     SvxHyperlinkDlgWrapper::RegisterChildWindow( sal_False, pMod, SFX_CHILDWIN_FORCEDOCK );
425     SvxFontWorkChildWindow::RegisterChildWindow( sal_False, pMod );
426     SwFldDlgWrapper::RegisterChildWindow( sal_False, pMod );
427     SwFldDataOnlyDlgWrapper::RegisterChildWindow( sal_False, pMod );
428     SvxContourDlgChildWindow::RegisterChildWindow( sal_False, pMod );
429     SwNavigationChild::RegisterChildWindowContext( pMod );
430     SwInputChild::RegisterChildWindow( sal_False, pMod, SFX_CHILDWIN_FORCEDOCK );
431     SwRedlineAcceptChild::RegisterChildWindow( sal_False, pMod );
432     SwSyncChildWin::RegisterChildWindow( sal_True, pMod );
433     SwMailMergeChildWindow::RegisterChildWindow( sal_False, pMod );
434 //  SwSendMailChildWindow::RegisterChildWindow( sal_False, pMod );
435     SwInsertIdxMarkWrapper::RegisterChildWindow( sal_False, pMod );
436     SwInsertAuthMarkWrapper::RegisterChildWindow( sal_False, pMod );
437     SvxRubyChildWindow::RegisterChildWindow( sal_False, pMod);
438     SwSpellDialogChildWindow::RegisterChildWindow(sal_False, pMod);
439 
440     SvxGrafRedToolBoxControl::RegisterControl( SID_ATTR_GRAF_RED, pMod );
441     SvxGrafGreenToolBoxControl::RegisterControl( SID_ATTR_GRAF_GREEN, pMod );
442     SvxGrafBlueToolBoxControl::RegisterControl( SID_ATTR_GRAF_BLUE, pMod );
443     SvxGrafLuminanceToolBoxControl::RegisterControl( SID_ATTR_GRAF_LUMINANCE, pMod );
444     SvxGrafContrastToolBoxControl::RegisterControl( SID_ATTR_GRAF_CONTRAST, pMod );
445     SvxGrafGammaToolBoxControl::RegisterControl( SID_ATTR_GRAF_GAMMA, pMod );
446     SvxGrafTransparenceToolBoxControl::RegisterControl( SID_ATTR_GRAF_TRANSPARENCE, pMod );
447     SvxGrafModeToolBoxControl::RegisterControl( SID_ATTR_GRAF_MODE, pMod );
448     SvxGrafFilterToolBoxControl::RegisterControl( SID_GRFFILTER, pMod );
449     SvxVertTextTbxCtrl::RegisterControl(SID_TEXTDIRECTION_LEFT_TO_RIGHT, pMod);
450     SvxVertTextTbxCtrl::RegisterControl(SID_TEXTDIRECTION_TOP_TO_BOTTOM, pMod);
451     SvxVertTextTbxCtrl::RegisterControl(SID_DRAW_CAPTION_VERTICAL, pMod);
452     SvxVertTextTbxCtrl::RegisterControl(SID_DRAW_TEXT_VERTICAL, pMod);
453 
454     SvxCTLTextTbxCtrl::RegisterControl(SID_ATTR_PARA_LEFT_TO_RIGHT, pMod);
455     SvxCTLTextTbxCtrl::RegisterControl(SID_ATTR_PARA_RIGHT_TO_LEFT, pMod);
456 
457     GalleryChildWindow::RegisterChildWindow(0, pMod);
458 
459     ::avmedia::MediaToolBoxControl::RegisterControl(SID_AVMEDIA_TOOLBOX, pMod);
460     ::avmedia::MediaPlayer::RegisterChildWindow(0, pMod);
461 
462     SvxSmartTagsControl::RegisterControl(SID_OPEN_SMARTTAGMENU, pMod);
463     ::sfx2::sidebar::SidebarChildWindow::RegisterChildWindow(sal_False, pMod);
464 }
465 
466 /*************************************************************************
467 |* Modul laden (nur Attrappe für das Linken der DLL)
468 \************************************************************************/
469 
470 /* -----------------20.04.99 10:46-------------------
471  *
472  * --------------------------------------------------*/
473 void    SwModule::InitAttrPool()
474 {
475     DBG_ASSERT(!pAttrPool, "Pool is already there!");
476     pAttrPool = new SwAttrPool(0);
477     SetPool(pAttrPool);
478 }
479 /* -----------------20.04.99 10:46-------------------
480  *
481  * --------------------------------------------------*/
482 void    SwModule::RemoveAttrPool()
483 {
484     SetPool(0);
485     SfxItemPool::Free(pAttrPool);
486 }
487 
488 /* vim: set noet sw=4 ts=4: */
489