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