bump product version to 4.1.6.2
[LibreOffice.git] / framework / inc / helper / oframes.hxx
blob04078b082c13f111ed6ed8294f6b85889a769ed9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef __FRAMEWORK_HELPER_OFRAMES_HXX_
21 #define __FRAMEWORK_HELPER_OFRAMES_HXX_
23 #include <classes/framecontainer.hxx>
24 #include <threadhelp/threadhelpbase.hxx>
25 #include <macros/generic.hxx>
26 #include <macros/xinterface.hxx>
27 #include <macros/xtypeprovider.hxx>
28 #include <macros/debug.hxx>
29 #include <general.h>
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 #include <com/sun/star/frame/XFrames.hpp>
33 #include <com/sun/star/frame/XFrame.hpp>
35 #include <cppuhelper/implbase1.hxx>
36 #include <cppuhelper/weakref.hxx>
38 namespace framework{
40 /*-************************************************************************************************************//**
41 @short implement XFrames, XIndexAccess and XElementAccess interfaces as helper for services
42 @descr Use this class as helper for these interfaces. We share mutex and framecontainer with ouer owner.
43 The framecontainer is a member of it from type "FrameContainer". That means;
44 we have the same information as ouer owner. In current implementation we use mutex and lock-mechanism
45 to prevent against compete access. In future we plan support of semaphore!
47 @devstatus deprecated
48 @implements XInterface
49 XFrames
50 XIndexAccess
51 XElementAccess
52 @base OWeakObject
54 @ATTENTION Don't use this class as direct member - use it dynamicly. Do not derive from this class.
55 We hold a weakreference to ouer owner not to ouer superclass.
57 @devstatus deprecated
58 *//*-*************************************************************************************************************/
60 class OFrames : private ThreadHelpBase , // Must be the first of baseclasses - Is necessary for right initialization of objects!
61 public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XFrames >
63 //-------------------------------------------------------------------------------------------------------------
64 // public methods
65 //-------------------------------------------------------------------------------------------------------------
67 public:
69 //---------------------------------------------------------------------------------------------------------
70 // constructor / destructor
71 //---------------------------------------------------------------------------------------------------------
73 /*-****************************************************************************************************//**
74 @short standard ctor
75 @descr These initialize a new instance of this class with all needed information for work.
76 We share framecontainer with owner implementation! It's a threadsafe container.
78 @seealso -
80 @param "xFactory" , reference to factory which has created ouer owner(!). We can use these to create new uno-services.
81 @param "xOwner" , reference to ouer owner. We hold a wekreference to prevent us against cross-references!
82 @param "pFrameContainer" , pointer to shared framecontainer of owner. It's valid only, if weakreference is valid!
83 @return -
85 @onerror -
86 *//*-*****************************************************************************************************/
88 OFrames( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ,
89 const css::uno::Reference< css::frame::XFrame >& xOwner ,
90 FrameContainer* pFrameContainer );
92 //---------------------------------------------------------------------------------------------------------
93 // XFrames
94 //---------------------------------------------------------------------------------------------------------
96 /*-****************************************************************************************************//**
97 @short append frame to container
98 @descr We share the container with ouer owner. We can do this only, if no lock is set on container.
99 Valid references are accepted only!
101 @seealso class FrameContainer
103 @param "xFrame", reference to an existing frame to append.
104 @return -
106 @onerror We do nothing in release or throw an assert in debug version.
107 *//*-*****************************************************************************************************/
109 virtual void SAL_CALL append( const css::uno::Reference< css::frame::XFrame >& xFrame ) throw( css::uno::RuntimeException );
111 /*-****************************************************************************************************//**
112 @short remove frame from container
113 @descr This is the companion to append(). We only accept valid references and don't work, if
114 a lock is set.
116 @seealso class FrameContainer
118 @param "xFrame", reference to an existing frame to remove.
119 @return -
121 @onerror We do nothing in release or throw an assert in debug version.
122 *//*-*****************************************************************************************************/
124 virtual void SAL_CALL remove( const css::uno::Reference< css::frame::XFrame >& xFrame ) throw( css::uno::RuntimeException );
126 /*-****************************************************************************************************//**
127 @short return list of all applicable frames for given flags
128 @descr Call these to get a list of all frames, which are match with given search flags.
130 @seealso -
132 @param "nSearchFlag", flags to search right frames.
133 @return A list of founded frames.
135 @onerror An empty list is returned.
136 *//*-*****************************************************************************************************/
138 virtual css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > SAL_CALL queryFrames( sal_Int32 nSearchFlags ) throw( css::uno::RuntimeException );
140 //---------------------------------------------------------------------------------------------------------
141 // XIndexAccess
142 //---------------------------------------------------------------------------------------------------------
144 /*-****************************************************************************************************//**
145 @short get count of all current frames in container
146 @descr This is the beginning of full index-access. With a count you can step over all items in container.
147 Next call shuoƶd be getByIndex(). But these mechanism works only, if no lock in container is set!
149 @seealso class FrameContainer
150 @seealso method getByIndex()
152 @param -
153 @return Count of current items in container.
155 @onerror If a lock is set, we return 0 for prevent further access!
156 *//*-*****************************************************************************************************/
158 virtual sal_Int32 SAL_CALL getCount() throw( css::uno::RuntimeException );
160 /*-****************************************************************************************************//**
161 @short get specified container item by index
162 @descr If you called getCount() successful - this method return the specified element as an Any.
163 You must observe the range from 0 to count-1! Otherwise an IndexOutOfBoundsException is thrown.
165 @seealso class FrameContainer
166 @seealso method getCount()
168 @param "nIndex", valid index to get container item.
169 @return A container item (specified by index) wrapped in an Any.
171 @onerror If a lock is set, we return an empty Any!
172 @onerror If index out of range, an IndexOutOfBoundsException is thrown.
173 *//*-*****************************************************************************************************/
175 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) throw( css::lang::IndexOutOfBoundsException ,
176 css::lang::WrappedTargetException ,
177 css::uno::RuntimeException );
179 //---------------------------------------------------------------------------------------------------------
180 // XElementAccess
181 //---------------------------------------------------------------------------------------------------------
183 /*-****************************************************************************************************//**
184 @short get uno-type of all container items
185 @descr In current implementation type is fixed to XFrame!
186 (container-lock is ignored)
188 @seealso -
190 @param -
191 @return A uno-type descriptor.
193 @onerror -
194 *//*-*****************************************************************************************************/
196 virtual css::uno::Type SAL_CALL getElementType() throw( css::uno::RuntimeException );
198 /*-****************************************************************************************************//**
199 @short get fill state of current container
200 @descr Call these to get information about, if items exist in container or not.
201 (container-lock is ignored)
203 @seealso -
205 @param -
206 @return sal_True, if container contains some items.
207 @return sal_False, otherwise.
209 @onerror We return sal_False.
210 *//*-*****************************************************************************************************/
212 virtual sal_Bool SAL_CALL hasElements() throw( css::uno::RuntimeException );
214 //-------------------------------------------------------------------------------------------------------------
215 // protected methods
216 //-------------------------------------------------------------------------------------------------------------
218 protected:
220 /*-****************************************************************************************************//**
221 @short standard destructor
222 @descr This method destruct an instance of this class and clear some member.
223 This method is protected, because its not allowed to use this class as a member!
224 You MUST use a dynamical instance (pointer). That's the reason for a protected dtor.
226 @seealso -
228 @param -
229 @return -
231 @onerror -
232 *//*-*****************************************************************************************************/
234 virtual ~OFrames();
236 /*-****************************************************************************************************//**
237 @short reset instance to default values
238 @descr There are two ways to delete an instance of this class.<BR>
239 1) delete with destructor<BR>
240 2) dispose from parent or factory ore ...<BR>
241 This method do the same for both ways! It free used memory and release references ...
243 @seealso method dispose() (if it exist!)
244 @seealso destructor ~TaskEnumeration()
246 @param -
248 @return -
250 @onerror -
251 *//*-*****************************************************************************************************/
253 virtual void impl_resetObject();
255 //-------------------------------------------------------------------------------------------------------------
256 // private methods
257 //-------------------------------------------------------------------------------------------------------------
259 private:
261 /*-****************************************************************************************************//**
262 @short append one sequence to another
263 @descr There is no operation to add to sequences! Use this helper-method to do this.
265 @seealso class Sequence
267 @param "seqDestination", reference to sequence on which operation will append the other sequence.
268 @param "seqSource" , reference to sequence for append.
269 @return "seqDestination" is parameter AND return value at the same time.
271 @onerror -
272 *//*-*****************************************************************************************************/
274 void impl_appendSequence( css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >& seqDestination ,
275 const css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >& seqSource );
277 //-------------------------------------------------------------------------------------------------------------
278 // debug methods
279 // (should be private everyway!)
280 //-------------------------------------------------------------------------------------------------------------
282 /*-****************************************************************************************************//**
283 @short debug-method to check incoming parameter of some other mehods of this class
284 @descr The following methods are used to check parameters for other methods
285 of this class. The return value is used directly for an ASSERT(...).
287 @seealso ASSERTs in implementation!
289 @param references to checking variables
290 @return sal_False ,on invalid parameter
291 @return sal_True ,otherwise
293 @onerror -
294 *//*-*****************************************************************************************************/
296 #ifdef ENABLE_ASSERTIONS
298 private:
300 static sal_Bool impldbg_checkParameter_OFramesCtor ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ,
301 const css::uno::Reference< css::frame::XFrame >& xOwner ,
302 FrameContainer* pFrameContainer );
303 static sal_Bool impldbg_checkParameter_append ( const css::uno::Reference< css::frame::XFrame >& xFrame );
304 static sal_Bool impldbg_checkParameter_remove ( const css::uno::Reference< css::frame::XFrame >& xFrame );
305 static sal_Bool impldbg_checkParameter_queryFrames ( sal_Int32 nSearchFlags );
307 #endif // #ifdef ENABLE_ASSERTIONS
309 //-------------------------------------------------------------------------------------------------------------
310 // variables
311 // (should be private everyway!)
312 //-------------------------------------------------------------------------------------------------------------
314 private:
316 css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// reference to global servicemanager
317 css::uno::WeakReference< css::frame::XFrame > m_xOwner ; /// reference to owner of this instance (Hold no hard reference!)
318 FrameContainer* m_pFrameContainer ; /// with owner shared list to hold all direct children of an XFramesSupplier
319 sal_Bool m_bRecursiveSearchProtection ; /// flag to protect against recursive searches of frames at parents
321 }; // class OFrames
323 } // namespace framework
325 #endif // #ifndef __FRAMEWORK_HELPER_OFRAMES_HXX_
327 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */