LibreOffice Module sw (master) 1
swdll.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 <memory>
21
22#include <svx/svdobj.hxx>
23
24#include <swdll.hxx>
25#include <wdocsh.hxx>
26#include <globdoc.hxx>
27#include <initui.hxx>
28#include <swmodule.hxx>
29#include <init.hxx>
30#include <dobjfac.hxx>
31
32#include <com/sun/star/frame/Desktop.hpp>
37
38#include <sal/log.hxx>
39#include <svx/fmobjfac.hxx>
40#include <svx/objfac3d.hxx>
41#include <editeng/acorrcfg.hxx>
42
43#include <swacorr.hxx>
44#include <swabstdlg.hxx>
45
46#include "swdllimpl.hxx"
47
48using namespace com::sun::star;
49
50namespace
51{
52 //Holds a SwDLL and release it on exit, or dispose of the
53 //default XComponent, whichever comes first
54 class SwDLLInstance : public comphelper::unique_disposing_solar_mutex_reset_ptr<SwDLL>
55 {
56 public:
57 SwDLLInstance() : comphelper::unique_disposing_solar_mutex_reset_ptr<SwDLL>(uno::Reference<lang::XComponent>( frame::Desktop::create(comphelper::getProcessComponentContext()), uno::UNO_QUERY_THROW), new SwDLL, true)
58 {
59 }
60 };
61
62 struct theSwDLLInstance : public rtl::Static<SwDLLInstance, theSwDLLInstance> {};
63}
64
65namespace SwGlobals
66{
67 void ensure()
68 {
69 // coverity[side_effect_free : FALSE] - not actually side-effect-free
71 }
72
74 {
75 return theSwDLLInstance::get()->getFilters();
76 }
77}
78
80 : m_pAutoCorrCfg(nullptr)
81{
82 if ( SfxApplication::GetModule(SfxToolsModule::Writer) ) // Module already active
83 return;
84
85 std::unique_ptr<SvtModuleOptions> xOpt;
87 xOpt.reset(new SvtModuleOptions);
88 SfxObjectFactory* pDocFact = nullptr;
89 SfxObjectFactory* pGlobDocFact = nullptr;
90 if (!xOpt || xOpt->IsWriter())
91 {
92 pDocFact = &SwDocShell::Factory();
93 pGlobDocFact = &SwGlobalDocShell::Factory();
94 }
95
96 SfxObjectFactory* pWDocFact = &SwWebDocShell::Factory();
97
98 auto pUniqueModule = std::make_unique<SwModule>(pWDocFact, pDocFact, pGlobDocFact);
99 SwModule* pModule = pUniqueModule.get();
100 SfxApplication::SetModule(SfxToolsModule::Writer, std::move(pUniqueModule));
101
102 pWDocFact->SetDocumentServiceName("com.sun.star.text.WebDocument");
103
104 if (!xOpt || xOpt->IsWriter())
105 {
106 pGlobDocFact->SetDocumentServiceName("com.sun.star.text.GlobalDocument");
107 pDocFact->SetDocumentServiceName("com.sun.star.text.TextDocument");
108 }
109
110 // register 3D-object-Factory
112
113 // register form::component::Form-object-Factory
115
117
118 SAL_INFO( "sw.ui", "Init Core/UI/Filter" );
119 // Initialisation of Statics
120 ::InitCore();
121 m_pFilters.reset(new sw::Filters);
122 ::InitUI();
123
124 pModule->InitAttrPool();
125 // now SWModule can create its Pool
126
127 // register your view-factories here
129
130 // register your shell-interfaces here
132
133 // register your controllers here
135
137 {
138 // replace SvxAutocorrect with SwAutocorrect
140 const SvxAutoCorrect* pOld = rACfg.GetAutoCorrect();
141 rACfg.SetAutoCorrect(new SwAutoCorrect( *pOld ));
142 m_pAutoCorrCfg = &rACfg;
143 }
144}
145
146SwDLL::~SwDLL() COVERITY_NOEXCEPT_FALSE
147{
148 if (m_pAutoCorrCfg)
149 {
150 // fdo#86494 SwAutoCorrect must be deleted before FinitCore
151 m_pAutoCorrCfg->SetAutoCorrect(nullptr); // delete SwAutoCorrect before exit handlers
152 }
153
154 // Pool has to be deleted before statics are
155 SW_MOD()->RemoveAttrPool();
156
157 ::FinitUI();
158 m_pFilters.reset();
159 ::FinitCore();
160 // sign out object-Factory
162}
163
165{
166 assert(m_pFilters);
167 return *m_pFilters;
168}
169
170#ifndef DISABLE_DYNLOADING
171
172extern "C" SAL_DLLPUBLIC_EXPORT
174{
176}
177
178#endif
179
180/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void InsertMakeObjectHdl(Link< SdrObjCreatorParams, rtl::Reference< SdrObject > > const &rLink)
static void RemoveMakeObjectHdl(Link< SdrObjCreatorParams, rtl::Reference< SdrObject > > const &rLink)
static void SetModule(SfxToolsModule nSharedLib, std::unique_ptr< SfxModule > pModule)
static SfxModule * GetModule(SfxToolsModule nSharedLib)
void SetDocumentServiceName(const OUString &rServiceName)
SvxAutoCorrect * GetAutoCorrect()
static SvxAutoCorrCfg & Get()
void SetAutoCorrect(SvxAutoCorrect *)
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
sw::Filters & getFilters()
Definition: swdll.cxx:164
SvxAutoCorrCfg * m_pAutoCorrCfg
Definition: swdllimpl.hxx:43
static void RegisterFactories()
Definition: swmodule.cxx:206
SwDLL()
Definition: swdll.cxx:79
static void RegisterControls()
Definition: swmodule.cxx:261
~SwDLL() COVERITY_NOEXCEPT_FALSE
Definition: swdll.cxx:146
static void RegisterInterfaces()
Definition: swmodule.cxx:224
std::unique_ptr< sw::Filters > m_pFilters
Definition: swdllimpl.hxx:42
void InitAttrPool()
Definition: swmodule.cxx:335
static bool IsFuzzing()
SwObjectFactory aSwObjectFactory
Definition: dobjfac.cxx:24
void InitCore()
Definition: init.cxx:449
void FinitCore()
Definition: init.cxx:668
void InitUI()
Definition: initui.cxx:87
void FinitUI()
Definition: initui.cxx:68
#define SAL_INFO(area, stream)
This class is a wrapper for a Load-On-Demand-DLL.
Definition: swdll.cxx:66
sw::Filters & getFilters()
Definition: swdll.cxx:73
void ensure()
Definition: swdll.cxx:67
Reference< XComponentContext > getProcessComponentContext()
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
Reference
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
SAL_DLLPUBLIC_EXPORT void lok_preload_hook()
Definition: swdll.cxx:173
#define SW_MOD()
Definition: swmodule.hxx:256