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_TEXT_CHANGED_QUEUE_HXX
25 #define _SVX_TEXT_CHANGED_QUEUE_HXX
26 
27 #include <memory>
28 #include <list>
29 #include <algorithm>
30 #include <tools/solar.h>
31 #include <tools/rtti.hxx>
32 
33 class SfxHint;
34 class SdrHint;
35 class SfxSimpleHint;
36 class TextHint;
37 class SvxViewHint;
38 class SvxEditSourceHint;
39 
40 namespace accessibility
41 {
42     /** This class handles the notification events for the
43         AccessibleTextHelper class.
44 
45         For various reasons, we cannot process EditEngine events as
46         they arrive, but have to queue and handle them in a batch.
47      */
48 	class AccessibleTextEventQueue
49     {
50     public:
51         typedef ::std::list< SfxHint* > EventQueue;
52 
53         AccessibleTextEventQueue();
54         ~AccessibleTextEventQueue();
55 
56         /// Append event to end of queue
57         void Append( const SfxHint& rHint );
58         /// Append event to end of queue
59         void Append( const SdrHint& rHint );
60         /// Append event to end of queue
61         void Append( const SfxSimpleHint& rHint );
62         /// Append event to end of queue
63         void Append( const TextHint& rHint );
64         /// Append event to end of queue
65         void Append( const SvxViewHint& rHint );
66         /// Append event to end of queue
67         void Append( const SvxEditSourceHint& rHint );
68 
69         /** Pop first queue element
70 
71         	return first queue element, ownership transfers to caller
72         */
73         ::std::auto_ptr< SfxHint > PopFront();
74 
75         /** Apply functor to every queue member
76 
77         	@param rFunctor
78             Functor to apply. Functor receives queue element as
79             parameter: void func( const SfxHint* );
80         */
ForEach(Functor & rFunctor) const81         template < typename Functor > void ForEach( Functor& rFunctor ) const
82         {
83             // #109864# Make sure results are put back into rFunctor
84             rFunctor = ::std::for_each( maEventQueue.begin(), maEventQueue.end(), rFunctor );
85         }
86 
87         /// Query whether queue is empty
88         bool IsEmpty() const;
89 
90         /// Clear event queue
91         void Clear();
92 
93     private:
94         EventQueue maEventQueue;
95     };
96 
97 } // end of namespace accessibility
98 
99 #endif /* _SVX_TEXT_CHANGED_QUEUE_HXX */
100