LCOV - code coverage report
Current view: top level - libreoffice/sd/source/helper - simplereferencecomponent.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 31 0.0 %
Date: 2012-12-27 Functions: 0 11 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             : 
      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           0 : SimpleReferenceComponent::SimpleReferenceComponent()
      32             : : m_nCount(0)
      33           0 : , mbDisposed(false)
      34             : {
      35           0 : }
      36             : 
      37           0 : SimpleReferenceComponent::~SimpleReferenceComponent()
      38             : {
      39             :     OSL_ASSERT(m_nCount == 0);
      40             :     OSL_ASSERT(mbDisposed);
      41           0 : }
      42             : 
      43           0 : void SimpleReferenceComponent::acquire()
      44             : {
      45           0 :     osl_atomic_increment(&m_nCount);
      46           0 : }
      47             : 
      48           0 : void SimpleReferenceComponent::release()
      49             : {
      50           0 :     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             :             rtl::OString msg( rtl::OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
      64             :             OSL_FAIL( msg.getStr() );
      65             : #endif
      66             :         }
      67             :     }
      68             : 
      69           0 :     if(osl_atomic_decrement(&m_nCount) == 0) delete this;
      70           0 : }
      71             : 
      72           0 : void SimpleReferenceComponent::Dispose()
      73             : {
      74           0 :     if( !mbDisposed )
      75             :     {
      76           0 :         mbDisposed = true;
      77           0 :         disposing();
      78             :     }
      79           0 : }
      80             : 
      81           0 : void SimpleReferenceComponent::disposing()
      82             : {
      83           0 : }
      84             : 
      85           0 : void * SimpleReferenceComponent::operator new(std::size_t nSize)
      86             :     SAL_THROW((std::bad_alloc))
      87             : {
      88           0 :     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           0 : void SimpleReferenceComponent::operator delete(void * pPtr) SAL_THROW(())
     108             : {
     109           0 :     ::operator delete(pPtr);
     110           0 : }
     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