1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <config_features.h>
22 #include <svtools/ehdl.hxx>
23 #include <svtools/accessibilityoptions.hxx>
24 #include <unotools/resmgr.hxx>
25 #include <unotools/useroptions.hxx>
26 #include <svl/ctloptions.hxx>
27 #include <svx/ParaSpacingControl.hxx>
28 #include <svx/pszctrl.hxx>
29 #include <svx/insctrl.hxx>
30 #include <svx/selctrl.hxx>
31 #include <svx/linectrl.hxx>
32 #include <svx/tbxctl.hxx>
33 #include <svx/fillctrl.hxx>
34 #include <svx/formatpaintbrushctrl.hxx>
35 #include <svx/contdlg.hxx>
36 #include <svx/fontwork.hxx>
37 #include <SwSpellDialogChildWindow.hxx>
38 #include <svx/grafctrl.hxx>
39 #include <svx/clipboardctl.hxx>
40 #include <svx/imapdlg.hxx>
41 #include <svx/srchdlg.hxx>
42 #include <svx/hyperdlg.hxx>
43 #include <svx/modctrl.hxx>
44 #include <com/sun/star/scanner/ScannerManager.hpp>
45 #include <com/sun/star/linguistic2/LanguageGuessing.hpp>
46 #include <ooo/vba/XSinkCaller.hpp>
47 #include <comphelper/lok.hxx>
48 #include <comphelper/processfactory.hxx>
50 #include <swmodule.hxx>
55 #include <srcview.hxx>
56 #include <glshell.hxx>
60 #include <mediash.hxx>
63 #include <wformsh.hxx>
64 #include <drwtxtsh.hxx>
65 #include <beziersh.hxx>
66 #include <wtextsh.hxx>
68 #include <drformsh.hxx>
71 #include <wlistsh.hxx>
74 #include <inputwin.hxx>
75 #include <usrpref.hxx>
78 #include <bookctrl.hxx>
79 #include <tmplctrl.hxx>
80 #include <viewlayoutctrl.hxx>
81 #include <svx/zoomsliderctrl.hxx>
82 #include <zoomctrl.hxx>
83 #include <wordcountctrl.hxx>
84 #include <AccessibilityStatusBarControl.hxx>
85 #include <workctrl.hxx>
86 #include <fldwrap.hxx>
87 #include <redlndlg.hxx>
88 #include <syncbtn.hxx>
90 #include <fontcfg.hxx>
91 #include <sfx2/sidebar/SidebarChildWindow.hxx>
92 #include <sfx2/devtools/DevelopmentToolChildWindow.hxx>
93 #include <swatrset.hxx>
95 #include <wordcountdialog.hxx>
96 #include <dlelstnr.hxx>
98 #include <svx/rubydialog.hxx>
99 #include <svtools/colorcfg.hxx>
101 #include <comphelper/configuration.hxx>
102 #include <unotools/moduleoptions.hxx>
104 #include <avmedia/mediaplayer.hxx>
105 #include <avmedia/mediatoolbox.hxx>
107 #include <annotsh.hxx>
112 #include <strings.hrc>
113 #include <bitmaps.hlst>
114 #include <svx/xmlsecctrl.hxx>
115 bool g_bNoInterrupt
= false;
117 #include <sfx2/app.hxx>
119 #include <svx/svxerr.hxx>
121 #include "swdllimpl.hxx"
122 #include <dbconfig.hxx>
123 #include <navicfg.hxx>
125 using namespace com::sun::star
;
126 using namespace ::com::sun::star::uno
;
128 SwModule::SwModule( SfxObjectFactory
* pWebFact
,
129 SfxObjectFactory
* pFact
,
130 SfxObjectFactory
* pGlobalFact
)
131 : SfxModule("sw"_ostr
, {pWebFact
, pFact
, pGlobalFact
}),
133 m_eCTLTextNumerals(SvtCTLOptions::GetCTLTextNumerals()),
134 m_bAuthorInitialised(false),
135 m_bEmbeddedLoadSave( false ),
136 m_pDragDrop( nullptr ),
137 m_pXSelection( nullptr )
139 SetName( u
"StarWriter"_ustr
);
140 SvxErrorHandler::ensure();
141 m_pErrorHandler
.reset( new SfxErrorHandler( RID_SW_ERRHDL
,
146 m_pModuleConfig
.reset(new SwModuleOptions
);
148 // We need them anyways
149 m_pToolbarConfig
.reset(new SwToolbarConfigItem( false ));
150 m_pWebToolbarConfig
.reset(new SwToolbarConfigItem( true ));
152 m_pStdFontConfig
.reset(new SwStdFontConfig
);
156 StartListening( *SfxGetpApp() );
159 if (!comphelper::IsFuzzing())
161 // init color configuration
162 // member <pColorConfig> is created and the color configuration is applied
163 // at the view options.
165 m_xLinguServiceEventListener
= new SwLinguServiceEventListener
;
169 OUString
SwResId(TranslateId aId
)
171 return Translate::get(aId
, SwModule::get()->GetResLocale());
174 OUString
SwResId(TranslateNId aContextSingularPlural
, int nCardinality
)
176 return Translate::nget(aContextSingularPlural
, nCardinality
, SwModule::get()->GetResLocale());
179 uno::Reference
< scanner::XScannerManager2
> const &
180 SwModule::GetScannerManager()
182 static bool bTestScannerManager
= true;
183 if (bTestScannerManager
&& !m_xScannerManager
.is())
186 m_xScannerManager
= scanner::ScannerManager::create( comphelper::getProcessComponentContext() );
189 bTestScannerManager
= false;
191 return m_xScannerManager
;
194 uno::Reference
< linguistic2::XLanguageGuessing
> const & SwModule::GetLanguageGuesser()
196 if (!m_xLanguageGuesser
.is())
198 m_xLanguageGuesser
= linguistic2::LanguageGuessing::create( comphelper::getProcessComponentContext() );
200 return m_xLanguageGuesser
;
203 SwModule::~SwModule()
205 css::uno::Sequence
< css::uno::Any
> aArgs
;
206 CallAutomationApplicationEventSinks( u
"Quit"_ustr
, aArgs
);
207 m_pErrorHandler
.reset();
208 EndListening( *SfxGetpApp() );
211 void SwDLL::RegisterFactories()
213 // These Id's must not be changed. Through these Id's the View (resume Documentview)
214 // is created by Sfx.
215 SvtModuleOptions aOptions
;
216 if (comphelper::IsFuzzing() || aOptions
.IsWriterInstalled())
217 SwView::RegisterFactory ( SFX_INTERFACE_SFXDOCSH
);
219 #if HAVE_FEATURE_DESKTOP
220 SwWebView::RegisterFactory ( SFX_INTERFACE_SFXMODULE
);
222 if (comphelper::IsFuzzing() || aOptions
.IsWriterInstalled())
224 SwSrcView::RegisterFactory ( SfxInterfaceId(6) );
225 SwPagePreview::RegisterFactory ( SfxInterfaceId(7) );
230 void SwDLL::RegisterInterfaces()
232 SwModule
* pMod
= SwModule::get();
233 SwModule::RegisterInterface( pMod
);
234 SwDocShell::RegisterInterface( pMod
);
235 SwWebDocShell::RegisterInterface( pMod
);
236 SwGlosDocShell::RegisterInterface( pMod
);
237 SwWebGlosDocShell::RegisterInterface( pMod
);
238 SwView::RegisterInterface( pMod
);
239 SwWebView::RegisterInterface( pMod
);
240 SwPagePreview::RegisterInterface( pMod
);
241 SwSrcView::RegisterInterface( pMod
);
243 SwBaseShell::RegisterInterface(pMod
);
244 SwTextShell::RegisterInterface(pMod
);
245 SwTableShell::RegisterInterface(pMod
);
246 SwListShell::RegisterInterface(pMod
);
247 SwFrameShell::RegisterInterface(pMod
);
248 SwDrawBaseShell::RegisterInterface(pMod
);
249 SwDrawShell::RegisterInterface(pMod
);
250 SwDrawFormShell::RegisterInterface(pMod
);
251 SwDrawTextShell::RegisterInterface(pMod
);
252 SwBezierShell::RegisterInterface(pMod
);
253 SwGrfShell::RegisterInterface(pMod
);
254 SwOleShell::RegisterInterface(pMod
);
255 SwNavigationShell::RegisterInterface(pMod
);
256 SwWebTextShell::RegisterInterface(pMod
);
257 SwWebFrameShell::RegisterInterface(pMod
);
258 SwWebGrfShell::RegisterInterface(pMod
);
259 SwWebListShell::RegisterInterface(pMod
);
260 SwWebTableShell::RegisterInterface(pMod
);
261 SwWebDrawFormShell::RegisterInterface(pMod
);
262 SwWebOleShell::RegisterInterface(pMod
);
263 SwMediaShell::RegisterInterface(pMod
);
264 SwAnnotationShell::RegisterInterface(pMod
);
267 void SwDLL::RegisterControls()
269 SwModule
* pMod
= SwModule::get();
271 SvxTbxCtlDraw::RegisterControl(SID_INSERT_DRAW
, pMod
);
272 SvxTbxCtlDraw::RegisterControl(SID_TRACK_CHANGES_BAR
, pMod
);
273 SwTbxAutoTextCtrl::RegisterControl(FN_GLOSSARY_DLG
, pMod
);
274 svx::ParaAboveSpacingControl::RegisterControl(SID_ATTR_PARA_ABOVESPACE
, pMod
);
275 svx::ParaBelowSpacingControl::RegisterControl(SID_ATTR_PARA_BELOWSPACE
, pMod
);
276 svx::ParaLeftSpacingControl::RegisterControl(SID_ATTR_PARA_LEFTSPACE
, pMod
);
277 svx::ParaRightSpacingControl::RegisterControl(SID_ATTR_PARA_RIGHTSPACE
, pMod
);
278 svx::ParaFirstLineSpacingControl::RegisterControl(SID_ATTR_PARA_FIRSTLINESPACE
, pMod
);
280 SvxClipBoardControl::RegisterControl(SID_PASTE
, pMod
);
281 svx::FormatPaintBrushToolBoxControl::RegisterControl(SID_FORMATPAINTBRUSH
, pMod
);
283 SvxFillToolBoxControl::RegisterControl(SID_ATTR_FILL_STYLE
, pMod
);
284 SvxLineWidthToolBoxControl::RegisterControl(SID_ATTR_LINE_WIDTH
, pMod
);
286 SwZoomControl::RegisterControl(SID_ATTR_ZOOM
, pMod
);
287 SwPreviewZoomControl::RegisterControl(FN_PREVIEW_ZOOM
, pMod
);
288 SvxPosSizeStatusBarControl::RegisterControl(0, pMod
);
289 SvxInsertStatusBarControl::RegisterControl(SID_ATTR_INSERT
, pMod
);
290 SvxSelectionModeControl::RegisterControl(FN_STAT_SELMODE
, pMod
);
291 XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE
, pMod
);
292 SwWordCountStatusBarControl::RegisterControl(FN_STAT_WORDCOUNT
, pMod
);
293 sw::AccessibilityStatusBarControl::RegisterControl(FN_STAT_ACCESSIBILITY_CHECK
, pMod
);
295 SwBookmarkControl::RegisterControl(FN_STAT_PAGE
, pMod
);
296 SwTemplateControl::RegisterControl(FN_STAT_TEMPLATE
, pMod
);
297 SwViewLayoutControl::RegisterControl( SID_ATTR_VIEWLAYOUT
, pMod
);
298 SvxModifyControl::RegisterControl( SID_DOC_MODIFIED
, pMod
);
299 SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER
, pMod
);
301 SvxIMapDlgChildWindow::RegisterChildWindow( false, pMod
);
302 SvxSearchDialogWrapper::RegisterChildWindow( false, pMod
);
303 SvxHlinkDlgWrapper::RegisterChildWindow( false, pMod
);
304 SvxFontWorkChildWindow::RegisterChildWindow( false, pMod
);
305 SwFieldDlgWrapper::RegisterChildWindow( false, pMod
);
306 SwFieldDataOnlyDlgWrapper::RegisterChildWindow( false, pMod
);
307 SvxContourDlgChildWindow::RegisterChildWindow( false, pMod
);
308 SwInputChild::RegisterChildWindow( false, pMod
, SfxChildWindowFlags::FORCEDOCK
);
309 SwRedlineAcceptChild::RegisterChildWindow( false, pMod
);
310 SwSyncChildWin::RegisterChildWindow( true, pMod
);
311 SwInsertIdxMarkWrapper::RegisterChildWindow( false, pMod
);
312 SwInsertAuthMarkWrapper::RegisterChildWindow( false, pMod
);
313 SwWordCountWrapper::RegisterChildWindow( false, pMod
);
314 SvxRubyChildWindow::RegisterChildWindow( false, pMod
);
315 SwSpellDialogChildWindow::RegisterChildWindow(false, pMod
);
316 DevelopmentToolChildWindow::RegisterChildWindow(false, pMod
);
318 SvxGrafRedToolBoxControl::RegisterControl( SID_ATTR_GRAF_RED
, pMod
);
319 SvxGrafGreenToolBoxControl::RegisterControl( SID_ATTR_GRAF_GREEN
, pMod
);
320 SvxGrafBlueToolBoxControl::RegisterControl( SID_ATTR_GRAF_BLUE
, pMod
);
321 SvxGrafLuminanceToolBoxControl::RegisterControl( SID_ATTR_GRAF_LUMINANCE
, pMod
);
322 SvxGrafContrastToolBoxControl::RegisterControl( SID_ATTR_GRAF_CONTRAST
, pMod
);
323 SvxGrafGammaToolBoxControl::RegisterControl( SID_ATTR_GRAF_GAMMA
, pMod
);
324 SvxGrafTransparenceToolBoxControl::RegisterControl( SID_ATTR_GRAF_TRANSPARENCE
, pMod
);
325 SvxGrafModeToolBoxControl::RegisterControl( SID_ATTR_GRAF_MODE
, pMod
);
327 #if HAVE_FEATURE_AVMEDIA
328 ::avmedia::MediaToolBoxControl::RegisterControl(SID_AVMEDIA_TOOLBOX
, pMod
);
329 ::avmedia::MediaPlayer::RegisterChildWindow(false, pMod
);
332 ::sfx2::sidebar::SidebarChildWindow::RegisterChildWindow(false, pMod
);
334 SwNavigatorWrapper::RegisterChildWindow(false, pMod
, SfxChildWindowFlags::NEVERHIDE
);
336 SwJumpToSpecificPageControl::RegisterControl(SID_JUMP_TO_SPECIFIC_PAGE
, pMod
);
339 // Load Module (only dummy for linking of the DLL)
340 void SwModule::InitAttrPool()
342 OSL_ENSURE(!m_pAttrPool
, "Pool already exists!");
343 m_pAttrPool
= new SwAttrPool(nullptr);
344 SetPool(m_pAttrPool
.get());
347 void SwModule::RemoveAttrPool()
353 std::optional
<SfxStyleFamilies
> SwModule::CreateStyleFamilies()
355 SfxStyleFamilies aStyleFamilies
;
357 aStyleFamilies
.emplace_back(SfxStyleFamily::Para
,
358 SwResId(STR_PARAGRAPHSTYLEFAMILY
),
359 BMP_STYLES_FAMILY_PARA
,
360 RID_PARAGRAPHSTYLEFAMILY
, GetResLocale());
362 aStyleFamilies
.emplace_back(SfxStyleFamily::Char
,
363 SwResId(STR_CHARACTERSTYLEFAMILY
),
364 BMP_STYLES_FAMILY_CHAR
,
365 RID_CHARACTERSTYLEFAMILY
, GetResLocale());
367 aStyleFamilies
.emplace_back(SfxStyleFamily::Frame
,
368 SwResId(STR_FRAMESTYLEFAMILY
),
369 BMP_STYLES_FAMILY_FRAME
,
370 RID_FRAMESTYLEFAMILY
, GetResLocale());
372 aStyleFamilies
.emplace_back(SfxStyleFamily::Page
,
373 SwResId(STR_PAGESTYLEFAMILY
),
374 BMP_STYLES_FAMILY_PAGE
,
375 RID_PAGESTYLEFAMILY
, GetResLocale());
377 aStyleFamilies
.emplace_back(SfxStyleFamily::Pseudo
,
378 SwResId(STR_LISTSTYLEFAMILY
),
379 BMP_STYLES_FAMILY_LIST
,
380 RID_LISTSTYLEFAMILY
, GetResLocale());
382 aStyleFamilies
.emplace_back(SfxStyleFamily::Table
,
383 SwResId(STR_TABLESTYLEFAMILY
),
384 BMP_STYLES_FAMILY_TABLE
,
385 RID_TABLESTYLEFAMILY
, GetResLocale());
387 return aStyleFamilies
;
390 void SwModule::RegisterAutomationApplicationEventsCaller(css::uno::Reference
< ooo::vba::XSinkCaller
> const& xCaller
)
392 mxAutomationApplicationEventsCaller
= xCaller
;
395 void SwModule::CallAutomationApplicationEventSinks(const OUString
& Method
, css::uno::Sequence
< css::uno::Any
>& Arguments
)
397 if (mxAutomationApplicationEventsCaller
.is())
398 mxAutomationApplicationEventsCaller
->CallSinks(Method
, Arguments
);
401 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */