Hi Rony,

i haven't tested your Java program but i have tested it in Basic and it works as expected

sub Main
servicemgr = getProcessServiceManager()
tdmgr = servicemgr.DefaultContext.getValueByName("/singletons/com.sun.star.reflection.theTypeDescriptionManager")

Dim types(1)
types(0)= com.sun.star.uno.TypeClass.INTERFACE
types(1)= com.sun.star.uno.TypeClass.SERVICE
tds = tdmgr.createTypeDescriptionEnumeration("com.sun.star.text", types(), com.sun.star.reflection.TypeDescriptionSearchDepth.ONE)

while tds.hasMoreElements()
td = tds.nextTypeDescription()
print td.name
wend
end sub

When i have time i will test your Java program as well.

Juergen

Rony G. Flatscher wrote:
Hi Jürgen,

public class TestTDEnum
{
   static  String                 unoURL=null;
   static  XComponentContext      context=null;
   static  XUnoUrlResolver        xuur=null;
   static  XNamingService         xns=null;
   static  XMultiComponentFactory xmcf=null;
   static  XComponentContext      xcc=null;

public static XHierarchicalNameAccess theTypeDescriptionManager=null;

   static void testTypeDescriptionEnumeration()
   {

say("\n-------------------- ------------------ ------------------- -----------\n"); XTypeDescriptionEnumerationAccess enumerationAccess = (XTypeDescriptionEnumerationAccess) UnoRuntime.queryInterface(XTypeDescriptionEnumerationAccess.class, theTypeDescriptionManager);

say("testTypeDescriptionEnumeration(): enumerationAccess:\n\t"+pp(enumerationAccess));

       try
       {
           TypeClass tc[] = {TypeClass.INTERFACE, TypeClass.SERVICE};

XTypeDescriptionEnumeration tdEnum1=null, tdEnum2=null, tdEnum3=null, tdEnum4=null;

           String module="com.sun.star";   // module to analyze

say("Does not work, should enumerate all TypeClass.INTERFACE, TypeClass.SERVICE types:");
           tdEnum1=enumerationAccess.createTypeDescriptionEnumeration(
               module,             // module to analyze
               tc,                 // INTERFACE, SERVICE
TypeDescriptionSearchDepth.INFINITE // enumerate all submodules as well
           );
say("tdEnum1.hasMoreElements()="+pp(""+tdEnum1.hasMoreElements())+"\n");

           say("Does work: no restriction on types to enumerate:");
           tdEnum2=enumerationAccess.createTypeDescriptionEnumeration(
               module,             // module to analyze
new TypeClass[0], // all UNOIDL types, could also use null instead TypeDescriptionSearchDepth.INFINITE // enumerate all submodules as well
           );
say("tdEnum2.hasMoreElements()="+pp(""+tdEnum2.hasMoreElements())+"\n");

           say("Does work: no restriction on types to enumerate:");
           tdEnum3=enumerationAccess.createTypeDescriptionEnumeration(
               module,             // module to analyze
new TypeClass[0], // all UNOIDL types, could also use null instead TypeDescriptionSearchDepth.ONE // enumerate given module only
           );
say("tdEnum3.hasMoreElements()="+pp(""+tdEnum3.hasMoreElements())+"\n");

say("Does NOT work: trying to enumerate interface types only:");
           tdEnum4=enumerationAccess.createTypeDescriptionEnumeration(
               module,             // module to analyze
new TypeClass[] {TypeClass.INTERFACE} , // all UNOIDL types, could also use null instead TypeDescriptionSearchDepth.ONE // enumerate given module only
           );



The problem here is thast you search with TypeDescriptionSearchDepth.ONE in module com.sun.star for interfaces. TypeDescriptionSearchDepth.ONE means only in this module and not recursive. But in this module you will not find any interfaces. At this point you have to search with TypeDescriptionSearchDepth.INFINITE or you have to specify for exampe com.sun.star.lang


There are four examples of getting an enumeration above: the very first two *use* INFINITE. Yet the very first version where I explictly list TypeClass.INTERFACE and TypeClass.SERVICE returns an empty enumeration, the second one (givign no restrictions) brings them up.

Of course, your observation is right, that the base module "com.sun.star" has no interfaces (just modules), so I changed the program to work on "com.sun.star.text", which posesses interfaces, yet, "tdEnum4" (using ONE) above does still *not* yield an enumeration containing elements, although interfaces at that level *are* defined.

This is the relevant output (which now also shows the module's name), other than that it is the same as above, where tdEnum1 through tdEnum4 use variations of the arguments for createTypeDescriptionEnumeration():

------------------- cut here --------------
testTypeDescriptionEnumeration(): enumerationAccess:
<[Proxy:17977639,35a1e8;msci[0];6d2898e19a211dab6d7e51a2d5d17e2,Type[com.sun.star.reflection
.XTypeDescriptionEnumerationAccess]]>
Enumerating the module: <com.sun.star.text>:

Does not work, should enumerate all TypeClass.INTERFACE, TypeClass.SERVICE types:
tdEnum1.hasMoreElements()=<false>

Does work: no restriction on types to enumerate:
tdEnum2.hasMoreElements()=<true>

Does work: no restriction on types to enumerate:
tdEnum3.hasMoreElements()=<true>

Does NOT work: trying to enumerate interface types only:
tdEnum4.hasMoreElements()=<false>
------------------- cut here --------------

So, what do you think?

Regards,

---rony



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to