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: aqua11yactionwrapper.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"
36 #include "aqua11yactionwrapper.h"
38 // Wrapper for XAccessibleAction
40 @implementation AquaA11yActionWrapper : NSObject
42 +(NSString *)nativeActionNameFor:(NSString *)actionName {
44 // Use NSAccessibilityActionDescription
45 if ( [ actionName isEqualToString: @"click" ] ) {
46 return NSAccessibilityPressAction;
47 } else if ( [ actionName isEqualToString: @"togglePopup" ] ) {
48 return NSAccessibilityShowMenuAction;
49 } else if ( [ actionName isEqualToString: @"select" ] ) {
50 return NSAccessibilityPickAction;
51 } else if ( [ actionName isEqualToString: @"incrementLine" ] ) {
52 return NSAccessibilityIncrementAction;
53 } else if ( [ actionName isEqualToString: @"decrementLine" ] ) {
54 return NSAccessibilityDecrementAction;
55 } else if ( [ actionName isEqualToString: @"incrementBlock" ] ) {
56 return NSAccessibilityIncrementAction; // TODO ?
57 } else if ( [ actionName isEqualToString: @"decrementBlock" ] ) {
58 return NSAccessibilityDecrementAction; // TODO ?
59 } else if ( [ actionName isEqualToString: @"Browse" ] ) {
60 return NSAccessibilityPressAction; // TODO ?
62 return [ NSString string ];
66 +(NSArray *)actionNamesForElement:(AquaA11yWrapper *)wrapper {
67 NSMutableArray * actionNames = [ [ NSMutableArray alloc ] init ];
68 if ( [ wrapper accessibleAction ] != nil ) {
69 for ( int cnt = 0; cnt < [ wrapper accessibleAction ] -> getAccessibleActionCount(); cnt++ ) {
70 [ actionNames addObject: [ AquaA11yActionWrapper nativeActionNameFor: CreateNSString ( [ wrapper accessibleAction ] -> getAccessibleActionDescription ( cnt ) ) ] ];
76 +(void)doAction:(NSString *)action ofElement:(AquaA11yWrapper *)wrapper {
77 if ( [ wrapper accessibleAction ] != nil ) {
78 for ( int cnt = 0; cnt < [ wrapper accessibleAction ] -> getAccessibleActionCount(); cnt++ ) {
79 if ( [ action isEqualToString: [ AquaA11yActionWrapper nativeActionNameFor: CreateNSString ( [ wrapper accessibleAction ] -> getAccessibleActionDescription ( cnt ) ) ] ] ) {
80 [ wrapper accessibleAction ] -> doAccessibleAction ( cnt );