LCOV - code coverage report
Current view: top level - sw/source/core/uibase/app - swdll.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 45 45 100.0 %
Date: 2014-04-11 Functions: 7 8 87.5 %
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          37 :     class SwDLLInstance : public comphelper::scoped_disposing_solar_mutex_reset_ptr<SwDLL>
      56             :     {
      57             :     public:
      58          37 :         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          37 :         }
      61             :     };
      62             : 
      63             :     struct theSwDLLInstance : public rtl::Static<SwDLLInstance, theSwDLLInstance> {};
      64             : }
      65             : 
      66             : namespace SwGlobals
      67             : {
      68        1746 :     void ensure()
      69             :     {
      70        1746 :         theSwDLLInstance::get();
      71        1746 :     }
      72             : 
      73          21 :     sw::Filters & getFilters()
      74             :     {
      75          21 :         return theSwDLLInstance::get().get()->getFilters();
      76             :     }
      77             : }
      78             : 
      79          37 : SwDLL::SwDLL()
      80             : {
      81             :     // the SdModule must be created
      82          37 :     SwModule** ppShlPtr = (SwModule**) GetAppData(SHL_WRITER);
      83          37 :     if ( *ppShlPtr )
      84          37 :         return;
      85             : 
      86          37 :     SvtModuleOptions aOpt;
      87          37 :     SfxObjectFactory* pDocFact = 0;
      88          37 :     SfxObjectFactory* pGlobDocFact = 0;
      89          37 :     if ( aOpt.IsWriter() )
      90             :     {
      91          37 :         pDocFact = &SwDocShell::Factory();
      92          37 :         pGlobDocFact = &SwGlobalDocShell::Factory();
      93             :     }
      94             : 
      95          37 :     SfxObjectFactory* pWDocFact = &SwWebDocShell::Factory();
      96             : 
      97          37 :     SwModule* pModule = new SwModule( pWDocFact, pDocFact, pGlobDocFact );
      98          37 :     *ppShlPtr = pModule;
      99             : 
     100          37 :     pWDocFact->SetDocumentServiceName(OUString("com.sun.star.text.WebDocument"));
     101             : 
     102          37 :     if ( aOpt.IsWriter() )
     103             :     {
     104          37 :         pGlobDocFact->SetDocumentServiceName(OUString("com.sun.star.text.GlobalDocument"));
     105          37 :         pDocFact->SetDocumentServiceName(OUString("com.sun.star.text.TextDocument"));
     106             :     }
     107             : 
     108             :     // register SvDraw-Fields
     109          37 :     SdrRegisterFieldClasses();
     110             : 
     111             :     // register 3D-Objekt-Factory
     112          37 :     E3dObjFactory();
     113             : 
     114             :     // register form::component::Form-Objekt-Factory
     115          37 :     FmFormObjFactory();
     116             : 
     117          37 :     SdrObjFactory::InsertMakeObjectHdl( LINK( &aSwObjectFactory, SwObjectFactory, MakeObject ) );
     118             : 
     119             :     SAL_INFO( "sw.ui", "Init Core/UI/Filter" );
     120             :     // Initialisation of Statics
     121          37 :     ::_InitCore();
     122          37 :     filters_.reset(new sw::Filters);
     123          37 :     ::_InitUI();
     124             : 
     125          37 :     pModule->InitAttrPool();
     126             :     // now SWModule can create its Pool
     127             : 
     128             :     // register your view-factories here
     129          37 :     RegisterFactories();
     130             : 
     131             : #if HAVE_FEATURE_DESKTOP
     132             :     // register your shell-interfaces here
     133          37 :     RegisterInterfaces();
     134             : 
     135             :     // register your controllers here
     136          37 :     RegisterControls();
     137             : #endif
     138             : }
     139             : 
     140          74 : SwDLL::~SwDLL()
     141             : {
     142             :     // Pool has to be deleted before statics are
     143          37 :     SW_MOD()->RemoveAttrPool();
     144             : 
     145          37 :     ::_FinitUI();
     146          37 :     filters_.reset();
     147          37 :     ::_FinitCore();
     148             :     // sign out Objekt-Factory
     149          37 :     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          37 : }
     157             : 
     158          21 : sw::Filters & SwDLL::getFilters()
     159             : {
     160             :     OSL_ASSERT(filters_);
     161          21 :     return *filters_.get();
     162             : }
     163             : 
     164             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10