1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <osx/a11yfactory.h>
23 #include "a11yrolehelper.h"
25 #include <com/sun/star/accessibility/AccessibleRole.hpp>
26 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
28 using namespace ::com::sun::star::accessibility;
29 using namespace ::com::sun::star::uno;
31 @implementation AquaA11yRoleHelper
33 +(id)simpleMapNativeRoleFrom: (XAccessibleContext *) accessibleContext {
36 if (accessibleContext == nullptr)
39 switch( accessibleContext -> getAccessibleRole() ) {
41 case a: nativeRole = b; break
43 MAP( AccessibleRole::UNKNOWN, NSAccessibilityUnknownRole );
44 MAP( AccessibleRole::ALERT, NSAccessibilityUnknownRole ); // FIXME
45 MAP( AccessibleRole::COLUMN_HEADER, NSAccessibilityColumnRole );
46 MAP( AccessibleRole::CANVAS, NSAccessibilityUnknownRole ); // FIXME
47 MAP( AccessibleRole::CHECK_BOX, NSAccessibilityCheckBoxRole );
48 MAP( AccessibleRole::CHECK_MENU_ITEM, NSAccessibilityUnknownRole ); // FIXME
49 MAP( AccessibleRole::COLOR_CHOOSER, NSAccessibilityColorWellRole ); // FIXME
50 MAP( AccessibleRole::COMBO_BOX, NSAccessibilityComboBoxRole );
51 MAP( AccessibleRole::DATE_EDITOR, NSAccessibilityUnknownRole ); // FIXME
52 MAP( AccessibleRole::DESKTOP_ICON, NSAccessibilityUnknownRole ); // FIXME
53 MAP( AccessibleRole::DESKTOP_PANE, NSAccessibilityUnknownRole ); // FIXME
54 MAP( AccessibleRole::DIRECTORY_PANE, NSAccessibilityUnknownRole ); // FIXME
55 MAP( AccessibleRole::DIALOG, NSAccessibilityGroupRole );
56 MAP( AccessibleRole::DOCUMENT, NSAccessibilityGroupRole );
57 MAP( AccessibleRole::EMBEDDED_OBJECT, NSAccessibilityUnknownRole ); // FIXME
58 MAP( AccessibleRole::END_NOTE, NSAccessibilityUnknownRole ); // FIXME
59 MAP( AccessibleRole::FILE_CHOOSER, NSAccessibilityUnknownRole ); // FIXME
60 MAP( AccessibleRole::FILLER, NSAccessibilityUnknownRole ); // FIXME
61 MAP( AccessibleRole::FONT_CHOOSER, NSAccessibilityUnknownRole ); // FIXME
62 MAP( AccessibleRole::FOOTER, NSAccessibilityGroupRole ); // FIXME
63 MAP( AccessibleRole::FOOTNOTE, NSAccessibilityUnknownRole ); // FIXME
64 MAP( AccessibleRole::FRAME, NSAccessibilityWindowRole );
65 MAP( AccessibleRole::GLASS_PANE, NSAccessibilityUnknownRole ); // FIXME
66 MAP( AccessibleRole::GRAPHIC, NSAccessibilityImageRole );
67 MAP( AccessibleRole::GROUP_BOX, NSAccessibilityGroupRole );
68 MAP( AccessibleRole::HEADER, NSAccessibilityGroupRole ); // FIXME
69 MAP( AccessibleRole::HEADING, NSAccessibilityTextAreaRole ); // FIXME
70 MAP( AccessibleRole::HYPER_LINK, NSAccessibilityLinkRole );
71 MAP( AccessibleRole::ICON, NSAccessibilityImageRole );
72 MAP( AccessibleRole::INTERNAL_FRAME, NSAccessibilityUnknownRole ); // FIXME
73 MAP( AccessibleRole::LABEL, NSAccessibilityStaticTextRole );
74 MAP( AccessibleRole::LAYERED_PANE, NSAccessibilityUnknownRole ); // FIXME
75 MAP( AccessibleRole::LIST, NSAccessibilityMenuRole );
76 MAP( AccessibleRole::LIST_ITEM, NSAccessibilityMenuItemRole );
77 MAP( AccessibleRole::MENU, NSAccessibilityMenuRole );
78 MAP( AccessibleRole::MENU_BAR, NSAccessibilityMenuBarRole );
79 MAP( AccessibleRole::MENU_ITEM, NSAccessibilityMenuItemRole );
80 MAP( AccessibleRole::OPTION_PANE, NSAccessibilityUnknownRole ); // FIXME
81 MAP( AccessibleRole::PAGE_TAB, NSAccessibilityButtonRole );
82 MAP( AccessibleRole::PAGE_TAB_LIST, NSAccessibilityTabGroupRole );
83 MAP( AccessibleRole::PANEL, NSAccessibilityGroupRole );
84 MAP( AccessibleRole::PARAGRAPH, NSAccessibilityTextAreaRole );
85 MAP( AccessibleRole::PASSWORD_TEXT, NSAccessibilityTextFieldRole );
86 MAP( AccessibleRole::POPUP_MENU, NSAccessibilityMenuRole );
87 MAP( AccessibleRole::PUSH_BUTTON, NSAccessibilityButtonRole );
88 MAP( AccessibleRole::PROGRESS_BAR, NSAccessibilityProgressIndicatorRole );
89 MAP( AccessibleRole::RADIO_BUTTON, NSAccessibilityRadioButtonRole );
90 MAP( AccessibleRole::RADIO_MENU_ITEM, NSAccessibilityUnknownRole ); // FIXME
91 MAP( AccessibleRole::ROW_HEADER, NSAccessibilityRowRole );
92 MAP( AccessibleRole::ROOT_PANE, NSAccessibilityUnknownRole ); // FIXME
93 MAP( AccessibleRole::SCROLL_BAR, NSAccessibilityScrollBarRole );
94 MAP( AccessibleRole::SCROLL_PANE, NSAccessibilityScrollAreaRole );
95 MAP( AccessibleRole::SHAPE, NSAccessibilityUnknownRole ); // FIXME
96 MAP( AccessibleRole::SEPARATOR, NSAccessibilitySplitterRole ); // FIXME
97 MAP( AccessibleRole::SLIDER, NSAccessibilitySliderRole );
98 MAP( AccessibleRole::SPIN_BOX, NSAccessibilityUnknownRole ); // FIXME
99 MAP( AccessibleRole::SPLIT_PANE, NSAccessibilitySplitGroupRole );
100 MAP( AccessibleRole::STATUS_BAR, NSAccessibilityGroupRole ); // FIXME
101 MAP( AccessibleRole::TABLE, NSAccessibilityTableRole );
102 MAP( AccessibleRole::TABLE_CELL, NSAccessibilityTextFieldRole );
103 MAP( AccessibleRole::TEXT, NSAccessibilityTextAreaRole );
104 MAP( AccessibleRole::TEXT_FRAME, NSAccessibilityGroupRole );
105 MAP( AccessibleRole::TOGGLE_BUTTON, NSAccessibilityCheckBoxRole );
106 MAP( AccessibleRole::TOOL_BAR, NSAccessibilityToolbarRole );
107 MAP( AccessibleRole::TOOL_TIP, NSAccessibilityUnknownRole ); // FIXME
108 MAP( AccessibleRole::TREE, NSAccessibilityGroupRole );
109 MAP( AccessibleRole::VIEW_PORT, NSAccessibilityUnknownRole ); // FIXME
110 MAP( AccessibleRole::WINDOW, NSAccessibilityWindowRole );
112 MAP( AccessibleRole::BUTTON_DROPDOWN, NSAccessibilityMenuButtonRole );
113 MAP( AccessibleRole::BUTTON_MENU, NSAccessibilityMenuButtonRole );
114 MAP( AccessibleRole::CAPTION, NSAccessibilityUnknownRole );
115 MAP( AccessibleRole::CHART, NSAccessibilityUnknownRole );
116 MAP( AccessibleRole::FORM, NSAccessibilityUnknownRole );
117 MAP( AccessibleRole::IMAGE_MAP, NSAccessibilityUnknownRole );
118 MAP( AccessibleRole::NOTE, NSAccessibilityUnknownRole );
119 MAP( AccessibleRole::PAGE, NSAccessibilityUnknownRole );
120 MAP( AccessibleRole::RULER, NSAccessibilityUnknownRole );
121 MAP( AccessibleRole::SECTION, NSAccessibilityUnknownRole );
122 MAP( AccessibleRole::TREE_ITEM, NSAccessibilityUnknownRole );
123 MAP( AccessibleRole::TREE_TABLE, NSAccessibilityUnknownRole );
125 MAP( AccessibleRole::DOCUMENT_PRESENTATION, NSAccessibilityGroupRole );
126 MAP( AccessibleRole::DOCUMENT_SPREADSHEET, NSAccessibilityGroupRole );
127 MAP( AccessibleRole::DOCUMENT_TEXT, NSAccessibilityGroupRole );
128 MAP( AccessibleRole::STATIC, NSAccessibilityStaticTextRole );
137 +(id)getNativeRoleFrom: (XAccessibleContext *) accessibleContext {
138 id nativeRole = [ AquaA11yRoleHelper simpleMapNativeRoleFrom: accessibleContext ];
139 if ( accessibleContext -> getAccessibleRole() == AccessibleRole::LABEL ) {
140 if ( accessibleContext -> getAccessibleChildCount() > 0 ) {
141 [ nativeRole release ];
142 nativeRole = NSAccessibilityOutlineRole;
143 } else if ( accessibleContext -> getAccessibleParent().is() ) {
144 Reference < XAccessibleContext > rxParentContext = accessibleContext -> getAccessibleParent() -> getAccessibleContext();
145 if ( rxParentContext.is() ) {
146 NSString * roleParent = static_cast<NSString *>([ AquaA11yRoleHelper simpleMapNativeRoleFrom: rxParentContext.get() ]);
147 if ( [ roleParent isEqualToString: NSAccessibilityOutlineRole ] ) {
148 [ nativeRole release ];
149 nativeRole = NSAccessibilityRowRole;
151 [ roleParent release ];
154 } else if ( accessibleContext -> getAccessibleRole() == AccessibleRole::COMBO_BOX ) {
155 Reference < XAccessible > rxAccessible = accessibleContext -> getAccessibleChild(0);
156 if ( rxAccessible.is() ) {
157 Reference < XAccessibleContext > rxAccessibleContext = rxAccessible -> getAccessibleContext();
158 if ( rxAccessibleContext.is() && rxAccessibleContext -> getAccessibleRole() == AccessibleRole::TEXT ) {
159 if ( ! rxAccessibleContext -> getAccessibleStateSet() -> contains ( AccessibleStateType::EDITABLE ) ) {
160 [ nativeRole release ];
161 nativeRole = NSAccessibilityPopUpButtonRole;
169 +(id)getNativeSubroleFrom: (sal_Int16) nRole {
170 id nativeSubrole = nil;
173 case a: nativeSubrole = b; break
175 MAP( AccessibleRole::UNKNOWN, NSAccessibilityUnknownSubrole );
176 MAP( AccessibleRole::ALERT, NSAccessibilitySystemDialogSubrole );
177 MAP( AccessibleRole::COLUMN_HEADER, @"" );
178 MAP( AccessibleRole::CANVAS, @"" );
179 MAP( AccessibleRole::CHECK_BOX, @"" );
180 MAP( AccessibleRole::CHECK_MENU_ITEM, @"" );
181 MAP( AccessibleRole::COLOR_CHOOSER, @"" );
182 MAP( AccessibleRole::COMBO_BOX, @"" );
183 MAP( AccessibleRole::DATE_EDITOR, @"" );
184 MAP( AccessibleRole::DESKTOP_ICON, @"" );
185 MAP( AccessibleRole::DESKTOP_PANE, @"" );
186 MAP( AccessibleRole::DIRECTORY_PANE, @"" );
187 MAP( AccessibleRole::DIALOG, NSAccessibilityDialogSubrole );
188 MAP( AccessibleRole::DOCUMENT, @"" );
189 MAP( AccessibleRole::EMBEDDED_OBJECT, @"" );
190 MAP( AccessibleRole::END_NOTE, @"" );
191 MAP( AccessibleRole::FILE_CHOOSER, @"" );
192 MAP( AccessibleRole::FILLER, @"" );
193 MAP( AccessibleRole::FONT_CHOOSER, @"" );
194 MAP( AccessibleRole::FOOTER, @"" );
195 MAP( AccessibleRole::FOOTNOTE, @"" );
196 MAP( AccessibleRole::FRAME, @"" );
197 MAP( AccessibleRole::GLASS_PANE, @"" );
198 MAP( AccessibleRole::GRAPHIC, @"" );
199 MAP( AccessibleRole::GROUP_BOX, @"" );
200 MAP( AccessibleRole::HEADER, @"" );
201 MAP( AccessibleRole::HEADING, @"" );
202 MAP( AccessibleRole::HYPER_LINK, NSAccessibilityTextLinkSubrole );
203 MAP( AccessibleRole::ICON, @"" );
204 MAP( AccessibleRole::INTERNAL_FRAME, @"" );
205 MAP( AccessibleRole::LABEL, @"" );
206 MAP( AccessibleRole::LAYERED_PANE, @"" );
207 MAP( AccessibleRole::LIST, @"" );
208 MAP( AccessibleRole::LIST_ITEM, NSAccessibilityOutlineRowSubrole );
209 MAP( AccessibleRole::MENU, @"" );
210 MAP( AccessibleRole::MENU_BAR, @"" );
211 MAP( AccessibleRole::MENU_ITEM, @"" );
212 MAP( AccessibleRole::OPTION_PANE, @"" );
213 MAP( AccessibleRole::PAGE_TAB, @"" );
214 MAP( AccessibleRole::PAGE_TAB_LIST, @"" );
215 MAP( AccessibleRole::PANEL, @"" );
216 MAP( AccessibleRole::PARAGRAPH, @"" );
217 MAP( AccessibleRole::PASSWORD_TEXT, NSAccessibilitySecureTextFieldSubrole );
218 MAP( AccessibleRole::POPUP_MENU, @"" );
219 MAP( AccessibleRole::PUSH_BUTTON, @"" );
220 MAP( AccessibleRole::PROGRESS_BAR, @"" );
221 MAP( AccessibleRole::RADIO_BUTTON, @"" );
222 MAP( AccessibleRole::RADIO_MENU_ITEM, @"" );
223 MAP( AccessibleRole::ROW_HEADER, @"" );
224 MAP( AccessibleRole::ROOT_PANE, @"" );
225 MAP( AccessibleRole::SCROLL_BAR, @"" );
226 MAP( AccessibleRole::SCROLL_PANE, @"" );
227 MAP( AccessibleRole::SHAPE, @"" );
228 MAP( AccessibleRole::SEPARATOR, @"" );
229 MAP( AccessibleRole::SLIDER, @"" );
230 MAP( AccessibleRole::SPIN_BOX, @"" );
231 MAP( AccessibleRole::SPLIT_PANE, @"" );
232 MAP( AccessibleRole::STATUS_BAR, @"" );
233 MAP( AccessibleRole::TABLE, @"" );
234 MAP( AccessibleRole::TABLE_CELL, @"" );
235 MAP( AccessibleRole::TEXT, @"" );
236 MAP( AccessibleRole::TEXT_FRAME, @"" );
237 MAP( AccessibleRole::TOGGLE_BUTTON, @"" );
238 MAP( AccessibleRole::TOOL_BAR, @"" );
239 MAP( AccessibleRole::TOOL_TIP, @"" );
240 MAP( AccessibleRole::TREE, @"" );
241 MAP( AccessibleRole::VIEW_PORT, @"" );
242 MAP( AccessibleRole::WINDOW, NSAccessibilityStandardWindowSubrole );
244 MAP( AccessibleRole::BUTTON_DROPDOWN, @"" );
245 MAP( AccessibleRole::BUTTON_MENU, @"" );
246 MAP( AccessibleRole::CAPTION, @"" );
247 MAP( AccessibleRole::CHART, @"" );
248 MAP( AccessibleRole::FORM, @"" );
249 MAP( AccessibleRole::IMAGE_MAP, @"" );
250 MAP( AccessibleRole::NOTE, @"" );
251 MAP( AccessibleRole::PAGE, @"" );
252 MAP( AccessibleRole::RULER, @"" );
253 MAP( AccessibleRole::SECTION, @"" );
254 MAP( AccessibleRole::TREE_ITEM, @"" );
255 MAP( AccessibleRole::TREE_TABLE, @"" );
257 MAP( AccessibleRole::DOCUMENT_PRESENTATION, @"" );
258 MAP( AccessibleRole::DOCUMENT_SPREADSHEET, @"" );
259 MAP( AccessibleRole::DOCUMENT_TEXT, @"" );
261 MAP( AccessibleRole::STATIC, @"" );
267 return nativeSubrole;
270 +(id)getRoleDescriptionFrom: (NSString *) role with: (NSString *) subRole {
272 if ( [ subRole length ] == 0 )
273 roleDescription = NSAccessibilityRoleDescription( role, nil );
275 roleDescription = NSAccessibilityRoleDescription( role, subRole );
276 return roleDescription;
281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */