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 SwDLLInstance& theSwDLLInstance()
63 {
64 static SwDLLInstance aInstance;
65 return aInstance;
66 }
67}
68
69namespace SwGlobals
70{
71 void ensure()
72 {
73 // coverity[side_effect_free : FALSE] - not actually side-effect-free
74 theSwDLLInstance();
75 }
76
78 {
79 return theSwDLLInstance()->getFilters();
80 }
81}
82
84 : m_pAutoCorrCfg(nullptr)
85{
86 if ( SfxApplication::GetModule(SfxToolsModule::Writer) ) // Module already active
87 return;
88
89 std::unique_ptr<SvtModuleOptions> xOpt;
91 xOpt.reset(new SvtModuleOptions);
92 SfxObjectFactory* pDocFact = nullptr;
93 SfxObjectFactory* pGlobDocFact = nullptr;
94 if (!xOpt || xOpt->IsWriter())
95 {
96 pDocFact = &SwDocShell::Factory();
97 pGlobDocFact = &SwGlobalDocShell::Factory();
98 }
99
100 SfxObjectFactory* pWDocFact = &SwWebDocShell::Factory();
101
102 auto pUniqueModule = std::make_unique<SwModule>(pWDocFact, pDocFact, pGlobDocFact);
103 SwModule* pModule = pUniqueModule.get();
104 SfxApplication::SetModule(SfxToolsModule::Writer, std::move(pUniqueModule));
105
106 pWDocFact->SetDocumentServiceName("com.sun.star.text.WebDocument");
107
108 if (!xOpt || xOpt->IsWriter())
109 {
110 pGlobDocFact->SetDocumentServiceName("com.sun.star.text.GlobalDocument");
111 pDocFact->SetDocumentServiceName("com.sun.star.text.TextDocument");
112 }
113
114 // register 3D-object-Factory
116
117 // register form::component::Form-object-Factory
119
121
122 SAL_INFO( "sw.ui", "Init Core/UI/Filter" );
123 // Initialisation of Statics
124 ::InitCore();
125 m_pFilters.reset(new sw::Filters);
126 ::InitUI();
127
128 pModule->InitAttrPool();
129 // now SWModule can create its Pool
130
131 // register your view-factories here
133
134 // register your shell-interfaces here
136
137 // register your controllers here
139
141 {
142 // replace SvxAutocorrect with SwAutocorrect
144 const SvxAutoCorrect* pOld = rACfg.GetAutoCorrect();
145 rACfg.SetAutoCorrect(new SwAutoCorrect( *pOld ));
146 m_pAutoCorrCfg = &rACfg;
147 }
148}
149
150SwDLL::~SwDLL() COVERITY_NOEXCEPT_FALSE
151{
152 if (m_pAutoCorrCfg)
153 {
154 // fdo#86494 SwAutoCorrect must be deleted before FinitCore
155 m_pAutoCorrCfg->SetAutoCorrect(nullptr); // delete SwAutoCorrect before exit handlers
156 }
157
158 // Pool has to be deleted before statics are
159 SW_MOD()->RemoveAttrPool();
160
161 ::FinitUI();
162 m_pFilters.reset();
163 ::FinitCore();
164 // sign out object-Factory
166}
167
169{
170 assert(m_pFilters);
171 return *m_pFilters;
172}
173
174#ifndef DISABLE_DYNLOADING
175
176extern "C" SAL_DLLPUBLIC_EXPORT
178{
180}
181
182#endif
183
184/* 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:168
SvxAutoCorrCfg * m_pAutoCorrCfg
Definition: swdllimpl.hxx:43
static void RegisterFactories()
Definition: swmodule.cxx:210
SwDLL()
Definition: swdll.cxx:83
static void RegisterControls()
Definition: swmodule.cxx:265
~SwDLL() COVERITY_NOEXCEPT_FALSE
Definition: swdll.cxx:150
static void RegisterInterfaces()
Definition: swmodule.cxx:228
std::unique_ptr< sw::Filters > m_pFilters
Definition: swdllimpl.hxx:42
void InitAttrPool()
Definition: swmodule.cxx:340
static bool IsFuzzing()
SwObjectFactory aSwObjectFactory
Definition: dobjfac.cxx:24
void InitCore()
Definition: init.cxx:459
void FinitCore()
Definition: init.cxx:684
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:70
sw::Filters & getFilters()
Definition: swdll.cxx:77
void ensure()
Definition: swdll.cxx:71
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
SAL_DLLPUBLIC_EXPORT void lok_preload_hook()
Definition: swdll.cxx:177
#define SW_MOD()
Definition: swmodule.hxx:254