LCOV - code coverage report
Current view: top level - sw/source/uibase/app - swdll.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 50 50 100.0 %
Date: 2015-06-13 12:38:46 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/unique_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             : #include <editeng/acorrcfg.hxx>
      45             : 
      46             : #include <swacorr.hxx>
      47             : #include <unomid.h>
      48             : 
      49             : #include "swdllimpl.hxx"
      50             : 
      51             : using namespace com::sun::star;
      52             : 
      53             : namespace
      54             : {
      55             :     //Holds a SwDLL and release it on exit, or dispose of the
      56             :     //default XComponent, whichever comes first
      57          59 :     class SwDLLInstance : public comphelper::unique_disposing_solar_mutex_reset_ptr<SwDLL>
      58             :     {
      59             :     public:
      60          59 :         SwDLLInstance() : comphelper::unique_disposing_solar_mutex_reset_ptr<SwDLL>(uno::Reference<lang::XComponent>( frame::Desktop::create(comphelper::getProcessComponentContext()), uno::UNO_QUERY_THROW), new SwDLL)
      61             :         {
      62          59 :         }
      63             :     };
      64             : 
      65             :     struct theSwDLLInstance : public rtl::Static<SwDLLInstance, theSwDLLInstance> {};
      66             : }
      67             : 
      68             : namespace SwGlobals
      69             : {
      70        2765 :     void ensure()
      71             :     {
      72        2765 :         theSwDLLInstance::get();
      73        2765 :     }
      74             : 
      75          43 :     sw::Filters & getFilters()
      76             :     {
      77          43 :         return theSwDLLInstance::get().get()->getFilters();
      78             :     }
      79             : }
      80             : 
      81          59 : SwDLL::SwDLL()
      82             : {
      83             :     // the SdModule must be created
      84          59 :     SwModule** ppShlPtr = reinterpret_cast<SwModule**>(GetAppData(SHL_WRITER));
      85          59 :     if ( *ppShlPtr )
      86          59 :         return;
      87             : 
      88          59 :     SvtModuleOptions aOpt;
      89          59 :     SfxObjectFactory* pDocFact = 0;
      90          59 :     SfxObjectFactory* pGlobDocFact = 0;
      91          59 :     if ( aOpt.IsWriter() )
      92             :     {
      93          59 :         pDocFact = &SwDocShell::Factory();
      94          59 :         pGlobDocFact = &SwGlobalDocShell::Factory();
      95             :     }
      96             : 
      97          59 :     SfxObjectFactory* pWDocFact = &SwWebDocShell::Factory();
      98             : 
      99          59 :     SwModule* pModule = new SwModule( pWDocFact, pDocFact, pGlobDocFact );
     100          59 :     *ppShlPtr = pModule;
     101             : 
     102          59 :     pWDocFact->SetDocumentServiceName(OUString("com.sun.star.text.WebDocument"));
     103             : 
     104          59 :     if ( aOpt.IsWriter() )
     105             :     {
     106          59 :         pGlobDocFact->SetDocumentServiceName(OUString("com.sun.star.text.GlobalDocument"));
     107          59 :         pDocFact->SetDocumentServiceName(OUString("com.sun.star.text.TextDocument"));
     108             :     }
     109             : 
     110             :     // register SvDraw-Fields
     111          59 :     SdrRegisterFieldClasses();
     112             : 
     113             :     // register 3D-Objekt-Factory
     114          59 :     E3dObjFactory();
     115             : 
     116             :     // register form::component::Form-Objekt-Factory
     117          59 :     FmFormObjFactory();
     118             : 
     119          59 :     SdrObjFactory::InsertMakeObjectHdl( LINK( &aSwObjectFactory, SwObjectFactory, MakeObject ) );
     120             : 
     121             :     SAL_INFO( "sw.ui", "Init Core/UI/Filter" );
     122             :     // Initialisation of Statics
     123          59 :     ::_InitCore();
     124          59 :     filters_.reset(new sw::Filters);
     125          59 :     ::_InitUI();
     126             : 
     127          59 :     pModule->InitAttrPool();
     128             :     // now SWModule can create its Pool
     129             : 
     130             :     // register your view-factories here
     131          59 :     RegisterFactories();
     132             : 
     133             :     // register your shell-interfaces here
     134          59 :     RegisterInterfaces();
     135             : 
     136             : #if HAVE_FEATURE_DESKTOP
     137             :     // register your controllers here
     138          59 :     RegisterControls();
     139             : #endif
     140             : 
     141             :     // replace SvxAutocorrect with SwAutocorrect
     142          59 :     SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get();
     143          59 :     const SvxAutoCorrect* pOld = rACfg.GetAutoCorrect();
     144          59 :     rACfg.SetAutoCorrect(new SwAutoCorrect( *pOld ));
     145             : }
     146             : 
     147         118 : SwDLL::~SwDLL()
     148             : {
     149             :     // fdo#86494 SwAutoCorrect must be deleted before _FinitCore
     150          59 :     SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get();
     151          59 :     rACfg.SetAutoCorrect(0); // delete SwAutoCorrect before exit handlers
     152             : 
     153             :     // Pool has to be deleted before statics are
     154          59 :     SW_MOD()->RemoveAttrPool();
     155             : 
     156          59 :     ::_FinitUI();
     157          59 :     filters_.reset();
     158          59 :     ::_FinitCore();
     159             :     // sign out Objekt-Factory
     160          59 :     SdrObjFactory::RemoveMakeObjectHdl(LINK(&aSwObjectFactory, SwObjectFactory, MakeObject ));
     161             : #if 0
     162             :     // the SwModule must be destroyed
     163             :     SwModule** ppShlPtr = (SwModule**) GetAppData(SHL_WRITER);
     164             :     delete (*ppShlPtr);
     165             :     (*ppShlPtr) = NULL;
     166             : #endif
     167          59 : }
     168             : 
     169          43 : sw::Filters & SwDLL::getFilters()
     170             : {
     171             :     OSL_ASSERT(filters_);
     172          43 :     return *filters_.get();
     173             : }
     174             : 
     175             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11