LCOV - code coverage report
Current view: top level - svtools/source/misc - itemdel.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 16 16 100.0 %
Date: 2012-08-25 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 6 50.0 %

           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 <svtools/itemdel.hxx>
      31                 :            : #include <vcl/svapp.hxx>
      32                 :            : #include <tools/errcode.hxx>
      33                 :            : #include <limits.h>
      34                 :            : #include <vector>
      35                 :            : 
      36                 :            : #include <svl/itempool.hxx>
      37                 :            : 
      38                 :            : // STATIC DATA -----------------------------------------------------------
      39                 :            : 
      40                 :            : DBG_NAME(SfxItemDesruptor_Impl);
      41                 :            : 
      42                 :            : // -----------------------------------------------------------------------
      43                 :            : 
      44                 :            : class SfxItemDesruptor_Impl
      45                 :            : {
      46                 :            :     SfxPoolItem *pItem;
      47                 :            :     Link         aLink;
      48                 :            : 
      49                 :            : private:
      50                 :            :                  DECL_LINK( Delete, void * );
      51                 :            :                  SfxItemDesruptor_Impl( const SfxItemDesruptor_Impl& ); // n.i.
      52                 :            : 
      53                 :            : public:
      54                 :            :                  SfxItemDesruptor_Impl( SfxPoolItem *pItemToDesrupt );
      55                 :            :                  ~SfxItemDesruptor_Impl();
      56                 :            : };
      57                 :            : 
      58                 :            : // ------------------------------------------------------------------------
      59                 :      89690 : SfxItemDesruptor_Impl::SfxItemDesruptor_Impl( SfxPoolItem *pItemToDesrupt ):
      60                 :            :     pItem(pItemToDesrupt),
      61                 :      89690 :     aLink( LINK(this, SfxItemDesruptor_Impl, Delete) )
      62                 :            : {
      63                 :            :     DBG_CTOR(SfxItemDesruptor_Impl, 0);
      64                 :            : 
      65                 :            :     DBG_ASSERT( 0 == pItem->GetRefCount(), "desrupting pooled item" );
      66                 :      89690 :     pItem->SetKind( SFX_ITEMS_DELETEONIDLE );
      67                 :            : 
      68                 :            :     // im Idle abarbeiten
      69                 :      89690 :     GetpApp()->InsertIdleHdl( aLink, 1 );
      70                 :      89690 : }
      71                 :            : 
      72                 :            : // ------------------------------------------------------------------------
      73                 :      89034 : SfxItemDesruptor_Impl::~SfxItemDesruptor_Impl()
      74                 :            : {
      75                 :            :     DBG_DTOR(SfxItemDesruptor_Impl, 0);
      76                 :            : 
      77                 :            :     // aus Idle-Handler austragen
      78                 :      89034 :     GetpApp()->RemoveIdleHdl( aLink );
      79                 :            : 
      80                 :            :     // reset RefCount (was set to SFX_ITEMS_SPECIAL before!)
      81                 :      89034 :     pItem->SetRefCount( 0 );
      82                 :            :     //DBG_CHKOBJ( pItem, SfxPoolItem, 0 );
      83         [ +  - ]:      89034 :     delete pItem;
      84                 :      89034 : }
      85                 :            : 
      86                 :            : // ------------------------------------------------------------------------
      87                 :      89034 : IMPL_LINK_NOARG(SfxItemDesruptor_Impl, Delete)
      88                 :            : {
      89                 :            :     {DBG_CHKTHIS(SfxItemDesruptor_Impl, 0);}
      90         [ +  - ]:      89034 :     delete this;
      91                 :      89034 :     return 0;
      92                 :            : }
      93                 :            : 
      94                 :            : // ------------------------------------------------------------------------
      95                 :      89690 : SfxPoolItem* DeleteItemOnIdle( SfxPoolItem* pItem )
      96                 :            : {
      97                 :            :     DBG_ASSERT( 0 == pItem->GetRefCount(), "deleting item in use" );
      98         [ +  - ]:      89690 :     new SfxItemDesruptor_Impl( pItem );
      99                 :      89690 :     return pItem;
     100                 :            : }
     101                 :            : 
     102                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10