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_pAttrPool(nullptr),
133  m_pView(nullptr),
134  m_bAuthorInitialised(false),
135  m_bEmbeddedLoadSave( false ),
136  m_pDragDrop( nullptr ),
137  m_pXSelection( nullptr )
138 {
139  SetName( "StarWriter" );
141  m_pErrorHandler.reset( new SfxErrorHandler( RID_SW_ERRHDL,
142  ErrCodeArea::Sw,
143  ErrCodeArea::Sw,
144  GetResLocale() ) );
145 
146  m_pModuleConfig.reset(new SwModuleOptions);
147 
148  // We need them anyways
149  m_pToolbarConfig.reset(new SwToolbarConfigItem( false ));
150  m_pWebToolbarConfig.reset(new SwToolbarConfigItem( true ));
151 
152  m_pStdFontConfig.reset(new SwStdFontConfig);
153 
155 
157  {
158  // init color configuration
159  // member <pColorConfig> is created and the color configuration is applied
160  // at the view options.
161  GetColorConfig();
162  m_xLinguServiceEventListener = new SwLinguServiceEventListener;
163  }
164 }
165 
166 OUString SwResId(const char* pId)
167 {
168  return Translate::get(pId, SW_MOD()->GetResLocale());
169 }
170 
171 OUString SwResId(const char* pId, int nCardinality)
172 {
173  return Translate::nget(pId, nCardinality, SW_MOD()->GetResLocale());
174 }
175 
176 uno::Reference< scanner::XScannerManager2 > const &
178 {
179  if (!m_xScannerManager.is())
180  {
181  m_xScannerManager = scanner::ScannerManager::create( comphelper::getProcessComponentContext() );
182  }
183  return m_xScannerManager;
184 }
185 
186 uno::Reference< linguistic2::XLanguageGuessing > const & SwModule::GetLanguageGuesser()
187 {
188  if (!m_xLanguageGuesser.is())
189  {
190  m_xLanguageGuesser = linguistic2::LanguageGuessing::create( comphelper::getProcessComponentContext() );
191  }
192  return m_xLanguageGuesser;
193 }
194 
196 {
197  css::uno::Sequence< css::uno::Any > aArgs;
198  CallAutomationApplicationEventSinks( "Quit", aArgs );
199  m_pErrorHandler.reset();
200  EndListening( *SfxGetpApp() );
201 }
202 
204 {
205  // These Id's must not be changed. Through these Id's the View (resume Documentview)
206  // is created by Sfx.
207  if (utl::ConfigManager::IsFuzzing() || SvtModuleOptions().IsWriter())
208  SwView::RegisterFactory ( SFX_INTERFACE_SFXDOCSH );
209 
210 #if HAVE_FEATURE_DESKTOP
211  SwWebView::RegisterFactory ( SFX_INTERFACE_SFXMODULE );
212 
213  if (utl::ConfigManager::IsFuzzing() || SvtModuleOptions().IsWriter())
214  {
215  SwSrcView::RegisterFactory ( SfxInterfaceId(6) );
216  SwPagePreview::RegisterFactory ( SfxInterfaceId(7) );
217  }
218 #endif
219 }
220 
222 {
223  SwModule* pMod = SW_MOD();
224  SwModule::RegisterInterface( pMod );
225  SwDocShell::RegisterInterface( pMod );
226  SwWebDocShell::RegisterInterface( pMod );
227  SwGlosDocShell::RegisterInterface( pMod );
228  SwWebGlosDocShell::RegisterInterface( pMod );
229  SwView::RegisterInterface( pMod );
230  SwWebView::RegisterInterface( pMod );
231  SwPagePreview::RegisterInterface( pMod );
232  SwSrcView::RegisterInterface( pMod );
233 
234  SwBaseShell::RegisterInterface(pMod);
235  SwTextShell::RegisterInterface(pMod);
236  SwTableShell::RegisterInterface(pMod);
237  SwListShell::RegisterInterface(pMod);
238  SwFrameShell::RegisterInterface(pMod);
239  SwDrawBaseShell::RegisterInterface(pMod);
240  SwDrawShell::RegisterInterface(pMod);
241  SwDrawFormShell::RegisterInterface(pMod);
242  SwDrawTextShell::RegisterInterface(pMod);
243  SwBezierShell::RegisterInterface(pMod);
244  SwGrfShell::RegisterInterface(pMod);
245  SwOleShell::RegisterInterface(pMod);
246  SwNavigationShell::RegisterInterface(pMod);
247  SwWebTextShell::RegisterInterface(pMod);
248  SwWebFrameShell::RegisterInterface(pMod);
249  SwWebGrfShell::RegisterInterface(pMod);
250  SwWebListShell::RegisterInterface(pMod);
251  SwWebTableShell::RegisterInterface(pMod);
252  SwWebDrawFormShell::RegisterInterface(pMod);
253  SwWebOleShell::RegisterInterface(pMod);
254  SwMediaShell::RegisterInterface(pMod);
255  SwAnnotationShell::RegisterInterface(pMod);
256 }
257 
259 {
260  SwModule* pMod = SW_MOD();
261 
262  SvxTbxCtlDraw::RegisterControl(SID_INSERT_DRAW, pMod );
263  SvxTbxCtlDraw::RegisterControl(SID_TRACK_CHANGES_BAR, pMod );
264  SwTbxAutoTextCtrl::RegisterControl(FN_GLOSSARY_DLG, pMod );
265  svx::ParaAboveSpacingControl::RegisterControl(SID_ATTR_PARA_ABOVESPACE, pMod);
266  svx::ParaBelowSpacingControl::RegisterControl(SID_ATTR_PARA_BELOWSPACE, pMod);
267  svx::ParaLeftSpacingControl::RegisterControl(SID_ATTR_PARA_LEFTSPACE, pMod);
268  svx::ParaRightSpacingControl::RegisterControl(SID_ATTR_PARA_RIGHTSPACE, pMod);
269  svx::ParaFirstLineSpacingControl::RegisterControl(SID_ATTR_PARA_FIRSTLINESPACE, pMod);
270 
271  SvxClipBoardControl::RegisterControl(SID_PASTE, pMod );
272  svx::FormatPaintBrushToolBoxControl::RegisterControl(SID_FORMATPAINTBRUSH, pMod );
273 
274  SvxFillToolBoxControl::RegisterControl(SID_ATTR_FILL_STYLE, pMod );
275  SvxLineWidthToolBoxControl::RegisterControl(SID_ATTR_LINE_WIDTH, pMod );
276 
277  SwZoomControl::RegisterControl(SID_ATTR_ZOOM, pMod );
278  SwPreviewZoomControl::RegisterControl(FN_PREVIEW_ZOOM, pMod);
279  SvxPosSizeStatusBarControl::RegisterControl(0, pMod );
280  SvxInsertStatusBarControl::RegisterControl(SID_ATTR_INSERT, pMod );
281  SvxSelectionModeControl::RegisterControl(FN_STAT_SELMODE, pMod );
282  XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pMod );
283  SwWordCountStatusBarControl::RegisterControl(FN_STAT_WORDCOUNT, pMod);
284 
285  SwBookmarkControl::RegisterControl(FN_STAT_PAGE, pMod );
286  SwTemplateControl::RegisterControl(FN_STAT_TEMPLATE, pMod );
287  SwViewLayoutControl::RegisterControl( SID_ATTR_VIEWLAYOUT, pMod );
288  SvxModifyControl::RegisterControl( SID_DOC_MODIFIED, pMod );
289  SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER, pMod );
290 
291  SvxIMapDlgChildWindow::RegisterChildWindow( false, pMod );
292  SvxSearchDialogWrapper::RegisterChildWindow( false, pMod );
293  SvxHlinkDlgWrapper::RegisterChildWindow( false, pMod );
294  SvxFontWorkChildWindow::RegisterChildWindow( false, pMod );
297  SvxContourDlgChildWindow::RegisterChildWindow( false, pMod );
299  SwInputChild::RegisterChildWindow( false, pMod, SfxChildWindowFlags::FORCEDOCK );
305  SvxRubyChildWindow::RegisterChildWindow( false, pMod);
306  SwSpellDialogChildWindow::RegisterChildWindow(
307  false, pMod, comphelper::LibreOfficeKit::isActive() ? SfxChildWindowFlags::NEVERCLONE
308  : SfxChildWindowFlags::NONE);
310 
311  SvxGrafRedToolBoxControl::RegisterControl( SID_ATTR_GRAF_RED, pMod );
312  SvxGrafGreenToolBoxControl::RegisterControl( SID_ATTR_GRAF_GREEN, pMod );
313  SvxGrafBlueToolBoxControl::RegisterControl( SID_ATTR_GRAF_BLUE, pMod );
314  SvxGrafLuminanceToolBoxControl::RegisterControl( SID_ATTR_GRAF_LUMINANCE, pMod );
315  SvxGrafContrastToolBoxControl::RegisterControl( SID_ATTR_GRAF_CONTRAST, pMod );
316  SvxGrafGammaToolBoxControl::RegisterControl( SID_ATTR_GRAF_GAMMA, pMod );
317  SvxGrafTransparenceToolBoxControl::RegisterControl( SID_ATTR_GRAF_TRANSPARENCE, pMod );
318  SvxGrafModeToolBoxControl::RegisterControl( SID_ATTR_GRAF_MODE, pMod );
319 
320 #if HAVE_FEATURE_AVMEDIA
321  ::avmedia::MediaToolBoxControl::RegisterControl(SID_AVMEDIA_TOOLBOX, pMod);
322  ::avmedia::MediaPlayer::RegisterChildWindow(false, pMod);
323 #endif
324 
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 = new SwAttrPool(nullptr);
336 }
337 
339 {
340  SetPool(nullptr);
342 }
343 
344 std::unique_ptr<SfxStyleFamilies> SwModule::CreateStyleFamilies()
345 {
346  std::unique_ptr<SfxStyleFamilies> pStyleFamilies(new SfxStyleFamilies);
347 
348  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Para,
349  SwResId(STR_PARAGRAPHSTYLEFAMILY),
350  BMP_STYLES_FAMILY_PARA,
351  RID_PARAGRAPHSTYLEFAMILY, GetResLocale()));
352 
353  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Char,
354  SwResId(STR_CHARACTERSTYLEFAMILY),
355  BMP_STYLES_FAMILY_CHAR,
356  RID_CHARACTERSTYLEFAMILY, GetResLocale()));
357 
358  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Frame,
359  SwResId(STR_FRAMESTYLEFAMILY),
360  BMP_STYLES_FAMILY_FRAME,
361  RID_FRAMESTYLEFAMILY, GetResLocale()));
362 
363  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Page,
364  SwResId(STR_PAGESTYLEFAMILY),
365  BMP_STYLES_FAMILY_PAGE,
366  RID_PAGESTYLEFAMILY, GetResLocale()));
367 
368  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Pseudo,
369  SwResId(STR_LISTSTYLEFAMILY),
370  BMP_STYLES_FAMILY_LIST,
371  RID_LISTSTYLEFAMILY, GetResLocale()));
372 
373  pStyleFamilies->emplace_back(SfxStyleFamilyItem(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:177
SwAttrPool * m_pAttrPool
Definition: swmodule.hxx:97
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:258
#define FN_STAT_PAGE
Definition: cmdid.h:831
SfxApplication * SfxGetpApp()
css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller
Definition: swmodule.hxx:124
static bool IsFuzzing()
#define SID_JUMP_TO_SPECIFIC_PAGE
Definition: cmdid.h:724
#define FN_STAT_SELMODE
Definition: cmdid.h:834
#define FN_STAT_TEMPLATE
Definition: cmdid.h:832
OUString nget(const char *pContextAndIds, int n, const std::locale &loc)
#define SW_MOD()
Definition: swmodule.hxx:255
static void RegisterInterfaces()
Definition: swmodule.cxx:221
#define FN_GLOSSARY_DLG
Definition: cmdid.h:494
constexpr auto SFX_INTERFACE_SFXMODULE
void SetPool(SfxItemPool *pNewPool)
static void RegisterChildWindow(SfxModule *, std::unique_ptr< SfxChildWinFactory >)
virtual ~SwModule() override
Definition: swmodule.cxx:195
OUString SwResId(const char *pId)
Definition: swmodule.cxx:166
#define FN_STAT_WORDCOUNT
Definition: cmdid.h:836
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:109
static void RegisterFactories()
Definition: swmodule.cxx:203
static void Free(SfxItemPool *pPool)
static void RegisterChildWindowContext(SfxModule *pMod)
Definition: navipi.cxx:61
css::uno::Reference< css::linguistic2::XLanguageGuessing > const & GetLanguageGuesser()
Definition: swmodule.cxx:186
EventListener that triggers spellchecking and hyphenation.
Definition: dlelstnr.hxx:42
css::uno::Reference< css::linguistic2::XLanguageGuessing > m_xLanguageGuesser
Definition: swmodule.hxx:110
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:725
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:95