1 /************************************************************************* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * Copyright 2000, 2010 Oracle and/or its affiliates. 5 * 6 * OpenOffice.org - a multi-platform office productivity suite 7 * 8 * This file is part of OpenOffice.org. 9 * 10 * OpenOffice.org is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser General Public License version 3 12 * only, as published by the Free Software Foundation. 13 * 14 * OpenOffice.org is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU Lesser General Public License version 3 for more details 18 * (a copy is included in the LICENSE file that accompanied this code). 19 * 20 * You should have received a copy of the GNU Lesser General Public License 21 * version 3 along with OpenOffice.org. If not, see 22 * <http://www.openoffice.org/license.html> 23 * for a copy of the LGPLv3 License. 24 * 25 ************************************************************************/ 26 27 #ifndef SVX_DELAYEDLINK_HXX 28 #define SVX_DELAYEDLINK_HXX 29 30 #include <tools/link.hxx> 31 32 //........................................................................ 33 namespace svxform 34 { 35 //........................................................................ 36 37 //==================================================================== 38 //= DelayedEvent 39 //==================================================================== 40 /** small class which encapsulates posting a Link instance as ApplicationUserEvent 41 42 No thread safety at all here, just a little saving of code to type multiple times 43 */ 44 class DelayedEvent 45 { 46 public: 47 DelayedEvent( const Link& _rHandler ) 48 :m_aHandler( _rHandler ) 49 ,m_nEventId( 0 ) 50 { 51 } 52 53 ~DelayedEvent() 54 { 55 CancelPendingCall(); 56 } 57 58 /** calls the handler asynchronously 59 60 If there's already a call pending, this previous call is cancelled. 61 */ 62 void Call( void* _pArg = NULL ); 63 64 /** cancels a call which is currently pending 65 66 If no call is currently pending, then this is ignored. 67 */ 68 void CancelPendingCall(); 69 70 private: 71 Link m_aHandler; 72 sal_uLong m_nEventId; 73 74 private: 75 DECL_LINK( OnCall, void* ); 76 77 private: 78 DelayedEvent(); // never implemented 79 DelayedEvent( const DelayedEvent& ); // never implemented 80 DelayedEvent& operator=( const DelayedEvent& ); // never implemented 81 }; 82 83 //........................................................................ 84 } // namespace svxform 85 //........................................................................ 86 87 #endif // SVX_DELAYEDLINK_HXX 88