xref: /aoo42x/main/svx/source/inc/delayedevent.hxx (revision 3334a7e6)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SVX_DELAYEDLINK_HXX
25 #define SVX_DELAYEDLINK_HXX
26 
27 #include <tools/link.hxx>
28 
29 //........................................................................
30 namespace svxform
31 {
32 //........................................................................
33 
34 	//====================================================================
35 	//= DelayedEvent
36 	//====================================================================
37     /** small class which encapsulates posting a Link instance as ApplicationUserEvent
38 
39         No thread safety at all here, just a little saving of code to type multiple times
40     */
41 	class DelayedEvent
42 	{
43     public:
DelayedEvent(const Link & _rHandler)44         DelayedEvent( const Link& _rHandler )
45             :m_aHandler( _rHandler )
46             ,m_nEventId( 0 )
47         {
48         }
49 
~DelayedEvent()50         ~DelayedEvent()
51         {
52             CancelPendingCall();
53         }
54 
55         /** calls the handler asynchronously
56 
57             If there's already a call pending, this previous call is cancelled.
58         */
59         void    Call( void* _pArg = NULL );
60 
61         /** cancels a call which is currently pending
62 
63             If no call is currently pending, then this is ignored.
64         */
65         void    CancelPendingCall();
66 
67     private:
68         Link    m_aHandler;
69         sal_uLong   m_nEventId;
70 
71     private:
72         DECL_LINK( OnCall, void* );
73 
74     private:
75         DelayedEvent();                                  // never implemented
76         DelayedEvent( const DelayedEvent& );              // never implemented
77         DelayedEvent& operator=( const DelayedEvent& );   // never implemented
78 	};
79 
80 //........................................................................
81 } // namespace svxform
82 //........................................................................
83 
84 #endif // SVX_DELAYEDLINK_HXX
85