LibreOffice Module sw (master) 1
swmodule.cxx
Go to the documentation of this file.
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>
24#include <unotools/resmgr.hxx>
26#include <svl/ctloptions.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>
35#include <svx/contdlg.hxx>
36#include <svx/fontwork.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>
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 <listsh.hxx>
59#include <grfsh.hxx>
60#include <mediash.hxx>
61#include <olesh.hxx>
62#include <drawsh.hxx>
63#include <wformsh.hxx>
64#include <drwtxtsh.hxx>
65#include <beziersh.hxx>
66#include <wtextsh.hxx>
67#include <wfrmsh.hxx>
68#include <drformsh.hxx>
69#include <wgrfsh.hxx>
70#include <wolesh.hxx>
71#include <wlistsh.hxx>
72#include <wtabsh.hxx>
73#include <navipi.hxx>
74#include <inputwin.hxx>
75#include <usrpref.hxx>
76#include <uinums.hxx>
77#include <prtopt.hxx>
78#include <bookctrl.hxx>
79#include <tmplctrl.hxx>
80#include <viewlayoutctrl.hxx>
82#include <zoomctrl.hxx>
83#include <wordcountctrl.hxx>
85#include <workctrl.hxx>
86#include <fldwrap.hxx>
87#include <redlndlg.hxx>
88#include <syncbtn.hxx>
89#include <modcfg.hxx>
90#include <fontcfg.hxx>
93#include <swatrset.hxx>
94#include <idxmrk.hxx>
95#include <wordcountdialog.hxx>
96#include <dlelstnr.hxx>
97#include <barcfg.hxx>
98#include <svx/rubydialog.hxx>
99#include <svtools/colorcfg.hxx>
100
101#include <unotools/configmgr.hxx>
103
106
107#include <annotsh.hxx>
108#include <navsh.hxx>
109
110#include <app.hrc>
111#include <error.hrc>
112#include <strings.hrc>
113#include <bitmaps.hlst>
114#include <svx/xmlsecctrl.hxx>
115bool g_bNoInterrupt = false;
116
117#include <sfx2/app.hxx>
118
119#include <svx/svxerr.hxx>
120
121#include "swdllimpl.hxx"
122#include <dbconfig.hxx>
123#include <navicfg.hxx>
124
125using namespace com::sun::star;
126using namespace ::com::sun::star::uno;
127
129 SfxObjectFactory* pFact,
130 SfxObjectFactory* pGlobalFact )
131 : SfxModule("sw", {pWebFact, pFact, pGlobalFact}),
132 m_pView(nullptr),
133 m_bAuthorInitialised(false),
134 m_bEmbeddedLoadSave( false ),
135 m_pDragDrop( nullptr ),
136 m_pXSelection( nullptr )
137{
138 SetName( "StarWriter" );
140 m_pErrorHandler.reset( new SfxErrorHandler( RID_SW_ERRHDL,
141 ErrCodeArea::Sw,
142 ErrCodeArea::Sw,
143 GetResLocale() ) );
144
145 m_pModuleConfig.reset(new SwModuleOptions);
146
147 // We need them anyways
148 m_pToolbarConfig.reset(new SwToolbarConfigItem( false ));
149 m_pWebToolbarConfig.reset(new SwToolbarConfigItem( true ));
150
151 m_pStdFontConfig.reset(new SwStdFontConfig);
152
153 {
156 }
157
159 {
160 // init color configuration
161 // member <pColorConfig> is created and the color configuration is applied
162 // at the view options.
163 GetColorConfig();
164 m_xLinguServiceEventListener = new SwLinguServiceEventListener;
165 }
166}
167
168OUString SwResId(TranslateId aId)
169{
170 return Translate::get(aId, SW_MOD()->GetResLocale());
171}
172
173OUString SwResId(TranslateNId aContextSingularPlural, int nCardinality)
174{
175 return Translate::nget(aContextSingularPlural, nCardinality, SW_MOD()->GetResLocale());
176}
177
178uno::Reference< scanner::XScannerManager2 > const &
180{
181 static bool bTestScannerManager = true;
182 if (bTestScannerManager && !m_xScannerManager.is())
183 {
184 try {
185 m_xScannerManager = scanner::ScannerManager::create( comphelper::getProcessComponentContext() );
186 }
187 catch (...) {}
188 bTestScannerManager = false;
189 }
190 return m_xScannerManager;
191}
192
193uno::Reference< linguistic2::XLanguageGuessing > const & SwModule::GetLanguageGuesser()
194{
195 if (!m_xLanguageGuesser.is())
196 {
197 m_xLanguageGuesser = linguistic2::LanguageGuessing::create( comphelper::getProcessComponentContext() );
198 }
199 return m_xLanguageGuesser;
200}
201
203{
204 css::uno::Sequence< css::uno::Any > aArgs;
206 m_pErrorHandler.reset();
208}
209
211{
212 // These Id's must not be changed. Through these Id's the View (resume Documentview)
213 // is created by Sfx.
215 SwView::RegisterFactory ( SFX_INTERFACE_SFXDOCSH );
216
217#if HAVE_FEATURE_DESKTOP
218 SwWebView::RegisterFactory ( SFX_INTERFACE_SFXMODULE );
219
221 {
222 SwSrcView::RegisterFactory ( SfxInterfaceId(6) );
223 SwPagePreview::RegisterFactory ( SfxInterfaceId(7) );
224 }
225#endif
226}
227
229{
230 SwModule* pMod = SW_MOD();
231 SwModule::RegisterInterface( pMod );
232 SwDocShell::RegisterInterface( pMod );
233 SwWebDocShell::RegisterInterface( pMod );
234 SwGlosDocShell::RegisterInterface( pMod );
235 SwWebGlosDocShell::RegisterInterface( pMod );
236 SwView::RegisterInterface( pMod );
237 SwWebView::RegisterInterface( pMod );
238 SwPagePreview::RegisterInterface( pMod );
239 SwSrcView::RegisterInterface( pMod );
240
241 SwBaseShell::RegisterInterface(pMod);
242 SwTextShell::RegisterInterface(pMod);
243 SwTableShell::RegisterInterface(pMod);
244 SwListShell::RegisterInterface(pMod);
245 SwFrameShell::RegisterInterface(pMod);
246 SwDrawBaseShell::RegisterInterface(pMod);
247 SwDrawShell::RegisterInterface(pMod);
248 SwDrawFormShell::RegisterInterface(pMod);
249 SwDrawTextShell::RegisterInterface(pMod);
250 SwBezierShell::RegisterInterface(pMod);
251 SwGrfShell::RegisterInterface(pMod);
252 SwOleShell::RegisterInterface(pMod);
253 SwNavigationShell::RegisterInterface(pMod);
254 SwWebTextShell::RegisterInterface(pMod);
255 SwWebFrameShell::RegisterInterface(pMod);
256 SwWebGrfShell::RegisterInterface(pMod);
257 SwWebListShell::RegisterInterface(pMod);
258 SwWebTableShell::RegisterInterface(pMod);
259 SwWebDrawFormShell::RegisterInterface(pMod);
260 SwWebOleShell::RegisterInterface(pMod);
261 SwMediaShell::RegisterInterface(pMod);
262 SwAnnotationShell::RegisterInterface(pMod);
263}
264
266{
267 SwModule* pMod = SW_MOD();
268
269 SvxTbxCtlDraw::RegisterControl(SID_INSERT_DRAW, pMod );
270 SvxTbxCtlDraw::RegisterControl(SID_TRACK_CHANGES_BAR, pMod );
271 SwTbxAutoTextCtrl::RegisterControl(FN_GLOSSARY_DLG, pMod );
272 svx::ParaAboveSpacingControl::RegisterControl(SID_ATTR_PARA_ABOVESPACE, pMod);
273 svx::ParaBelowSpacingControl::RegisterControl(SID_ATTR_PARA_BELOWSPACE, pMod);
274 svx::ParaLeftSpacingControl::RegisterControl(SID_ATTR_PARA_LEFTSPACE, pMod);
275 svx::ParaRightSpacingControl::RegisterControl(SID_ATTR_PARA_RIGHTSPACE, pMod);
276 svx::ParaFirstLineSpacingControl::RegisterControl(SID_ATTR_PARA_FIRSTLINESPACE, pMod);
277
278 SvxClipBoardControl::RegisterControl(SID_PASTE, pMod );
279 svx::FormatPaintBrushToolBoxControl::RegisterControl(SID_FORMATPAINTBRUSH, pMod );
280
281 SvxFillToolBoxControl::RegisterControl(SID_ATTR_FILL_STYLE, pMod );
282 SvxLineWidthToolBoxControl::RegisterControl(SID_ATTR_LINE_WIDTH, pMod );
283
284 SwZoomControl::RegisterControl(SID_ATTR_ZOOM, pMod );
285 SwPreviewZoomControl::RegisterControl(FN_PREVIEW_ZOOM, pMod);
286 SvxPosSizeStatusBarControl::RegisterControl(0, pMod );
287 SvxInsertStatusBarControl::RegisterControl(SID_ATTR_INSERT, pMod );
288 SvxSelectionModeControl::RegisterControl(FN_STAT_SELMODE, pMod );
289 XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pMod );
290 SwWordCountStatusBarControl::RegisterControl(FN_STAT_WORDCOUNT, pMod);
291 sw::AccessibilityStatusBarControl::RegisterControl(FN_STAT_ACCESSIBILITY_CHECK, pMod);
292
293 SwBookmarkControl::RegisterControl(FN_STAT_PAGE, pMod );
294 SwTemplateControl::RegisterControl(FN_STAT_TEMPLATE, pMod );
295 SwViewLayoutControl::RegisterControl( SID_ATTR_VIEWLAYOUT, pMod );
296 SvxModifyControl::RegisterControl( SID_DOC_MODIFIED, pMod );
297 SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER, pMod );
298
299 SvxIMapDlgChildWindow::RegisterChildWindow( false, pMod );
300 SvxSearchDialogWrapper::RegisterChildWindow( false, pMod );
301 SvxHlinkDlgWrapper::RegisterChildWindow( false, pMod );
302 SvxFontWorkChildWindow::RegisterChildWindow( false, pMod );
305 SvxContourDlgChildWindow::RegisterChildWindow( false, pMod );
306 SwInputChild::RegisterChildWindow( false, pMod, SfxChildWindowFlags::FORCEDOCK );
312 SvxRubyChildWindow::RegisterChildWindow( false, pMod);
313 SwSpellDialogChildWindow::RegisterChildWindow(
314 false, pMod, comphelper::LibreOfficeKit::isActive() ? SfxChildWindowFlags::NEVERCLONE
315 : SfxChildWindowFlags::NONE);
317
318 SvxGrafRedToolBoxControl::RegisterControl( SID_ATTR_GRAF_RED, pMod );
319 SvxGrafGreenToolBoxControl::RegisterControl( SID_ATTR_GRAF_GREEN, pMod );
320 SvxGrafBlueToolBoxControl::RegisterControl( SID_ATTR_GRAF_BLUE, pMod );
321 SvxGrafLuminanceToolBoxControl::RegisterControl( SID_ATTR_GRAF_LUMINANCE, pMod );
322 SvxGrafContrastToolBoxControl::RegisterControl( SID_ATTR_GRAF_CONTRAST, pMod );
323 SvxGrafGammaToolBoxControl::RegisterControl( SID_ATTR_GRAF_GAMMA, pMod );
324 SvxGrafTransparenceToolBoxControl::RegisterControl( SID_ATTR_GRAF_TRANSPARENCE, pMod );
325 SvxGrafModeToolBoxControl::RegisterControl( SID_ATTR_GRAF_MODE, pMod );
326
327#if HAVE_FEATURE_AVMEDIA
328 ::avmedia::MediaToolBoxControl::RegisterControl(SID_AVMEDIA_TOOLBOX, pMod);
329 ::avmedia::MediaPlayer::RegisterChildWindow(false, pMod);
330#endif
331
333
334 SwNavigatorWrapper::RegisterChildWindow(false, pMod, SfxChildWindowFlags::NEVERHIDE);
335
336 SwJumpToSpecificPageControl::RegisterControl(SID_JUMP_TO_SPECIFIC_PAGE, pMod);
337}
338
339// Load Module (only dummy for linking of the DLL)
341{
342 OSL_ENSURE(!m_pAttrPool, "Pool already exists!");
343 m_pAttrPool = new SwAttrPool(nullptr);
344 SetPool(m_pAttrPool.get());
345}
346
348{
349 SetPool(nullptr);
350 m_pAttrPool.clear();
351}
352
353std::optional<SfxStyleFamilies> SwModule::CreateStyleFamilies()
354{
355 SfxStyleFamilies aStyleFamilies;
356
357 aStyleFamilies.emplace_back(SfxStyleFamily::Para,
358 SwResId(STR_PARAGRAPHSTYLEFAMILY),
359 BMP_STYLES_FAMILY_PARA,
360 RID_PARAGRAPHSTYLEFAMILY, GetResLocale());
361
362 aStyleFamilies.emplace_back(SfxStyleFamily::Char,
363 SwResId(STR_CHARACTERSTYLEFAMILY),
364 BMP_STYLES_FAMILY_CHAR,
365 RID_CHARACTERSTYLEFAMILY, GetResLocale());
366
367 aStyleFamilies.emplace_back(SfxStyleFamily::Frame,
368 SwResId(STR_FRAMESTYLEFAMILY),
369 BMP_STYLES_FAMILY_FRAME,
370 RID_FRAMESTYLEFAMILY, GetResLocale());
371
372 aStyleFamilies.emplace_back(SfxStyleFamily::Page,
373 SwResId(STR_PAGESTYLEFAMILY),
374 BMP_STYLES_FAMILY_PAGE,
375 RID_PAGESTYLEFAMILY, GetResLocale());
376
377 aStyleFamilies.emplace_back(SfxStyleFamily::Pseudo,
378 SwResId(STR_LISTSTYLEFAMILY),
379 BMP_STYLES_FAMILY_LIST,
380 RID_LISTSTYLEFAMILY, GetResLocale());
381
382 aStyleFamilies.emplace_back(SfxStyleFamily::Table,
383 SwResId(STR_TABLESTYLEFAMILY),
384 BMP_STYLES_FAMILY_TABLE,
385 RID_TABLESTYLEFAMILY, GetResLocale());
386
387 return aStyleFamilies;
388}
389
390void SwModule::RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller)
391{
393}
394
395void SwModule::CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments)
396{
398 mxAutomationApplicationEventsCaller->CallSinks(Method, Arguments);
399}
400
401/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxApplication * SfxGetpApp()
static void RegisterChildWindow(SfxModule *, const SfxChildWinFactory &)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
std::locale GetResLocale() const
void SetPool(SfxItemPool *pNewPool)
static void ensure()
static void RegisterFactories()
Definition: swmodule.cxx:210
static void RegisterControls()
Definition: swmodule.cxx:265
static void RegisterInterfaces()
Definition: swmodule.cxx:228
EventListener that triggers spellchecking and hyphenation.
Definition: dlelstnr.hxx:48
void CallAutomationApplicationEventSinks(const OUString &Method, css::uno::Sequence< css::uno::Any > &Arguments)
Definition: swmodule.cxx:395
virtual std::optional< SfxStyleFamilies > CreateStyleFamilies() override
Definition: swmodule.cxx:353
css::uno::Reference< css::scanner::XScannerManager2 > m_xScannerManager
Definition: swmodule.hxx:109
css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller
Definition: swmodule.hxx:124
std::unique_ptr< SfxErrorHandler > m_pErrorHandler
Definition: swmodule.hxx:95
void InitAttrPool()
Definition: swmodule.cxx:340
css::uno::Reference< css::linguistic2::XLanguageGuessing > const & GetLanguageGuesser()
Definition: swmodule.cxx:193
css::uno::Reference< css::scanner::XScannerManager2 > const & GetScannerManager()
Definition: swmodule.cxx:179
void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const &xCaller)
Definition: swmodule.cxx:390
void RemoveAttrPool()
Definition: swmodule.cxx:347
virtual ~SwModule() override
Definition: swmodule.cxx:202
css::uno::Reference< css::linguistic2::XLanguageGuessing > m_xLanguageGuesser
Definition: swmodule.hxx:110
rtl::Reference< SwAttrPool > m_pAttrPool
Definition: swmodule.hxx:97
SwModule(SfxObjectFactory *pFact, SfxObjectFactory *pWebFact, SfxObjectFactory *pGlobalFact)
Definition: swmodule.cxx:128
static bool IsFuzzing()
#define FN_PREVIEW_ZOOM
Definition: cmdid.h:182
#define FN_STAT_TEMPLATE
Definition: cmdid.h:865
#define SID_JUMP_TO_SPECIFIC_PAGE
Definition: cmdid.h:761
#define FN_STAT_PAGE
Definition: cmdid.h:864
#define FN_STAT_WORDCOUNT
Definition: cmdid.h:869
#define FN_STAT_SELMODE
Definition: cmdid.h:867
#define FN_GLOSSARY_DLG
Definition: cmdid.h:525
#define FN_STAT_ACCESSIBILITY_CHECK
Definition: cmdid.h:870
#define SID_TRACK_CHANGES_BAR
Definition: cmdid.h:762
OUString nget(TranslateNId aContextSingularPlural, int n, const std::locale &loc)
OUString get(TranslateId sContextAndId, const std::locale &loc)
Reference< XComponentContext > getProcessComponentContext()
constexpr auto SFX_INTERFACE_SFXMODULE
constexpr auto SFX_INTERFACE_SFXDOCSH
std::vector< SfxStyleFamilyItem > SfxStyleFamilies
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:168
bool g_bNoInterrupt
Definition: swmodule.cxx:115
#define SW_MOD()
Definition: swmodule.hxx:254
Method