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