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>
92 #include <swatrset.hxx>
93 #include <idxmrk.hxx>
94 #include <wordcountdialog.hxx>
95 #include <dlelstnr.hxx>
96 #include <barcfg.hxx>
97 #include <svx/rubydialog.hxx>
98 #include <svtools/colorcfg.hxx>
99 
100 #include <unotools/configmgr.hxx>
102 
103 #include <avmedia/mediaplayer.hxx>
104 #include <avmedia/mediatoolbox.hxx>
105 
106 #include <annotsh.hxx>
107 #include <navsh.hxx>
108 
109 #include <app.hrc>
110 #include <error.hrc>
111 #include <strings.hrc>
112 #include <bitmaps.hlst>
113 #include <svx/xmlsecctrl.hxx>
114 bool g_bNoInterrupt = false;
115 
116 #include <sfx2/app.hxx>
117 
118 #include <svx/svxerr.hxx>
119 
120 #include "swdllimpl.hxx"
121 #include <dbconfig.hxx>
122 #include <navicfg.hxx>
123 
124 using namespace com::sun::star;
125 using namespace ::com::sun::star::uno;
126 
128  SfxObjectFactory* pFact,
129  SfxObjectFactory* pGlobalFact )
130  : SfxModule("sw", {pWebFact, pFact, pGlobalFact}),
131  m_pAttrPool(nullptr),
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 );
298  SwInputChild::RegisterChildWindow( false, pMod, SfxChildWindowFlags::FORCEDOCK );
304  SvxRubyChildWindow::RegisterChildWindow( false, pMod);
305  SwSpellDialogChildWindow::RegisterChildWindow(
306  false, pMod, comphelper::LibreOfficeKit::isActive() ? SfxChildWindowFlags::NEVERCLONE
307  : 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  SwJumpToSpecificPageControl::RegisterControl(SID_JUMP_TO_SPECIFIC_PAGE, pMod);
326 }
327 
328 // Load Module (only dummy for linking of the DLL)
330 {
331  OSL_ENSURE(!m_pAttrPool, "Pool already exists!");
332  m_pAttrPool = new SwAttrPool(nullptr);
334 }
335 
337 {
338  SetPool(nullptr);
340 }
341 
342 std::unique_ptr<SfxStyleFamilies> SwModule::CreateStyleFamilies()
343 {
344  std::unique_ptr<SfxStyleFamilies> pStyleFamilies(new SfxStyleFamilies);
345 
346  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Para,
347  SwResId(STR_PARAGRAPHSTYLEFAMILY),
348  BMP_STYLES_FAMILY_PARA,
349  RID_PARAGRAPHSTYLEFAMILY, GetResLocale()));
350 
351  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Char,
352  SwResId(STR_CHARACTERSTYLEFAMILY),
353  BMP_STYLES_FAMILY_CHAR,
354  RID_CHARACTERSTYLEFAMILY, GetResLocale()));
355 
356  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Frame,
357  SwResId(STR_FRAMESTYLEFAMILY),
358  BMP_STYLES_FAMILY_FRAME,
359  RID_FRAMESTYLEFAMILY, GetResLocale()));
360 
361  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Page,
362  SwResId(STR_PAGESTYLEFAMILY),
363  BMP_STYLES_FAMILY_PAGE,
364  RID_PAGESTYLEFAMILY, GetResLocale()));
365 
366  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Pseudo,
367  SwResId(STR_LISTSTYLEFAMILY),
368  BMP_STYLES_FAMILY_LIST,
369  RID_LISTSTYLEFAMILY, GetResLocale()));
370 
371  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Table,
372  SwResId(STR_TABLESTYLEFAMILY),
373  BMP_STYLES_FAMILY_TABLE,
374  RID_TABLESTYLEFAMILY, GetResLocale()));
375 
376  return pStyleFamilies;
377 }
378 
379 void SwModule::RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller)
380 {
382 }
383 
384 void SwModule::CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments)
385 {
387  mxAutomationApplicationEventsCaller->CallSinks(Method, Arguments);
388 }
389 
390 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::scanner::XScannerManager2 > const & GetScannerManager()
Definition: swmodule.cxx:176
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:127
#define FN_PREVIEW_ZOOM
Definition: cmdid.h:175
void CallAutomationApplicationEventSinks(const OUString &Method, css::uno::Sequence< css::uno::Any > &Arguments)
Definition: swmodule.cxx:384
void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const &xCaller)
Definition: swmodule.cxx:379
void InitAttrPool()
Definition: swmodule.cxx:329
static void RegisterControls()
Definition: swmodule.cxx:257
#define FN_STAT_PAGE
Definition: cmdid.h:829
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:722
#define FN_STAT_SELMODE
Definition: cmdid.h:832
#define FN_STAT_TEMPLATE
Definition: cmdid.h:830
OUString nget(const char *pContextAndIds, int n, const std::locale &loc)
#define SW_MOD()
Definition: swmodule.hxx:255
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:834
constexpr auto SFX_INTERFACE_SFXDOCSH
virtual std::unique_ptr< SfxStyleFamilies > CreateStyleFamilies() override
Definition: swmodule.cxx:342
css::uno::Reference< css::scanner::XScannerManager2 > m_xScannerManager
Definition: swmodule.hxx:109
static void RegisterFactories()
Definition: swmodule.cxx:202
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:185
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:336
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:114
OUString get(const char *pContextAndId, const std::locale &loc)
std::unique_ptr< SfxErrorHandler > m_pErrorHandler
Definition: swmodule.hxx:95