1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SVX_TEXT_CHANGED_QUEUE_HXX
29 #define _SVX_TEXT_CHANGED_QUEUE_HXX
30 
31 #include <memory>
32 #include <list>
33 #include <algorithm>
34 #include <tools/solar.h>
35 #include <tools/rtti.hxx>
36 
37 class SfxHint;
38 class SdrHint;
39 class SfxSimpleHint;
40 class TextHint;
41 class SvxViewHint;
42 class SvxEditSourceHint;
43 
44 namespace accessibility
45 {
46     /** This class handles the notification events for the
47         AccessibleTextHelper class.
48 
49         For various reasons, we cannot process EditEngine events as
50         they arrive, but have to queue and handle them in a batch.
51      */
52 	class AccessibleTextEventQueue
53     {
54     public:
55         typedef ::std::list< SfxHint* > EventQueue;
56 
57         AccessibleTextEventQueue();
58         ~AccessibleTextEventQueue();
59 
60         /// Append event to end of queue
61         void Append( const SfxHint& rHint );
62         /// Append event to end of queue
63         void Append( const SdrHint& rHint );
64         /// Append event to end of queue
65         void Append( const SfxSimpleHint& rHint );
66         /// Append event to end of queue
67         void Append( const TextHint& rHint );
68         /// Append event to end of queue
69         void Append( const SvxViewHint& rHint );
70         /// Append event to end of queue
71         void Append( const SvxEditSourceHint& rHint );
72 
73         /** Pop first queue element
74 
75         	return first queue element, ownership transfers to caller
76         */
77         ::std::auto_ptr< SfxHint > PopFront();
78 
79         /** Apply functor to every queue member
80 
81         	@param rFunctor
82             Functor to apply. Functor receives queue element as
83             parameter: void func( const SfxHint* );
84         */
85         template < typename Functor > void ForEach( Functor& rFunctor ) const
86         {
87             // #109864# Make sure results are put back into rFunctor
88             rFunctor = ::std::for_each( maEventQueue.begin(), maEventQueue.end(), rFunctor );
89         }
90 
91         /// Query whether queue is empty
92         bool IsEmpty() const;
93 
94         /// Clear event queue
95         void Clear();
96 
97     private:
98         EventQueue maEventQueue;
99     };
100 
101 } // end of namespace accessibility
102 
103 #endif /* _SVX_TEXT_CHANGED_QUEUE_HXX */
104