LCOV - code coverage report
Current view: top level - sd/source/helper - simplereferencecomponent.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 24 31 77.4 %
Date: 2014-11-03 Functions: 8 11 72.7 %
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 "helper/simplereferencecomponent.hxx"
      21             : 
      22             : #include "com/sun/star/uno/RuntimeException.hpp"
      23             : #include "osl/diagnose.h"
      24             : 
      25             : #include <new>
      26             : 
      27             : using com::sun::star::uno::RuntimeException;
      28             : using sd::SimpleReferenceComponent;
      29             : 
      30         338 : SimpleReferenceComponent::SimpleReferenceComponent()
      31             : : m_nCount(0)
      32         338 : , mbDisposed(false)
      33             : {
      34         338 : }
      35             : 
      36         338 : SimpleReferenceComponent::~SimpleReferenceComponent()
      37             : {
      38             :     OSL_ASSERT(m_nCount == 0);
      39             :     OSL_ASSERT(mbDisposed);
      40         338 : }
      41             : 
      42       17181 : void SimpleReferenceComponent::acquire()
      43             : {
      44       17181 :     osl_atomic_increment(&m_nCount);
      45       17181 : }
      46             : 
      47       17181 : void SimpleReferenceComponent::release()
      48             : {
      49       17181 :     if((1 == m_nCount) && !mbDisposed)
      50             :     {
      51             :         try
      52             :         {
      53           0 :             Dispose();
      54             :         }
      55           0 :         catch (RuntimeException &
      56             : #if OSL_DEBUG_LEVEL > 0
      57             :             exc
      58             : #endif
      59             :             ) // don't break throw ()
      60             :         {
      61             : #if OSL_DEBUG_LEVEL > 0
      62             :             OString msg( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
      63             :             OSL_FAIL( msg.getStr() );
      64             : #endif
      65             :         }
      66             :     }
      67             : 
      68       17181 :     if(osl_atomic_decrement(&m_nCount) == 0) delete this;
      69       17181 : }
      70             : 
      71         464 : void SimpleReferenceComponent::Dispose()
      72             : {
      73         464 :     if( !mbDisposed )
      74             :     {
      75         338 :         mbDisposed = true;
      76         338 :         disposing();
      77             :     }
      78         464 : }
      79             : 
      80         338 : void SimpleReferenceComponent::disposing()
      81             : {
      82         338 : }
      83             : 
      84         338 : void * SimpleReferenceComponent::operator new(std::size_t nSize)
      85             : {
      86         338 :     return ::operator new(nSize);
      87             : }
      88             : 
      89           0 : void * SimpleReferenceComponent::operator new(std::size_t nSize,
      90             :                                            std::nothrow_t const &
      91             : #ifndef WNT
      92             :                                            rNothrow
      93             : #endif
      94             :                                            )
      95             : {
      96             : #if defined WNT
      97             :     return ::operator new(nSize);
      98             :         // WNT lacks a global nothrow operator new...
      99             : #else // WNT
     100           0 :     return ::operator new(nSize, rNothrow);
     101             : #endif // WNT
     102             : }
     103             : 
     104         338 : void SimpleReferenceComponent::operator delete(void * pPtr)
     105             : {
     106         338 :     ::operator delete(pPtr);
     107         338 : }
     108             : 
     109           0 : void SimpleReferenceComponent::operator delete(void * pPtr,
     110             :                                             std::nothrow_t const &
     111             : #ifndef WNT
     112             :                                             rNothrow
     113             : #endif
     114             : )
     115             : {
     116             : #if defined WNT
     117             :     ::operator delete(pPtr); // WNT lacks a global nothrow operator delete...
     118             : #else // WNT
     119           0 :     ::operator delete(pPtr, rNothrow);
     120             : #endif // WNT
     121           0 : }
     122             : 
     123             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10