xref: /AOO41X/main/toolkit/test/accessibility/InformationWriter.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir import java.lang.Thread;
2*cdf0e10cSrcweir 
3*cdf0e10cSrcweir import com.sun.star.awt.Rectangle;
4*cdf0e10cSrcweir import com.sun.star.awt.XWindow;
5*cdf0e10cSrcweir 
6*cdf0e10cSrcweir import com.sun.star.beans.Property;
7*cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
8*cdf0e10cSrcweir import com.sun.star.beans.XPropertySet;
9*cdf0e10cSrcweir import com.sun.star.beans.XPropertySetInfo;
10*cdf0e10cSrcweir 
11*cdf0e10cSrcweir import com.sun.star.container.XIndexAccess;
12*cdf0e10cSrcweir import com.sun.star.container.XChild;
13*cdf0e10cSrcweir import com.sun.star.container.XEnumerationAccess;
14*cdf0e10cSrcweir import com.sun.star.container.XEnumeration;
15*cdf0e10cSrcweir 
16*cdf0e10cSrcweir import com.sun.star.frame.XComponentLoader;
17*cdf0e10cSrcweir import com.sun.star.frame.XController;
18*cdf0e10cSrcweir import com.sun.star.frame.XDesktop;
19*cdf0e10cSrcweir import com.sun.star.frame.XFrame;
20*cdf0e10cSrcweir import com.sun.star.frame.XTasksSupplier;
21*cdf0e10cSrcweir import com.sun.star.frame.XTask;
22*cdf0e10cSrcweir 
23*cdf0e10cSrcweir import com.sun.star.lang.XComponent;
24*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
25*cdf0e10cSrcweir import com.sun.star.lang.XServiceInfo;
26*cdf0e10cSrcweir import com.sun.star.lang.XServiceName;
27*cdf0e10cSrcweir import com.sun.star.lang.XTypeProvider;
28*cdf0e10cSrcweir 
29*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
30*cdf0e10cSrcweir import com.sun.star.uno.XInterface;
31*cdf0e10cSrcweir import com.sun.star.uno.Type;
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir import com.sun.star.drawing.XDrawView;
34*cdf0e10cSrcweir import com.sun.star.drawing.XDrawPage;
35*cdf0e10cSrcweir import com.sun.star.drawing.XShapes;
36*cdf0e10cSrcweir import com.sun.star.drawing.XShape;
37*cdf0e10cSrcweir import com.sun.star.drawing.XShapeDescriptor;
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir import com.sun.star.accessibility.XAccessible;
40*cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleContext;
41*cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleComponent;
42*cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleRelationSet;
43*cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleStateSet;
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir public class InformationWriter
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir     public InformationWriter ()
48*cdf0e10cSrcweir     {
49*cdf0e10cSrcweir     }
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir     public void drawPageTest (XInterface xPage)
52*cdf0e10cSrcweir     {
53*cdf0e10cSrcweir         try
54*cdf0e10cSrcweir         {
55*cdf0e10cSrcweir             printProperty (xPage, "BorderBottom  ", "BorderBottom");
56*cdf0e10cSrcweir             printProperty (xPage, "BorderLeft    ", "BorderLeft");
57*cdf0e10cSrcweir             printProperty (xPage, "BorderRight   ", "BorderRight");
58*cdf0e10cSrcweir             printProperty (xPage, "BorderTop     ", "BorderTop");
59*cdf0e10cSrcweir             printProperty (xPage, "Height        ", "Height");
60*cdf0e10cSrcweir             printProperty (xPage, "Width         ", "Width");
61*cdf0e10cSrcweir             printProperty (xPage, "Number        ", "Number");
62*cdf0e10cSrcweir         }
63*cdf0e10cSrcweir         catch  (Exception e)
64*cdf0e10cSrcweir         {
65*cdf0e10cSrcweir             System.out.println ("caught exception while testing draw page:" + e);
66*cdf0e10cSrcweir         }
67*cdf0e10cSrcweir     }
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir     public void printProperty (XInterface xObject, String prefix, String name)
70*cdf0e10cSrcweir     {
71*cdf0e10cSrcweir         try
72*cdf0e10cSrcweir         {
73*cdf0e10cSrcweir             XPropertySet xPropertySet =  (XPropertySet) UnoRuntime.queryInterface(
74*cdf0e10cSrcweir                 XPropertySet.class, xObject);
75*cdf0e10cSrcweir             MessageArea.println (prefix +
76*cdf0e10cSrcweir                 xPropertySet.getPropertyValue (name));
77*cdf0e10cSrcweir         }
78*cdf0e10cSrcweir         catch (Exception e)
79*cdf0e10cSrcweir         {
80*cdf0e10cSrcweir             MessageArea.println ("caught exception while getting property "
81*cdf0e10cSrcweir                 + name + " : " + e);
82*cdf0e10cSrcweir         }
83*cdf0e10cSrcweir     }
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir     public void showShapes (XDrawPage xPage)
88*cdf0e10cSrcweir     {
89*cdf0e10cSrcweir         try
90*cdf0e10cSrcweir         {
91*cdf0e10cSrcweir             XIndexAccess xShapeList = (XIndexAccess) UnoRuntime.queryInterface(
92*cdf0e10cSrcweir                 XIndexAccess.class, xPage);
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir             MessageArea.println ("There are " + xShapeList.getCount()
95*cdf0e10cSrcweir                 + " shapes");
96*cdf0e10cSrcweir             for (int i=0; i<xShapeList.getCount(); i++)
97*cdf0e10cSrcweir             {
98*cdf0e10cSrcweir                 XShape xShape = (XShape) UnoRuntime.queryInterface(
99*cdf0e10cSrcweir                     XShape.class, xShapeList.getByIndex (i));
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir                 XShapeDescriptor xShapeDescriptor =
102*cdf0e10cSrcweir                     (XShapeDescriptor) UnoRuntime.queryInterface(
103*cdf0e10cSrcweir                         XShapeDescriptor.class, xShape);
104*cdf0e10cSrcweir                 String sName = xShapeDescriptor.getShapeType ();
105*cdf0e10cSrcweir                 MessageArea.println ("   shape " + i + " : " + sName);
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir                 XPropertySet xPropertySet =
108*cdf0e10cSrcweir                     (XPropertySet) UnoRuntime.queryInterface(
109*cdf0e10cSrcweir                         XPropertySet.class, xShape);
110*cdf0e10cSrcweir                 Integer nZOrder =
111*cdf0e10cSrcweir                     (Integer) xPropertySet.getPropertyValue ("ZOrder");
112*cdf0e10cSrcweir                 MessageArea.println ("   zorder = " + nZOrder);
113*cdf0e10cSrcweir             }
114*cdf0e10cSrcweir         }
115*cdf0e10cSrcweir         catch (Exception e)
116*cdf0e10cSrcweir         {
117*cdf0e10cSrcweir             MessageArea.println ("caught exception in showShapes: " + e);
118*cdf0e10cSrcweir         }
119*cdf0e10cSrcweir     }
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     /** @descr Print all available services of the given object to the
125*cdf0e10cSrcweir                 standard output.
126*cdf0e10cSrcweir     */
127*cdf0e10cSrcweir     public void showServices (XInterface xObject)
128*cdf0e10cSrcweir     {
129*cdf0e10cSrcweir         try
130*cdf0e10cSrcweir         {
131*cdf0e10cSrcweir             MessageArea.println ("Services:");
132*cdf0e10cSrcweir             XMultiServiceFactory xMSF = (XMultiServiceFactory) UnoRuntime.queryInterface (
133*cdf0e10cSrcweir                 XMultiServiceFactory.class,
134*cdf0e10cSrcweir                 xObject
135*cdf0e10cSrcweir                 );
136*cdf0e10cSrcweir             if (xMSF == null)
137*cdf0e10cSrcweir                 MessageArea.println ("    object does not support interface XMultiServiceFactory");
138*cdf0e10cSrcweir             else
139*cdf0e10cSrcweir             {
140*cdf0e10cSrcweir                 String[] sServiceNames = xMSF.getAvailableServiceNames ();
141*cdf0e10cSrcweir                 MessageArea.println ("    object can create "
142*cdf0e10cSrcweir                     + sServiceNames.length + " services");
143*cdf0e10cSrcweir                 for (int i=0; i<sServiceNames.length; i++)
144*cdf0e10cSrcweir                     MessageArea.println ("        service " + i + " : " + sServiceNames[i]);
145*cdf0e10cSrcweir             }
146*cdf0e10cSrcweir         }
147*cdf0e10cSrcweir         catch (Exception e)
148*cdf0e10cSrcweir         {
149*cdf0e10cSrcweir             MessageArea.println ("caught exception in showServices : " + e);
150*cdf0e10cSrcweir         }
151*cdf0e10cSrcweir     }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir     /** @descr Print the service and implementation name of the given
154*cdf0e10cSrcweir                 object.
155*cdf0e10cSrcweir     */
156*cdf0e10cSrcweir     public void showInfo (XInterface xObject)
157*cdf0e10cSrcweir     {
158*cdf0e10cSrcweir         try
159*cdf0e10cSrcweir         {
160*cdf0e10cSrcweir             System.out.println ("Info:");
161*cdf0e10cSrcweir             // Use interface XServiceName to retrieve name of (main) service.
162*cdf0e10cSrcweir             XServiceName xSN = (XServiceName) UnoRuntime.queryInterface (
163*cdf0e10cSrcweir                 XServiceName.class, xObject);
164*cdf0e10cSrcweir             if (xSN == null)
165*cdf0e10cSrcweir                 MessageArea.println ("    interface XServiceName not supported");
166*cdf0e10cSrcweir             else
167*cdf0e10cSrcweir             {
168*cdf0e10cSrcweir                 MessageArea.println ("    Service name        : " + xSN.getServiceName ());
169*cdf0e10cSrcweir             }
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir             // Use interface XServiceInfo to retrieve information about
172*cdf0e10cSrcweir             // supported services.
173*cdf0e10cSrcweir             XServiceInfo xSI = (XServiceInfo) UnoRuntime.queryInterface (
174*cdf0e10cSrcweir                 XServiceInfo.class, xObject);
175*cdf0e10cSrcweir             if (xSI == null)
176*cdf0e10cSrcweir                 MessageArea.println ("    interface XServiceInfo not supported");
177*cdf0e10cSrcweir             else
178*cdf0e10cSrcweir             {
179*cdf0e10cSrcweir                 MessageArea.println ("    Implementation name : "
180*cdf0e10cSrcweir                     + xSI.getImplementationName ());
181*cdf0e10cSrcweir             }
182*cdf0e10cSrcweir         }
183*cdf0e10cSrcweir         catch (Exception e)
184*cdf0e10cSrcweir         {
185*cdf0e10cSrcweir             MessageArea.println ("caught exception in showInfo : " + e);
186*cdf0e10cSrcweir         }
187*cdf0e10cSrcweir     }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir     /** @descr Print information about supported interfaces.
193*cdf0e10cSrcweir     */
194*cdf0e10cSrcweir     public void showInterfaces (XInterface xObject)
195*cdf0e10cSrcweir     {
196*cdf0e10cSrcweir         try
197*cdf0e10cSrcweir         {
198*cdf0e10cSrcweir             MessageArea.println ("Interfaces:");
199*cdf0e10cSrcweir             // Use interface XTypeProvider to retrieve a list of supported
200*cdf0e10cSrcweir             // interfaces.
201*cdf0e10cSrcweir             XTypeProvider xTP = (XTypeProvider) UnoRuntime.queryInterface (
202*cdf0e10cSrcweir                 XTypeProvider.class, xObject);
203*cdf0e10cSrcweir             if (xTP == null)
204*cdf0e10cSrcweir                 MessageArea.println ("    interface XTypeProvider not supported");
205*cdf0e10cSrcweir             else
206*cdf0e10cSrcweir             {
207*cdf0e10cSrcweir                 Type[] aTypeList = xTP.getTypes ();
208*cdf0e10cSrcweir                 MessageArea.println ("    object supports " + aTypeList.length
209*cdf0e10cSrcweir                     + " interfaces");
210*cdf0e10cSrcweir                 for (int i=0; i<aTypeList.length; i++)
211*cdf0e10cSrcweir                     MessageArea.println ("        " + i + " : "
212*cdf0e10cSrcweir                         + aTypeList[i].getTypeName());
213*cdf0e10cSrcweir             }
214*cdf0e10cSrcweir         }
215*cdf0e10cSrcweir         catch (Exception e)
216*cdf0e10cSrcweir         {
217*cdf0e10cSrcweir             MessageArea.println ("caught exception in showInterfaces : " + e);
218*cdf0e10cSrcweir         }
219*cdf0e10cSrcweir     }
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir     /** @descr Print information concerning the accessibility of the given
223*cdf0e10cSrcweir         object.
224*cdf0e10cSrcweir     */
225*cdf0e10cSrcweir     public boolean showAccessibility (XInterface xObject, int depth)
226*cdf0e10cSrcweir     {
227*cdf0e10cSrcweir         try
228*cdf0e10cSrcweir         {
229*cdf0e10cSrcweir             // Create indentation string.
230*cdf0e10cSrcweir             String sIndent = "";
231*cdf0e10cSrcweir             while (depth-- > 0)
232*cdf0e10cSrcweir                 sIndent += "    ";
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir             //  Get XAccessibleContext object if given object does not
235*cdf0e10cSrcweir             //  already support this interface.
236*cdf0e10cSrcweir             XAccessibleContext xContext
237*cdf0e10cSrcweir                 = (XAccessibleContext) UnoRuntime.queryInterface (
238*cdf0e10cSrcweir                     XAccessibleContext.class, xObject);
239*cdf0e10cSrcweir             if (xContext == null)
240*cdf0e10cSrcweir             {
241*cdf0e10cSrcweir                 XAccessible xAccessible
242*cdf0e10cSrcweir                     = (XAccessible) UnoRuntime.queryInterface (
243*cdf0e10cSrcweir                         XAccessible.class, xObject);
244*cdf0e10cSrcweir                 if (xAccessible == null)
245*cdf0e10cSrcweir                 {
246*cdf0e10cSrcweir                     MessageArea.println (sIndent + "given object " + xObject
247*cdf0e10cSrcweir                         + " is not accessible");
248*cdf0e10cSrcweir                     return false;
249*cdf0e10cSrcweir                 }
250*cdf0e10cSrcweir                 else
251*cdf0e10cSrcweir                     xContext = xAccessible.getAccessibleContext();
252*cdf0e10cSrcweir             }
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir             //  Print information about the accessible context.
255*cdf0e10cSrcweir             if (xContext != null)
256*cdf0e10cSrcweir             {
257*cdf0e10cSrcweir                 MessageArea.println (sIndent + "Name         : "
258*cdf0e10cSrcweir                     + xContext.getAccessibleName());
259*cdf0e10cSrcweir                 MessageArea.println (sIndent + "Description  : "
260*cdf0e10cSrcweir                     + xContext.getAccessibleDescription());
261*cdf0e10cSrcweir                 MessageArea.println (sIndent + "Role         : "
262*cdf0e10cSrcweir                     + xContext.getAccessibleRole());
263*cdf0e10cSrcweir                 String sHasParent;
264*cdf0e10cSrcweir                 if (xContext.getAccessibleParent() != null)
265*cdf0e10cSrcweir                 {
266*cdf0e10cSrcweir                     MessageArea.println (sIndent + "Has parent   : yes");
267*cdf0e10cSrcweir                     MessageArea.println (sIndent + "Parent index : "
268*cdf0e10cSrcweir                         + xContext.getAccessibleIndexInParent());
269*cdf0e10cSrcweir                 }
270*cdf0e10cSrcweir                 else
271*cdf0e10cSrcweir                     MessageArea.println (sIndent + "Has parent   : no");
272*cdf0e10cSrcweir                 MessageArea.println (sIndent + "Child count  : "
273*cdf0e10cSrcweir                     + xContext.getAccessibleChildCount());
274*cdf0e10cSrcweir                 MessageArea.print (sIndent + "Relation set : ");
275*cdf0e10cSrcweir                 XAccessibleRelationSet xRelationSet
276*cdf0e10cSrcweir                     = xContext.getAccessibleRelationSet();
277*cdf0e10cSrcweir                 if (xRelationSet != null)
278*cdf0e10cSrcweir                 {
279*cdf0e10cSrcweir                     MessageArea.print (xRelationSet.getRelationCount() + " (");
280*cdf0e10cSrcweir                     for (int i=0; i<xRelationSet.getRelationCount(); i++)
281*cdf0e10cSrcweir                     {
282*cdf0e10cSrcweir                         if (i > 0)
283*cdf0e10cSrcweir                             MessageArea.print (", ");
284*cdf0e10cSrcweir                         MessageArea.print (xRelationSet.getRelation(i).toString());
285*cdf0e10cSrcweir                     }
286*cdf0e10cSrcweir                     MessageArea.println (")");
287*cdf0e10cSrcweir                 }
288*cdf0e10cSrcweir                 else
289*cdf0e10cSrcweir                     MessageArea.println ("no relation set");
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir                 MessageArea.print (sIndent + "State set    : ");
292*cdf0e10cSrcweir                 XAccessibleStateSet xStateSet =
293*cdf0e10cSrcweir                     xContext.getAccessibleStateSet();
294*cdf0e10cSrcweir                 if (xStateSet != null)
295*cdf0e10cSrcweir                 {
296*cdf0e10cSrcweir                     XIndexAccess xStates =
297*cdf0e10cSrcweir                         (XIndexAccess) UnoRuntime.queryInterface (
298*cdf0e10cSrcweir                             XIndexAccess.class, xStateSet);
299*cdf0e10cSrcweir                     MessageArea.print (xStates.getCount() + " (");
300*cdf0e10cSrcweir                     for (int i=0; i<xStates.getCount(); i++)
301*cdf0e10cSrcweir                     {
302*cdf0e10cSrcweir                         if (i > 0)
303*cdf0e10cSrcweir                             MessageArea.print (", ");
304*cdf0e10cSrcweir                         MessageArea.print (xStates.getByIndex(i).toString());
305*cdf0e10cSrcweir                     }
306*cdf0e10cSrcweir                     MessageArea.println (")");
307*cdf0e10cSrcweir                 }
308*cdf0e10cSrcweir                 else
309*cdf0e10cSrcweir                     MessageArea.println ("no state set");
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir                 showAccessibleComponent (xContext, sIndent);
312*cdf0e10cSrcweir             }
313*cdf0e10cSrcweir             else
314*cdf0e10cSrcweir                 MessageArea.println ("object has no accessible context.");
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir             //            showInfo (xContext);
317*cdf0e10cSrcweir             //            showServices (xContext);
318*cdf0e10cSrcweir             //            showInterfaces (xContext);
319*cdf0e10cSrcweir         }
320*cdf0e10cSrcweir         catch (Exception e)
321*cdf0e10cSrcweir         {
322*cdf0e10cSrcweir             System.out.println ("caught exception in showAccessibility :" + e);
323*cdf0e10cSrcweir         }
324*cdf0e10cSrcweir         return true;
325*cdf0e10cSrcweir     }
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir     /** @descr Print information about the given accessible component.
331*cdf0e10cSrcweir     */
332*cdf0e10cSrcweir     public void showAccessibleComponent (XInterface xObject, String sIndent)
333*cdf0e10cSrcweir     {
334*cdf0e10cSrcweir         try
335*cdf0e10cSrcweir         {
336*cdf0e10cSrcweir             XAccessibleComponent xComponent =
337*cdf0e10cSrcweir                 (XAccessibleComponent) UnoRuntime.queryInterface (
338*cdf0e10cSrcweir                     XAccessibleComponent.class, xObject);
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir             //  Print information about the accessible context.
341*cdf0e10cSrcweir             if (xComponent != null)
342*cdf0e10cSrcweir             {
343*cdf0e10cSrcweir                 MessageArea.println (sIndent + "Position        : "
344*cdf0e10cSrcweir                     + xComponent.getLocation().X+", "
345*cdf0e10cSrcweir                     + xComponent.getLocation().Y);
346*cdf0e10cSrcweir                 MessageArea.println (sIndent + "Screen position : "
347*cdf0e10cSrcweir                     + xComponent.getLocationOnScreen().X+", "
348*cdf0e10cSrcweir                     + xComponent.getLocationOnScreen().Y);
349*cdf0e10cSrcweir                 MessageArea.println (sIndent + "Size            : "
350*cdf0e10cSrcweir                     + xComponent.getSize().Width+", "
351*cdf0e10cSrcweir                     + xComponent.getSize().Height);
352*cdf0e10cSrcweir             }
353*cdf0e10cSrcweir         }
354*cdf0e10cSrcweir         catch (Exception e)
355*cdf0e10cSrcweir         {
356*cdf0e10cSrcweir             System.out.println (
357*cdf0e10cSrcweir                 "caught exception in showAccessibleComponent : " + e);
358*cdf0e10cSrcweir         }
359*cdf0e10cSrcweir     }
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir     /** Show a textual representation of the accessibility subtree rooted in
363*cdf0e10cSrcweir         xRoot.
364*cdf0e10cSrcweir     */
365*cdf0e10cSrcweir     public boolean showAccessibilityTree (XAccessible xRoot, int depth)
366*cdf0e10cSrcweir     {
367*cdf0e10cSrcweir         try
368*cdf0e10cSrcweir         {
369*cdf0e10cSrcweir             if ( ! showAccessibility (xRoot, depth))
370*cdf0e10cSrcweir                 return false;
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir             String sIndent = "";
373*cdf0e10cSrcweir             for (int i=0; i<depth; i++)
374*cdf0e10cSrcweir                 sIndent += "    ";
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir             //  Iterate over children and show them.
377*cdf0e10cSrcweir             XAccessibleContext xContext = xRoot.getAccessibleContext();
378*cdf0e10cSrcweir             if (xContext != null)
379*cdf0e10cSrcweir             {
380*cdf0e10cSrcweir                 int n = xContext.getAccessibleChildCount();
381*cdf0e10cSrcweir                 for (int i=0; i<n; i++)
382*cdf0e10cSrcweir                 {
383*cdf0e10cSrcweir                     MessageArea.println (sIndent + "child " + i + " :");
384*cdf0e10cSrcweir                     showAccessibilityTree (xContext.getAccessibleChild(i),depth+1);
385*cdf0e10cSrcweir                 }
386*cdf0e10cSrcweir             }
387*cdf0e10cSrcweir             else
388*cdf0e10cSrcweir                 MessageArea.println ("Accessible object has no context");
389*cdf0e10cSrcweir         }
390*cdf0e10cSrcweir         catch (Exception e)
391*cdf0e10cSrcweir         {
392*cdf0e10cSrcweir             System.out.println (
393*cdf0e10cSrcweir                 "caught exception in showAccessibleTree : " + e);
394*cdf0e10cSrcweir             return false;
395*cdf0e10cSrcweir         }
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir         return true;
398*cdf0e10cSrcweir     }
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir     public void showProperties (XInterface xObject)
401*cdf0e10cSrcweir     {
402*cdf0e10cSrcweir         XPropertySet xSet = (XPropertySet) UnoRuntime.queryInterface (
403*cdf0e10cSrcweir             XPropertySet.class, xObject);
404*cdf0e10cSrcweir         if (xSet == null)
405*cdf0e10cSrcweir             MessageArea.println ("object does not support XPropertySet");
406*cdf0e10cSrcweir         else
407*cdf0e10cSrcweir         {
408*cdf0e10cSrcweir             XPropertySetInfo xInfo = xSet.getPropertySetInfo ();
409*cdf0e10cSrcweir             Property[] aProperties = xInfo.getProperties ();
410*cdf0e10cSrcweir             int n = aProperties.length;
411*cdf0e10cSrcweir             for (int i=0; i<n; i++)
412*cdf0e10cSrcweir                 MessageArea.println (i + " : " + aProperties[i].Name +", " + aProperties[i].Type);
413*cdf0e10cSrcweir         }
414*cdf0e10cSrcweir     }
415*cdf0e10cSrcweir }
416