1rem	_______________________________________________________________________________________________________________________________________
2rem	Test script for helper class "framework/helper/OComponentAccess and OComponentEnumeration.
3rem	These two classes are used for "framework/baeh_services/Desktop::getComponents()" only.
4rem	_______________________________________________________________________________________________________________________________________
5
6
7Sub Main
8
9	rem	___________________________________________________________________________________________________________________________________
10	rem	Get all current components of the frame tree as an enumeration access object.
11	rem	The return value must be a valid reference!
12	xComponentAccess = StarDesktop.Components
13	if( isNull(xComponentAccess) = TRUE ) then
14		msgbox "Error: Desktop return null reference as enumeration access to all tree components!"
15		exit Sub
16	endif
17
18	rem	___________________________________________________________________________________________________________________________________
19	rem	Control service specification of helper class "framework/helper/OComponentAccess".
20	rem	The follow output must occure:	com.sun.star.lang.XTypeProvider
21	rem									com.sun.star.container.XEnumerationAccess -> com.sun.star.container.XElementAccess
22	msgbox xComponentAccess.dbg_supportedInterfaces
23
24	rem	___________________________________________________________________________________________________________________________________
25	rem	Test interface XElementAccess of helper OComponentAcces.
26
27	rem	Method hasElements() must return TRUE, because if you call this from the basic IDE at least one task must exist ...
28	rem	the IDE by himself. Normaly two tasks exist - an empty writer document and a basic frame.
29	rem Attention: Not all tasks or frames must support a full implemented component!
30	if( xComponentAccess.hasElements <> TRUE ) then
31		msgbox "Error: xComponentAccess has no elements - but I can't believe it!"
32		exit Sub
33	endif
34
35	rem	Method getElementType() must return the cppu type of XComponent.
36	rem	Otherwise something is wrong or implementation has changed.
37	if( xComponentAccess.getElementType.Name <> "com.sun.star.lang.XComponent" ) then
38		msgbox "Error: xComponentAccess return wrong type as element type! - Has implementation changed?"
39		exit Sub
40	endif
41
42	rem	___________________________________________________________________________________________________________________________________
43	rem	Test interface XEnumerationAccess of helper OComponentAcces.
44	rem	The return value must be a valid reference!
45	xComponentEnumeration = xComponentAccess.createEnumeration
46	if( isNull(xComponentEnumeration) = TRUE ) then
47		msgbox "Error: Could not create a component enumeration!"
48		exit Sub
49	endif
50
51	rem ___________________________________________________________________________________________________________________________________
52	rem	Control service specification of helper class "framework/helper/OComponentEnumeration".
53	rem	The follow output must occure:	com.sun.star.lang.XTypeProvider
54	rem									com.sun.star.lang.XEventListener
55	rem									com.sun.star.container.XEnumeration
56	msgbox xComponentEnumeration.dbg_supportedInterfaces
57
58	rem ___________________________________________________________________________________________________________________________________
59	rem	Test interface XEnumeration of helper OComponentEnumeration.
60	nElementCounter = 0
61	while( xComponentEnumeration.hasMoreElements = TRUE )
62		xElement = xComponentEnumeration.nextElement
63		if( isNull(xElement) = TRUE ) then
64			msgbox "Error: An empty component in enumeration detected! Whats wrong?"
65			exit Sub
66		endif
67		nElementCounter = nElementCounter + 1
68	wend
69	if( nElementCounter < 1 ) then
70		msgbox "Warning: The enumeration was empty. I think it's wrong ... please check it again."
71	endif
72	msgbox "Info: An enumeration with " + nElementCounter + " element(s) was detected."
73
74	rem ___________________________________________________________________________________________________________________________________
75	rem If this point arrived our test was successful.
76	msgbox "Test of framework/helper/OComponentAccess & OComponentEnumeration was successful!"
77
78End Sub
79