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