1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_vcl.hxx"
26
27#include "aqua/salinst.h"
28
29#include "aqua11yactionwrapper.h"
30
31// Wrapper for XAccessibleAction
32
33@implementation AquaA11yActionWrapper : NSObject
34
35+(NSString *)nativeActionNameFor:(NSString *)actionName {
36    // TODO: Optimize ?
37    //       Use NSAccessibilityActionDescription
38    if ( [ actionName isEqualToString: @"click" ] ) {
39        return NSAccessibilityPressAction;
40    } else if ( [ actionName isEqualToString: @"togglePopup" ] ) {
41        return NSAccessibilityShowMenuAction;
42    } else if ( [ actionName isEqualToString: @"select" ] ) {
43        return NSAccessibilityPickAction;
44    } else if ( [ actionName isEqualToString: @"incrementLine" ] ) {
45        return NSAccessibilityIncrementAction;
46    } else if ( [ actionName isEqualToString: @"decrementLine" ] ) {
47        return NSAccessibilityDecrementAction;
48    } else if ( [ actionName isEqualToString: @"incrementBlock" ] ) {
49        return NSAccessibilityIncrementAction; // TODO ?
50    } else if ( [ actionName isEqualToString: @"decrementBlock" ] ) {
51        return NSAccessibilityDecrementAction; // TODO ?
52    } else if ( [ actionName isEqualToString: @"Browse" ] ) {
53        return NSAccessibilityPressAction; // TODO ?
54    } else {
55        return [ NSString string ];
56    }
57}
58
59+(NSArray *)actionNamesForElement:(AquaA11yWrapper *)wrapper {
60    NSMutableArray * actionNames = [ [ NSMutableArray alloc ] init ];
61    if ( [ wrapper accessibleAction ] != nil ) {
62        for ( int cnt = 0; cnt < [ wrapper accessibleAction ] -> getAccessibleActionCount(); cnt++ ) {
63            [ actionNames addObject: [ AquaA11yActionWrapper nativeActionNameFor: CreateNSString ( [ wrapper accessibleAction ] -> getAccessibleActionDescription ( cnt ) ) ] ];
64        }
65    }
66    return actionNames;
67}
68
69+(void)doAction:(NSString *)action ofElement:(AquaA11yWrapper *)wrapper {
70    if ( [ wrapper accessibleAction ] != nil ) {
71        for ( int cnt = 0; cnt < [ wrapper accessibleAction ] -> getAccessibleActionCount(); cnt++ ) {
72            if ( [ action isEqualToString: [ AquaA11yActionWrapper nativeActionNameFor: CreateNSString ( [ wrapper accessibleAction ] -> getAccessibleActionDescription ( cnt ) ) ] ] ) {
73                [ wrapper accessibleAction ] -> doAccessibleAction ( cnt );
74                break;
75            }
76        }
77    }
78}
79
80@end
81