LCOV - code coverage report
Current view: top level - libreoffice/reportdesign/source/core/sdr - ModuleHelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 29 0.0 %
Date: 2012-12-27 Functions: 0 7 0.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             : #include "ModuleHelper.hxx"
      20             : #include <comphelper/configurationhelper.hxx>
      21             : #include <comphelper/processfactory.hxx>
      22             : #include <osl/thread.h>
      23             : #include <com/sun/star/util/XMacroExpander.hpp>
      24             : #include <com/sun/star/beans/XPropertySet.hpp>
      25             : #include <com/sun/star/uno/XComponentContext.hpp>
      26             : #include <rtl/instance.hxx>
      27             : #include <rtl/uri.hxx>
      28             : #include <tools/debug.hxx>
      29             : #include <svl/solar.hrc>
      30             : 
      31             : #define EXPAND_PROTOCOL     "vnd.sun.star.expand:"
      32             : #define ENTER_MOD_METHOD()  \
      33             :     ::osl::MutexGuard aGuard(theOModuleMutex::get()); \
      34             :     ensureImpl()
      35             : 
      36             : //.........................................................................
      37             : namespace rptui
      38             : {
      39             : //.........................................................................
      40             :     using namespace ::com::sun::star;
      41             : //=========================================================================
      42             : //= OModuleImpl
      43             : //=========================================================================
      44             : /** implementation for <type>OModule</type>. not threadsafe, has to be guarded by it's owner
      45             : */
      46             : class OModuleImpl
      47             : {
      48             :     ResMgr* m_pResources;
      49             : 
      50             : public:
      51             :     /// ctor
      52             :     OModuleImpl();
      53             :     ~OModuleImpl();
      54             : 
      55             :     /// get the manager for the resources of the module
      56             :     ResMgr* getResManager();
      57             : };
      58             : 
      59             : DBG_NAME( rpt_OModuleImpl )
      60             : //-------------------------------------------------------------------------
      61           0 : OModuleImpl::OModuleImpl()
      62           0 :     :m_pResources(NULL)
      63             : {
      64             :     DBG_CTOR( rpt_OModuleImpl,NULL);
      65             : 
      66           0 : }
      67             : 
      68             : //-------------------------------------------------------------------------
      69           0 : OModuleImpl::~OModuleImpl()
      70             : {
      71           0 :     if (m_pResources)
      72           0 :         delete m_pResources;
      73             : 
      74             :     DBG_DTOR( rpt_OModuleImpl,NULL);
      75           0 : }
      76             : 
      77             : //-------------------------------------------------------------------------
      78           0 : ResMgr* OModuleImpl::getResManager()
      79             : {
      80             :     // note that this method is not threadsafe, which counts for the whole class !
      81             : 
      82           0 :     if (!m_pResources)
      83             :     {
      84             :         // create a manager with a fixed prefix
      85           0 :         m_pResources = ResMgr::CreateResMgr("rptui");
      86             :     }
      87           0 :     return m_pResources;
      88             : }
      89             : 
      90             : //=========================================================================
      91             : //= OModule
      92             : //=========================================================================
      93             : 
      94             : namespace
      95             : {
      96             :     // access safety
      97             :     struct theOModuleMutex : public rtl::Static< osl::Mutex, theOModuleMutex > {};
      98             : }
      99             : 
     100             : sal_Int32       OModule::s_nClients = 0;
     101             : OModuleImpl*    OModule::s_pImpl = NULL;
     102             : //-------------------------------------------------------------------------
     103           0 : ResMgr* OModule::getResManager()
     104             : {
     105           0 :     ENTER_MOD_METHOD();
     106           0 :     return s_pImpl->getResManager();
     107             : }
     108             : 
     109             : //-------------------------------------------------------------------------
     110           0 : void OModule::registerClient()
     111             : {
     112           0 :     ::osl::MutexGuard aGuard(theOModuleMutex::get());
     113           0 :     ++s_nClients;
     114           0 : }
     115             : 
     116             : //-------------------------------------------------------------------------
     117           0 : void OModule::revokeClient()
     118             : {
     119           0 :     ::osl::MutexGuard aGuard(theOModuleMutex::get());
     120           0 :     if (!--s_nClients && s_pImpl)
     121             :     {
     122           0 :         delete s_pImpl;
     123           0 :         s_pImpl = NULL;
     124           0 :     }
     125           0 : }
     126             : 
     127             : //-------------------------------------------------------------------------
     128           0 : void OModule::ensureImpl()
     129             : {
     130           0 :     if (s_pImpl)
     131           0 :         return;
     132           0 :     s_pImpl = new OModuleImpl();
     133             : }
     134             : 
     135             : //.........................................................................
     136             : }   // namespace dbaui
     137             : //.........................................................................
     138             : 
     139             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10