fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svtools / source / misc / itemdel.cxx
blob731ea2522acafa4ed3aa31058e61e9ea919e1e8f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <svtools/itemdel.hxx>
22 #include <vcl/svapp.hxx>
23 #include <tools/errcode.hxx>
24 #include <limits.h>
25 #include <vector>
27 #include <svl/itempool.hxx>
29 // STATIC DATA -----------------------------------------------------------
31 DBG_NAME(SfxItemDesruptor_Impl);
33 // -----------------------------------------------------------------------
35 class SfxItemDesruptor_Impl
37 SfxPoolItem *pItem;
38 Link aLink;
40 private:
41 DECL_LINK( Delete, void * );
42 SfxItemDesruptor_Impl( const SfxItemDesruptor_Impl& ); // n.i.
44 public:
45 SfxItemDesruptor_Impl( SfxPoolItem *pItemToDesrupt );
46 ~SfxItemDesruptor_Impl();
49 // ------------------------------------------------------------------------
50 SfxItemDesruptor_Impl::SfxItemDesruptor_Impl( SfxPoolItem *pItemToDesrupt ):
51 pItem(pItemToDesrupt),
52 aLink( LINK(this, SfxItemDesruptor_Impl, Delete) )
54 DBG_CTOR(SfxItemDesruptor_Impl, 0);
56 DBG_ASSERT( 0 == pItem->GetRefCount(), "desrupting pooled item" );
57 pItem->SetKind( SFX_ITEMS_DELETEONIDLE );
59 // im Idle abarbeiten
60 GetpApp()->InsertIdleHdl( aLink, 1 );
63 // ------------------------------------------------------------------------
64 SfxItemDesruptor_Impl::~SfxItemDesruptor_Impl()
66 DBG_DTOR(SfxItemDesruptor_Impl, 0);
68 // aus Idle-Handler austragen
69 GetpApp()->RemoveIdleHdl( aLink );
71 // reset RefCount (was set to SFX_ITEMS_SPECIAL before!)
72 pItem->SetRefCount( 0 );
73 //DBG_CHKOBJ( pItem, SfxPoolItem, 0 );
74 delete pItem;
77 // ------------------------------------------------------------------------
78 IMPL_LINK_NOARG(SfxItemDesruptor_Impl, Delete)
80 {DBG_CHKTHIS(SfxItemDesruptor_Impl, 0);}
81 delete this;
82 return 0;
85 // ------------------------------------------------------------------------
86 SfxPoolItem* DeleteItemOnIdle( SfxPoolItem* pItem )
88 DBG_ASSERT( 0 == pItem->GetRefCount(), "deleting item in use" );
89 new SfxItemDesruptor_Impl( pItem );
90 return pItem;
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */