LCOV - code coverage report
Current view: top level - sd/source/helper - simplereferencecomponent.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 31 77.4 %
Date: 2012-08-25 Functions: 8 11 72.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 9 16 56.2 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "helper/simplereferencecomponent.hxx"
      31                 :            : 
      32                 :            : #include "com/sun/star/uno/RuntimeException.hpp"
      33                 :            : #include "osl/diagnose.h"
      34                 :            : 
      35                 :            : #include <new>
      36                 :            : 
      37                 :            : using com::sun::star::uno::RuntimeException;
      38                 :            : using sd::SimpleReferenceComponent;
      39                 :            : 
      40                 :        260 : SimpleReferenceComponent::SimpleReferenceComponent()
      41                 :            : : m_nCount(0)
      42                 :        260 : , mbDisposed(false)
      43                 :            : {
      44                 :        260 : }
      45                 :            : 
      46                 :        260 : SimpleReferenceComponent::~SimpleReferenceComponent()
      47                 :            : {
      48                 :            :     OSL_ASSERT(m_nCount == 0);
      49                 :            :     OSL_ASSERT(mbDisposed);
      50         [ -  + ]:        260 : }
      51                 :            : 
      52                 :      23949 : void SimpleReferenceComponent::acquire()
      53                 :            : {
      54                 :      23949 :     osl_incrementInterlockedCount(&m_nCount);
      55                 :      23949 : }
      56                 :            : 
      57                 :      23949 : void SimpleReferenceComponent::release()
      58                 :            : {
      59 [ +  + ][ -  + ]:      23949 :     if((1 == m_nCount) && !mbDisposed)
      60                 :            :     {
      61                 :            :         try
      62                 :            :         {
      63         [ #  # ]:          0 :             Dispose();
      64                 :            :         }
      65                 :          0 :         catch (RuntimeException &
      66                 :            : #if OSL_DEBUG_LEVEL > 0
      67                 :            :             exc
      68                 :            : #endif
      69                 :            :             ) // don't break throw ()
      70                 :            :         {
      71                 :            : #if OSL_DEBUG_LEVEL > 0
      72                 :            :             rtl::OString msg( rtl::OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
      73                 :            :             OSL_FAIL( msg.getStr() );
      74                 :            : #endif
      75                 :            :         }
      76                 :            :     }
      77                 :            : 
      78 [ +  + ][ +  - ]:      23949 :     if(osl_decrementInterlockedCount(&m_nCount) == 0) delete this;
      79         [ #  # ]:      23949 : }
      80                 :            : 
      81                 :        390 : void SimpleReferenceComponent::Dispose()
      82                 :            : {
      83         [ +  + ]:        390 :     if( !mbDisposed )
      84                 :            :     {
      85                 :        260 :         mbDisposed = true;
      86                 :        260 :         disposing();
      87                 :            :     }
      88                 :        390 : }
      89                 :            : 
      90                 :        260 : void SimpleReferenceComponent::disposing()
      91                 :            : {
      92                 :        260 : }
      93                 :            : 
      94                 :        260 : void * SimpleReferenceComponent::operator new(std::size_t nSize)
      95                 :            :     SAL_THROW((std::bad_alloc))
      96                 :            : {
      97                 :        260 :     return ::operator new(nSize);
      98                 :            : }
      99                 :            : 
     100                 :          0 : void * SimpleReferenceComponent::operator new(std::size_t nSize,
     101                 :            :                                            std::nothrow_t const &
     102                 :            : #ifndef WNT
     103                 :            :                                            rNothrow
     104                 :            : #endif
     105                 :            :                                            )
     106                 :            :     SAL_THROW(())
     107                 :            : {
     108                 :            : #if defined WNT
     109                 :            :     return ::operator new(nSize);
     110                 :            :         // WNT lacks a global nothrow operator new...
     111                 :            : #else // WNT
     112                 :          0 :     return ::operator new(nSize, rNothrow);
     113                 :            : #endif // WNT
     114                 :            : }
     115                 :            : 
     116                 :        260 : void SimpleReferenceComponent::operator delete(void * pPtr) SAL_THROW(())
     117                 :            : {
     118                 :        260 :     ::operator delete(pPtr);
     119                 :        260 : }
     120                 :            : 
     121                 :          0 : void SimpleReferenceComponent::operator delete(void * pPtr,
     122                 :            :                                             std::nothrow_t const &
     123                 :            : #ifndef WNT
     124                 :            :                                             rNothrow
     125                 :            : #endif
     126                 :            : )
     127                 :            :     SAL_THROW(())
     128                 :            : {
     129                 :            : #if defined WNT
     130                 :            :     ::operator delete(pPtr); // WNT lacks a global nothrow operator delete...
     131                 :            : #else // WNT
     132                 :          0 :     ::operator delete(pPtr, rNothrow);
     133                 :            : #endif // WNT
     134                 :          0 : }
     135                 :            : 
     136                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10