Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <svx/svdobj.hxx>
30 : : #include <rtl/logfile.hxx>
31 : :
32 : : #include "globdoc.hrc"
33 : :
34 : : #include <swdll.hxx>
35 : : #include <wdocsh.hxx>
36 : : #include <globdoc.hxx>
37 : : #include <initui.hxx>
38 : : #include <swmodule.hxx>
39 : : #include <swtypes.hxx>
40 : : #include <init.hxx>
41 : : #include <dobjfac.hxx>
42 : : #include <cfgid.h>
43 : :
44 : : #include <unotools/moduleoptions.hxx>
45 : : #include <comphelper/scoped_disposing_ptr.hxx>
46 : : #include <comphelper/processfactory.hxx>
47 : :
48 : : #include <svx/fmobjfac.hxx>
49 : : #include <svx/svdfield.hxx>
50 : : #include <svx/objfac3d.hxx>
51 : :
52 : : #include <unomid.h>
53 : :
54 : : #include "swdllimpl.hxx"
55 : :
56 : : namespace
57 : : {
58 : : //Holds a SwDLL and release it on exit, or dispose of the
59 : : //default XComponent, whichever comes first
60 [ - + ]: 73 : class SwDLLInstance : public comphelper::scoped_disposing_solar_mutex_reset_ptr<SwDLL>
61 : : {
62 : : public:
63 [ + - ][ + - ]: 73 : SwDLLInstance() : comphelper::scoped_disposing_solar_mutex_reset_ptr<SwDLL>(::com::sun::star::uno::Reference<com::sun::star::lang::XComponent>(comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop"))), ::com::sun::star::uno::UNO_QUERY_THROW), new SwDLL)
[ + - ][ + - ]
[ + - ][ + - ]
64 : : {
65 : 73 : }
66 : : };
67 : :
68 : : struct theSwDLLInstance : public rtl::Static<SwDLLInstance, theSwDLLInstance> {};
69 : : }
70 : :
71 : : namespace SwGlobals
72 : : {
73 : 1352 : void ensure()
74 : : {
75 : 1352 : theSwDLLInstance::get();
76 : 1352 : }
77 : :
78 : 21 : sw::Filters & getFilters()
79 : : {
80 : 21 : return theSwDLLInstance::get().get()->getFilters();
81 : : }
82 : : }
83 : :
84 : 73 : SwDLL::SwDLL()
85 : : {
86 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDLL" );
87 : :
88 : : // the SdModule must be created
89 [ + - ]: 73 : SwModule** ppShlPtr = (SwModule**) GetAppData(SHL_WRITER);
90 [ + - ]: 73 : if ( *ppShlPtr )
91 : 73 : return;
92 : :
93 [ + - ]: 73 : SvtModuleOptions aOpt;
94 : 73 : SfxObjectFactory* pDocFact = 0;
95 : 73 : SfxObjectFactory* pGlobDocFact = 0;
96 [ + - ][ + + ]: 73 : if ( aOpt.IsWriter() )
97 : : {
98 [ + - ]: 67 : pDocFact = &SwDocShell::Factory();
99 [ + - ]: 67 : pGlobDocFact = &SwGlobalDocShell::Factory();
100 : : }
101 : :
102 [ + - ]: 73 : SfxObjectFactory* pWDocFact = &SwWebDocShell::Factory();
103 : :
104 [ + - ][ + - ]: 73 : SwModule* pModule = new SwModule( pWDocFact, pDocFact, pGlobDocFact );
105 : 73 : *ppShlPtr = pModule;
106 : :
107 [ + - ]: 73 : pWDocFact->SetDocumentServiceName(rtl::OUString("com.sun.star.text.WebDocument"));
108 : :
109 [ + + ][ + - ]: 73 : if ( aOpt.IsWriter() )
110 : : {
111 [ + - ]: 67 : pGlobDocFact->SetDocumentServiceName(rtl::OUString("com.sun.star.text.GlobalDocument"));
112 [ + - ]: 67 : pDocFact->SetDocumentServiceName(rtl::OUString("com.sun.star.text.TextDocument"));
113 : : }
114 : :
115 : : // register SvDraw-Fields
116 [ + - ]: 73 : SdrRegisterFieldClasses();
117 : :
118 : : // register 3D-Objekt-Factory
119 [ + - ][ + - ]: 73 : E3dObjFactory();
120 : :
121 : : // register form::component::Form-Objekt-Factory
122 [ + - ][ + - ]: 73 : FmFormObjFactory();
123 : :
124 [ + - ][ + - ]: 73 : SdrObjFactory::InsertMakeObjectHdl( LINK( &aSwObjectFactory, SwObjectFactory, MakeObject ) );
125 : :
126 : : RTL_LOGFILE_CONTEXT_TRACE( aLog, "Init Core/UI/Filter" );
127 : :
128 : : // Initialisation of Statics
129 [ + - ]: 73 : ::_InitCore();
130 [ + - ][ + - ]: 73 : filters_.reset(new sw::Filters);
[ + - ]
131 [ + - ]: 73 : ::_InitUI();
132 : :
133 [ + - ]: 73 : pModule->InitAttrPool();
134 : : // now SWModule can create its Pool
135 : :
136 : : // register your view-factories here
137 [ + - ]: 73 : RegisterFactories();
138 : :
139 : : // register your shell-interfaces here
140 [ + - ]: 73 : RegisterInterfaces();
141 : :
142 : : // register your controllers here
143 [ + - ][ + - ]: 73 : RegisterControls();
144 : : }
145 : :
146 [ + - ]: 73 : SwDLL::~SwDLL()
147 : : {
148 : : // Pool has to be deleted before statics are
149 [ + - ][ + - ]: 73 : SW_MOD()->RemoveAttrPool();
150 : :
151 [ + - ]: 73 : ::_FinitUI();
152 [ + - ]: 73 : filters_.reset();
153 [ + - ]: 73 : ::_FinitCore();
154 : : // sign out Objekt-Factory
155 [ + - ][ + - ]: 73 : SdrObjFactory::RemoveMakeObjectHdl(LINK(&aSwObjectFactory, SwObjectFactory, MakeObject ));
156 : : #if 0
157 : : // the SwModule must be destroyed
158 : : SwModule** ppShlPtr = (SwModule**) GetAppData(SHL_WRITER);
159 : : delete (*ppShlPtr);
160 : : (*ppShlPtr) = NULL;
161 : : #endif
162 : 73 : }
163 : :
164 : 21 : sw::Filters & SwDLL::getFilters()
165 : : {
166 : : OSL_ASSERT(filters_);
167 : 21 : return *filters_.get();
168 : : }
169 : :
170 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|