xref: /trunk/main/sw/source/ui/app/swmodule.cxx (revision 6bcc9fe0e9ad8e3adcad10b35c622961480f57f3)
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/taskpane.hxx>
136 #include <sfx2/evntconf.hxx>
137 #include <sfx2/appuno.hxx>
138 #include <swatrset.hxx>
139 #include <idxmrk.hxx>
140 #include <dlelstnr.hxx>
141 #ifndef _BARCFG_HXX
142 #include <barcfg.hxx>
143 #endif
144 #include <svx/rubydialog.hxx>
145 // OD 14.02.2003 #107424#
146 #include <svtools/colorcfg.hxx>
147 
148 #include <editeng/acorrcfg.hxx>
149 #include <unotools/moduleoptions.hxx>
150 
151 #ifndef _AVMEDIA_MEDIAPPLAYER_HXX
152 #include <avmedia/mediaplayer.hxx>
153 #endif
154 #include <avmedia/mediatoolbox.hxx>
155 
156 #include <annotsh.hxx>
157 
158 #include <app.hrc>
159 #include <svx/xmlsecctrl.hxx>
160 ResMgr *pSwResMgr = 0;
161 sal_Bool    bNoInterrupt    = sal_False;
162 
163 #include <sfx2/app.hxx>
164 
165 #include <svx/svxerr.hxx>
166 
167 #include <unomid.h>
168 
169 using namespace com::sun::star;
170 
171 
172 TYPEINIT1( SwModule, SfxModule );
173 
174 using namespace ::com::sun::star;
175 using namespace ::com::sun::star::uno;
176 
177 //************************************************************************
178 
179 SwModule::SwModule( SfxObjectFactory* pWebFact,
180                     SfxObjectFactory* pFact,
181                     SfxObjectFactory* pGlobalFact )
182     : SfxModule( SfxApplication::CreateResManager( "sw" ), sal_False, pWebFact,
183                      pFact, pGlobalFact, NULL ),
184     pModuleConfig(0),
185     pUsrPref(0),
186     pWebUsrPref(0),
187     pPrtOpt(0),
188     pWebPrtOpt(0),
189     pChapterNumRules(0),
190     pStdFontConfig(0),
191     pNavigationConfig(0),
192     pToolbarConfig(0),
193     pWebToolbarConfig(0),
194     pDBConfig(0),
195     pColorConfig(0),
196     pAccessibilityOptions(0),
197     pCTLOptions(0),
198     pUserOptions(0),
199     pUndoOptions(0),
200     pAttrPool(0),
201     pView(0),
202     bAuthorInitialised(sal_False),
203     bEmbeddedLoadSave( sal_False ),
204     pDragDrop( 0 ),
205     pXSelection( 0 )
206 {
207     SetName( String::CreateFromAscii("StarWriter") );
208     pSwResMgr = GetResMgr();
209     SvxErrorHandler::Get();
210     pErrorHdl = new SfxErrorHandler( RID_SW_ERRHDL,
211                                      ERRCODE_AREA_SW,
212                                      ERRCODE_AREA_SW_END,
213                                      pSwResMgr );
214 
215     pModuleConfig = new SwModuleOptions;
216 
217     //Die brauchen wie sowieso
218     pToolbarConfig = new SwToolbarConfigItem( sal_False );
219     pWebToolbarConfig = new SwToolbarConfigItem( sal_True );
220 
221     pStdFontConfig = new SwStdFontConfig;
222 
223     pAuthorNames = new SvStringsDtor(5, 1); // Alle Redlining-Autoren
224 
225     // JP 18.10.96: SvxAutocorrect gegen die SwAutocorrect austauschen
226     SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get();
227     if( pACfg )
228     {
229         const SvxAutoCorrect* pOld = pACfg->GetAutoCorrect();
230         pACfg->SetAutoCorrect(new SwAutoCorrect( *pOld ));
231     }
232 
233     StartListening( *SFX_APP() );
234 
235     // OD 14.02.2003 #107424# - init color configuration
236     // member <pColorConfig> is created and the color configuration is applied
237     // at the view options.
238     GetColorConfig();
239 }
240 
241 //************************************************************************
242 
243 uno::Reference< scanner::XScannerManager >
244 SwModule::GetScannerManager()
245 {
246     if (!m_xScannerManager.is())
247     {
248         uno::Reference< lang::XMultiServiceFactory > xMgr (
249             comphelper::getProcessServiceFactory() );
250         if( xMgr.is() )
251         {
252             m_xScannerManager =
253                 uno::Reference< scanner::XScannerManager >(
254                     xMgr->createInstance(
255                         rtl::OUString::createFromAscii(
256                             "com.sun.star.scanner.ScannerManager" ) ),
257                     uno::UNO_QUERY );
258         }
259     }
260     return m_xScannerManager;
261 }
262 
263 uno::Reference< linguistic2::XLanguageGuessing > SwModule::GetLanguageGuesser()
264 {
265     if (!m_xLanguageGuesser.is())
266     {
267         uno::Reference< lang::XMultiServiceFactory > xMgr ( comphelper::getProcessServiceFactory() );
268         if (xMgr.is())
269         {
270             m_xLanguageGuesser = uno::Reference< linguistic2::XLanguageGuessing >(
271                     xMgr->createInstance(
272                         rtl::OUString::createFromAscii( "com.sun.star.linguistic2.LanguageGuessing" ) ),
273                         uno::UNO_QUERY );
274         }
275     }
276     return m_xLanguageGuesser;
277 }
278 
279 //************************************************************************
280 
281 SwModule::~SwModule()
282 {
283     SetPool(0);
284     SfxItemPool::Free(pAttrPool);
285     delete pErrorHdl;
286     EndListening( *SFX_APP() );
287 }
288 
289 //************************************************************************
290 
291 void SwModule::CreateLngSvcEvtListener()
292 {
293     if (!xLngSvcEvtListener.is())
294         xLngSvcEvtListener = new SwLinguServiceEventListener;
295 }
296 
297 //************************************************************************
298 
299 void SwDLL::RegisterFactories()
300 {
301     //Diese Id's duerfen nicht geaendert werden. Mittels der Id's wird vom
302     //Sfx die View (Dokumentansicht wiederherstellen) erzeugt.
303     if ( SvtModuleOptions().IsWriter() )
304         SwView::RegisterFactory     ( 2 );
305 
306     SwWebView::RegisterFactory      ( 5 );
307 
308     if ( SvtModuleOptions().IsWriter() )
309     {
310         SwSrcView::RegisterFactory      ( 6 );
311         SwPagePreView::RegisterFactory  ( 7 );
312     }
313 }
314 
315 //************************************************************************
316 
317 
318 void SwDLL::RegisterInterfaces()
319 {
320     SwModule* pMod = SW_MOD();
321     SwModule::RegisterInterface( pMod );
322     SwDocShell::RegisterInterface( pMod );
323     SwWebDocShell::RegisterInterface( pMod );
324     SwGlosDocShell::RegisterInterface( pMod );
325     SwWebGlosDocShell::RegisterInterface( pMod );
326     SwView::RegisterInterface( pMod );
327     SwWebView::RegisterInterface( pMod );
328     SwPagePreView::RegisterInterface( pMod );
329     SwSrcView::RegisterInterface( pMod );
330 
331 
332     SwBaseShell::RegisterInterface(pMod);
333     SwTextShell::RegisterInterface(pMod);
334     SwTableShell::RegisterInterface(pMod);
335     SwListShell::RegisterInterface(pMod);
336     SwFrameShell::RegisterInterface(pMod);
337     SwDrawBaseShell::RegisterInterface(pMod);
338     SwDrawShell::RegisterInterface(pMod);
339     SwDrawFormShell::RegisterInterface(pMod);
340     SwDrawTextShell::RegisterInterface(pMod);
341     SwBezierShell::RegisterInterface(pMod);
342     SwGrfShell::RegisterInterface(pMod);
343     SwOleShell::RegisterInterface(pMod);
344     SwWebTextShell::RegisterInterface(pMod);
345     SwWebFrameShell::RegisterInterface(pMod);
346     SwWebGrfShell::RegisterInterface(pMod);
347     SwWebListShell::RegisterInterface(pMod);
348     SwWebTableShell::RegisterInterface(pMod);
349     SwWebDrawFormShell::RegisterInterface(pMod);
350     SwWebOleShell::RegisterInterface(pMod);
351     SwMediaShell::RegisterInterface(pMod);
352     SwAnnotationShell::RegisterInterface(pMod);
353 }
354 
355 //************************************************************************
356 
357 void SwDLL::RegisterControls()
358 {
359     SwModule* pMod = SW_MOD();
360     SvxTbxCtlDraw::RegisterControl(SID_INSERT_DRAW, pMod );
361     SvxTbxCtlAlign::RegisterControl(SID_OBJECT_ALIGN, pMod );
362     SwTbxAnchor::RegisterControl(FN_TOOL_ANCHOR, pMod );
363     SwTbxInsertCtrl::RegisterControl(FN_INSERT_CTRL, pMod );
364     SwTbxInsertCtrl::RegisterControl(FN_INSERT_OBJ_CTRL, pMod );
365     SwTbxAutoTextCtrl::RegisterControl(FN_INSERT_FIELD_CTRL, pMod );
366     SwTbxAutoTextCtrl::RegisterControl(FN_GLOSSARY_DLG, pMod );
367 
368     SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_BASIC, pMod );
369     SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_SYMBOL, pMod );
370     SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_ARROW, pMod );
371     SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_FLOWCHART, pMod );
372     SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_CALLOUT, pMod );
373     SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_STAR, pMod );
374 
375     svx::ExtrusionColorControl::RegisterControl( SID_EXTRUSION_3D_COLOR, pMod );
376     svx::FontWorkShapeTypeControl::RegisterControl( SID_FONTWORK_SHAPE_TYPE, pMod );
377 
378     SvxClipBoardControl::RegisterControl(SID_PASTE, pMod );
379     SvxUndoRedoControl::RegisterControl(SID_UNDO, pMod );
380     SvxUndoRedoControl::RegisterControl(SID_REDO, pMod );
381     svx::FormatPaintBrushToolBoxControl::RegisterControl(SID_FORMATPAINTBRUSH, pMod );
382 
383     SvxFillToolBoxControl::RegisterControl(SID_ATTR_FILL_STYLE, pMod );
384     SvxLineStyleToolBoxControl::RegisterControl(SID_ATTR_LINE_STYLE, pMod );
385     SvxLineWidthToolBoxControl::RegisterControl(SID_ATTR_LINE_WIDTH, pMod );
386     SvxLineColorToolBoxControl::RegisterControl(SID_ATTR_LINE_COLOR, pMod );
387     SvxLineEndToolBoxControl::RegisterControl(SID_ATTR_LINEEND_STYLE, pMod );
388 
389     SvxFontNameToolBoxControl::RegisterControl(SID_ATTR_CHAR_FONT, pMod );
390 //  SvxFontHeightToolBoxControl::RegisterControl(SID_ATTR_CHAR_FONTHEIGHT, pMod );
391     SvxFontColorToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR, pMod );
392     SvxFontColorExtToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR2, pMod );
393     SvxFontColorExtToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR_BACKGROUND, pMod );
394     SvxStyleToolBoxControl::RegisterControl(SID_STYLE_APPLY, pMod );
395     SvxColorToolBoxControl::RegisterControl(SID_BACKGROUND_COLOR, pMod );
396     SvxFrameToolBoxControl::RegisterControl(SID_ATTR_BORDER, pMod );
397     SvxFrameLineStyleToolBoxControl::RegisterControl(SID_FRAME_LINESTYLE, pMod );
398     SvxFrameLineColorToolBoxControl::RegisterControl(SID_FRAME_LINECOLOR, pMod );
399 
400     SvxColumnsToolBoxControl::RegisterControl(FN_INSERT_FRAME_INTERACT, pMod );
401     SvxColumnsToolBoxControl::RegisterControl(FN_INSERT_FRAME, pMod );
402     SvxColumnsToolBoxControl::RegisterControl(FN_INSERT_REGION, pMod );
403     SvxTableToolBoxControl::RegisterControl(FN_INSERT_TABLE, pMod );
404     SvxTableToolBoxControl::RegisterControl(FN_SHOW_MULTIPLE_PAGES, pMod );
405 
406     SvxFontMenuControl::RegisterControl(SID_ATTR_CHAR_FONT, pMod );
407     SvxFontSizeMenuControl::RegisterControl(SID_ATTR_CHAR_FONTHEIGHT, pMod );
408 
409     SwZoomControl::RegisterControl(SID_ATTR_ZOOM, pMod );
410     SwPreviewZoomControl::RegisterControl(FN_PREVIEW_ZOOM, pMod);
411     SvxPosSizeStatusBarControl::RegisterControl(0, pMod );
412     SvxInsertStatusBarControl::RegisterControl(SID_ATTR_INSERT, pMod );
413     SvxSelectionModeControl::RegisterControl(FN_STAT_SELMODE, pMod );
414     XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pMod );
415 
416     SwBookmarkControl::RegisterControl(FN_STAT_PAGE, pMod );
417     SwTemplateControl::RegisterControl(FN_STAT_TEMPLATE, pMod );
418     SwViewLayoutControl::RegisterControl( SID_ATTR_VIEWLAYOUT, pMod );
419     SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER, pMod );
420 
421     SwTableOptimizeCtrl::RegisterControl(FN_OPTIMIZE_TABLE, pMod);
422 
423     SvxIMapDlgChildWindow::RegisterChildWindow( sal_False, pMod );
424     SvxSearchDialogWrapper::RegisterChildWindow( sal_False, pMod );
425     SvxHlinkDlgWrapper::RegisterChildWindow( sal_False, pMod );
426     SvxHyperlinkDlgWrapper::RegisterChildWindow( sal_False, pMod, SFX_CHILDWIN_FORCEDOCK );
427     SvxFontWorkChildWindow::RegisterChildWindow( sal_False, pMod );
428     SwFldDlgWrapper::RegisterChildWindow( sal_False, pMod );
429     SwFldDataOnlyDlgWrapper::RegisterChildWindow( sal_False, pMod );
430     SvxContourDlgChildWindow::RegisterChildWindow( sal_False, pMod );
431     SwNavigationChild::RegisterChildWindowContext( pMod );
432     SwInputChild::RegisterChildWindow( sal_False, pMod, SFX_CHILDWIN_FORCEDOCK );
433     SwRedlineAcceptChild::RegisterChildWindow( sal_False, pMod );
434     SwSyncChildWin::RegisterChildWindow( sal_True, pMod );
435     SwMailMergeChildWindow::RegisterChildWindow( sal_False, pMod );
436 //  SwSendMailChildWindow::RegisterChildWindow( sal_False, pMod );
437     SwInsertIdxMarkWrapper::RegisterChildWindow( sal_False, pMod );
438     SwInsertAuthMarkWrapper::RegisterChildWindow( sal_False, pMod );
439     SvxRubyChildWindow::RegisterChildWindow( sal_False, pMod);
440     SwSpellDialogChildWindow::RegisterChildWindow(sal_False, pMod);
441 
442     SvxGrafRedToolBoxControl::RegisterControl( SID_ATTR_GRAF_RED, pMod );
443     SvxGrafGreenToolBoxControl::RegisterControl( SID_ATTR_GRAF_GREEN, pMod );
444     SvxGrafBlueToolBoxControl::RegisterControl( SID_ATTR_GRAF_BLUE, pMod );
445     SvxGrafLuminanceToolBoxControl::RegisterControl( SID_ATTR_GRAF_LUMINANCE, pMod );
446     SvxGrafContrastToolBoxControl::RegisterControl( SID_ATTR_GRAF_CONTRAST, pMod );
447     SvxGrafGammaToolBoxControl::RegisterControl( SID_ATTR_GRAF_GAMMA, pMod );
448     SvxGrafTransparenceToolBoxControl::RegisterControl( SID_ATTR_GRAF_TRANSPARENCE, pMod );
449     SvxGrafModeToolBoxControl::RegisterControl( SID_ATTR_GRAF_MODE, pMod );
450     SvxGrafFilterToolBoxControl::RegisterControl( SID_GRFFILTER, pMod );
451     SvxVertTextTbxCtrl::RegisterControl(SID_TEXTDIRECTION_LEFT_TO_RIGHT, pMod);
452     SvxVertTextTbxCtrl::RegisterControl(SID_TEXTDIRECTION_TOP_TO_BOTTOM, pMod);
453     SvxVertTextTbxCtrl::RegisterControl(SID_DRAW_CAPTION_VERTICAL, pMod);
454     SvxVertTextTbxCtrl::RegisterControl(SID_DRAW_TEXT_VERTICAL, pMod);
455 
456     SvxCTLTextTbxCtrl::RegisterControl(SID_ATTR_PARA_LEFT_TO_RIGHT, pMod);
457     SvxCTLTextTbxCtrl::RegisterControl(SID_ATTR_PARA_RIGHT_TO_LEFT, pMod);
458 
459     GalleryChildWindow::RegisterChildWindow(0, pMod);
460 
461     ::avmedia::MediaToolBoxControl::RegisterControl(SID_AVMEDIA_TOOLBOX, pMod);
462     ::avmedia::MediaPlayer::RegisterChildWindow(0, pMod);
463 
464     SvxSmartTagsControl::RegisterControl(SID_OPEN_SMARTTAGMENU, pMod);
465     ::sfx2::sidebar::SidebarChildWindow::RegisterChildWindow(sal_False, pMod);
466     ::sfx2::TaskPaneWrapper::RegisterChildWindow(sal_False, pMod);
467 }
468 
469 
470 
471 /*************************************************************************
472 |* Modul laden (nur Attrappe für das Linken der DLL)
473 \************************************************************************/
474 
475 /* -----------------20.04.99 10:46-------------------
476  *
477  * --------------------------------------------------*/
478 void    SwModule::InitAttrPool()
479 {
480     DBG_ASSERT(!pAttrPool, "Pool ist schon da!");
481     pAttrPool = new SwAttrPool(0);
482     SetPool(pAttrPool);
483 }
484 /* -----------------20.04.99 10:46-------------------
485  *
486  * --------------------------------------------------*/
487 void    SwModule::RemoveAttrPool()
488 {
489     SetPool(0);
490     SfxItemPool::Free(pAttrPool);
491 }
492 
493 /* vim: set noet sw=4 ts=4: */
494