xref: /AOO41X/main/framework/inc/helper/oframes.hxx (revision f8e07b45f7e1fb69563504f404bb0b75210f0be6)
1*f8e07b45SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f8e07b45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f8e07b45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f8e07b45SAndrew Rist  * distributed with this work for additional information
6*f8e07b45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f8e07b45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f8e07b45SAndrew Rist  * "License"); you may not use this file except in compliance
9*f8e07b45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*f8e07b45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f8e07b45SAndrew Rist  * software distributed under the License is distributed on an
15*f8e07b45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f8e07b45SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f8e07b45SAndrew Rist  * specific language governing permissions and limitations
18*f8e07b45SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*f8e07b45SAndrew Rist  *************************************************************/
21*f8e07b45SAndrew Rist 
22*f8e07b45SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __FRAMEWORK_HELPER_OFRAMES_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_HELPER_OFRAMES_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_________________________________________________________________________________________________________________
28cdf0e10cSrcweir //	my own includes
29cdf0e10cSrcweir //_________________________________________________________________________________________________________________
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <classes/framecontainer.hxx>
32cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
33cdf0e10cSrcweir #include <macros/generic.hxx>
34cdf0e10cSrcweir #include <macros/xinterface.hxx>
35cdf0e10cSrcweir #include <macros/xtypeprovider.hxx>
36cdf0e10cSrcweir #include <macros/debug.hxx>
37cdf0e10cSrcweir #include <general.h>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir //_________________________________________________________________________________________________________________
40cdf0e10cSrcweir //	interface includes
41cdf0e10cSrcweir //_________________________________________________________________________________________________________________
42cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
43cdf0e10cSrcweir #include <com/sun/star/frame/XFrames.hpp>
44cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir //_________________________________________________________________________________________________________________
47cdf0e10cSrcweir //	other includes
48cdf0e10cSrcweir //_________________________________________________________________________________________________________________
49cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
50cdf0e10cSrcweir #include <cppuhelper/weakref.hxx>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir //_________________________________________________________________________________________________________________
53cdf0e10cSrcweir //	namespace
54cdf0e10cSrcweir //_________________________________________________________________________________________________________________
55cdf0e10cSrcweir 
56cdf0e10cSrcweir namespace framework{
57cdf0e10cSrcweir 
58cdf0e10cSrcweir //_________________________________________________________________________________________________________________
59cdf0e10cSrcweir //	exported const
60cdf0e10cSrcweir //_________________________________________________________________________________________________________________
61cdf0e10cSrcweir 
62cdf0e10cSrcweir //_________________________________________________________________________________________________________________
63cdf0e10cSrcweir //	exported definitions
64cdf0e10cSrcweir //_________________________________________________________________________________________________________________
65cdf0e10cSrcweir 
66cdf0e10cSrcweir /*-************************************************************************************************************//**
67cdf0e10cSrcweir 	@short          implement XFrames, XIndexAccess and XElementAccess interfaces as helper for services
68cdf0e10cSrcweir 	@descr			Use this class as helper for these interfaces. We share mutex and framecontainer with ouer owner.
69cdf0e10cSrcweir 					The framecontainer is a member of it from type "FrameContainer". That means;
70cdf0e10cSrcweir 					we have the same information as ouer owner. In current implementation we use mutex and lock-mechanism
71cdf0e10cSrcweir 					to prevent against compete access. In future we plan support of semaphore!
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	@devstatus		deprecated
74cdf0e10cSrcweir 	@implements		XInterface
75cdf0e10cSrcweir 					XFrames
76cdf0e10cSrcweir 					XIndexAccess
77cdf0e10cSrcweir 					XElementAccess
78cdf0e10cSrcweir 	@base			OWeakObject
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 	@ATTENTION		Don't use this class as direct member - use it dynamicly. Do not derive from this class.
81cdf0e10cSrcweir 					We hold a weakreference to ouer owner not to ouer superclass.
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	@devstatus		deprecated
84cdf0e10cSrcweir *//*-*************************************************************************************************************/
85cdf0e10cSrcweir 
86cdf0e10cSrcweir class OFrames   :   private ThreadHelpBase      ,   // Must be the first of baseclasses - Is neccessary for right initialization of objects!
87cdf0e10cSrcweir 					public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XFrames >
88cdf0e10cSrcweir {
89cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
90cdf0e10cSrcweir 	//	public methods
91cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 	public:
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
96cdf0e10cSrcweir 		//	constructor / destructor
97cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 		/*-****************************************************************************************************//**
100cdf0e10cSrcweir 			@short		standard ctor
101cdf0e10cSrcweir 			@descr		These initialize a new instance of this class with all needed informations for work.
102cdf0e10cSrcweir                         We share framecontainer with owner implementation! It's a threadsafe container.
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 			@seealso	-
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 			@param		"xFactory"			, reference to factory which has created ouer owner(!). We can use these to create new uno-services.
107cdf0e10cSrcweir 			@param		"xOwner"			, reference to ouer owner. We hold a wekreference to prevent us against cross-references!
108cdf0e10cSrcweir 			@param		"pFrameContainer"	, pointer to shared framecontainer of owner. It's valid only, if weakreference is valid!
109cdf0e10cSrcweir 			@return		-
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 			@onerror	-
112cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	 	OFrames(	const	css::uno::Reference< css::lang::XMultiServiceFactory >&	xFactory		,
115cdf0e10cSrcweir 					const	css::uno::Reference< css::frame::XFrame >&				xOwner			,
116cdf0e10cSrcweir 							FrameContainer*											pFrameContainer	);
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
119cdf0e10cSrcweir 		//	XFrames
120cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 		/*-****************************************************************************************************//**
123cdf0e10cSrcweir 			@short      append frame to container
124cdf0e10cSrcweir 			@descr		We share the container with ouer owner. We can do this only, if no lock is set on container.
125cdf0e10cSrcweir 						Valid references are accepted only!
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 			@seealso	class FrameContainer
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 			@param		"xFrame", reference to an existing frame to append.
130cdf0e10cSrcweir 			@return		-
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 			@onerror	We do nothing in release or throw an assert in debug version.
133cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     	virtual void SAL_CALL append( const css::uno::Reference< css::frame::XFrame >& xFrame ) throw( css::uno::RuntimeException );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 		/*-****************************************************************************************************//**
138cdf0e10cSrcweir 			@short      remove frame from container
139cdf0e10cSrcweir 			@descr		This is the companion to append(). We only accept valid references and don't work, if
140cdf0e10cSrcweir 						a lock is set.
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 			@seealso	class FrameContainer
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 			@param		"xFrame", reference to an existing frame to remove.
145cdf0e10cSrcweir 			@return		-
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 			@onerror	We do nothing in release or throw an assert in debug version.
148cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     	virtual void SAL_CALL remove( const css::uno::Reference< css::frame::XFrame >& xFrame ) throw( css::uno::RuntimeException );
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 		/*-****************************************************************************************************//**
153cdf0e10cSrcweir 			@short      return list of all applicable frames for given flags
154cdf0e10cSrcweir 			@descr		Call these to get a list of all frames, which are match with given search flags.
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 			@seealso	-
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 			@param		"nSearchFlag", flags to search right frames.
159cdf0e10cSrcweir 			@return		A list of founded frames.
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 			@onerror	An empty list is returned.
162cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
163cdf0e10cSrcweir 
164cdf0e10cSrcweir     	virtual css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > SAL_CALL queryFrames( sal_Int32 nSearchFlags ) throw( css::uno::RuntimeException );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
167cdf0e10cSrcweir 		//	XIndexAccess
168cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 		/*-****************************************************************************************************//**
171cdf0e10cSrcweir 			@short      get count of all current frames in container
172cdf0e10cSrcweir 			@descr		This is the beginning of full index-access. With a count you can step over all items in container.
173cdf0e10cSrcweir 						Next call shuo�d be getByIndex(). But these mechanism works only, if no lock in container is set!
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 			@seealso	class FrameContainer
176cdf0e10cSrcweir 			@seealso	method getByIndex()
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 			@param		-
179cdf0e10cSrcweir 			@return		Count of current items in container.
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 			@onerror	If a lock is set, we return 0 for prevent further access!
182cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
183cdf0e10cSrcweir 
184cdf0e10cSrcweir     	virtual sal_Int32 SAL_CALL getCount() throw( css::uno::RuntimeException );
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 		/*-****************************************************************************************************//**
187cdf0e10cSrcweir 			@short		get specified container item by index
188cdf0e10cSrcweir 			@descr		If you called getCount() successful - this method return the specified element as an Any.
189cdf0e10cSrcweir 						You must observe the range from 0 to count-1! Otherwise an IndexOutOfBoundsException is thrown.
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 			@seealso	class FrameContainer
192cdf0e10cSrcweir 			@seealso	method getCount()
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 			@param		"nIndex", valid index to get container item.
195cdf0e10cSrcweir 			@return		A container item (specified by index) wrapped in an Any.
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 			@onerror	If a lock is set, we return an empty Any!
198cdf0e10cSrcweir 			@onerror	If index out of range, an IndexOutOfBoundsException is thrown.
199cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
200cdf0e10cSrcweir 
201cdf0e10cSrcweir     	virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) throw(	css::lang::IndexOutOfBoundsException	,
202cdf0e10cSrcweir 																				css::lang::WrappedTargetException		,
203cdf0e10cSrcweir 																				css::uno::RuntimeException				);
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
206cdf0e10cSrcweir 		//	XElementAccess
207cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 		/*-****************************************************************************************************//**
210cdf0e10cSrcweir 			@short      get uno-type of all container items
211cdf0e10cSrcweir 			@descr		In current implementation type is fixed to XFrame!
212cdf0e10cSrcweir 						(container-lock is ignored)
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 			@seealso	-
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 			@param		-
217cdf0e10cSrcweir 			@return		A uno-type descriptor.
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 			@onerror	-
220cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 		virtual css::uno::Type SAL_CALL getElementType() throw( css::uno::RuntimeException );
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 		/*-****************************************************************************************************//**
225cdf0e10cSrcweir 			@short      get fill state of current container
226cdf0e10cSrcweir 			@descr		Call these to get information about, if items exist in container or not.
227cdf0e10cSrcweir 						(container-lock is ignored)
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 			@seealso	-
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 			@param		-
232cdf0e10cSrcweir 			@return		sal_True, if container contains some items.
233cdf0e10cSrcweir 			@return		sal_False, otherwise.
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 			@onerror	We return sal_False.
236cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
237cdf0e10cSrcweir 
238cdf0e10cSrcweir     	virtual sal_Bool SAL_CALL hasElements() throw( css::uno::RuntimeException );
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
241cdf0e10cSrcweir 	//	protected methods
242cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 	protected:
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 		/*-****************************************************************************************************//**
247cdf0e10cSrcweir 			@short		standard destructor
248cdf0e10cSrcweir 			@descr		This method destruct an instance of this class and clear some member.
249cdf0e10cSrcweir 						This method is protected, because its not allowed to use this class as a member!
250cdf0e10cSrcweir 						You MUST use a dynamical instance (pointer). That's the reason for a protected dtor.
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 			@seealso	-
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 			@param		-
255cdf0e10cSrcweir 			@return		-
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 			@onerror	-
258cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 		virtual	~OFrames();
261cdf0e10cSrcweir 
262cdf0e10cSrcweir 		/*-****************************************************************************************************//**
263cdf0e10cSrcweir 			@short		reset instance to default values
264cdf0e10cSrcweir 			@descr		There are two ways to delete an instance of this class.<BR>
265cdf0e10cSrcweir 						1) delete with destructor<BR>
266cdf0e10cSrcweir 						2) dispose from parent or factory ore ...<BR>
267cdf0e10cSrcweir 						This method do the same for both ways! It free used memory and release references ...
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 			@seealso	method dispose() (if it exist!)
270cdf0e10cSrcweir 			@seealso	destructor ~TaskEnumeration()
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 			@param		-
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 			@return		-
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 			@onerror	-
277cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
278cdf0e10cSrcweir 
279cdf0e10cSrcweir 		virtual void impl_resetObject();
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
282cdf0e10cSrcweir 	//	private methods
283cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 	private:
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 		/*-****************************************************************************************************//**
288cdf0e10cSrcweir 			@short		append one sequence to another
289cdf0e10cSrcweir 			@descr		There is no operation to add to sequences! Use this helper-method to do this.
290cdf0e10cSrcweir 
291cdf0e10cSrcweir 			@seealso	class Sequence
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 			@param		"seqDestination", reference to sequence on which operation will append the other sequence.
294cdf0e10cSrcweir 			@param		"seqSource"		, reference to sequence for append.
295cdf0e10cSrcweir 			@return		"seqDestination" is parameter AND return value at the same time.
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 			@onerror	-
298cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 		void impl_appendSequence(			css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >&	seqDestination	,
301cdf0e10cSrcweir 			 						const	css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >&	seqSource		);
302cdf0e10cSrcweir 
303cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
304cdf0e10cSrcweir 	//	debug methods
305cdf0e10cSrcweir 	//	(should be private everyway!)
306cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 		/*-****************************************************************************************************//**
309cdf0e10cSrcweir 			@short		debug-method to check incoming parameter of some other mehods of this class
310cdf0e10cSrcweir 			@descr		The following methods are used to check parameters for other methods
311cdf0e10cSrcweir 						of this class. The return value is used directly for an ASSERT(...).
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 			@seealso	ASSERTs in implementation!
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 			@param		references to checking variables
316cdf0e10cSrcweir 			@return		sal_False ,on invalid parameter
317cdf0e10cSrcweir 			@return		sal_True  ,otherwise
318cdf0e10cSrcweir 
319cdf0e10cSrcweir 			@onerror	-
320cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 	#ifdef ENABLE_ASSERTIONS
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 	private:
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 		static sal_Bool impldbg_checkParameter_OFramesCtor	(	const	css::uno::Reference< css::lang::XMultiServiceFactory >&	xFactory		,
327cdf0e10cSrcweir 																const	css::uno::Reference< css::frame::XFrame >&				xOwner			,
328cdf0e10cSrcweir 																		FrameContainer*											pFrameContainer	);
329cdf0e10cSrcweir 		static sal_Bool impldbg_checkParameter_append		(	const	css::uno::Reference< css::frame::XFrame >&				xFrame			);
330cdf0e10cSrcweir 		static sal_Bool impldbg_checkParameter_remove		(	const	css::uno::Reference< css::frame::XFrame >&				xFrame			);
331cdf0e10cSrcweir 		static sal_Bool impldbg_checkParameter_queryFrames	(			sal_Int32												nSearchFlags	);
332cdf0e10cSrcweir 
333cdf0e10cSrcweir 	#endif	// #ifdef ENABLE_ASSERTIONS
334cdf0e10cSrcweir 
335cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
336cdf0e10cSrcweir 	//	variables
337cdf0e10cSrcweir 	//	(should be private everyway!)
338cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
339cdf0e10cSrcweir 
340cdf0e10cSrcweir 	private:
341cdf0e10cSrcweir 
342cdf0e10cSrcweir 		css::uno::Reference< css::lang::XMultiServiceFactory >		m_xFactory						;	/// reference to global servicemanager
343cdf0e10cSrcweir 		css::uno::WeakReference< css::frame::XFrame >				m_xOwner						;	/// reference to owner of this instance (Hold no hard reference!)
344cdf0e10cSrcweir 		FrameContainer*												m_pFrameContainer				;	/// with owner shared list to hold all direct childs of an XFramesSupplier
345cdf0e10cSrcweir 		sal_Bool													m_bRecursiveSearchProtection	;	/// flag to protect against recursive searches of frames at parents
346cdf0e10cSrcweir 
347cdf0e10cSrcweir };		//	class OFrames
348cdf0e10cSrcweir 
349cdf0e10cSrcweir }		//	namespace framework
350cdf0e10cSrcweir 
351cdf0e10cSrcweir #endif	//	#ifndef __FRAMEWORK_HELPER_OFRAMES_HXX_
352