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

Generated by: LCOV version 1.10