1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 import com.sun.star.uno.UnoRuntime;
23 import com.sun.star.accessibility.XAccessibleContext;
24 import com.sun.star.accessibility.XAccessibleExtendedComponent;
25 
26 
27 class AccessibleExtendedComponentHandler
28     extends NodeHandler
29 {
createHandler(XAccessibleContext xContext)30     public NodeHandler createHandler (XAccessibleContext xContext)
31     {
32         XAccessibleExtendedComponent xEComponent =
33             (XAccessibleExtendedComponent) UnoRuntime.queryInterface (
34                 XAccessibleExtendedComponent.class, xContext);
35         if (xEComponent != null)
36             return new AccessibleExtendedComponentHandler (xEComponent);
37         else
38             return null;
39     }
40 
AccessibleExtendedComponentHandler()41     public AccessibleExtendedComponentHandler ()
42     {
43     }
44 
AccessibleExtendedComponentHandler(XAccessibleExtendedComponent xEComponent)45     public AccessibleExtendedComponentHandler (XAccessibleExtendedComponent xEComponent)
46     {
47         if (xEComponent != null)
48             maChildList.setSize (0);
49     }
50 
getComponent(AccTreeNode aNode)51     private static XAccessibleExtendedComponent getComponent (AccTreeNode aNode)
52     {
53         return (XAccessibleExtendedComponent) UnoRuntime.queryInterface (
54             XAccessibleExtendedComponent.class,
55             aNode.getContext());
56     }
57 
58 
createChild(AccessibleTreeNode aParent, int nIndex)59     public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex)
60     {
61         AccessibleTreeNode aChild = null;
62         if (aParent instanceof AccTreeNode)
63         {
64             XAccessibleExtendedComponent xEComponent = getComponent ((AccTreeNode)aParent);
65 
66             if (xEComponent != null)
67             {
68                 int nColor;
69                 switch( nIndex )
70                 {
71                     case 0:
72                         nColor = xEComponent.getForeground();
73                         aChild = new StringNode ("Depricated Foreground color: R"
74                             +       (nColor>>16&0xff)
75                             + "G" + (nColor>>8&0xff)
76                             + "B" + (nColor>>0&0xff)
77                             + "A" + (nColor>>24&0xff),
78                             aParent);
79                         break;
80                     case 1:
81                         nColor = xEComponent.getBackground();
82                         aChild = new StringNode ("Depricated Background color: R"
83                             +       (nColor>>16&0xff)
84                             + "G" + (nColor>>8&0xff)
85                             + "B" + (nColor>>0&0xff)
86                             + "A" + (nColor>>24&0xff),
87                             aParent);
88                         break;
89                 }
90             }
91         }
92         return aChild;
93     }
94 }
95