1rem ************************************************************* 2rem 3rem Licensed to the Apache Software Foundation (ASF) under one 4rem or more contributor license agreements. See the NOTICE file 5rem distributed with this work for additional information 6rem regarding copyright ownership. The ASF licenses this file 7rem to you under the Apache License, Version 2.0 (the 8rem "License"); you may not use this file except in compliance 9rem with the License. You may obtain a copy of the License at 10rem 11rem http://www.apache.org/licenses/LICENSE-2.0 12rem 13rem Unless required by applicable law or agreed to in writing, 14rem software distributed under the License is distributed on an 15rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16rem KIND, either express or implied. See the License for the 17rem specific language governing permissions and limitations 18rem under the License. 19rem 20rem ************************************************************* 21rem _______________________________________________________________________________________________________________________________________ 22rem Test script for helper class "framework/helper/OComponentAccess and OComponentEnumeration. 23rem These two classes are used for "framework/baeh_services/Desktop::getComponents()" only. 24rem _______________________________________________________________________________________________________________________________________ 25 26 27Sub Main 28 29 rem ___________________________________________________________________________________________________________________________________ 30 rem Get all current components of the frame tree as an enumeration access object. 31 rem The return value must be a valid reference! 32 xComponentAccess = StarDesktop.Components 33 if( isNull(xComponentAccess) = TRUE ) then 34 msgbox "Error: Desktop return null reference as enumeration access to all tree components!" 35 exit Sub 36 endif 37 38 rem ___________________________________________________________________________________________________________________________________ 39 rem Control service specification of helper class "framework/helper/OComponentAccess". 40 rem The follow output must occur: com.sun.star.lang.XTypeProvider 41 rem com.sun.star.container.XEnumerationAccess -> com.sun.star.container.XElementAccess 42 msgbox xComponentAccess.dbg_supportedInterfaces 43 44 rem ___________________________________________________________________________________________________________________________________ 45 rem Test interface XElementAccess of helper OComponentAcces. 46 47 rem Method hasElements() must return TRUE, because if you call this from the basic IDE at least one task must exist ... 48 rem the IDE by himself. Normally two tasks exist - an empty writer document and a basic frame. 49 rem Attention: Not all tasks or frames must support a full implemented component! 50 if( xComponentAccess.hasElements <> TRUE ) then 51 msgbox "Error: xComponentAccess has no elements - but I can't believe it!" 52 exit Sub 53 endif 54 55 rem Method getElementType() must return the cppu type of XComponent. 56 rem Otherwise something is wrong or implementation has changed. 57 if( xComponentAccess.getElementType.Name <> "com.sun.star.lang.XComponent" ) then 58 msgbox "Error: xComponentAccess return wrong type as element type! - Has implementation changed?" 59 exit Sub 60 endif 61 62 rem ___________________________________________________________________________________________________________________________________ 63 rem Test interface XEnumerationAccess of helper OComponentAcces. 64 rem The return value must be a valid reference! 65 xComponentEnumeration = xComponentAccess.createEnumeration 66 if( isNull(xComponentEnumeration) = TRUE ) then 67 msgbox "Error: Could not create a component enumeration!" 68 exit Sub 69 endif 70 71 rem ___________________________________________________________________________________________________________________________________ 72 rem Control service specification of helper class "framework/helper/OComponentEnumeration". 73 rem The follow output must occur: com.sun.star.lang.XTypeProvider 74 rem com.sun.star.lang.XEventListener 75 rem com.sun.star.container.XEnumeration 76 msgbox xComponentEnumeration.dbg_supportedInterfaces 77 78 rem ___________________________________________________________________________________________________________________________________ 79 rem Test interface XEnumeration of helper OComponentEnumeration. 80 nElementCounter = 0 81 while( xComponentEnumeration.hasMoreElements = TRUE ) 82 xElement = xComponentEnumeration.nextElement 83 if( isNull(xElement) = TRUE ) then 84 msgbox "Error: An empty component in enumeration detected! Whats wrong?" 85 exit Sub 86 endif 87 nElementCounter = nElementCounter + 1 88 wend 89 if( nElementCounter < 1 ) then 90 msgbox "Warning: The enumeration was empty. I think it's wrong ... please check it again." 91 endif 92 msgbox "Info: An enumeration with " + nElementCounter + " element(s) was detected." 93 94 rem ___________________________________________________________________________________________________________________________________ 95 rem If this point arrived our test was successful. 96 msgbox "Test of framework/helper/OComponentAccess & OComponentEnumeration was successful!" 97 98End Sub 99