1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #include <config_features.h>
21
22 #include <svtools/ehdl.hxx>
23 #include <svtools/accessibilityoptions.hxx>
24 #include <unotools/resmgr.hxx>
25 #include <unotools/useroptions.hxx>
26 #include <svl/ctloptions.hxx>
27 #include <svx/ParaSpacingControl.hxx>
28 #include <svx/pszctrl.hxx>
29 #include <svx/insctrl.hxx>
30 #include <svx/selctrl.hxx>
31 #include <svx/linectrl.hxx>
32 #include <svx/tbxctl.hxx>
33 #include <svx/fillctrl.hxx>
34 #include <svx/formatpaintbrushctrl.hxx>
35 #include <svx/contdlg.hxx>
36 #include <svx/fontwork.hxx>
37 #include <SwSpellDialogChildWindow.hxx>
38 #include <svx/grafctrl.hxx>
39 #include <svx/clipboardctl.hxx>
40 #include <svx/imapdlg.hxx>
41 #include <svx/srchdlg.hxx>
42 #include <svx/hyperdlg.hxx>
43 #include <svx/modctrl.hxx>
44 #include <com/sun/star/scanner/ScannerManager.hpp>
45 #include <com/sun/star/linguistic2/LanguageGuessing.hpp>
46 #include <ooo/vba/XSinkCaller.hpp>
47 #include <comphelper/lok.hxx>
48 #include <comphelper/processfactory.hxx>
49 #include <docsh.hxx>
50 #include <swmodule.hxx>
51 #include <cmdid.h>
52 #include <pview.hxx>
53 #include <wview.hxx>
54 #include <wdocsh.hxx>
55 #include <srcview.hxx>
56 #include <glshell.hxx>
57 #include <tabsh.hxx>
58 #include <tblafmt.hxx>
59 #include <listsh.hxx>
60 #include <grfsh.hxx>
61 #include <mediash.hxx>
62 #include <olesh.hxx>
63 #include <drawsh.hxx>
64 #include <wformsh.hxx>
65 #include <drwtxtsh.hxx>
66 #include <beziersh.hxx>
67 #include <wtextsh.hxx>
68 #include <wfrmsh.hxx>
69 #include <drformsh.hxx>
70 #include <wgrfsh.hxx>
71 #include <wolesh.hxx>
72 #include <wlistsh.hxx>
73 #include <wtabsh.hxx>
74 #include <navipi.hxx>
75 #include <inputwin.hxx>
76 #include <usrpref.hxx>
77 #include <uinums.hxx>
78 #include <prtopt.hxx>
79 #include <bookctrl.hxx>
80 #include <tmplctrl.hxx>
81 #include <viewlayoutctrl.hxx>
82 #include <svx/zoomsliderctrl.hxx>
83 #include <zoomctrl.hxx>
84 #include <wordcountctrl.hxx>
85 #include <AccessibilityStatusBarControl.hxx>
86 #include <workctrl.hxx>
87 #include <fldwrap.hxx>
88 #include <redlndlg.hxx>
89 #include <syncbtn.hxx>
90 #include <modcfg.hxx>
91 #include <fontcfg.hxx>
92 #include <sfx2/sidebar/SidebarChildWindow.hxx>
93 #include <sfx2/devtools/DevelopmentToolChildWindow.hxx>
94 #include <swatrset.hxx>
95 #include <idxmrk.hxx>
96 #include <wordcountdialog.hxx>
97 #include <dlelstnr.hxx>
98 #include <barcfg.hxx>
99 #include <svx/rubydialog.hxx>
100 #include <svtools/colorcfg.hxx>
101
102 #include <comphelper/configuration.hxx>
103 #include <unotools/moduleoptions.hxx>
104
105 #include <avmedia/mediaplayer.hxx>
106 #include <avmedia/mediatoolbox.hxx>
107
108 #include <annotsh.hxx>
109 #include <navsh.hxx>
110
111 #include <app.hrc>
112 #include <error.hrc>
113 #include <strings.hrc>
114 #include <bitmaps.hlst>
115 #include <svx/xmlsecctrl.hxx>
116 bool g_bNoInterrupt = false;
117
118 #include <sfx2/app.hxx>
119
120 #include <svx/svxerr.hxx>
121
122 #include "swdllimpl.hxx"
123 #include <dbconfig.hxx>
124 #include <navicfg.hxx>
125
126 using namespace com::sun::star;
127 using namespace ::com::sun::star::uno;
128
SwModule(SfxObjectFactory * pWebFact,SfxObjectFactory * pFact,SfxObjectFactory * pGlobalFact)129 SwModule::SwModule( SfxObjectFactory* pWebFact,
130 SfxObjectFactory* pFact,
131 SfxObjectFactory* pGlobalFact )
132 : SfxModule("sw"_ostr, {pWebFact, pFact, pGlobalFact}),
133 m_pView(nullptr),
134 m_eCTLTextNumerals(SvtCTLOptions::GetCTLTextNumerals()),
135 m_bAuthorInitialised(false),
136 m_bEmbeddedLoadSave( false ),
137 m_pDragDrop( nullptr ),
138 m_pXSelection( nullptr )
139 {
140 SetName( u"StarWriter"_ustr );
141 SvxErrorHandler::ensure();
142 m_pErrorHandler.reset( new SfxErrorHandler( RID_SW_ERRHDL,
143 ErrCodeArea::Sw,
144 ErrCodeArea::Sw,
145 GetResLocale() ) );
146
147 m_pModuleConfig.reset(new SwModuleOptions);
148
149 // We need them anyways
150 m_pToolbarConfig.reset(new SwToolbarConfigItem( false ));
151 m_pWebToolbarConfig.reset(new SwToolbarConfigItem( true ));
152
153 m_pStdFontConfig.reset(new SwStdFontConfig);
154
155 {
156 SolarMutexGuard g;
157 StartListening( *SfxGetpApp() );
158 }
159
160 if (!comphelper::IsFuzzing())
161 {
162 // init color configuration
163 // member <pColorConfig> is created and the color configuration is applied
164 // at the view options.
165 GetColorConfig();
166 m_xLinguServiceEventListener = new SwLinguServiceEventListener;
167 }
168 }
169
SwResId(TranslateId aId)170 OUString SwResId(TranslateId aId)
171 {
172 return Translate::get(aId, SwModule::get()->GetResLocale());
173 }
174
SwResId(TranslateNId aContextSingularPlural,int nCardinality)175 OUString SwResId(TranslateNId aContextSingularPlural, int nCardinality)
176 {
177 return Translate::nget(aContextSingularPlural, nCardinality, SwModule::get()->GetResLocale());
178 }
179
180 uno::Reference< scanner::XScannerManager2 > const &
GetScannerManager()181 SwModule::GetScannerManager()
182 {
183 static bool bTestScannerManager = true;
184 if (bTestScannerManager && !m_xScannerManager.is())
185 {
186 try {
187 m_xScannerManager = scanner::ScannerManager::create( comphelper::getProcessComponentContext() );
188 }
189 catch (...) {}
190 bTestScannerManager = false;
191 }
192 return m_xScannerManager;
193 }
194
GetLanguageGuesser()195 uno::Reference< linguistic2::XLanguageGuessing > const & SwModule::GetLanguageGuesser()
196 {
197 if (!m_xLanguageGuesser.is())
198 {
199 m_xLanguageGuesser = linguistic2::LanguageGuessing::create( comphelper::getProcessComponentContext() );
200 }
201 return m_xLanguageGuesser;
202 }
203
~SwModule()204 SwModule::~SwModule()
205 {
206 css::uno::Sequence< css::uno::Any > aArgs;
207 CallAutomationApplicationEventSinks( u"Quit"_ustr, aArgs );
208 m_pErrorHandler.reset();
209 EndListening( *SfxGetpApp() );
210 }
211
RegisterFactories()212 void SwDLL::RegisterFactories()
213 {
214 // These Id's must not be changed. Through these Id's the View (resume Documentview)
215 // is created by Sfx.
216 SvtModuleOptions aOptions;
217 if (comphelper::IsFuzzing() || aOptions.IsWriterInstalled())
218 SwView::RegisterFactory ( SFX_INTERFACE_SFXDOCSH );
219
220 #if HAVE_FEATURE_DESKTOP
221 SwWebView::RegisterFactory ( SFX_INTERFACE_SFXMODULE );
222
223 if (comphelper::IsFuzzing() || aOptions.IsWriterInstalled())
224 {
225 SwSrcView::RegisterFactory ( SfxInterfaceId(6) );
226 SwPagePreview::RegisterFactory ( SfxInterfaceId(7) );
227 }
228 #endif
229 }
230
RegisterInterfaces()231 void SwDLL::RegisterInterfaces()
232 {
233 SwModule* pMod = SwModule::get();
234 SwModule::RegisterInterface( pMod );
235 SwDocShell::RegisterInterface( pMod );
236 SwWebDocShell::RegisterInterface( pMod );
237 SwGlosDocShell::RegisterInterface( pMod );
238 SwWebGlosDocShell::RegisterInterface( pMod );
239 SwView::RegisterInterface( pMod );
240 SwWebView::RegisterInterface( pMod );
241 SwPagePreview::RegisterInterface( pMod );
242 SwSrcView::RegisterInterface( pMod );
243
244 SwBaseShell::RegisterInterface(pMod);
245 SwTextShell::RegisterInterface(pMod);
246 SwTableShell::RegisterInterface(pMod);
247 SwListShell::RegisterInterface(pMod);
248 SwFrameShell::RegisterInterface(pMod);
249 SwDrawBaseShell::RegisterInterface(pMod);
250 SwDrawShell::RegisterInterface(pMod);
251 SwDrawFormShell::RegisterInterface(pMod);
252 SwDrawTextShell::RegisterInterface(pMod);
253 SwBezierShell::RegisterInterface(pMod);
254 SwGrfShell::RegisterInterface(pMod);
255 SwOleShell::RegisterInterface(pMod);
256 SwNavigationShell::RegisterInterface(pMod);
257 SwWebTextShell::RegisterInterface(pMod);
258 SwWebFrameShell::RegisterInterface(pMod);
259 SwWebGrfShell::RegisterInterface(pMod);
260 SwWebListShell::RegisterInterface(pMod);
261 SwWebTableShell::RegisterInterface(pMod);
262 SwWebDrawFormShell::RegisterInterface(pMod);
263 SwWebOleShell::RegisterInterface(pMod);
264 SwMediaShell::RegisterInterface(pMod);
265 SwAnnotationShell::RegisterInterface(pMod);
266 }
267
RegisterControls()268 void SwDLL::RegisterControls()
269 {
270 SwModule* pMod = SwModule::get();
271
272 SvxTbxCtlDraw::RegisterControl(SID_INSERT_DRAW, pMod );
273 SvxTbxCtlDraw::RegisterControl(SID_TRACK_CHANGES_BAR, pMod );
274 SwTbxAutoTextCtrl::RegisterControl(FN_GLOSSARY_DLG, pMod );
275 svx::ParaAboveSpacingControl::RegisterControl(SID_ATTR_PARA_ABOVESPACE, pMod);
276 svx::ParaBelowSpacingControl::RegisterControl(SID_ATTR_PARA_BELOWSPACE, pMod);
277 svx::ParaLeftSpacingControl::RegisterControl(SID_ATTR_PARA_LEFTSPACE, pMod);
278 svx::ParaRightSpacingControl::RegisterControl(SID_ATTR_PARA_RIGHTSPACE, pMod);
279 svx::ParaFirstLineSpacingControl::RegisterControl(SID_ATTR_PARA_FIRSTLINESPACE, pMod);
280
281 SvxClipBoardControl::RegisterControl(SID_PASTE, pMod );
282 svx::FormatPaintBrushToolBoxControl::RegisterControl(SID_FORMATPAINTBRUSH, pMod );
283
284 SvxFillToolBoxControl::RegisterControl(SID_ATTR_FILL_STYLE, pMod );
285 SvxLineWidthToolBoxControl::RegisterControl(SID_ATTR_LINE_WIDTH, pMod );
286
287 SwZoomControl::RegisterControl(SID_ATTR_ZOOM, pMod );
288 SwPreviewZoomControl::RegisterControl(FN_PREVIEW_ZOOM, pMod);
289 SvxPosSizeStatusBarControl::RegisterControl(0, pMod );
290 SvxInsertStatusBarControl::RegisterControl(SID_ATTR_INSERT, pMod );
291 SvxSelectionModeControl::RegisterControl(FN_STAT_SELMODE, pMod );
292 XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pMod );
293 SwWordCountStatusBarControl::RegisterControl(FN_STAT_WORDCOUNT, pMod);
294 sw::AccessibilityStatusBarControl::RegisterControl(FN_STAT_ACCESSIBILITY_CHECK, pMod);
295
296 SwBookmarkControl::RegisterControl(FN_STAT_PAGE, pMod );
297 SwTemplateControl::RegisterControl(FN_STAT_TEMPLATE, pMod );
298 SwViewLayoutControl::RegisterControl( SID_ATTR_VIEWLAYOUT, pMod );
299 SvxModifyControl::RegisterControl( SID_DOC_MODIFIED, pMod );
300 SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER, pMod );
301
302 SvxIMapDlgChildWindow::RegisterChildWindow( false, pMod );
303 SvxSearchDialogWrapper::RegisterChildWindow( false, pMod );
304 SvxHlinkDlgWrapper::RegisterChildWindow( false, pMod );
305 SvxFontWorkChildWindow::RegisterChildWindow( false, pMod );
306 SwFieldDlgWrapper::RegisterChildWindow( false, pMod );
307 SwFieldDataOnlyDlgWrapper::RegisterChildWindow( false, pMod );
308 SvxContourDlgChildWindow::RegisterChildWindow( false, pMod );
309 SwInputChild::RegisterChildWindow( false, pMod, SfxChildWindowFlags::FORCEDOCK );
310 SwRedlineAcceptChild::RegisterChildWindow( false, pMod );
311 SwSyncChildWin::RegisterChildWindow( true, pMod );
312 SwInsertIdxMarkWrapper::RegisterChildWindow( false, pMod );
313 SwInsertAuthMarkWrapper::RegisterChildWindow( false, pMod );
314 SwWordCountWrapper::RegisterChildWindow( false, pMod );
315 SvxRubyChildWindow::RegisterChildWindow( false, pMod);
316 SwSpellDialogChildWindow::RegisterChildWindow(false, pMod);
317 DevelopmentToolChildWindow::RegisterChildWindow(false, pMod);
318
319 SvxGrafRedToolBoxControl::RegisterControl( SID_ATTR_GRAF_RED, pMod );
320 SvxGrafGreenToolBoxControl::RegisterControl( SID_ATTR_GRAF_GREEN, pMod );
321 SvxGrafBlueToolBoxControl::RegisterControl( SID_ATTR_GRAF_BLUE, pMod );
322 SvxGrafLuminanceToolBoxControl::RegisterControl( SID_ATTR_GRAF_LUMINANCE, pMod );
323 SvxGrafContrastToolBoxControl::RegisterControl( SID_ATTR_GRAF_CONTRAST, pMod );
324 SvxGrafGammaToolBoxControl::RegisterControl( SID_ATTR_GRAF_GAMMA, pMod );
325 SvxGrafTransparenceToolBoxControl::RegisterControl( SID_ATTR_GRAF_TRANSPARENCE, pMod );
326 SvxGrafModeToolBoxControl::RegisterControl( SID_ATTR_GRAF_MODE, pMod );
327
328 #if HAVE_FEATURE_AVMEDIA
329 ::avmedia::MediaToolBoxControl::RegisterControl(SID_AVMEDIA_TOOLBOX, pMod);
330 ::avmedia::MediaPlayer::RegisterChildWindow(false, pMod);
331 #endif
332
333 ::sfx2::sidebar::SidebarChildWindow::RegisterChildWindow(false, pMod);
334
335 SwNavigatorWrapper::RegisterChildWindow(false, pMod, SfxChildWindowFlags::NEVERHIDE);
336
337 SwJumpToSpecificPageControl::RegisterControl(SID_JUMP_TO_SPECIFIC_PAGE, pMod);
338 }
339
CreateStyleFamilies()340 SfxStyleFamilies SwModule::CreateStyleFamilies()
341 {
342 SfxStyleFamilies aStyleFamilies;
343
344 aStyleFamilies.emplace_back(SfxStyleFamily::Para,
345 SwResId(STR_PARAGRAPHSTYLEFAMILY),
346 BMP_STYLES_FAMILY_PARA,
347 RID_PARAGRAPHSTYLEFAMILY, GetResLocale());
348
349 aStyleFamilies.emplace_back(SfxStyleFamily::Char,
350 SwResId(STR_CHARACTERSTYLEFAMILY),
351 BMP_STYLES_FAMILY_CHAR,
352 RID_CHARACTERSTYLEFAMILY, GetResLocale());
353
354 aStyleFamilies.emplace_back(SfxStyleFamily::Frame,
355 SwResId(STR_FRAMESTYLEFAMILY),
356 BMP_STYLES_FAMILY_FRAME,
357 RID_FRAMESTYLEFAMILY, GetResLocale());
358
359 aStyleFamilies.emplace_back(SfxStyleFamily::Page,
360 SwResId(STR_PAGESTYLEFAMILY),
361 BMP_STYLES_FAMILY_PAGE,
362 RID_PAGESTYLEFAMILY, GetResLocale());
363
364 aStyleFamilies.emplace_back(SfxStyleFamily::Pseudo,
365 SwResId(STR_LISTSTYLEFAMILY),
366 BMP_STYLES_FAMILY_LIST,
367 RID_LISTSTYLEFAMILY, GetResLocale());
368
369 aStyleFamilies.emplace_back(SfxStyleFamily::Table,
370 SwResId(STR_TABLESTYLEFAMILY),
371 BMP_STYLES_FAMILY_TABLE,
372 RID_TABLESTYLEFAMILY, GetResLocale());
373
374 return aStyleFamilies;
375 }
376
RegisterAutomationApplicationEventsCaller(css::uno::Reference<ooo::vba::XSinkCaller> const & xCaller)377 void SwModule::RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller)
378 {
379 mxAutomationApplicationEventsCaller = xCaller;
380 }
381
CallAutomationApplicationEventSinks(const OUString & Method,css::uno::Sequence<css::uno::Any> & Arguments)382 void SwModule::CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments)
383 {
384 if (mxAutomationApplicationEventsCaller.is())
385 mxAutomationApplicationEventsCaller->CallSinks(Method, Arguments);
386 }
387
GetAutoFormatTable()388 const SwTableAutoFormatTable& SwModule::GetAutoFormatTable()
389 {
390 if (!m_xTableAutoFormatTable)
391 m_xTableAutoFormatTable = std::make_unique<SwTableAutoFormatTable>();
392 return *m_xTableAutoFormatTable;
393 }
394
InvalidateAutoFormatTable()395 void SwModule::InvalidateAutoFormatTable()
396 {
397 m_xTableAutoFormatTable.reset();
398 }
399
400 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
401