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