OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

a little utility function for you

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
vbms
Power User
Power User


Joined: 13 Aug 2007
Posts: 63

PostPosted: Mon Aug 20, 2007 5:52 am    Post subject: a little utility function for you Reply with quote

it is oftern unclear to witch objects you can cast, get interfaces, services, propertys for this reason ... the following code helps

Code:

   private void printObjectInfo (Object xobj) {
      
      System.out.println("-------------- printing object info");
      
      XTypeProvider xTypeProvider = (XTypeProvider)
         UnoRuntime.queryInterface(XTypeProvider.class, xobj);
      
      if (xTypeProvider!=null) {
         Type [] types = xTypeProvider.getTypes();
         System.out.println("--------------------- Type names");
         for (int ix=0; ix<types.length; ix++) {
            System.out.println(types[ix].getTypeName());
         }
      }
      
      XServiceInfo xServiceInfo = (XServiceInfo)
         UnoRuntime.queryInterface(XServiceInfo.class, xobj);
      
      if (xServiceInfo!=null) {
         String [] serviceNames = xServiceInfo.getSupportedServiceNames();
         System.out.println("--------------------- supported service names");
         for (int ix=0; ix<serviceNames.length; ix++) {
            System.out.println(serviceNames[ix]);
         }
      }
      
      XPropertySet xPropertySet = (XPropertySet)
         UnoRuntime.queryInterface(XPropertySet.class, xobj);
      if (xPropertySet!=null) {
         Property [] prop = xPropertySet.getPropertySetInfo().getProperties();
         System.out.println("--------------------- property names");
         for (int ix=0; ix<prop.length; ix++) {
            System.out.println(prop[ix].Name);
         }
      }
      System.out.println("-------------- end");
   }


Last edited by vbms on Tue Aug 21, 2007 12:38 am; edited 1 time in total
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Mon Aug 20, 2007 8:04 am    Post subject: Reply with quote

Hi,

XRay is a very useful tool for OO Basic programmers to reveal interfaces, properties, and services of any objects. You may want to try to call XRay from Java ... this should be quite comfortable. See http://www.oooforum.org/forum/viewtopic.phtml?t=23333 as a starter. I do not know if the BeanShell method can be directly transported to normal Java.

ms777
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group