merge the formfield patch from ooo-build
[ooovba.git] / odk / examples / DevelopersGuide / Accessibility / NameProvider.java
blob2ca320f05ec92abf4db1ceeefc716a02945601de
1 /*************************************************************************
3 * $RCSfile: NameProvider.java,v $
5 * $Revision: 1.3 $
7 * last change: $Author: hr $ $Date: 2003-06-30 15:07:07 $
9 * The Contents of this file are made available subject to the terms of
10 * the BSD license.
12 * Copyright (c) 2003 by Sun Microsystems, Inc.
13 * All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
34 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *************************************************************************/
41 import java.util.HashMap;
42 import com.sun.star.accessibility.AccessibleStateType;
43 import com.sun.star.accessibility.AccessibleEventId;
44 import com.sun.star.accessibility.AccessibleRole;
45 import com.sun.star.accessibility.AccessibleRelationType;
48 /** Provide names for several accessibility constants groups.
50 public class NameProvider
52 /** Return the name of the specified state.
53 @param nStateId
54 Id of the state for which to return its name. This is one of
55 the ids listed in the <type>AccessibleStateType</const>
56 constants group.
57 @return
58 Returns the name of the specified state or an empty string if an
59 invalid / unknown state id was given.
61 public static String getStateName (int nStateId)
63 return (String)maStateMap.get (new Integer(nStateId));
67 /** Return the name of the specified event.
68 @param nEventId
69 Id of the event type for which to return its name. This is one
70 of the ids listed in the <type>AccessibleEventId</const>
71 constants group.
72 @return
73 Returns the name of the specified event type or an empty string
74 if an invalid / unknown event id was given.
76 public static String getEventName (int nEventId)
78 return (String)maEventMap.get (new Integer(nEventId));
82 /** Return the name of the specified role.
83 @param nRole
84 Id of the role for which to return its name. This is one of
85 the ids listed in the <type>AccessibleRole</const>
86 constants group.
87 @return
88 Returns the name of the specified role or an empty string if an
89 invalid / unknown role id was given.
91 public static String getRoleName (int nRole)
93 return (String)maRoleMap.get (new Integer(nRole));
97 /** Return the name of the specified relation.
98 @param nRelation
99 Id of the relation for which to return its name. This is one of
100 the ids listed in the <type>AccessibleRelationType</const>
101 constants group.
102 @return
103 Returns the name of the specified relation type or an empty
104 string if an invalid / unknown role id was given.
106 public static String getRelationName (int nRelation)
108 return (String)maRelationMap.get (new Integer(nRelation));
112 private static HashMap maStateMap = new HashMap();
113 private static HashMap maEventMap = new HashMap();
114 private static HashMap maRoleMap = new HashMap();
115 private static HashMap maRelationMap = new HashMap();
117 static {
118 maStateMap.put (new Integer (AccessibleStateType.INVALID), "INVALID");
119 maStateMap.put (new Integer (AccessibleStateType.ACTIVE), "ACTIVE");
120 maStateMap.put (new Integer (AccessibleStateType.ARMED), "ARMED");
121 maStateMap.put (new Integer (AccessibleStateType.BUSY), "BUSY");
122 maStateMap.put (new Integer (AccessibleStateType.CHECKED), "CHECKED");
123 maStateMap.put (new Integer (AccessibleStateType.DEFUNC), "DEFUNC");
124 maStateMap.put (new Integer (AccessibleStateType.EDITABLE), "EDITABLE");
125 maStateMap.put (new Integer (AccessibleStateType.ENABLED), "ENABLED");
126 maStateMap.put (new Integer (AccessibleStateType.EXPANDABLE), "EXPANDABLE");
127 maStateMap.put (new Integer (AccessibleStateType.EXPANDED), "EXPANDED");
128 maStateMap.put (new Integer (AccessibleStateType.FOCUSABLE), "FOCUSABLE");
129 maStateMap.put (new Integer (AccessibleStateType.FOCUSED), "FOCUSED");
130 maStateMap.put (new Integer (AccessibleStateType.HORIZONTAL), "HORIZONTAL");
131 maStateMap.put (new Integer (AccessibleStateType.ICONIFIED), "ICONIFIED");
132 maStateMap.put (new Integer (AccessibleStateType.MODAL), "MODAL");
133 maStateMap.put (new Integer (AccessibleStateType.MULTI_LINE), "MULTI_LINE");
134 maStateMap.put (new Integer (AccessibleStateType.MULTI_SELECTABLE), "MULTI_SELECTABLE");
135 maStateMap.put (new Integer (AccessibleStateType.OPAQUE), "OPAQUE");
136 maStateMap.put (new Integer (AccessibleStateType.PRESSED), "PRESSED");
137 maStateMap.put (new Integer (AccessibleStateType.RESIZABLE), "RESIZABLE");
138 maStateMap.put (new Integer (AccessibleStateType.SELECTABLE), "SELECTABLE");
139 maStateMap.put (new Integer (AccessibleStateType.SELECTED), "SELECTED");
140 maStateMap.put (new Integer (AccessibleStateType.SENSITIVE), "SENSITIVE");
141 maStateMap.put (new Integer (AccessibleStateType.SHOWING), "SHOWING");
142 maStateMap.put (new Integer (AccessibleStateType.SINGLE_LINE), "SINGLE_LINE");
143 maStateMap.put (new Integer (AccessibleStateType.STALE), "STALE");
144 maStateMap.put (new Integer (AccessibleStateType.TRANSIENT), "TRANSIENT");
145 maStateMap.put (new Integer (AccessibleStateType.VERTICAL), "VERTICAL");
146 maStateMap.put (new Integer (AccessibleStateType.VISIBLE), "VISIBLE");
147 maStateMap.put (new Integer (AccessibleStateType.MANAGES_DESCENDANTS),
148 "MANAGES_DESCENDANTS");
149 // maStateMap.put (new Integer (AccessibleStateType.INCONSISTENT),"INCONSISTENT");
152 maEventMap.put (new Integer (0),
153 "[UNKNOWN]");
154 maEventMap.put (new Integer (AccessibleEventId.NAME_CHANGED),
155 "NAME_CHANGED");
156 maEventMap.put (new Integer (AccessibleEventId.DESCRIPTION_CHANGED),
157 "DESCRIPTION_CHANGED");
158 maEventMap.put (new Integer (AccessibleEventId.ACTION_CHANGED),
159 "ACTION_CHANGED");
160 maEventMap.put (new Integer (AccessibleEventId.STATE_CHANGED),
161 "STATE_CHANGED");
162 maEventMap.put (new Integer (AccessibleEventId.ACTIVE_DESCENDANT_CHANGED),
163 "ACTIVE_DESCENDANT_CHANGED");
164 maEventMap.put (new Integer (AccessibleEventId.BOUNDRECT_CHANGED),
165 "BOUNDRECT_CHANGED");
166 maEventMap.put (new Integer (AccessibleEventId.CHILD),
167 "CHILD");
168 maEventMap.put (new Integer (AccessibleEventId.INVALIDATE_ALL_CHILDREN),
169 "INVALIDATE_ALL_CHILDREN");
170 maEventMap.put (new Integer (AccessibleEventId.SELECTION_CHANGED),
171 "SELECTION_CHANGED");
172 maEventMap.put (new Integer (AccessibleEventId.VISIBLE_DATA_CHANGED),
173 "VISIBLE_DATA_CHANGED");
174 maEventMap.put (new Integer (AccessibleEventId.VALUE_CHANGED),
175 "VALUE_CHANGED");
176 maEventMap.put (new Integer (AccessibleEventId.CONTENT_FLOWS_FROM_RELATION_CHANGED),
177 "CONTENT_FLOWS_FROM_RELATION_CHANGED");
178 maEventMap.put (new Integer (AccessibleEventId.CONTENT_FLOWS_TO_RELATION_CHANGED),
179 "CONTENT_FLOWS_TO_RELATION_CHANGED");
180 maEventMap.put (new Integer (AccessibleEventId.CONTROLLED_BY_RELATION_CHANGED),
181 "CONTROLLED_BY_RELATION_CHANGED");
182 maEventMap.put (new Integer (AccessibleEventId.CONTROLLER_FOR_RELATION_CHANGED),
183 "CONTROLLER_FOR_RELATION_CHANGED");
184 maEventMap.put (new Integer (AccessibleEventId.LABEL_FOR_RELATION_CHANGED),
185 "LABEL_FOR_RELATION_CHANGED");
186 maEventMap.put (new Integer (AccessibleEventId.LABELED_BY_RELATION_CHANGED),
187 "LABELED_BY_RELATION_CHANGED");
188 maEventMap.put (new Integer (AccessibleEventId.MEMBER_OF_RELATION_CHANGED),
189 "MEMBER_OF_RELATION_CHANGED");
190 maEventMap.put (new Integer (AccessibleEventId.SUB_WINDOW_OF_RELATION_CHANGED),
191 "SUB_WINDOW_OF_RELATION_CHANGED");
192 maEventMap.put (new Integer (AccessibleEventId.CARET_CHANGED),
193 "CARET_CHANGED");
194 maEventMap.put (new Integer (AccessibleEventId.TEXT_SELECTION_CHANGED),
195 "TEXT_SELECTION_CHANGED");
196 maEventMap.put (new Integer (AccessibleEventId.TEXT_CHANGED),
197 "TEXT_CHANGED");
198 maEventMap.put (new Integer (AccessibleEventId.TEXT_ATTRIBUTE_CHANGED),
199 "TEXT_ATTRIBUTE_CHANGED");
200 maEventMap.put (new Integer (AccessibleEventId.HYPERTEXT_CHANGED),
201 "HYPERTEXT_CHANGED");
202 maEventMap.put (new Integer (AccessibleEventId.TABLE_CAPTION_CHANGED),
203 "TABLE_CAPTION_CHANGED");
204 maEventMap.put (new Integer (AccessibleEventId.TABLE_COLUMN_DESCRIPTION_CHANGED),
205 "TABLE_COLUMN_DESCRIPTION_CHANGED");
206 maEventMap.put (new Integer (AccessibleEventId.TABLE_COLUMN_HEADER_CHANGED),
207 "TABLE_COLUMN_HEADER_CHANGED");
208 maEventMap.put (new Integer (AccessibleEventId.TABLE_MODEL_CHANGED),
209 "TABLE_MODEL_CHANGED");
210 maEventMap.put (new Integer (AccessibleEventId.TABLE_ROW_DESCRIPTION_CHANGED),
211 "TABLE_ROW_DESCRIPTION_CHANGED");
212 maEventMap.put (new Integer (AccessibleEventId.TABLE_ROW_HEADER_CHANGED),
213 "TABLE_ROW_HEADER_CHANGED");
214 maEventMap.put (new Integer (AccessibleEventId.TABLE_SUMMARY_CHANGED),
215 "TABLE_SUMMARY_CHANGED");
217 maRoleMap.put (new Integer(AccessibleRole.UNKNOWN), "UNKNOWN");
218 maRoleMap.put (new Integer (AccessibleRole.UNKNOWN), "UNKNOWN");
219 maRoleMap.put (new Integer (AccessibleRole.ALERT), "ALERT");
220 maRoleMap.put (new Integer (AccessibleRole.COLUMN_HEADER), "COLUMN_HEADER");
221 maRoleMap.put (new Integer (AccessibleRole.CANVAS), "CANVAS");
222 maRoleMap.put (new Integer (AccessibleRole.CHECK_BOX), "CHECK_BOX");
223 maRoleMap.put (new Integer (AccessibleRole.CHECK_MENU_ITEM), "CHECK_MENU_ITEM");
224 maRoleMap.put (new Integer (AccessibleRole.COLOR_CHOOSER), "COLOR_CHOOSER");
225 maRoleMap.put (new Integer (AccessibleRole.COMBO_BOX), "COMBO_BOX");
226 maRoleMap.put (new Integer (AccessibleRole.DESKTOP_ICON), "DESKTOP_ICON");
227 maRoleMap.put (new Integer (AccessibleRole.DESKTOP_PANE), "DESKTOP_PANE");
228 maRoleMap.put (new Integer (AccessibleRole.DIRECTORY_PANE), "DIRECTORY_PANE");
229 maRoleMap.put (new Integer (AccessibleRole.DIALOG), "DIALOG");
230 maRoleMap.put (new Integer (AccessibleRole.DOCUMENT), "DOCUMENT");
231 maRoleMap.put (new Integer (AccessibleRole.EMBEDDED_OBJECT), "EMBEDDED_OBJECT");
232 maRoleMap.put (new Integer (AccessibleRole.END_NOTE), "END_NOTE");
233 maRoleMap.put (new Integer (AccessibleRole.FILE_CHOOSER), "FILE_CHOOSER");
234 maRoleMap.put (new Integer (AccessibleRole.FILLER), "FILLER");
235 maRoleMap.put (new Integer (AccessibleRole.FONT_CHOOSER), "FONT_CHOOSER");
236 maRoleMap.put (new Integer (AccessibleRole.FOOTER), "FOOTER");
237 maRoleMap.put (new Integer (AccessibleRole.FOOTNOTE), "FOOTNOTE");
238 maRoleMap.put (new Integer (AccessibleRole.FRAME), "FRAME");
239 maRoleMap.put (new Integer (AccessibleRole.GLASS_PANE), "GLASS_PANE");
240 maRoleMap.put (new Integer (AccessibleRole.GRAPHIC), "GRAPHIC");
241 maRoleMap.put (new Integer (AccessibleRole.GROUP_BOX), "GROUP_BOX");
242 maRoleMap.put (new Integer (AccessibleRole.HEADER), "HEADER");
243 maRoleMap.put (new Integer (AccessibleRole.HEADING), "HEADING");
244 maRoleMap.put (new Integer (AccessibleRole.HYPER_LINK), "HYPER_LINK");
245 maRoleMap.put (new Integer (AccessibleRole.ICON), "ICON");
246 maRoleMap.put (new Integer (AccessibleRole.INTERNAL_FRAME), "INTERNAL_FRAME");
247 maRoleMap.put (new Integer (AccessibleRole.LABEL), "LABEL");
248 maRoleMap.put (new Integer (AccessibleRole.LAYERED_PANE), "LAYERED_PANE");
249 maRoleMap.put (new Integer (AccessibleRole.LIST), "LIST");
250 maRoleMap.put (new Integer (AccessibleRole.LIST_ITEM), "LIST_ITEM");
251 maRoleMap.put (new Integer (AccessibleRole.MENU), "MENU");
252 maRoleMap.put (new Integer (AccessibleRole.MENU_BAR), "MENU_BAR");
253 maRoleMap.put (new Integer (AccessibleRole.MENU_ITEM), "MENU_ITEM");
254 maRoleMap.put (new Integer (AccessibleRole.OPTION_PANE), "OPTION_PANE");
255 maRoleMap.put (new Integer (AccessibleRole.PAGE_TAB), "PAGE_TAB");
256 maRoleMap.put (new Integer (AccessibleRole.PAGE_TAB_LIST), "PAGE_TAB_LIST");
257 maRoleMap.put (new Integer (AccessibleRole.PANEL), "PANEL");
258 maRoleMap.put (new Integer (AccessibleRole.PARAGRAPH), "PARAGRAPH");
259 maRoleMap.put (new Integer (AccessibleRole.PASSWORD_TEXT), "PASSWORD_TEXT");
260 maRoleMap.put (new Integer (AccessibleRole.POPUP_MENU), "POPUP_MENU");
261 maRoleMap.put (new Integer (AccessibleRole.PUSH_BUTTON), "PUSH_BUTTON");
262 maRoleMap.put (new Integer (AccessibleRole.PROGRESS_BAR), "PROGRESS_BAR");
263 maRoleMap.put (new Integer (AccessibleRole.RADIO_BUTTON), "RADIO_BUTTON");
264 maRoleMap.put (new Integer (AccessibleRole.RADIO_MENU_ITEM), "RADIO_MENU_ITEM");
265 maRoleMap.put (new Integer (AccessibleRole.ROW_HEADER), "ROW_HEADER");
266 maRoleMap.put (new Integer (AccessibleRole.ROOT_PANE), "ROOT_PANE");
267 maRoleMap.put (new Integer (AccessibleRole.SCROLL_BAR), "SCROLL_BAR");
268 maRoleMap.put (new Integer (AccessibleRole.SCROLL_PANE), "SCROLL_PANE");
269 maRoleMap.put (new Integer (AccessibleRole.SHAPE), "SHAPE");
270 maRoleMap.put (new Integer (AccessibleRole.SEPARATOR), "SEPARATOR");
271 maRoleMap.put (new Integer (AccessibleRole.SLIDER), "SLIDER");
272 maRoleMap.put (new Integer (AccessibleRole.SPIN_BOX), "SPIN_BOX");
273 maRoleMap.put (new Integer (AccessibleRole.SPLIT_PANE), "SPLIT_PANE");
274 maRoleMap.put (new Integer (AccessibleRole.STATUS_BAR), "STATUS_BAR");
275 maRoleMap.put (new Integer (AccessibleRole.TABLE), "TABLE");
276 maRoleMap.put (new Integer (AccessibleRole.TABLE_CELL), "TABLE_CELL");
277 maRoleMap.put (new Integer (AccessibleRole.TEXT), "TEXT");
278 maRoleMap.put (new Integer (AccessibleRole.TEXT_FRAME), "TEXT_FRAME");
279 maRoleMap.put (new Integer (AccessibleRole.TOGGLE_BUTTON), "TOGGLE_BUTTON");
280 maRoleMap.put (new Integer (AccessibleRole.TOOL_BAR), "TOOL_BAR");
281 maRoleMap.put (new Integer (AccessibleRole.TOOL_TIP), "TOOL_TIP");
282 maRoleMap.put (new Integer (AccessibleRole.TREE), "TREE");
283 maRoleMap.put (new Integer (AccessibleRole.VIEW_PORT), "VIEW_PORT");
284 maRoleMap.put (new Integer (AccessibleRole.WINDOW), "WINDOW");
286 maRelationMap.put (new Integer (AccessibleRelationType.INVALID), "INVALID");
287 maRelationMap.put (new Integer (AccessibleRelationType.CONTENT_FLOWS_FROM), "CONTENT_FLOWS_FROM");
288 maRelationMap.put (new Integer (AccessibleRelationType.CONTENT_FLOWS_TO), "CONTENT_FLOWS_TO");
289 maRelationMap.put (new Integer (AccessibleRelationType.CONTROLLED_BY), "CONTROLLED_BY");
290 maRelationMap.put (new Integer (AccessibleRelationType.CONTROLLER_FOR), "CONTROLLER_FOR");
291 maRelationMap.put (new Integer (AccessibleRelationType.LABEL_FOR), "LABEL_FOR");
292 maRelationMap.put (new Integer (AccessibleRelationType.LABELED_BY), "LABELED_BY");
293 maRelationMap.put (new Integer (AccessibleRelationType.MEMBER_OF), "MEMBER_OF");
294 maRelationMap.put (new Integer (AccessibleRelationType.SUB_WINDOW_OF), "SUB_WINDOW_OF");