LCOV - code coverage report
Current view: top level - sw/source/uibase/app - swdll.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 46 46 100.0 %
Date: 2014-11-03 Functions: 9 10 90.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <config_features.h>
      21             : 
      22             : #include <svx/svdobj.hxx>
      23             : 
      24             : #include "globdoc.hrc"
      25             : 
      26             : #include <swdll.hxx>
      27             : #include <wdocsh.hxx>
      28             : #include <globdoc.hxx>
      29             : #include <initui.hxx>
      30             : #include <swmodule.hxx>
      31             : #include <swtypes.hxx>
      32             : #include <init.hxx>
      33             : #include <dobjfac.hxx>
      34             : #include <cfgid.h>
      35             : 
      36             : #include <com/sun/star/frame/Desktop.hpp>
      37             : #include <unotools/moduleoptions.hxx>
      38             : #include <comphelper/scoped_disposing_ptr.hxx>
      39             : #include <comphelper/processfactory.hxx>
      40             : 
      41             : #include <svx/fmobjfac.hxx>
      42             : #include <svx/svdfield.hxx>
      43             : #include <svx/objfac3d.hxx>
      44             : 
      45             : #include <unomid.h>
      46             : 
      47             : #include "swdllimpl.hxx"
      48             : 
      49             : using namespace com::sun::star;
      50             : 
      51             : namespace
      52             : {
      53             :     //Holds a SwDLL and release it on exit, or dispose of the
      54             :     //default XComponent, whichever comes first
      55          90 :     class SwDLLInstance : public comphelper::scoped_disposing_solar_mutex_reset_ptr<SwDLL>
      56             :     {
      57             :     public:
      58          90 :         SwDLLInstance() : comphelper::scoped_disposing_solar_mutex_reset_ptr<SwDLL>(uno::Reference<lang::XComponent>( frame::Desktop::create(comphelper::getProcessComponentContext()), uno::UNO_QUERY_THROW), new SwDLL)
      59             :         {
      60          90 :         }
      61             :     };
      62             : 
      63             :     struct theSwDLLInstance : public rtl::Static<SwDLLInstance, theSwDLLInstance> {};
      64             : }
      65             : 
      66             : namespace SwGlobals
      67             : {
      68        4774 :     void ensure()
      69             :     {
      70        4774 :         theSwDLLInstance::get();
      71        4774 :     }
      72             : 
      73          54 :     sw::Filters & getFilters()
      74             :     {
      75          54 :         return theSwDLLInstance::get().get()->getFilters();
      76             :     }
      77             : }
      78             : 
      79          90 : SwDLL::SwDLL()
      80             : {
      81             :     // the SdModule must be created
      82          90 :     SwModule** ppShlPtr = (SwModule**) GetAppData(SHL_WRITER);
      83          90 :     if ( *ppShlPtr )
      84          90 :         return;
      85             : 
      86          90 :     SvtModuleOptions aOpt;
      87          90 :     SfxObjectFactory* pDocFact = 0;
      88          90 :     SfxObjectFactory* pGlobDocFact = 0;
      89          90 :     if ( aOpt.IsWriter() )
      90             :     {
      91          90 :         pDocFact = &SwDocShell::Factory();
      92          90 :         pGlobDocFact = &SwGlobalDocShell::Factory();
      93             :     }
      94             : 
      95          90 :     SfxObjectFactory* pWDocFact = &SwWebDocShell::Factory();
      96             : 
      97          90 :     SwModule* pModule = new SwModule( pWDocFact, pDocFact, pGlobDocFact );
      98          90 :     *ppShlPtr = pModule;
      99             : 
     100          90 :     pWDocFact->SetDocumentServiceName(OUString("com.sun.star.text.WebDocument"));
     101             : 
     102          90 :     if ( aOpt.IsWriter() )
     103             :     {
     104          90 :         pGlobDocFact->SetDocumentServiceName(OUString("com.sun.star.text.GlobalDocument"));
     105          90 :         pDocFact->SetDocumentServiceName(OUString("com.sun.star.text.TextDocument"));
     106             :     }
     107             : 
     108             :     // register SvDraw-Fields
     109          90 :     SdrRegisterFieldClasses();
     110             : 
     111             :     // register 3D-Objekt-Factory
     112          90 :     E3dObjFactory();
     113             : 
     114             :     // register form::component::Form-Objekt-Factory
     115          90 :     FmFormObjFactory();
     116             : 
     117          90 :     SdrObjFactory::InsertMakeObjectHdl( LINK( &aSwObjectFactory, SwObjectFactory, MakeObject ) );
     118             : 
     119             :     SAL_INFO( "sw.ui", "Init Core/UI/Filter" );
     120             :     // Initialisation of Statics
     121          90 :     ::_InitCore();
     122          90 :     filters_.reset(new sw::Filters);
     123          90 :     ::_InitUI();
     124             : 
     125          90 :     pModule->InitAttrPool();
     126             :     // now SWModule can create its Pool
     127             : 
     128             :     // register your view-factories here
     129          90 :     RegisterFactories();
     130             : 
     131             : #if HAVE_FEATURE_DESKTOP
     132             :     // register your shell-interfaces here
     133          90 :     RegisterInterfaces();
     134             : 
     135             :     // register your controllers here
     136          90 :     RegisterControls();
     137             : #endif
     138             : }
     139             : 
     140         180 : SwDLL::~SwDLL()
     141             : {
     142             :     // Pool has to be deleted before statics are
     143          90 :     SW_MOD()->RemoveAttrPool();
     144             : 
     145          90 :     ::_FinitUI();
     146          90 :     filters_.reset();
     147          90 :     ::_FinitCore();
     148             :     // sign out Objekt-Factory
     149          90 :     SdrObjFactory::RemoveMakeObjectHdl(LINK(&aSwObjectFactory, SwObjectFactory, MakeObject ));
     150             : #if 0
     151             :     // the SwModule must be destroyed
     152             :     SwModule** ppShlPtr = (SwModule**) GetAppData(SHL_WRITER);
     153             :     delete (*ppShlPtr);
     154             :     (*ppShlPtr) = NULL;
     155             : #endif
     156          90 : }
     157             : 
     158          54 : sw::Filters & SwDLL::getFilters()
     159             : {
     160             :     OSL_ASSERT(filters_);
     161          54 :     return *filters_.get();
     162         270 : }
     163             : 
     164             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10