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