fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / toolkit / test / accessibility / AccessibleUNOHandler.java
blob8af27d19b25d43c1fd60f4b8ac00ba0b7685cd12
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 import com.sun.star.uno.UnoRuntime;
20 import com.sun.star.accessibility.XAccessibleContext;
21 import com.sun.star.lang.XServiceInfo;
22 import com.sun.star.lang.XTypeProvider;
23 import com.sun.star.uno.Type;
26 /** This handler displays lower level UNO information. These are the
27 supported services, interfaces, and the implementation name.
29 class AccessibleUNOHandler
30 extends NodeHandler
32 public NodeHandler createHandler (XAccessibleContext xContext)
34 if (xContext == null)
35 return null;
36 else
37 return new AccessibleUNOHandler (xContext);
40 public AccessibleUNOHandler()
44 public AccessibleUNOHandler (XAccessibleContext xContext)
46 maChildList.setSize (3);
49 private XServiceInfo GetServiceInfo (AccessibleTreeNode aNode)
51 XServiceInfo xServiceInfo = null;
52 if (aNode instanceof AccTreeNode)
53 xServiceInfo = UnoRuntime.queryInterface(
54 XServiceInfo.class, ((AccTreeNode)aNode).getContext());
55 return xServiceInfo;
57 private XTypeProvider GetTypeProvider (AccessibleTreeNode aNode)
59 XTypeProvider xTypeProvider = null;
60 if (aNode instanceof AccTreeNode)
61 xTypeProvider = UnoRuntime.queryInterface(
62 XTypeProvider.class, ((AccTreeNode)aNode).getContext());
63 return xTypeProvider;
66 public AccessibleTreeNode createChild (AccessibleTreeNode aParent,
67 int nIndex)
69 AccessibleTreeNode aChild = null;
70 XServiceInfo xServiceInfo;
71 switch (nIndex)
73 case 0 : // Implemenation name.
74 xServiceInfo = GetServiceInfo (aParent);
75 aChild = new StringNode ("Implementation name: " +
76 (xServiceInfo!=null ? xServiceInfo.getImplementationName()
77 : "<XServiceInfo not supported>"),
78 aParent);
79 break;
80 case 1 :
81 xServiceInfo = GetServiceInfo (aParent);
82 if (xServiceInfo == null)
83 aChild = new StringNode (
84 "Supported services: <XServiceInfo not supported>",
85 aParent);
86 else
87 aChild = CreateServiceTree (aParent, xServiceInfo);
88 break;
89 case 2 :
90 XTypeProvider xTypeProvider = GetTypeProvider (aParent);
91 if (xTypeProvider == null)
92 aChild = new StringNode (
93 "Supported interfaces: <XTypeProvider not supported>",
94 aParent);
95 else
96 aChild = CreateInterfaceTree (aParent, xTypeProvider);
97 break;
100 return aChild;
104 private AccessibleTreeNode CreateServiceTree (AccessibleTreeNode aParent,
105 XServiceInfo xServiceInfo)
107 String[] aServiceNames = xServiceInfo.getSupportedServiceNames();
108 VectorNode aNode = new VectorNode ("Supported Services", aParent);
110 int nCount = aServiceNames.length;
111 for (int i=0; i<nCount; i++)
112 aNode.addChild (new StringNode (aServiceNames[i], aParent));
114 return aNode;
117 private AccessibleTreeNode CreateInterfaceTree (AccessibleTreeNode aParent,
118 XTypeProvider xTypeProvider)
120 Type[] aTypes = xTypeProvider.getTypes();
121 VectorNode aNode = new VectorNode ("Supported Interfaces", aParent);
123 int nCount = aTypes.length;
124 for (int i=0; i<nCount; i++)
125 aNode.addChild (new StringNode (aTypes[i].getTypeName(), aParent));
127 return aNode;