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