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