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 <hintids.hxx>
23 #include <svtools/ehdl.hxx>
25 #include <unotools/resmgr.hxx>
26 #include <unotools/useroptions.hxx>
27 #include <svl/ctloptions.hxx>
29 #include <svx/pszctrl.hxx>
30 #include <svx/insctrl.hxx>
31 #include <svx/selctrl.hxx>
32 #include <svx/linectrl.hxx>
33 #include <svx/tbxctl.hxx>
34 #include <svx/fillctrl.hxx>
36 #include <svx/contdlg.hxx>
37 #include <svx/fontwork.hxx>
39 #include <svx/grafctrl.hxx>
40 #include <svx/clipboardctl.hxx>
41 #include <svx/imapdlg.hxx>
42 #include <svx/srchdlg.hxx>
43 #include <svx/hyperdlg.hxx>
44 #include <svx/modctrl.hxx>
45 #include <com/sun/star/scanner/ScannerManager.hpp>
46 #include <com/sun/star/linguistic2/LanguageGuessing.hpp>
47 #include <ooo/vba/XSinkCaller.hpp>
48 #include <comphelper/lok.hxx>
50 #include <docsh.hxx>
51 #include <swmodule.hxx>
52 #include <cmdid.h>
53 #include <pview.hxx>
54 #include <wview.hxx>
55 #include <wdocsh.hxx>
56 #include <srcview.hxx>
57 #include <glshell.hxx>
58 #include <tabsh.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 <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 
104 #include <avmedia/mediaplayer.hxx>
105 #include <avmedia/mediatoolbox.hxx>
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>
115 bool 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 
125 using namespace com::sun::star;
126 using 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 
154 
156  {
157  // init color configuration
158  // member <pColorConfig> is created and the color configuration is applied
159  // at the view options.
160  GetColorConfig();
161  m_xLinguServiceEventListener = new SwLinguServiceEventListener;
162  }
163 }
164 
165 OUString SwResId(const char* pId)
166 {
167  return Translate::get(pId, SW_MOD()->GetResLocale());
168 }
169 
170 OUString SwResId(const char* pId, int nCardinality)
171 {
172  return Translate::nget(pId, nCardinality, SW_MOD()->GetResLocale());
173 }
174 
175 uno::Reference< scanner::XScannerManager2 > const &
177 {
178  if (!m_xScannerManager.is())
179  {
180  m_xScannerManager = scanner::ScannerManager::create( comphelper::getProcessComponentContext() );
181  }
182  return m_xScannerManager;
183 }
184 
185 uno::Reference< linguistic2::XLanguageGuessing > const & SwModule::GetLanguageGuesser()
186 {
187  if (!m_xLanguageGuesser.is())
188  {
189  m_xLanguageGuesser = linguistic2::LanguageGuessing::create( comphelper::getProcessComponentContext() );
190  }
191  return m_xLanguageGuesser;
192 }
193 
195 {
196  css::uno::Sequence< css::uno::Any > aArgs;
197  CallAutomationApplicationEventSinks( "Quit", aArgs );
198  m_pErrorHandler.reset();
199  EndListening( *SfxGetpApp() );
200 }
201 
203 {
204  // These Id's must not be changed. Through these Id's the View (resume Documentview)
205  // is created by Sfx.
206  if (utl::ConfigManager::IsFuzzing() || SvtModuleOptions().IsWriter())
207  SwView::RegisterFactory ( SFX_INTERFACE_SFXDOCSH );
208 
209 #if HAVE_FEATURE_DESKTOP
210  SwWebView::RegisterFactory ( SFX_INTERFACE_SFXMODULE );
211 
212  if (utl::ConfigManager::IsFuzzing() || SvtModuleOptions().IsWriter())
213  {
214  SwSrcView::RegisterFactory ( SfxInterfaceId(6) );
215  SwPagePreview::RegisterFactory ( SfxInterfaceId(7) );
216  }
217 #endif
218 }
219 
221 {
222  SwModule* pMod = SW_MOD();
223  SwModule::RegisterInterface( pMod );
224  SwDocShell::RegisterInterface( pMod );
225  SwWebDocShell::RegisterInterface( pMod );
226  SwGlosDocShell::RegisterInterface( pMod );
227  SwWebGlosDocShell::RegisterInterface( pMod );
228  SwView::RegisterInterface( pMod );
229  SwWebView::RegisterInterface( pMod );
230  SwPagePreview::RegisterInterface( pMod );
231  SwSrcView::RegisterInterface( pMod );
232 
233  SwBaseShell::RegisterInterface(pMod);
234  SwTextShell::RegisterInterface(pMod);
235  SwTableShell::RegisterInterface(pMod);
236  SwListShell::RegisterInterface(pMod);
237  SwFrameShell::RegisterInterface(pMod);
238  SwDrawBaseShell::RegisterInterface(pMod);
239  SwDrawShell::RegisterInterface(pMod);
240  SwDrawFormShell::RegisterInterface(pMod);
241  SwDrawTextShell::RegisterInterface(pMod);
242  SwBezierShell::RegisterInterface(pMod);
243  SwGrfShell::RegisterInterface(pMod);
244  SwOleShell::RegisterInterface(pMod);
245  SwNavigationShell::RegisterInterface(pMod);
246  SwWebTextShell::RegisterInterface(pMod);
247  SwWebFrameShell::RegisterInterface(pMod);
248  SwWebGrfShell::RegisterInterface(pMod);
249  SwWebListShell::RegisterInterface(pMod);
250  SwWebTableShell::RegisterInterface(pMod);
251  SwWebDrawFormShell::RegisterInterface(pMod);
252  SwWebOleShell::RegisterInterface(pMod);
253  SwMediaShell::RegisterInterface(pMod);
254  SwAnnotationShell::RegisterInterface(pMod);
255 }
256 
258 {
259  SwModule* pMod = SW_MOD();
260 
261  SvxTbxCtlDraw::RegisterControl(SID_INSERT_DRAW, pMod );
262  SvxTbxCtlDraw::RegisterControl(SID_TRACK_CHANGES_BAR, pMod );
263  SwTbxAutoTextCtrl::RegisterControl(FN_GLOSSARY_DLG, pMod );
264  svx::ParaAboveSpacingControl::RegisterControl(SID_ATTR_PARA_ABOVESPACE, pMod);
265  svx::ParaBelowSpacingControl::RegisterControl(SID_ATTR_PARA_BELOWSPACE, pMod);
266  svx::ParaLeftSpacingControl::RegisterControl(SID_ATTR_PARA_LEFTSPACE, pMod);
267  svx::ParaRightSpacingControl::RegisterControl(SID_ATTR_PARA_RIGHTSPACE, pMod);
268  svx::ParaFirstLineSpacingControl::RegisterControl(SID_ATTR_PARA_FIRSTLINESPACE, pMod);
269 
270  SvxClipBoardControl::RegisterControl(SID_PASTE, pMod );
271  svx::FormatPaintBrushToolBoxControl::RegisterControl(SID_FORMATPAINTBRUSH, pMod );
272 
273  SvxFillToolBoxControl::RegisterControl(SID_ATTR_FILL_STYLE, pMod );
274  SvxLineWidthToolBoxControl::RegisterControl(SID_ATTR_LINE_WIDTH, pMod );
275 
276  SwZoomControl::RegisterControl(SID_ATTR_ZOOM, pMod );
277  SwPreviewZoomControl::RegisterControl(FN_PREVIEW_ZOOM, pMod);
278  SvxPosSizeStatusBarControl::RegisterControl(0, pMod );
279  SvxInsertStatusBarControl::RegisterControl(SID_ATTR_INSERT, pMod );
280  SvxSelectionModeControl::RegisterControl(FN_STAT_SELMODE, pMod );
281  XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pMod );
282  SwWordCountStatusBarControl::RegisterControl(FN_STAT_WORDCOUNT, pMod);
283 
284  SwBookmarkControl::RegisterControl(FN_STAT_PAGE, pMod );
285  SwTemplateControl::RegisterControl(FN_STAT_TEMPLATE, pMod );
286  SwViewLayoutControl::RegisterControl( SID_ATTR_VIEWLAYOUT, pMod );
287  SvxModifyControl::RegisterControl( SID_DOC_MODIFIED, pMod );
288  SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER, pMod );
289 
290  SvxIMapDlgChildWindow::RegisterChildWindow( false, pMod );
291  SvxSearchDialogWrapper::RegisterChildWindow( false, pMod );
292  SvxHlinkDlgWrapper::RegisterChildWindow( false, pMod );
293  SvxFontWorkChildWindow::RegisterChildWindow( false, pMod );
296  SvxContourDlgChildWindow::RegisterChildWindow( false, pMod );
297  SwInputChild::RegisterChildWindow( false, pMod, SfxChildWindowFlags::FORCEDOCK );
303  SvxRubyChildWindow::RegisterChildWindow( false, pMod);
304  SwSpellDialogChildWindow::RegisterChildWindow(
305  false, pMod, comphelper::LibreOfficeKit::isActive() ? SfxChildWindowFlags::NEVERCLONE
306  : SfxChildWindowFlags::NONE);
308 
309  SvxGrafRedToolBoxControl::RegisterControl( SID_ATTR_GRAF_RED, pMod );
310  SvxGrafGreenToolBoxControl::RegisterControl( SID_ATTR_GRAF_GREEN, pMod );
311  SvxGrafBlueToolBoxControl::RegisterControl( SID_ATTR_GRAF_BLUE, pMod );
312  SvxGrafLuminanceToolBoxControl::RegisterControl( SID_ATTR_GRAF_LUMINANCE, pMod );
313  SvxGrafContrastToolBoxControl::RegisterControl( SID_ATTR_GRAF_CONTRAST, pMod );
314  SvxGrafGammaToolBoxControl::RegisterControl( SID_ATTR_GRAF_GAMMA, pMod );
315  SvxGrafTransparenceToolBoxControl::RegisterControl( SID_ATTR_GRAF_TRANSPARENCE, pMod );
316  SvxGrafModeToolBoxControl::RegisterControl( SID_ATTR_GRAF_MODE, pMod );
317 
318 #if HAVE_FEATURE_AVMEDIA
319  ::avmedia::MediaToolBoxControl::RegisterControl(SID_AVMEDIA_TOOLBOX, pMod);
320  ::avmedia::MediaPlayer::RegisterChildWindow(false, pMod);
321 #endif
322 
324 
325  SwNavigatorWrapper::RegisterChildWindow(false, pMod, SfxChildWindowFlags::NEVERHIDE);
326 
327  SwJumpToSpecificPageControl::RegisterControl(SID_JUMP_TO_SPECIFIC_PAGE, pMod);
328 }
329 
330 // Load Module (only dummy for linking of the DLL)
332 {
333  OSL_ENSURE(!m_pAttrPool, "Pool already exists!");
334  m_pAttrPool.reset(new SwAttrPool(nullptr));
335  SetPool(m_pAttrPool.get());
336 }
337 
339 {
340  SetPool(nullptr);
341  m_pAttrPool.reset();
342 }
343 
344 std::unique_ptr<SfxStyleFamilies> SwModule::CreateStyleFamilies()
345 {
346  std::unique_ptr<SfxStyleFamilies> pStyleFamilies(new SfxStyleFamilies);
347 
348  pStyleFamilies->emplace_back(SfxStyleFamily::Para,
349  SwResId(STR_PARAGRAPHSTYLEFAMILY),
350  BMP_STYLES_FAMILY_PARA,
351  RID_PARAGRAPHSTYLEFAMILY, GetResLocale());
352 
353  pStyleFamilies->emplace_back(SfxStyleFamily::Char,
354  SwResId(STR_CHARACTERSTYLEFAMILY),
355  BMP_STYLES_FAMILY_CHAR,
356  RID_CHARACTERSTYLEFAMILY, GetResLocale());
357 
358  pStyleFamilies->emplace_back(SfxStyleFamily::Frame,
359  SwResId(STR_FRAMESTYLEFAMILY),
360  BMP_STYLES_FAMILY_FRAME,
361  RID_FRAMESTYLEFAMILY, GetResLocale());
362 
363  pStyleFamilies->emplace_back(SfxStyleFamily::Page,
364  SwResId(STR_PAGESTYLEFAMILY),
365  BMP_STYLES_FAMILY_PAGE,
366  RID_PAGESTYLEFAMILY, GetResLocale());
367 
368  pStyleFamilies->emplace_back(SfxStyleFamily::Pseudo,
369  SwResId(STR_LISTSTYLEFAMILY),
370  BMP_STYLES_FAMILY_LIST,
371  RID_LISTSTYLEFAMILY, GetResLocale());
372 
373  pStyleFamilies->emplace_back(SfxStyleFamily::Table,
374  SwResId(STR_TABLESTYLEFAMILY),
375  BMP_STYLES_FAMILY_TABLE,
376  RID_TABLESTYLEFAMILY, GetResLocale());
377 
378  return pStyleFamilies;
379 }
380 
381 void SwModule::RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller)
382 {
384 }
385 
386 void SwModule::CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments)
387 {
389  mxAutomationApplicationEventsCaller->CallSinks(Method, Arguments);
390 }
391 
392 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::scanner::XScannerManager2 > const & GetScannerManager()
Definition: swmodule.cxx:176
std::vector< SfxStyleFamilyItem > SfxStyleFamilies
std::locale GetResLocale() const
SwModule(SfxObjectFactory *pFact, SfxObjectFactory *pWebFact, SfxObjectFactory *pGlobalFact)
Definition: swmodule.cxx:128
#define FN_PREVIEW_ZOOM
Definition: cmdid.h:173
void CallAutomationApplicationEventSinks(const OUString &Method, css::uno::Sequence< css::uno::Any > &Arguments)
Definition: swmodule.cxx:386
void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const &xCaller)
Definition: swmodule.cxx:381
void InitAttrPool()
Definition: swmodule.cxx:331
static void RegisterControls()
Definition: swmodule.cxx:257
#define FN_STAT_PAGE
Definition: cmdid.h:830
SfxApplication * SfxGetpApp()
css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller
Definition: swmodule.hxx:125
static bool IsFuzzing()
#define SID_JUMP_TO_SPECIFIC_PAGE
Definition: cmdid.h:722
#define FN_STAT_SELMODE
Definition: cmdid.h:833
std::unique_ptr< SwAttrPool, SfxItemPoolDeleter > m_pAttrPool
Definition: swmodule.hxx:98
#define FN_STAT_TEMPLATE
Definition: cmdid.h:831
OUString nget(const char *pContextAndIds, int n, const std::locale &loc)
#define SW_MOD()
Definition: swmodule.hxx:256
static void RegisterInterfaces()
Definition: swmodule.cxx:220
#define FN_GLOSSARY_DLG
Definition: cmdid.h:492
constexpr auto SFX_INTERFACE_SFXMODULE
void SetPool(SfxItemPool *pNewPool)
static void RegisterChildWindow(SfxModule *, std::unique_ptr< SfxChildWinFactory >)
virtual ~SwModule() override
Definition: swmodule.cxx:194
OUString SwResId(const char *pId)
Definition: swmodule.cxx:165
#define FN_STAT_WORDCOUNT
Definition: cmdid.h:835
constexpr auto SFX_INTERFACE_SFXDOCSH
virtual std::unique_ptr< SfxStyleFamilies > CreateStyleFamilies() override
Definition: swmodule.cxx:344
css::uno::Reference< css::scanner::XScannerManager2 > m_xScannerManager
Definition: swmodule.hxx:110
static void RegisterFactories()
Definition: swmodule.cxx:202
css::uno::Reference< css::linguistic2::XLanguageGuessing > const & GetLanguageGuesser()
Definition: swmodule.cxx:185
EventListener that triggers spellchecking and hyphenation.
Definition: dlelstnr.hxx:42
css::uno::Reference< css::linguistic2::XLanguageGuessing > m_xLanguageGuesser
Definition: swmodule.hxx:111
void RemoveAttrPool()
Definition: swmodule.cxx:338
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
Reference< XComponentContext > getProcessComponentContext()
static void ensure()
#define SID_TRACK_CHANGES_BAR
Definition: cmdid.h:723
bool g_bNoInterrupt
Definition: swmodule.cxx:115
OUString get(const char *pContextAndId, const std::locale &loc)
std::unique_ptr< SfxErrorHandler > m_pErrorHandler
Definition: swmodule.hxx:96