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  SvxUndoRedoControl::RegisterControl(SID_UNDO, pMod );
285  SvxUndoRedoControl::RegisterControl(SID_REDO, pMod );
286  svx::FormatPaintBrushToolBoxControl::RegisterControl(SID_FORMATPAINTBRUSH, pMod );
287 
288  SvxFillToolBoxControl::RegisterControl(SID_ATTR_FILL_STYLE, pMod );
289  SvxLineStyleToolBoxControl::RegisterControl(SID_ATTR_LINE_STYLE, pMod );
290  SvxLineWidthToolBoxControl::RegisterControl(SID_ATTR_LINE_WIDTH, pMod );
291 
292  SvxStyleToolBoxControl::RegisterControl(SID_STYLE_APPLY, pMod );
293 
294  SvxColumnsToolBoxControl::RegisterControl(FN_INSERT_FRAME_INTERACT, pMod );
295  SvxColumnsToolBoxControl::RegisterControl(FN_INSERT_FRAME, pMod );
296  SvxColumnsToolBoxControl::RegisterControl(FN_INSERT_REGION, pMod );
297 
298  SwZoomControl::RegisterControl(SID_ATTR_ZOOM, pMod );
299  SwPreviewZoomControl::RegisterControl(FN_PREVIEW_ZOOM, pMod);
300  SvxPosSizeStatusBarControl::RegisterControl(0, pMod );
301  SvxInsertStatusBarControl::RegisterControl(SID_ATTR_INSERT, pMod );
302  SvxSelectionModeControl::RegisterControl(FN_STAT_SELMODE, pMod );
303  XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pMod );
304  SwWordCountStatusBarControl::RegisterControl(FN_STAT_WORDCOUNT, pMod);
305 
306  SwBookmarkControl::RegisterControl(FN_STAT_PAGE, pMod );
307  SwTemplateControl::RegisterControl(FN_STAT_TEMPLATE, pMod );
308  SwViewLayoutControl::RegisterControl( SID_ATTR_VIEWLAYOUT, pMod );
309  SvxModifyControl::RegisterControl( SID_DOC_MODIFIED, pMod );
310  SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER, pMod );
311 
312  SvxIMapDlgChildWindow::RegisterChildWindow( false, pMod );
313  SvxSearchDialogWrapper::RegisterChildWindow( false, pMod );
314  SvxHlinkDlgWrapper::RegisterChildWindow( false, pMod );
315  SvxFontWorkChildWindow::RegisterChildWindow( false, pMod );
318  SvxContourDlgChildWindow::RegisterChildWindow( false, pMod );
320  SwInputChild::RegisterChildWindow( false, pMod, SfxChildWindowFlags::FORCEDOCK );
326  SvxRubyChildWindow::RegisterChildWindow( false, pMod);
327  SwSpellDialogChildWindow::RegisterChildWindow(
328  false, pMod, comphelper::LibreOfficeKit::isActive() ? SfxChildWindowFlags::NEVERCLONE
329  : SfxChildWindowFlags::NONE);
330 
331  SvxGrafRedToolBoxControl::RegisterControl( SID_ATTR_GRAF_RED, pMod );
332  SvxGrafGreenToolBoxControl::RegisterControl( SID_ATTR_GRAF_GREEN, pMod );
333  SvxGrafBlueToolBoxControl::RegisterControl( SID_ATTR_GRAF_BLUE, pMod );
334  SvxGrafLuminanceToolBoxControl::RegisterControl( SID_ATTR_GRAF_LUMINANCE, pMod );
335  SvxGrafContrastToolBoxControl::RegisterControl( SID_ATTR_GRAF_CONTRAST, pMod );
336  SvxGrafGammaToolBoxControl::RegisterControl( SID_ATTR_GRAF_GAMMA, pMod );
337  SvxGrafTransparenceToolBoxControl::RegisterControl( SID_ATTR_GRAF_TRANSPARENCE, pMod );
338  SvxGrafModeToolBoxControl::RegisterControl( SID_ATTR_GRAF_MODE, pMod );
339  SvxVertTextTbxCtrl::RegisterControl(SID_TEXTDIRECTION_LEFT_TO_RIGHT, pMod);
340  SvxVertTextTbxCtrl::RegisterControl(SID_TEXTDIRECTION_TOP_TO_BOTTOM, pMod);
341  SvxVertTextTbxCtrl::RegisterControl(SID_DRAW_CAPTION_VERTICAL, pMod);
342  SvxVertTextTbxCtrl::RegisterControl(SID_DRAW_TEXT_VERTICAL, pMod);
343 
344  SvxCTLTextTbxCtrl::RegisterControl(SID_ATTR_PARA_LEFT_TO_RIGHT, pMod);
345  SvxCTLTextTbxCtrl::RegisterControl(SID_ATTR_PARA_RIGHT_TO_LEFT, pMod);
346 
347 #if HAVE_FEATURE_AVMEDIA
348  ::avmedia::MediaToolBoxControl::RegisterControl(SID_AVMEDIA_TOOLBOX, pMod);
349  ::avmedia::MediaPlayer::RegisterChildWindow(false, pMod);
350 #endif
351 
353 
354  SwJumpToSpecificPageControl::RegisterControl(SID_JUMP_TO_SPECIFIC_PAGE, pMod);
355 }
356 
357 // Load Module (only dummy for linking of the DLL)
359 {
360  OSL_ENSURE(!m_pAttrPool, "Pool already exists!");
361  m_pAttrPool = new SwAttrPool(nullptr);
363 }
364 
366 {
367  SetPool(nullptr);
369 }
370 
371 std::unique_ptr<SfxStyleFamilies> SwModule::CreateStyleFamilies()
372 {
373  std::unique_ptr<SfxStyleFamilies> pStyleFamilies(new SfxStyleFamilies);
374 
375  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Para,
376  SwResId(STR_PARAGRAPHSTYLEFAMILY),
377  Image(StockImage::Yes, BMP_STYLES_FAMILY_PARA),
378  RID_PARAGRAPHSTYLEFAMILY, GetResLocale()));
379 
380  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Char,
381  SwResId(STR_CHARACTERSTYLEFAMILY),
382  Image(StockImage::Yes, BMP_STYLES_FAMILY_CHAR),
383  RID_CHARACTERSTYLEFAMILY, GetResLocale()));
384 
385  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Frame,
386  SwResId(STR_FRAMESTYLEFAMILY),
387  Image(StockImage::Yes, BMP_STYLES_FAMILY_FRAME),
388  RID_FRAMESTYLEFAMILY, GetResLocale()));
389 
390  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Page,
391  SwResId(STR_PAGESTYLEFAMILY),
392  Image(StockImage::Yes, BMP_STYLES_FAMILY_PAGE),
393  RID_PAGESTYLEFAMILY, GetResLocale()));
394 
395  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Pseudo,
396  SwResId(STR_LISTSTYLEFAMILY),
397  Image(StockImage::Yes, BMP_STYLES_FAMILY_LIST),
398  RID_LISTSTYLEFAMILY, GetResLocale()));
399 
400  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Table,
401  SwResId(STR_TABLESTYLEFAMILY),
402  Image(StockImage::Yes, BMP_STYLES_FAMILY_TABLE),
403  RID_TABLESTYLEFAMILY, GetResLocale()));
404 
405  return pStyleFamilies;
406 }
407 
408 void SwModule::RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller)
409 {
411 }
412 
413 void SwModule::CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments)
414 {
416  mxAutomationApplicationEventsCaller->CallSinks(Method, Arguments);
417 }
418 
419 /* 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:413
void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const &xCaller)
Definition: swmodule.cxx:408
#define FN_INSERT_REGION
Definition: cmdid.h:274
void InitAttrPool()
Definition: swmodule.cxx:358
static void RegisterControls()
Definition: swmodule.cxx:270
#define FN_STAT_PAGE
Definition: cmdid.h:816
#define FN_INSERT_FRAME_INTERACT
Definition: cmdid.h:211
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:714
#define FN_STAT_SELMODE
Definition: cmdid.h:819
#define FN_STAT_TEMPLATE
Definition: cmdid.h:817
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:484
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:821
constexpr auto SFX_INTERFACE_SFXDOCSH
virtual std::unique_ptr< SfxStyleFamilies > CreateStyleFamilies() override
Definition: swmodule.cxx:371
css::uno::Reference< css::scanner::XScannerManager2 > m_xScannerManager
Definition: swmodule.hxx:110
#define FN_INSERT_FRAME
Definition: cmdid.h:212
static void RegisterFactories()
Definition: swmodule.cxx:215
static void Free(SfxItemPool *pPool)
static void RegisterChildWindowContext(SfxModule *pMod)
Definition: navipi.cxx:73
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:365
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
Reference< XComponentContext > getProcessComponentContext()
static void ensure()
#define SID_TRACK_CHANGES_BAR
Definition: cmdid.h:715
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