xref: /aoo42x/main/sw/source/ui/app/swdll.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2*efeef26fSAndrew Rist  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <svx/svdobj.hxx>
29cdf0e10cSrcweir #include <rtl/logfile.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifndef _GLOBDOC_HRC
32cdf0e10cSrcweir #include "globdoc.hrc"
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #ifndef _SWDLL_HXX
36cdf0e10cSrcweir #include <swdll.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <wdocsh.hxx>
39cdf0e10cSrcweir #include <globdoc.hxx>
40cdf0e10cSrcweir #include <initui.hxx>
41cdf0e10cSrcweir #include <swmodule.hxx>
42cdf0e10cSrcweir #include <swtypes.hxx>
43cdf0e10cSrcweir #include <init.hxx>
44cdf0e10cSrcweir #include <dobjfac.hxx>
45cdf0e10cSrcweir #include <cfgid.h>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #ifndef _FM_FMOBJFAC_HXX
50cdf0e10cSrcweir #include <svx/fmobjfac.hxx>
51cdf0e10cSrcweir #endif
52cdf0e10cSrcweir #include <svx/svdfield.hxx>
53cdf0e10cSrcweir #include <svx/objfac3d.hxx>
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #include <unomid.h>
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 
58cdf0e10cSrcweir /*************************************************************************
59cdf0e10cSrcweir |*
60cdf0e10cSrcweir |* Init
61cdf0e10cSrcweir |*
62cdf0e10cSrcweir \************************************************************************/
63cdf0e10cSrcweir 
Init()64cdf0e10cSrcweir void SwDLL::Init()
65cdf0e10cSrcweir {
66cdf0e10cSrcweir 	RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722",  "SwDLL" );
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 	// the SdModule must be created
69cdf0e10cSrcweir 	SwModule** ppShlPtr = (SwModule**) GetAppData(SHL_WRITER);
70cdf0e10cSrcweir 	if ( *ppShlPtr )
71cdf0e10cSrcweir 		return;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     SvtModuleOptions aOpt;
74cdf0e10cSrcweir     SfxObjectFactory* pDocFact = 0;
75cdf0e10cSrcweir     SfxObjectFactory* pGlobDocFact = 0;
76cdf0e10cSrcweir 	if ( aOpt.IsWriter() )
77cdf0e10cSrcweir 	{
78cdf0e10cSrcweir 		pDocFact = &SwDocShell::Factory();
79cdf0e10cSrcweir 		pGlobDocFact = &SwGlobalDocShell::Factory();
80cdf0e10cSrcweir 	}
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	SfxObjectFactory* pWDocFact = &SwWebDocShell::Factory();
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     SwModule* pModule = new SwModule( pWDocFact, pDocFact, pGlobDocFact );
85cdf0e10cSrcweir 	(*ppShlPtr) = pModule;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     pWDocFact->SetDocumentServiceName(C2S("com.sun.star.text.WebDocument"));
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     if ( aOpt.IsWriter() )
90cdf0e10cSrcweir     {
91cdf0e10cSrcweir         pGlobDocFact->SetDocumentServiceName(C2S("com.sun.star.text.GlobalDocument"));
92cdf0e10cSrcweir         pDocFact->SetDocumentServiceName(C2S("com.sun.star.text.TextDocument"));
93cdf0e10cSrcweir     }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     // SvDraw-Felder registrieren
96cdf0e10cSrcweir     SdrRegisterFieldClasses();
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     // 3D-Objekt-Factory eintragen
99cdf0e10cSrcweir     E3dObjFactory();
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     // form::component::Form-Objekt-Factory eintragen
102cdf0e10cSrcweir     FmFormObjFactory();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	SdrObjFactory::InsertMakeObjectHdl( LINK( &aSwObjectFactory, SwObjectFactory, MakeObject ) );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	RTL_LOGFILE_CONTEXT_TRACE( aLog, "Init Core/UI/Filter" );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	//Initialisierung der Statics
109cdf0e10cSrcweir 	::_InitCore();
110cdf0e10cSrcweir 	::_InitFilter();
111cdf0e10cSrcweir 	::_InitUI();
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	pModule->InitAttrPool();
114cdf0e10cSrcweir 	//jetzt darf das SwModule seinen Pool anlegen
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 	// register your view-factories here
117cdf0e10cSrcweir 	RegisterFactories();
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	// register your shell-interfaces here
120cdf0e10cSrcweir 	RegisterInterfaces();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	// register your controllers here
123cdf0e10cSrcweir 	RegisterControls();
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 
128cdf0e10cSrcweir /*************************************************************************
129cdf0e10cSrcweir |*
130cdf0e10cSrcweir |* Exit
131cdf0e10cSrcweir |*
132cdf0e10cSrcweir \************************************************************************/
133cdf0e10cSrcweir 
Exit()134cdf0e10cSrcweir void SwDLL::Exit()
135cdf0e10cSrcweir {
136cdf0e10cSrcweir 	// called directly befor unloading the DLL
137cdf0e10cSrcweir 	// do whatever you want, Sw-DLL is accessible
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	// der Pool muss vor den statics geloescht werden
140cdf0e10cSrcweir 	SW_MOD()->RemoveAttrPool();
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	::_FinitUI();
143cdf0e10cSrcweir 	::_FinitFilter();
144cdf0e10cSrcweir 	::_FinitCore();
145cdf0e10cSrcweir 	// Objekt-Factory austragen
146cdf0e10cSrcweir 	SdrObjFactory::RemoveMakeObjectHdl(LINK(&aSwObjectFactory, SwObjectFactory, MakeObject ));
147cdf0e10cSrcweir    // the SwModule must be destroyed
148cdf0e10cSrcweir 	SwModule** ppShlPtr = (SwModule**) GetAppData(SHL_WRITER);
149cdf0e10cSrcweir 	delete (*ppShlPtr);
150cdf0e10cSrcweir 	(*ppShlPtr) = NULL;
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
153