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

Generated by: LCOV version 1.10