Line data Source code
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 <svx/svdobj.hxx>
21 : #include <rtl/logfile.hxx>
22 :
23 : #include "globdoc.hrc"
24 :
25 : #include <swdll.hxx>
26 : #include <wdocsh.hxx>
27 : #include <globdoc.hxx>
28 : #include <initui.hxx>
29 : #include <swmodule.hxx>
30 : #include <swtypes.hxx>
31 : #include <init.hxx>
32 : #include <dobjfac.hxx>
33 : #include <cfgid.h>
34 :
35 : #include <com/sun/star/frame/Desktop.hpp>
36 : #include <unotools/moduleoptions.hxx>
37 : #include <comphelper/scoped_disposing_ptr.hxx>
38 : #include <comphelper/processfactory.hxx>
39 :
40 : #include <svx/fmobjfac.hxx>
41 : #include <svx/svdfield.hxx>
42 : #include <svx/objfac3d.hxx>
43 :
44 : #include <unomid.h>
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 10 : class SwDLLInstance : public comphelper::scoped_disposing_solar_mutex_reset_ptr<SwDLL>
55 : {
56 : public:
57 10 : SwDLLInstance() : comphelper::scoped_disposing_solar_mutex_reset_ptr<SwDLL>(uno::Reference<lang::XComponent>( frame::Desktop::create(comphelper::getProcessComponentContext()), uno::UNO_QUERY_THROW), new SwDLL)
58 : {
59 10 : }
60 : };
61 :
62 : struct theSwDLLInstance : public rtl::Static<SwDLLInstance, theSwDLLInstance> {};
63 : }
64 :
65 : namespace SwGlobals
66 : {
67 247 : void ensure()
68 : {
69 247 : theSwDLLInstance::get();
70 247 : }
71 :
72 3 : sw::Filters & getFilters()
73 : {
74 3 : return theSwDLLInstance::get().get()->getFilters();
75 : }
76 : }
77 :
78 10 : SwDLL::SwDLL()
79 : {
80 : RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDLL" );
81 :
82 : // the SdModule must be created
83 10 : SwModule** ppShlPtr = (SwModule**) GetAppData(SHL_WRITER);
84 10 : if ( *ppShlPtr )
85 10 : return;
86 :
87 10 : SvtModuleOptions aOpt;
88 10 : SfxObjectFactory* pDocFact = 0;
89 10 : SfxObjectFactory* pGlobDocFact = 0;
90 10 : if ( aOpt.IsWriter() )
91 : {
92 8 : pDocFact = &SwDocShell::Factory();
93 8 : pGlobDocFact = &SwGlobalDocShell::Factory();
94 : }
95 :
96 10 : SfxObjectFactory* pWDocFact = &SwWebDocShell::Factory();
97 :
98 10 : SwModule* pModule = new SwModule( pWDocFact, pDocFact, pGlobDocFact );
99 10 : *ppShlPtr = pModule;
100 :
101 10 : pWDocFact->SetDocumentServiceName(rtl::OUString("com.sun.star.text.WebDocument"));
102 :
103 10 : if ( aOpt.IsWriter() )
104 : {
105 8 : pGlobDocFact->SetDocumentServiceName(rtl::OUString("com.sun.star.text.GlobalDocument"));
106 8 : pDocFact->SetDocumentServiceName(rtl::OUString("com.sun.star.text.TextDocument"));
107 : }
108 :
109 : // register SvDraw-Fields
110 10 : SdrRegisterFieldClasses();
111 :
112 : // register 3D-Objekt-Factory
113 10 : E3dObjFactory();
114 :
115 : // register form::component::Form-Objekt-Factory
116 10 : FmFormObjFactory();
117 :
118 10 : SdrObjFactory::InsertMakeObjectHdl( LINK( &aSwObjectFactory, SwObjectFactory, MakeObject ) );
119 :
120 : RTL_LOGFILE_CONTEXT_TRACE( aLog, "Init Core/UI/Filter" );
121 :
122 : // Initialisation of Statics
123 10 : ::_InitCore();
124 10 : filters_.reset(new sw::Filters);
125 10 : ::_InitUI();
126 :
127 10 : pModule->InitAttrPool();
128 : // now SWModule can create its Pool
129 :
130 : // register your view-factories here
131 10 : RegisterFactories();
132 :
133 : // register your shell-interfaces here
134 10 : RegisterInterfaces();
135 :
136 : // register your controllers here
137 10 : RegisterControls();
138 : }
139 :
140 20 : SwDLL::~SwDLL()
141 : {
142 : // Pool has to be deleted before statics are
143 10 : SW_MOD()->RemoveAttrPool();
144 :
145 10 : ::_FinitUI();
146 10 : filters_.reset();
147 10 : ::_FinitCore();
148 : // sign out Objekt-Factory
149 10 : SdrObjFactory::RemoveMakeObjectHdl(LINK(&aSwObjectFactory, SwObjectFactory, MakeObject ));
150 : #if 0
151 : // the SwModule must be destroyed
152 : SwModule** ppShlPtr = (SwModule**) GetAppData(SHL_WRITER);
153 : delete (*ppShlPtr);
154 : (*ppShlPtr) = NULL;
155 : #endif
156 10 : }
157 :
158 3 : sw::Filters & SwDLL::getFilters()
159 : {
160 : OSL_ASSERT(filters_);
161 3 : return *filters_.get();
162 : }
163 :
164 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|