LCOV - code coverage report
Current view: top level - sd/source/helper - simplereferencecomponent.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 24 31 77.4 %
Date: 2015-06-13 12:38:46 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         203 : SimpleReferenceComponent::SimpleReferenceComponent()
      31             : : m_nCount(0)
      32         203 : , mbDisposed(false)
      33             : {
      34         203 : }
      35             : 
      36         203 : SimpleReferenceComponent::~SimpleReferenceComponent()
      37             : {
      38             :     OSL_ASSERT(m_nCount == 0);
      39             :     OSL_ASSERT(mbDisposed);
      40         203 : }
      41             : 
      42       15061 : void SimpleReferenceComponent::acquire()
      43             : {
      44       15061 :     osl_atomic_increment(&m_nCount);
      45       15061 : }
      46             : 
      47       15061 : void SimpleReferenceComponent::release()
      48             : {
      49       15061 :     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       15061 :     if(osl_atomic_decrement(&m_nCount) == 0) delete this;
      69       15061 : }
      70             : 
      71         274 : void SimpleReferenceComponent::Dispose()
      72             : {
      73         274 :     if( !mbDisposed )
      74             :     {
      75         203 :         mbDisposed = true;
      76         203 :         disposing();
      77             :     }
      78         274 : }
      79             : 
      80         200 : void SimpleReferenceComponent::disposing()
      81             : {
      82         200 : }
      83             : 
      84         203 : void * SimpleReferenceComponent::operator new(std::size_t nSize)
      85             : {
      86         203 :     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         203 : void SimpleReferenceComponent::operator delete(void * pPtr)
     105             : {
     106         203 :     ::operator delete(pPtr);
     107         203 : }
     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.11