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