update dev300-m58
[ooovba.git] / framework / inc / helper / oframes.hxx
blob2e16c8f716eb107858f23e7361ac9bbab1399253
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: oframes.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_HELPER_OFRAMES_HXX_
32 #define __FRAMEWORK_HELPER_OFRAMES_HXX_
34 //_________________________________________________________________________________________________________________
35 // my own includes
36 //_________________________________________________________________________________________________________________
38 #include <classes/framecontainer.hxx>
39 #include <threadhelp/threadhelpbase.hxx>
40 #include <macros/generic.hxx>
41 #include <macros/xinterface.hxx>
42 #include <macros/xtypeprovider.hxx>
43 #include <macros/debug.hxx>
44 #include <general.h>
46 //_________________________________________________________________________________________________________________
47 // interface includes
48 //_________________________________________________________________________________________________________________
49 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
50 #include <com/sun/star/frame/XFrames.hpp>
51 #include <com/sun/star/frame/XFrame.hpp>
53 //_________________________________________________________________________________________________________________
54 // other includes
55 //_________________________________________________________________________________________________________________
56 #include <cppuhelper/implbase1.hxx>
57 #include <cppuhelper/weakref.hxx>
59 //_________________________________________________________________________________________________________________
60 // namespace
61 //_________________________________________________________________________________________________________________
63 namespace framework{
65 //_________________________________________________________________________________________________________________
66 // exported const
67 //_________________________________________________________________________________________________________________
69 //_________________________________________________________________________________________________________________
70 // exported definitions
71 //_________________________________________________________________________________________________________________
73 /*-************************************************************************************************************//**
74 @short implement XFrames, XIndexAccess and XElementAccess interfaces as helper for services
75 @descr Use this class as helper for these interfaces. We share mutex and framecontainer with ouer owner.
76 The framecontainer is a member of it from type "FrameContainer". That means;
77 we have the same information as ouer owner. In current implementation we use mutex and lock-mechanism
78 to prevent against compete access. In future we plan support of semaphore!
80 @devstatus deprecated
81 @implements XInterface
82 XFrames
83 XIndexAccess
84 XElementAccess
85 @base OWeakObject
87 @ATTENTION Don't use this class as direct member - use it dynamicly. Do not derive from this class.
88 We hold a weakreference to ouer owner not to ouer superclass.
90 @devstatus deprecated
91 *//*-*************************************************************************************************************/
93 class OFrames : private ThreadHelpBase , // Must be the first of baseclasses - Is neccessary for right initialization of objects!
94 public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XFrames >
96 //-------------------------------------------------------------------------------------------------------------
97 // public methods
98 //-------------------------------------------------------------------------------------------------------------
100 public:
102 //---------------------------------------------------------------------------------------------------------
103 // constructor / destructor
104 //---------------------------------------------------------------------------------------------------------
106 /*-****************************************************************************************************//**
107 @short standard ctor
108 @descr These initialize a new instance of this class with all needed informations for work.
109 We share framecontainer with owner implementation! It's a threadsafe container.
111 @seealso -
113 @param "xFactory" , reference to factory which has created ouer owner(!). We can use these to create new uno-services.
114 @param "xOwner" , reference to ouer owner. We hold a wekreference to prevent us against cross-references!
115 @param "pFrameContainer" , pointer to shared framecontainer of owner. It's valid only, if weakreference is valid!
116 @return -
118 @onerror -
119 *//*-*****************************************************************************************************/
121 OFrames( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ,
122 const css::uno::Reference< css::frame::XFrame >& xOwner ,
123 FrameContainer* pFrameContainer );
125 //---------------------------------------------------------------------------------------------------------
126 // XFrames
127 //---------------------------------------------------------------------------------------------------------
129 /*-****************************************************************************************************//**
130 @short append frame to container
131 @descr We share the container with ouer owner. We can do this only, if no lock is set on container.
132 Valid references are accepted only!
134 @seealso class FrameContainer
136 @param "xFrame", reference to an existing frame to append.
137 @return -
139 @onerror We do nothing in release or throw an assert in debug version.
140 *//*-*****************************************************************************************************/
142 virtual void SAL_CALL append( const css::uno::Reference< css::frame::XFrame >& xFrame ) throw( css::uno::RuntimeException );
144 /*-****************************************************************************************************//**
145 @short remove frame from container
146 @descr This is the companion to append(). We only accept valid references and don't work, if
147 a lock is set.
149 @seealso class FrameContainer
151 @param "xFrame", reference to an existing frame to remove.
152 @return -
154 @onerror We do nothing in release or throw an assert in debug version.
155 *//*-*****************************************************************************************************/
157 virtual void SAL_CALL remove( const css::uno::Reference< css::frame::XFrame >& xFrame ) throw( css::uno::RuntimeException );
159 /*-****************************************************************************************************//**
160 @short return list of all applicable frames for given flags
161 @descr Call these to get a list of all frames, which are match with given search flags.
163 @seealso -
165 @param "nSearchFlag", flags to search right frames.
166 @return A list of founded frames.
168 @onerror An empty list is returned.
169 *//*-*****************************************************************************************************/
171 virtual css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > SAL_CALL queryFrames( sal_Int32 nSearchFlags ) throw( css::uno::RuntimeException );
173 //---------------------------------------------------------------------------------------------------------
174 // XIndexAccess
175 //---------------------------------------------------------------------------------------------------------
177 /*-****************************************************************************************************//**
178 @short get count of all current frames in container
179 @descr This is the beginning of full index-access. With a count you can step over all items in container.
180 Next call shuoƶd be getByIndex(). But these mechanism works only, if no lock in container is set!
182 @seealso class FrameContainer
183 @seealso method getByIndex()
185 @param -
186 @return Count of current items in container.
188 @onerror If a lock is set, we return 0 for prevent further access!
189 *//*-*****************************************************************************************************/
191 virtual sal_Int32 SAL_CALL getCount() throw( css::uno::RuntimeException );
193 /*-****************************************************************************************************//**
194 @short get specified container item by index
195 @descr If you called getCount() successful - this method return the specified element as an Any.
196 You must observe the range from 0 to count-1! Otherwise an IndexOutOfBoundsException is thrown.
198 @seealso class FrameContainer
199 @seealso method getCount()
201 @param "nIndex", valid index to get container item.
202 @return A container item (specified by index) wrapped in an Any.
204 @onerror If a lock is set, we return an empty Any!
205 @onerror If index out of range, an IndexOutOfBoundsException is thrown.
206 *//*-*****************************************************************************************************/
208 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) throw( css::lang::IndexOutOfBoundsException ,
209 css::lang::WrappedTargetException ,
210 css::uno::RuntimeException );
212 //---------------------------------------------------------------------------------------------------------
213 // XElementAccess
214 //---------------------------------------------------------------------------------------------------------
216 /*-****************************************************************************************************//**
217 @short get uno-type of all container items
218 @descr In current implementation type is fixed to XFrame!
219 (container-lock is ignored)
221 @seealso -
223 @param -
224 @return A uno-type descriptor.
226 @onerror -
227 *//*-*****************************************************************************************************/
229 virtual css::uno::Type SAL_CALL getElementType() throw( css::uno::RuntimeException );
231 /*-****************************************************************************************************//**
232 @short get fill state of current container
233 @descr Call these to get information about, if items exist in container or not.
234 (container-lock is ignored)
236 @seealso -
238 @param -
239 @return sal_True, if container contains some items.
240 @return sal_False, otherwise.
242 @onerror We return sal_False.
243 *//*-*****************************************************************************************************/
245 virtual sal_Bool SAL_CALL hasElements() throw( css::uno::RuntimeException );
247 //-------------------------------------------------------------------------------------------------------------
248 // protected methods
249 //-------------------------------------------------------------------------------------------------------------
251 protected:
253 /*-****************************************************************************************************//**
254 @short standard destructor
255 @descr This method destruct an instance of this class and clear some member.
256 This method is protected, because its not allowed to use this class as a member!
257 You MUST use a dynamical instance (pointer). That's the reason for a protected dtor.
259 @seealso -
261 @param -
262 @return -
264 @onerror -
265 *//*-*****************************************************************************************************/
267 virtual ~OFrames();
269 /*-****************************************************************************************************//**
270 @short reset instance to default values
271 @descr There are two ways to delete an instance of this class.<BR>
272 1) delete with destructor<BR>
273 2) dispose from parent or factory ore ...<BR>
274 This method do the same for both ways! It free used memory and release references ...
276 @seealso method dispose() (if it exist!)
277 @seealso destructor ~TaskEnumeration()
279 @param -
281 @return -
283 @onerror -
284 *//*-*****************************************************************************************************/
286 virtual void impl_resetObject();
288 //-------------------------------------------------------------------------------------------------------------
289 // private methods
290 //-------------------------------------------------------------------------------------------------------------
292 private:
294 /*-****************************************************************************************************//**
295 @short append one sequence to another
296 @descr There is no operation to add to sequences! Use this helper-method to do this.
298 @seealso class Sequence
300 @param "seqDestination", reference to sequence on which operation will append the other sequence.
301 @param "seqSource" , reference to sequence for append.
302 @return "seqDestination" is parameter AND return value at the same time.
304 @onerror -
305 *//*-*****************************************************************************************************/
307 void impl_appendSequence( css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >& seqDestination ,
308 const css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >& seqSource );
310 //-------------------------------------------------------------------------------------------------------------
311 // debug methods
312 // (should be private everyway!)
313 //-------------------------------------------------------------------------------------------------------------
315 /*-****************************************************************************************************//**
316 @short debug-method to check incoming parameter of some other mehods of this class
317 @descr The following methods are used to check parameters for other methods
318 of this class. The return value is used directly for an ASSERT(...).
320 @seealso ASSERTs in implementation!
322 @param references to checking variables
323 @return sal_False ,on invalid parameter
324 @return sal_True ,otherwise
326 @onerror -
327 *//*-*****************************************************************************************************/
329 #ifdef ENABLE_ASSERTIONS
331 private:
333 static sal_Bool impldbg_checkParameter_OFramesCtor ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ,
334 const css::uno::Reference< css::frame::XFrame >& xOwner ,
335 FrameContainer* pFrameContainer );
336 static sal_Bool impldbg_checkParameter_append ( const css::uno::Reference< css::frame::XFrame >& xFrame );
337 static sal_Bool impldbg_checkParameter_remove ( const css::uno::Reference< css::frame::XFrame >& xFrame );
338 static sal_Bool impldbg_checkParameter_queryFrames ( sal_Int32 nSearchFlags );
340 #endif // #ifdef ENABLE_ASSERTIONS
342 //-------------------------------------------------------------------------------------------------------------
343 // variables
344 // (should be private everyway!)
345 //-------------------------------------------------------------------------------------------------------------
347 private:
349 css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// reference to global servicemanager
350 css::uno::WeakReference< css::frame::XFrame > m_xOwner ; /// reference to owner of this instance (Hold no hard reference!)
351 FrameContainer* m_pFrameContainer ; /// with owner shared list to hold all direct childs of an XFramesSupplier
352 sal_Bool m_bRecursiveSearchProtection ; /// flag to protect against recursive searches of frames at parents
354 }; // class OFrames
356 } // namespace framework
358 #endif // #ifndef __FRAMEWORK_HELPER_OFRAMES_HXX_