1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: aqua11yrolehelper.mm,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_vcl.hxx"
35 #include "aqua11yrolehelper.h"
36 #include "aqua11yfactory.h"
37 #include <com/sun/star/accessibility/AccessibleRole.hpp>
38 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
40 using namespace ::com::sun::star::accessibility;
41 using namespace ::com::sun::star::uno;
43 @implementation AquaA11yRoleHelper
45 +(id)simpleMapNativeRoleFrom: (XAccessibleContext *) accessibleContext {
47 switch( accessibleContext -> getAccessibleRole() ) {
49 case a: nativeRole = b; break
51 MAP( AccessibleRole::UNKNOWN, NSAccessibilityUnknownRole );
52 MAP( AccessibleRole::ALERT, NSAccessibilityUnknownRole ); // FIXME
53 MAP( AccessibleRole::COLUMN_HEADER, NSAccessibilityColumnRole );
54 MAP( AccessibleRole::CANVAS, NSAccessibilityUnknownRole ); // FIXME
55 MAP( AccessibleRole::CHECK_BOX, NSAccessibilityCheckBoxRole );
56 MAP( AccessibleRole::CHECK_MENU_ITEM, NSAccessibilityUnknownRole ); // FIXME
57 MAP( AccessibleRole::COLOR_CHOOSER, NSAccessibilityColorWellRole ); // FIXME
58 MAP( AccessibleRole::COMBO_BOX, NSAccessibilityComboBoxRole );
59 MAP( AccessibleRole::DATE_EDITOR, NSAccessibilityUnknownRole ); // FIXME
60 MAP( AccessibleRole::DESKTOP_ICON, NSAccessibilityUnknownRole ); // FIXME
61 MAP( AccessibleRole::DESKTOP_PANE, NSAccessibilityUnknownRole ); // FIXME
62 MAP( AccessibleRole::DIRECTORY_PANE, NSAccessibilityUnknownRole ); // FIXME
63 MAP( AccessibleRole::DIALOG, NSAccessibilityGroupRole );
64 MAP( AccessibleRole::DOCUMENT, NSAccessibilityGroupRole );
65 MAP( AccessibleRole::EMBEDDED_OBJECT, NSAccessibilityUnknownRole ); // FIXME
66 MAP( AccessibleRole::END_NOTE, NSAccessibilityUnknownRole ); // FIXME
67 MAP( AccessibleRole::FILE_CHOOSER, NSAccessibilityUnknownRole ); // FIXME
68 MAP( AccessibleRole::FILLER, NSAccessibilityUnknownRole ); // FIXME
69 MAP( AccessibleRole::FONT_CHOOSER, NSAccessibilityUnknownRole ); // FIXME
70 MAP( AccessibleRole::FOOTER, NSAccessibilityUnknownRole ); // FIXME
71 MAP( AccessibleRole::FOOTNOTE, NSAccessibilityUnknownRole ); // FIXME
72 MAP( AccessibleRole::FRAME, NSAccessibilityWindowRole );
73 MAP( AccessibleRole::GLASS_PANE, NSAccessibilityUnknownRole ); // FIXME
74 MAP( AccessibleRole::GRAPHIC, NSAccessibilityImageRole );
75 MAP( AccessibleRole::GROUP_BOX, NSAccessibilityGroupRole );
76 MAP( AccessibleRole::HEADER, NSAccessibilityUnknownRole ); // FIXME
77 MAP( AccessibleRole::HEADING, NSAccessibilityUnknownRole ); // FIXME
78 MAP( AccessibleRole::HYPER_LINK, NSAccessibilityLinkRole );
79 MAP( AccessibleRole::ICON, NSAccessibilityImageRole );
80 MAP( AccessibleRole::INTERNAL_FRAME, NSAccessibilityUnknownRole ); // FIXME
81 MAP( AccessibleRole::LABEL, NSAccessibilityStaticTextRole );
82 MAP( AccessibleRole::LAYERED_PANE, NSAccessibilityUnknownRole ); // FIXME
83 MAP( AccessibleRole::LIST, NSAccessibilityMenuRole );
84 MAP( AccessibleRole::LIST_ITEM, NSAccessibilityMenuItemRole );
85 MAP( AccessibleRole::MENU, NSAccessibilityMenuRole );
86 MAP( AccessibleRole::MENU_BAR, NSAccessibilityMenuBarRole );
87 MAP( AccessibleRole::MENU_ITEM, NSAccessibilityMenuItemRole );
88 MAP( AccessibleRole::OPTION_PANE, NSAccessibilityUnknownRole ); // FIXME
89 MAP( AccessibleRole::PAGE_TAB, NSAccessibilityButtonRole );
90 MAP( AccessibleRole::PAGE_TAB_LIST, NSAccessibilityTabGroupRole );
91 MAP( AccessibleRole::PANEL, NSAccessibilityGroupRole );
92 MAP( AccessibleRole::PARAGRAPH, NSAccessibilityTextAreaRole );
93 MAP( AccessibleRole::PASSWORD_TEXT, NSAccessibilityTextFieldRole );
94 MAP( AccessibleRole::POPUP_MENU, NSAccessibilityMenuRole );
95 MAP( AccessibleRole::PUSH_BUTTON, NSAccessibilityButtonRole );
96 MAP( AccessibleRole::PROGRESS_BAR, NSAccessibilityProgressIndicatorRole );
97 MAP( AccessibleRole::RADIO_BUTTON, NSAccessibilityRadioButtonRole );
98 MAP( AccessibleRole::RADIO_MENU_ITEM, NSAccessibilityUnknownRole ); // FIXME
99 MAP( AccessibleRole::ROW_HEADER, NSAccessibilityRowRole );
100 MAP( AccessibleRole::ROOT_PANE, NSAccessibilityUnknownRole ); // FIXME
101 MAP( AccessibleRole::SCROLL_BAR, NSAccessibilityScrollBarRole );
102 MAP( AccessibleRole::SCROLL_PANE, NSAccessibilityScrollAreaRole );
103 MAP( AccessibleRole::SHAPE, NSAccessibilityUnknownRole ); // FIXME
104 MAP( AccessibleRole::SEPARATOR, NSAccessibilitySplitterRole ); // FIXME
105 MAP( AccessibleRole::SLIDER, NSAccessibilitySliderRole );
106 MAP( AccessibleRole::SPIN_BOX, NSAccessibilityUnknownRole ); // FIXME
107 MAP( AccessibleRole::SPLIT_PANE, NSAccessibilitySplitterRole );
108 MAP( AccessibleRole::STATUS_BAR, NSAccessibilityGroupRole ); // FIXME
109 MAP( AccessibleRole::TABLE, NSAccessibilityTableRole );
110 MAP( AccessibleRole::TABLE_CELL, NSAccessibilityTextFieldRole );
111 MAP( AccessibleRole::TEXT, NSAccessibilityTextAreaRole );
112 MAP( AccessibleRole::TEXT_FRAME, NSAccessibilityGroupRole );
113 MAP( AccessibleRole::TOGGLE_BUTTON, NSAccessibilityCheckBoxRole );
114 MAP( AccessibleRole::TOOL_BAR, NSAccessibilityToolbarRole );
115 MAP( AccessibleRole::TOOL_TIP, NSAccessibilityUnknownRole ); // FIXME
116 MAP( AccessibleRole::TREE, NSAccessibilityGroupRole );
117 MAP( AccessibleRole::VIEW_PORT, NSAccessibilityUnknownRole ); // FIXME
118 MAP( AccessibleRole::WINDOW, NSAccessibilityWindowRole );
120 MAP( AccessibleRole::BUTTON_DROPDOWN, NSAccessibilityMenuButtonRole );
121 MAP( AccessibleRole::BUTTON_MENU, NSAccessibilityMenuButtonRole );
122 MAP( AccessibleRole::CAPTION, NSAccessibilityUnknownRole );
123 MAP( AccessibleRole::CHART, NSAccessibilityUnknownRole );
124 MAP( AccessibleRole::FORM, NSAccessibilityUnknownRole );
125 MAP( AccessibleRole::IMAGE_MAP, NSAccessibilityUnknownRole );
126 MAP( AccessibleRole::NOTE, NSAccessibilityUnknownRole );
127 MAP( AccessibleRole::PAGE, NSAccessibilityUnknownRole );
128 MAP( AccessibleRole::RULER, NSAccessibilityUnknownRole );
129 MAP( AccessibleRole::SECTION, NSAccessibilityUnknownRole );
130 MAP( AccessibleRole::TREE_ITEM, NSAccessibilityUnknownRole );
131 MAP( AccessibleRole::TREE_TABLE, NSAccessibilityUnknownRole );
140 +(id)getNativeRoleFrom: (XAccessibleContext *) accessibleContext {
141 id nativeRole = [ AquaA11yRoleHelper simpleMapNativeRoleFrom: accessibleContext ];
142 if ( accessibleContext -> getAccessibleRole() == AccessibleRole::LABEL ) {
143 if ( accessibleContext -> getAccessibleChildCount() > 0 ) {
144 [ nativeRole release ];
145 nativeRole = NSAccessibilityOutlineRole;
146 } else if ( accessibleContext -> getAccessibleParent().is() ) {
147 Reference < XAccessibleContext > rxParentContext = accessibleContext -> getAccessibleParent() -> getAccessibleContext();
148 if ( rxParentContext.is() ) {
149 NSString * roleParent = (NSString *) [ AquaA11yRoleHelper simpleMapNativeRoleFrom: rxParentContext.get() ];
150 if ( [ roleParent isEqualToString: NSAccessibilityOutlineRole ] ) {
151 [ nativeRole release ];
152 nativeRole = NSAccessibilityRowRole;
154 [ roleParent release ];
157 } else if ( accessibleContext -> getAccessibleRole() == AccessibleRole::COMBO_BOX ) {
158 Reference < XAccessible > rxAccessible = accessibleContext -> getAccessibleChild(0);
159 if ( rxAccessible.is() ) {
160 Reference < XAccessibleContext > rxAccessibleContext = rxAccessible -> getAccessibleContext();
161 if ( rxAccessibleContext.is() && rxAccessibleContext -> getAccessibleRole() == AccessibleRole::TEXT ) {
162 if ( ! rxAccessibleContext -> getAccessibleStateSet() -> contains ( AccessibleStateType::EDITABLE ) ) {
163 [ nativeRole release ];
164 nativeRole = NSAccessibilityPopUpButtonRole;
172 +(id)getNativeSubroleFrom: (sal_Int16) nRole {
173 id nativeSubrole = nil;
176 case a: nativeSubrole = b; break
178 MAP( AccessibleRole::UNKNOWN, NSAccessibilityUnknownSubrole );
179 MAP( AccessibleRole::ALERT, NSAccessibilitySystemDialogSubrole );
180 MAP( AccessibleRole::COLUMN_HEADER, @"" );
181 MAP( AccessibleRole::CANVAS, @"" );
182 MAP( AccessibleRole::CHECK_BOX, @"" );
183 MAP( AccessibleRole::CHECK_MENU_ITEM, @"" );
184 MAP( AccessibleRole::COLOR_CHOOSER, @"" );
185 MAP( AccessibleRole::COMBO_BOX, @"" );
186 MAP( AccessibleRole::DATE_EDITOR, @"" );
187 MAP( AccessibleRole::DESKTOP_ICON, @"" );
188 MAP( AccessibleRole::DESKTOP_PANE, @"" );
189 MAP( AccessibleRole::DIRECTORY_PANE, @"" );
190 MAP( AccessibleRole::DIALOG, NSAccessibilityDialogSubrole );
191 MAP( AccessibleRole::DOCUMENT, @"" );
192 MAP( AccessibleRole::EMBEDDED_OBJECT, @"" );
193 MAP( AccessibleRole::END_NOTE, @"" );
194 MAP( AccessibleRole::FILE_CHOOSER, @"" );
195 MAP( AccessibleRole::FILLER, @"" );
196 MAP( AccessibleRole::FONT_CHOOSER, @"" );
197 MAP( AccessibleRole::FOOTER, @"" );
198 MAP( AccessibleRole::FOOTNOTE, @"" );
199 MAP( AccessibleRole::FRAME, @"" );
200 MAP( AccessibleRole::GLASS_PANE, @"" );
201 MAP( AccessibleRole::GRAPHIC, @"" );
202 MAP( AccessibleRole::GROUP_BOX, @"" );
203 MAP( AccessibleRole::HEADER, @"" );
204 MAP( AccessibleRole::HEADING, @"" );
205 MAP( AccessibleRole::HYPER_LINK, NSAccessibilityTextLinkSubrole );
206 MAP( AccessibleRole::ICON, @"" );
207 MAP( AccessibleRole::INTERNAL_FRAME, @"" );
208 MAP( AccessibleRole::LABEL, @"" );
209 MAP( AccessibleRole::LAYERED_PANE, @"" );
210 MAP( AccessibleRole::LIST, @"" );
211 MAP( AccessibleRole::LIST_ITEM, NSAccessibilityOutlineRowSubrole );
212 MAP( AccessibleRole::MENU, @"" );
213 MAP( AccessibleRole::MENU_BAR, @"" );
214 MAP( AccessibleRole::MENU_ITEM, @"" );
215 MAP( AccessibleRole::OPTION_PANE, @"" );
216 MAP( AccessibleRole::PAGE_TAB, @"" );
217 MAP( AccessibleRole::PAGE_TAB_LIST, @"" );
218 MAP( AccessibleRole::PANEL, @"" );
219 MAP( AccessibleRole::PARAGRAPH, @"" );
220 MAP( AccessibleRole::PASSWORD_TEXT, NSAccessibilitySecureTextFieldSubrole );
221 MAP( AccessibleRole::POPUP_MENU, @"" );
222 MAP( AccessibleRole::PUSH_BUTTON, @"" );
223 MAP( AccessibleRole::PROGRESS_BAR, @"" );
224 MAP( AccessibleRole::RADIO_BUTTON, @"" );
225 MAP( AccessibleRole::RADIO_MENU_ITEM, @"" );
226 MAP( AccessibleRole::ROW_HEADER, @"" );
227 MAP( AccessibleRole::ROOT_PANE, @"" );
228 MAP( AccessibleRole::SCROLL_BAR, @"" );
229 MAP( AccessibleRole::SCROLL_PANE, @"" );
230 MAP( AccessibleRole::SHAPE, @"" );
231 MAP( AccessibleRole::SEPARATOR, @"" );
232 MAP( AccessibleRole::SLIDER, @"" );
233 MAP( AccessibleRole::SPIN_BOX, @"" );
234 MAP( AccessibleRole::SPLIT_PANE, @"" );
235 MAP( AccessibleRole::STATUS_BAR, @"" );
236 MAP( AccessibleRole::TABLE, @"" );
237 MAP( AccessibleRole::TABLE_CELL, @"" );
238 MAP( AccessibleRole::TEXT, @"" );
239 MAP( AccessibleRole::TEXT_FRAME, @"" );
240 MAP( AccessibleRole::TOGGLE_BUTTON, @"" );
241 MAP( AccessibleRole::TOOL_BAR, @"" );
242 MAP( AccessibleRole::TOOL_TIP, @"" );
243 MAP( AccessibleRole::TREE, @"" );
244 MAP( AccessibleRole::VIEW_PORT, @"" );
245 MAP( AccessibleRole::WINDOW, NSAccessibilityStandardWindowSubrole );
247 MAP( AccessibleRole::BUTTON_DROPDOWN, @"" );
248 MAP( AccessibleRole::BUTTON_MENU, @"" );
249 MAP( AccessibleRole::CAPTION, @"" );
250 MAP( AccessibleRole::CHART, @"" );
251 MAP( AccessibleRole::FORM, @"" );
252 MAP( AccessibleRole::IMAGE_MAP, @"" );
253 MAP( AccessibleRole::NOTE, @"" );
254 MAP( AccessibleRole::PAGE, @"" );
255 MAP( AccessibleRole::RULER, @"" );
256 MAP( AccessibleRole::SECTION, @"" );
257 MAP( AccessibleRole::TREE_ITEM, @"" );
258 MAP( AccessibleRole::TREE_TABLE, @"" );
264 return nativeSubrole;
267 +(id)getRoleDescriptionFrom: (NSString *) role with: (NSString *) subRole {
269 if ( [ subRole length ] == 0 )
270 roleDescription = NSAccessibilityRoleDescription( role, nil );
272 roleDescription = NSAccessibilityRoleDescription( role, subRole );
273 return roleDescription;