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  {
72  }
73 
75  {
76  return theSwDLLInstance::get()->getFilters();
77  }
78 }
79 
81  : m_pAutoCorrCfg(nullptr)
82 {
83  if ( SfxApplication::GetModule(SfxToolsModule::Writer) ) // Module already active
84  return;
85 
86  std::unique_ptr<SvtModuleOptions> xOpt;
88  xOpt.reset(new SvtModuleOptions);
89  SfxObjectFactory* pDocFact = nullptr;
90  SfxObjectFactory* pGlobDocFact = nullptr;
91  if (!xOpt || xOpt->IsWriter())
92  {
93  pDocFact = &SwDocShell::Factory();
94  pGlobDocFact = &SwGlobalDocShell::Factory();
95  }
96 
97  SfxObjectFactory* pWDocFact = &SwWebDocShell::Factory();
98 
99  auto pUniqueModule = std::make_unique<SwModule>(pWDocFact, pDocFact, pGlobDocFact);
100  SwModule* pModule = pUniqueModule.get();
101  SfxApplication::SetModule(SfxToolsModule::Writer, std::move(pUniqueModule));
102 
103  pWDocFact->SetDocumentServiceName("com.sun.star.text.WebDocument");
104 
105  if (!xOpt || xOpt->IsWriter())
106  {
107  pGlobDocFact->SetDocumentServiceName("com.sun.star.text.GlobalDocument");
108  pDocFact->SetDocumentServiceName("com.sun.star.text.TextDocument");
109  }
110 
111  // register 3D-object-Factory
112  E3dObjFactory();
113 
114  // register form::component::Form-object-Factory
116 
118 
119  SAL_INFO( "sw.ui", "Init Core/UI/Filter" );
120  // Initialisation of Statics
121  ::InitCore();
122  filters_.reset(new sw::Filters);
123  ::InitUI();
124 
125  pModule->InitAttrPool();
126  // now SWModule can create its Pool
127 
128  // register your view-factories here
130 
131  // register your shell-interfaces here
133 
134  // register your controllers here
136 
138  {
139  // replace SvxAutocorrect with SwAutocorrect
141  const SvxAutoCorrect* pOld = rACfg.GetAutoCorrect();
142  rACfg.SetAutoCorrect(new SwAutoCorrect( *pOld ));
143  m_pAutoCorrCfg = &rACfg;
144  }
145 }
146 
147 SwDLL::~SwDLL() COVERITY_NOEXCEPT_FALSE
148 {
149  if (m_pAutoCorrCfg)
150  {
151  // fdo#86494 SwAutoCorrect must be deleted before FinitCore
152  m_pAutoCorrCfg->SetAutoCorrect(nullptr); // delete SwAutoCorrect before exit handlers
153  }
154 
155  // Pool has to be deleted before statics are
156  SW_MOD()->RemoveAttrPool();
157 
158  ::FinitUI();
159  filters_.reset();
160  ::FinitCore();
161  // sign out object-Factory
163 }
164 
166 {
167  assert(filters_);
168  return *filters_;
169 }
170 
171 #ifndef DISABLE_DYNLOADING
172 
173 extern "C" SAL_DLLPUBLIC_EXPORT
175 {
177 }
178 
179 #endif
180 
181 /* 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:24
void SetAutoCorrect(SvxAutoCorrect *)
static void RegisterControls()
Definition: swmodule.cxx:283
Reference
SvxAutoCorrCfg * m_pAutoCorrCfg
Definition: swdllimpl.hxx:40
static void InsertMakeObjectHdl(Link< SdrObjCreatorParams, SdrObject * > const &rLink)
SwDLL()
Definition: swdll.cxx:80
static void SetModule(SfxToolsModule nSharedLib, std::unique_ptr< SfxModule > pModule)
sw::Filters & getFilters()
Definition: swdll.cxx:74
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:246
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:147
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
SAL_DLLPUBLIC_EXPORT void lok_preload_hook()
Definition: swdll.cxx:174
static void RemoveMakeObjectHdl(Link< SdrObjCreatorParams, SdrObject * > const &rLink)
static void RegisterFactories()
Definition: swmodule.cxx:228
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:165
void SetDocumentServiceName(const OUString &rServiceName)
static SfxModule * GetModule(SfxToolsModule nSharedLib)