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  SwZoomControl::RegisterControl(SID_ATTR_ZOOM, pMod );
290  SwPreviewZoomControl::RegisterControl(FN_PREVIEW_ZOOM, pMod);
291  SvxPosSizeStatusBarControl::RegisterControl(0, pMod );
292  SvxInsertStatusBarControl::RegisterControl(SID_ATTR_INSERT, pMod );
293  SvxSelectionModeControl::RegisterControl(FN_STAT_SELMODE, pMod );
294  XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pMod );
295  SwWordCountStatusBarControl::RegisterControl(FN_STAT_WORDCOUNT, pMod);
296 
297  SwBookmarkControl::RegisterControl(FN_STAT_PAGE, pMod );
298  SwTemplateControl::RegisterControl(FN_STAT_TEMPLATE, pMod );
299  SwViewLayoutControl::RegisterControl( SID_ATTR_VIEWLAYOUT, pMod );
300  SvxModifyControl::RegisterControl( SID_DOC_MODIFIED, pMod );
301  SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER, pMod );
302 
303  SvxIMapDlgChildWindow::RegisterChildWindow( false, pMod );
304  SvxSearchDialogWrapper::RegisterChildWindow( false, pMod );
305  SvxHlinkDlgWrapper::RegisterChildWindow( false, pMod );
306  SvxFontWorkChildWindow::RegisterChildWindow( false, pMod );
309  SvxContourDlgChildWindow::RegisterChildWindow( false, pMod );
311  SwInputChild::RegisterChildWindow( false, pMod, SfxChildWindowFlags::FORCEDOCK );
317  SvxRubyChildWindow::RegisterChildWindow( false, pMod);
318  SwSpellDialogChildWindow::RegisterChildWindow(
319  false, pMod, comphelper::LibreOfficeKit::isActive() ? SfxChildWindowFlags::NEVERCLONE
320  : SfxChildWindowFlags::NONE);
321 
322  SvxGrafRedToolBoxControl::RegisterControl( SID_ATTR_GRAF_RED, pMod );
323  SvxGrafGreenToolBoxControl::RegisterControl( SID_ATTR_GRAF_GREEN, pMod );
324  SvxGrafBlueToolBoxControl::RegisterControl( SID_ATTR_GRAF_BLUE, pMod );
325  SvxGrafLuminanceToolBoxControl::RegisterControl( SID_ATTR_GRAF_LUMINANCE, pMod );
326  SvxGrafContrastToolBoxControl::RegisterControl( SID_ATTR_GRAF_CONTRAST, pMod );
327  SvxGrafGammaToolBoxControl::RegisterControl( SID_ATTR_GRAF_GAMMA, pMod );
328  SvxGrafTransparenceToolBoxControl::RegisterControl( SID_ATTR_GRAF_TRANSPARENCE, pMod );
329  SvxGrafModeToolBoxControl::RegisterControl( SID_ATTR_GRAF_MODE, pMod );
330 
331 #if HAVE_FEATURE_AVMEDIA
332  ::avmedia::MediaToolBoxControl::RegisterControl(SID_AVMEDIA_TOOLBOX, pMod);
333  ::avmedia::MediaPlayer::RegisterChildWindow(false, pMod);
334 #endif
335 
337 
338  SwJumpToSpecificPageControl::RegisterControl(SID_JUMP_TO_SPECIFIC_PAGE, pMod);
339 }
340 
341 // Load Module (only dummy for linking of the DLL)
343 {
344  OSL_ENSURE(!m_pAttrPool, "Pool already exists!");
345  m_pAttrPool = new SwAttrPool(nullptr);
347 }
348 
350 {
351  SetPool(nullptr);
353 }
354 
355 std::unique_ptr<SfxStyleFamilies> SwModule::CreateStyleFamilies()
356 {
357  std::unique_ptr<SfxStyleFamilies> pStyleFamilies(new SfxStyleFamilies);
358 
359  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Para,
360  SwResId(STR_PARAGRAPHSTYLEFAMILY),
361  BMP_STYLES_FAMILY_PARA,
362  RID_PARAGRAPHSTYLEFAMILY, GetResLocale()));
363 
364  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Char,
365  SwResId(STR_CHARACTERSTYLEFAMILY),
366  BMP_STYLES_FAMILY_CHAR,
367  RID_CHARACTERSTYLEFAMILY, GetResLocale()));
368 
369  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Frame,
370  SwResId(STR_FRAMESTYLEFAMILY),
371  BMP_STYLES_FAMILY_FRAME,
372  RID_FRAMESTYLEFAMILY, GetResLocale()));
373 
374  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Page,
375  SwResId(STR_PAGESTYLEFAMILY),
376  BMP_STYLES_FAMILY_PAGE,
377  RID_PAGESTYLEFAMILY, GetResLocale()));
378 
379  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Pseudo,
380  SwResId(STR_LISTSTYLEFAMILY),
381  BMP_STYLES_FAMILY_LIST,
382  RID_LISTSTYLEFAMILY, GetResLocale()));
383 
384  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Table,
385  SwResId(STR_TABLESTYLEFAMILY),
386  BMP_STYLES_FAMILY_TABLE,
387  RID_TABLESTYLEFAMILY, GetResLocale()));
388 
389  return pStyleFamilies;
390 }
391 
392 void SwModule::RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller)
393 {
395 }
396 
397 void SwModule::CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments)
398 {
400  mxAutomationApplicationEventsCaller->CallSinks(Method, Arguments);
401 }
402 
403 /* 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:97
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:397
void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const &xCaller)
Definition: swmodule.cxx:392
void InitAttrPool()
Definition: swmodule.cxx:342
static void RegisterControls()
Definition: swmodule.cxx:270
#define FN_STAT_PAGE
Definition: cmdid.h:824
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:719
#define FN_STAT_SELMODE
Definition: cmdid.h:827
#define FN_STAT_TEMPLATE
Definition: cmdid.h:825
OUString nget(const char *pContextAndIds, int n, const std::locale &loc)
#define SW_MOD()
Definition: swmodule.hxx:255
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:829
constexpr auto SFX_INTERFACE_SFXDOCSH
virtual std::unique_ptr< SfxStyleFamilies > CreateStyleFamilies() override
Definition: swmodule.cxx:355
css::uno::Reference< css::scanner::XScannerManager2 > m_xScannerManager
Definition: swmodule.hxx:109
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:110
void RemoveAttrPool()
Definition: swmodule.cxx:349
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:95