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