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>
33 #include <unotools/configmgr.hxx>
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 
48 using namespace com::sun::star;
49 
50 namespace
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 
65 namespace 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
111  E3dObjFactory();
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  filters_.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 
146 SwDLL::~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  filters_.reset();
159  ::FinitCore();
160  // sign out object-Factory
162 }
163 
165 {
166  assert(filters_);
167  return *filters_;
168 }
169 
170 #ifndef DISABLE_DYNLOADING
171 
172 extern "C" SAL_DLLPUBLIC_EXPORT
174 {
176 }
177 
178 #endif
179 
180 /* 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:257
Reference
SvxAutoCorrCfg * m_pAutoCorrCfg
Definition: swdllimpl.hxx:40
static void InsertMakeObjectHdl(Link< SdrObjCreatorParams, SdrObject * > const &rLink)
SwDLL()
Definition: swdll.cxx:79
static void SetModule(SfxToolsModule nSharedLib, std::unique_ptr< SfxModule > pModule)
sw::Filters & getFilters()
Definition: swdll.cxx:73
exports com.sun.star. frame
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
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:65
#define SW_MOD()
Definition: swmodule.hxx:255
static void RegisterInterfaces()
Definition: swmodule.cxx:220
void InitUI()
Definition: initui.cxx:85
void ensure()
Definition: swdll.cxx:67
void FinitCore()
Definition: init.cxx:671
SvxAutoCorrect * GetAutoCorrect()
~SwDLL() COVERITY_NOEXCEPT_FALSE
Definition: swdll.cxx:146
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
SAL_DLLPUBLIC_EXPORT void lok_preload_hook()
Definition: swdll.cxx:173
static void RemoveMakeObjectHdl(Link< SdrObjCreatorParams, SdrObject * > const &rLink)
static void RegisterFactories()
Definition: swmodule.cxx:202
void InitCore()
Definition: init.cxx:454
std::unique_ptr< sw::Filters > filters_
Definition: swdllimpl.hxx:39
exports com.sun.star. lang
#define SAL_INFO(area, stream)
Reference< XComponentContext > getProcessComponentContext()
void FinitUI()
Definition: initui.cxx:66
sw::Filters & getFilters()
Definition: swdll.cxx:164
void SetDocumentServiceName(const OUString &rServiceName)
static SfxModule * GetModule(SfxToolsModule nSharedLib)