diff options
Diffstat (limited to 'sw/source/ui/app/swdll.cxx')
-rw-r--r-- | sw/source/ui/app/swdll.cxx | 73 |
1 files changed, 40 insertions, 33 deletions
diff --git a/sw/source/ui/app/swdll.cxx b/sw/source/ui/app/swdll.cxx index 71409e4dedf3..ff22a1c8f2e8 100644 --- a/sw/source/ui/app/swdll.cxx +++ b/sw/source/ui/app/swdll.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -32,13 +33,9 @@ #include <svx/svdobj.hxx> #include <rtl/logfile.hxx> -#ifndef _GLOBDOC_HRC #include "globdoc.hrc" -#endif -#ifndef _SWDLL_HXX #include <swdll.hxx> -#endif #include <wdocsh.hxx> #include <globdoc.hxx> #include <initui.hxx> @@ -49,23 +46,41 @@ #include <cfgid.h> #include <unotools/moduleoptions.hxx> +#include <comphelper/scoped_disposing_ptr.hxx> +#include <comphelper/processfactory.hxx> -#ifndef _FM_FMOBJFAC_HXX #include <svx/fmobjfac.hxx> -#endif #include <svx/svdfield.hxx> #include <svx/objfac3d.hxx> #include <unomid.h> +#include "swdllimpl.hxx" -/************************************************************************* -|* -|* Init -|* -\************************************************************************/ +namespace +{ + //Holds a SwDLL and release it on exit, or dispose of the + //default XComponent, whichever comes first + class SwDLLInstance : public comphelper::scoped_disposing_solar_mutex_reset_ptr<SwDLL> + { + public: + 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) + { + } + }; + + struct theSwDLLInstance : public rtl::Static<SwDLLInstance, theSwDLLInstance> {}; +} -void SwDLL::Init() +namespace SwGlobals +{ + void ensure() + { + theSwDLLInstance::get(); + } +} + +SwDLL::SwDLL() { RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDLL" ); @@ -86,7 +101,7 @@ void SwDLL::Init() SfxObjectFactory* pWDocFact = &SwWebDocShell::Factory(); SwModule* pModule = new SwModule( pWDocFact, pDocFact, pGlobDocFact ); - (*ppShlPtr) = pModule; + *ppShlPtr = pModule; pWDocFact->SetDocumentServiceName(C2S("com.sun.star.text.WebDocument")); @@ -96,26 +111,26 @@ void SwDLL::Init() pDocFact->SetDocumentServiceName(C2S("com.sun.star.text.TextDocument")); } - // SvDraw-Felder registrieren + // register SvDraw-Fields SdrRegisterFieldClasses(); - // 3D-Objekt-Factory eintragen + // register 3D-Objekt-Factory E3dObjFactory(); - // form::component::Form-Objekt-Factory eintragen + // register form::component::Form-Objekt-Factory FmFormObjFactory(); SdrObjFactory::InsertMakeObjectHdl( LINK( &aSwObjectFactory, SwObjectFactory, MakeObject ) ); RTL_LOGFILE_CONTEXT_TRACE( aLog, "Init Core/UI/Filter" ); - //Initialisierung der Statics + // Initialisation of Statics ::_InitCore(); ::_InitFilter(); ::_InitUI(); pModule->InitAttrPool(); - //jetzt darf das SwModule seinen Pool anlegen + // now SWModule can create its Pool // register your view-factories here RegisterFactories(); @@ -127,30 +142,22 @@ void SwDLL::Init() RegisterControls(); } - - -/************************************************************************* -|* -|* Exit -|* -\************************************************************************/ - -void SwDLL::Exit() +SwDLL::~SwDLL() { - // called directly befor unloading the DLL - // do whatever you want, Sw-DLL is accessible - - // der Pool muss vor den statics geloescht werden + // Pool has to be deleted before statics are SW_MOD()->RemoveAttrPool(); ::_FinitUI(); ::_FinitFilter(); ::_FinitCore(); - // Objekt-Factory austragen + // sign out Objekt-Factory SdrObjFactory::RemoveMakeObjectHdl(LINK(&aSwObjectFactory, SwObjectFactory, MakeObject )); - // the SwModule must be destroyed +#if 0 + // the SwModule must be destroyed SwModule** ppShlPtr = (SwModule**) GetAppData(SHL_WRITER); delete (*ppShlPtr); (*ppShlPtr) = NULL; +#endif } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |