xref: /trunk/main/sw/source/ui/app/swdll.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 
32 #include <svx/svdobj.hxx>
33 #include <rtl/logfile.hxx>
34 
35 #ifndef _GLOBDOC_HRC
36 #include "globdoc.hrc"
37 #endif
38 
39 #ifndef _SWDLL_HXX
40 #include <swdll.hxx>
41 #endif
42 #include <wdocsh.hxx>
43 #include <globdoc.hxx>
44 #include <initui.hxx>
45 #include <swmodule.hxx>
46 #include <swtypes.hxx>
47 #include <init.hxx>
48 #include <dobjfac.hxx>
49 #include <cfgid.h>
50 
51 #include <unotools/moduleoptions.hxx>
52 
53 #ifndef _FM_FMOBJFAC_HXX
54 #include <svx/fmobjfac.hxx>
55 #endif
56 #include <svx/svdfield.hxx>
57 #include <svx/objfac3d.hxx>
58 
59 #include <unomid.h>
60 
61 
62 /*************************************************************************
63 |*
64 |* Init
65 |*
66 \************************************************************************/
67 
68 void SwDLL::Init()
69 {
70     RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722",  "SwDLL" );
71 
72     // the SdModule must be created
73     SwModule** ppShlPtr = (SwModule**) GetAppData(SHL_WRITER);
74     if ( *ppShlPtr )
75         return;
76 
77     SvtModuleOptions aOpt;
78     SfxObjectFactory* pDocFact = 0;
79     SfxObjectFactory* pGlobDocFact = 0;
80     if ( aOpt.IsWriter() )
81     {
82         pDocFact = &SwDocShell::Factory();
83         pGlobDocFact = &SwGlobalDocShell::Factory();
84     }
85 
86     SfxObjectFactory* pWDocFact = &SwWebDocShell::Factory();
87 
88     SwModule* pModule = new SwModule( pWDocFact, pDocFact, pGlobDocFact );
89     (*ppShlPtr) = pModule;
90 
91     pWDocFact->SetDocumentServiceName(C2S("com.sun.star.text.WebDocument"));
92 
93     if ( aOpt.IsWriter() )
94     {
95         pGlobDocFact->SetDocumentServiceName(C2S("com.sun.star.text.GlobalDocument"));
96         pDocFact->SetDocumentServiceName(C2S("com.sun.star.text.TextDocument"));
97     }
98 
99     // SvDraw-Felder registrieren
100     SdrRegisterFieldClasses();
101 
102     // 3D-Objekt-Factory eintragen
103     E3dObjFactory();
104 
105     // form::component::Form-Objekt-Factory eintragen
106     FmFormObjFactory();
107 
108     SdrObjFactory::InsertMakeObjectHdl( LINK( &aSwObjectFactory, SwObjectFactory, MakeObject ) );
109 
110     RTL_LOGFILE_CONTEXT_TRACE( aLog, "Init Core/UI/Filter" );
111 
112     //Initialisierung der Statics
113     ::_InitCore();
114     ::_InitFilter();
115     ::_InitUI();
116 
117     pModule->InitAttrPool();
118     //jetzt darf das SwModule seinen Pool anlegen
119 
120     // register your view-factories here
121     RegisterFactories();
122 
123     // register your shell-interfaces here
124     RegisterInterfaces();
125 
126     // register your controllers here
127     RegisterControls();
128 }
129 
130 
131 
132 /*************************************************************************
133 |*
134 |* Exit
135 |*
136 \************************************************************************/
137 
138 void SwDLL::Exit()
139 {
140     // called directly befor unloading the DLL
141     // do whatever you want, Sw-DLL is accessible
142 
143     // der Pool muss vor den statics geloescht werden
144     SW_MOD()->RemoveAttrPool();
145 
146     ::_FinitUI();
147     ::_FinitFilter();
148     ::_FinitCore();
149     // Objekt-Factory austragen
150     SdrObjFactory::RemoveMakeObjectHdl(LINK(&aSwObjectFactory, SwObjectFactory, MakeObject ));
151    // the SwModule must be destroyed
152     SwModule** ppShlPtr = (SwModule**) GetAppData(SHL_WRITER);
153     delete (*ppShlPtr);
154     (*ppShlPtr) = NULL;
155 }
156 
157