xref: /trunk/main/framework/inc/helper/otasksenumeration.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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 __FRAMEWORK_HELPER_OTASKSENUMERATION_HXX_
29 #define __FRAMEWORK_HELPER_OTASKSENUMERATION_HXX_
30 
31 //_________________________________________________________________________________________________________________
32 //  my own includes
33 //_________________________________________________________________________________________________________________
34 
35 #ifndef __FRAMEWORK_OMUTEXMEMBER_HXX_
36 #include <threadhelp/threadhelpbase.hxx>
37 #endif
38 #include <macros/generic.hxx>
39 #include <macros/xinterface.hxx>
40 #include <macros/xtypeprovider.hxx>
41 #include <macros/debug.hxx>
42 #include <general.h>
43 
44 //_________________________________________________________________________________________________________________
45 //  interface includes
46 //_________________________________________________________________________________________________________________
47 #include <com/sun/star/lang/XEventListener.hpp>
48 #include <com/sun/star/container/XEnumeration.hpp>
49 #include <com/sun/star/frame/XTask.hpp>
50 #include <com/sun/star/frame/XFrame.hpp>
51 
52 //_________________________________________________________________________________________________________________
53 //  other includes
54 //_________________________________________________________________________________________________________________
55 #include <cppuhelper/weak.hxx>
56 
57 //_________________________________________________________________________________________________________________
58 //  namespace
59 //_________________________________________________________________________________________________________________
60 
61 namespace framework{
62 
63 //_________________________________________________________________________________________________________________
64 //  exported const
65 //_________________________________________________________________________________________________________________
66 
67 //_________________________________________________________________________________________________________________
68 //  exported definitions
69 //_________________________________________________________________________________________________________________
70 
71 /*-************************************************************************************************************//**
72     @short          implement a helper for a oneway enumeration of tasks
73     @descr          You can step during this list only for one time! Its a snapshot.
74                     Don't forget to release the reference. You are the owner of an instance of this implementation.
75                     You cant use this as a baseclass. Please use it as a dynamical object for return.
76 
77     @implements     XInterface
78                     XTypeProvider
79                     XEventListener
80                     XEnumeration
81 
82     @base           ThreadHelpBase
83                     OWeakObject
84 
85     @devstatus      ready to use
86 *//*-*************************************************************************************************************/
87 
88 class OTasksEnumeration :   public css::lang::XTypeProvider     ,
89                             public css::lang::XEventListener    ,
90                             public css::container::XEnumeration ,
91                             public ThreadHelpBase                   ,
92                             public ::cppu::OWeakObject
93 {
94     //-------------------------------------------------------------------------------------------------------------
95     //  public methods
96     //-------------------------------------------------------------------------------------------------------------
97 
98     public:
99 
100         //---------------------------------------------------------------------------------------------------------
101         //  constructor / destructor
102         //---------------------------------------------------------------------------------------------------------
103 
104         /*-****************************************************************************************************//**
105             @short      constructor to initialize this enumeration
106             @descr      An enumeration is a list with oneway-access! You can get every member only for one time.
107                         This method allow to initialize this oneway list with values.
108 
109             @seealso    -
110 
111             @param      "seqTasks" is a sequence of interfaces, which are tasks.
112             @return     -
113 
114             @onerror    Do nothing and reset this object to default with an empty list.
115         *//*-*****************************************************************************************************/
116 
117         OTasksEnumeration( const css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >& seqTasks );
118 
119         //---------------------------------------------------------------------------------------------------------
120         //  XInterface
121         //---------------------------------------------------------------------------------------------------------
122 
123         DECLARE_XINTERFACE
124         DECLARE_XTYPEPROVIDER
125 
126         //---------------------------------------------------------------------------------------------------------
127         //  XEventListener
128         //---------------------------------------------------------------------------------------------------------
129 
130         /*-****************************************************************************************************//**
131             @short      last chance to release all references and free memory
132             @descr      This method is called, if the enumeration is used completly and has no more elements.
133                         Then we must destroy ouer list and release all references to other objects.
134 
135             @seealso    interface XEventListener
136 
137             @param      "aEvent" describe the source of this event.
138             @return     -
139 
140             @onerror    -
141         *//*-*****************************************************************************************************/
142 
143         virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException );
144 
145         //---------------------------------------------------------------------------------------------------------
146         //  XEnumeration
147         //---------------------------------------------------------------------------------------------------------
148 
149         /*-****************************************************************************************************//**
150             @short      check count of accessible elements of enumeration
151             @descr      You can call this method to get information about accessible elements in future.
152                         Elements you have already getted are not accessible!
153 
154             @seealso    interface XEnumeration
155 
156             @param      -
157             @return     sal_True  = if more elements accessible<BR>
158                         sal_False = other way
159 
160             @onerror    sal_False<BR>
161                         (List is emtpy and there no accessible elements ...)
162         *//*-*****************************************************************************************************/
163 
164         virtual sal_Bool SAL_CALL hasMoreElements() throw( css::uno::RuntimeException );
165 
166         /*-****************************************************************************************************//**
167             @short      give the next element, if some exist
168             @descr      If a call "hasMoreElements()" return true, you can get the next element of list.
169 
170             @seealso    interface XEnumeration
171 
172             @param      -
173             @return     A Reference to a task, safed in an Any-structure.
174 
175             @onerror    If end of enumeration is arrived or there are no elements in list => a NoSuchElementException is thrown.
176         *//*-*****************************************************************************************************/
177 
178         virtual css::uno::Any SAL_CALL nextElement() throw( css::container::NoSuchElementException  ,
179                                                             css::lang::WrappedTargetException       ,
180                                                             css::uno::RuntimeException              );
181 
182     //-------------------------------------------------------------------------------------------------------------
183     //  protected methods
184     //-------------------------------------------------------------------------------------------------------------
185 
186     protected:
187 
188         /*-****************************************************************************************************//**
189             @short      standard destructor
190             @descr      This method destruct an instance of this class and clear some member.
191                         We make it protected, because its not supported to use this class as normal instance!
192                         You must create it dynamical in memory and use a pointer.
193 
194             @seealso    -
195 
196             @param      -
197             @return     -
198 
199             @onerror    -
200         *//*-*****************************************************************************************************/
201 
202         virtual ~OTasksEnumeration();
203 
204         /*-****************************************************************************************************//**
205             @short      reset instance to default values
206 
207             @descr      There are two ways to delete an instance of this class.<BR>
208                         1) delete with destructor<BR>
209                         2) dispose from parent or factory ore ...<BR>
210                         This method do the same for both ways! It free used memory and release references ...
211 
212             @seealso    method dispose()
213             @seealso    destructor ~TaskEnumeration()
214 
215             @param      -
216 
217             @return     -
218 
219             @onerror    -
220         *//*-*****************************************************************************************************/
221 
222         virtual void impl_resetObject();
223 
224     //-------------------------------------------------------------------------------------------------------------
225     //  private methods
226     //-------------------------------------------------------------------------------------------------------------
227 
228     private:
229 
230     //-------------------------------------------------------------------------------------------------------------
231     //  debug methods
232     //  (should be private everyway!)
233     //-------------------------------------------------------------------------------------------------------------
234 
235         /*-****************************************************************************************************//**
236             @short      debug-method to check incoming parameter of some other mehods of this class
237             @descr      The following methods are used to check parameters for other methods
238                         of this class. The return value is used directly for an ASSERT(...).
239 
240             @seealso    ASSERT in implementation!
241 
242             @param      references to checking variables
243             @return     sal_False on invalid parameter<BR>
244                         sal_True  otherway
245 
246             @onerror    -
247         *//*-*****************************************************************************************************/
248 
249     #ifdef ENABLE_ASSERTIONS
250 
251     private:
252 
253         static sal_Bool impldbg_checkParameter_OTasksEnumerationCtor    (   const   css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >&    seqTasks    );
254         static sal_Bool impldbg_checkParameter_disposing                (   const   css::lang::EventObject&                                             aEvent      );
255 
256     #endif  // #ifdef ENABLE_ASSERTIONS
257 
258     //-------------------------------------------------------------------------------------------------------------
259     //  variables
260     //  (should be private everyway!)
261     //-------------------------------------------------------------------------------------------------------------
262 
263     private:
264 
265         sal_uInt32                                                          m_nPosition         ;   /// current position in enumeration
266         css::uno::Sequence< css::uno::Reference< css::frame::XTask > >      m_seqTasks          ;   /// list of current tasks
267 
268 };      //  class OTasksEnumeration
269 
270 }       //  namespace framework
271 
272 #endif  //  #ifndef __FRAMEWORK_HELPER_OTASKSENUMERATION_HXX_
273