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