Hi Jürgen,

thank you for your feedback. It has clarified some things for me, but also one point is still up: XTypeDescriptionEnumerationAccess .createTypeDescriptionEnumeration() seems not to work as "announced in the docs": the enumeration can be restricted if one supplies a sequence of TypeClass values. Whenever I try to do that, an empty enumeration is created (I would be intrested in interfaces and services only).

Created another Java program version to demonstrate the effect:

----------------------- cut here ----------------------

import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;

import com.sun.star.bridge.XUnoUrlResolver;

import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.container.XHierarchicalNameAccess;

import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lang.XMultiServiceFactory;

import com.sun.star.reflection.TypeDescriptionSearchDepth;
import com.sun.star.reflection.XTypeDescription;
import com.sun.star.reflection.XTypeDescriptionEnumeration;
import com.sun.star.reflection.XTypeDescriptionEnumerationAccess;

import com.sun.star.uno.Type;
import com.sun.star.uno.TypeClass;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.uno.XCurrentContext;
import com.sun.star.uno.XInterface;
import com.sun.star.uno.XNamingService;


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
           );
           
say("tdEnum4.hasMoreElements()="+pp(""+tdEnum4.hasMoreElements())+"\n");

       }
       catch (Exception e)
       {
           say("\n--> exception occurred: "+pp(e));
       }
   }


   static void connect(String strPort)
   {
       try
       {
           
unoURL="uno:socket,host=localhost,port="+strPort+";urp;StarOffice.NamingService";
           say("unoURL:\t"+pp(unoURL));

           context=Bootstrap.createInitialComponentContext(null);
           say("context:\t"+pp(context));

           xuur=(XUnoUrlResolver) UnoRuntime.queryInterface(
               XUnoUrlResolver.class,
               context.getServiceManager().createInstanceWithContext(
                       "com.sun.star.bridge.UnoUrlResolver", context)
               );
           say("xuur:\t"+pp(xuur));

           xns=(XNamingService) UnoRuntime.queryInterface(
               XNamingService.class,
               xuur.resolve(unoURL)
               );
           say("xns:\t"+pp(xns));

           xmcf=(XMultiComponentFactory) UnoRuntime.queryInterface(
               XMultiComponentFactory.class,
               xns.getRegisteredObject("StarOffice.ServiceManager")
               );
           say("xmcf:\t"+pp(xmcf));

               // get the default context (should contain the singletons)
           xcc=(XComponentContext) UnoRuntime.queryInterface(
                   XComponentContext.class,
                   ((XPropertySet) UnoRuntime.queryInterface(
                       XPropertySet.class,
                       xmcf)).getPropertyValue("DefaultContext")
               );
           say("xcc:\t"+pp(xcc));
           say("");

               // get singletons
           theTypeDescriptionManager=(XHierarchicalNameAccess) 
UnoRuntime.queryInterface(
                   XHierarchicalNameAccess.class,
                   
xcc.getValueByName("/singletons/com.sun.star.reflection.theTypeDescriptionManager"));
           say("theTypeDescriptionManager:\t"+pp(theTypeDescriptionManager));
       }
       catch (Exception e)
       {
           say("sch...");
           e.printStackTrace();
       }
    }


   public static void main(String[] arguments) throws Exception
   {
           // default to port "1234"
       connect( arguments.length==0 ? "1234" : arguments[0] );

       testTypeDescriptionEnumeration();
       System.exit(0);
   }

   public static void say (String s)
   {
       System.err.println(s);
   }

   public static String pp (Object o)
   {
       if (o==null) return "<null> <-- <-- <--";
       return "<"+o+">";
   }
}

----------------------- cut here ----------------------


Output:
----------------------- cut here ----------------------

F:\work\ooo\tst>java TestTDEnum 8100
unoURL: <uno:socket,host=localhost,port=8100;urp;StarOffice.NamingService>
context:        <[EMAIL PROTECTED]>
xuur:   <[EMAIL PROTECTED]>
xns:    
<[Proxy:3736006,8763de8;msci[0];70eecbe18e211dab947faf9b9a0e22e,Type[com.sun.star.uno.XNamingService]]>
xmcf:   
<[Proxy:18734302,352a48;msci[0];70eecbe18e211dab947faf9b9a0e22e,Type[com.sun.star.lang.XMultiComponentFactory]]>
xcc:    
<[Proxy:23195919,3578c8;msci[0];70eecbe18e211dab947faf9b9a0e22e,Type[com.sun.star.uno.XComponentContext]]>

theTypeDescriptionManager:      
<[Proxy:18262862,35a1e8;msci[0];70eecbe18e211dab947faf9b9a0e22e,Type[com.sun.star.container.XHierarchicalNameAccess]]>

-------------------- ------------------ ------------------- -----------

testTypeDescriptionEnumeration(): enumerationAccess:
       
<[Proxy:17977639,35a1e8;msci[0];70eecbe18e211dab947faf9b9a0e22e,Type[com.sun.star.reflection.XTypeDescriptionEnumerationAccess]]>
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 ----------------------

Maybe you can see right away what I am doing wrong?

Regards,

---rony


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

Reply via email to