1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2/* 3 * This file is part of the LibreOffice project. 4 * 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/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 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 . 18 */ 19 20 21#include <osx/salinst.h> 22#include <quartz/utils.h> 23 24#include "a11yactionwrapper.h" 25 26// Wrapper for XAccessibleAction 27 28@implementation AquaA11yActionWrapper : NSObject 29 30+(NSString *)nativeActionNameFor:(NSString *)actionName { 31 // TODO: Optimize ? 32 // Use NSAccessibilityActionDescription 33 if ( [ actionName isEqualToString: @"press" ] ) { 34 return NSAccessibilityPressAction; 35 } else if ( [ actionName isEqualToString: @"togglePopup" ] ) { 36 return NSAccessibilityShowMenuAction; 37 } else if ( [ actionName isEqualToString: @"select" ] ) { 38 return NSAccessibilityPickAction; 39 } else if ( [ actionName isEqualToString: @"incrementLine" ] ) { 40 return NSAccessibilityIncrementAction; 41 } else if ( [ actionName isEqualToString: @"decrementLine" ] ) { 42 return NSAccessibilityDecrementAction; 43 } else if ( [ actionName isEqualToString: @"incrementBlock" ] ) { 44 return NSAccessibilityIncrementAction; // TODO ? 45 } else if ( [ actionName isEqualToString: @"decrementBlock" ] ) { 46 return NSAccessibilityDecrementAction; // TODO ? 47 } else if ( [ actionName isEqualToString: @"Browse" ] ) { 48 return NSAccessibilityPressAction; // TODO ? 49 } else { 50 return [ NSString string ]; 51 } 52} 53 54+(NSArray *)actionNamesForElement:(AquaA11yWrapper *)wrapper { 55 NSMutableArray * actionNames = [ [ NSMutableArray alloc ] init ]; 56 if ( [ wrapper accessibleAction ] ) { 57 for ( int cnt = 0; cnt < [ wrapper accessibleAction ] -> getAccessibleActionCount(); cnt++ ) { 58 [ actionNames addObject: [ AquaA11yActionWrapper nativeActionNameFor: CreateNSString ( [ wrapper accessibleAction ] -> getAccessibleActionDescription ( cnt ) ) ] ]; 59 } 60 } 61 return actionNames; 62} 63 64+(void)doAction:(NSString *)action ofElement:(AquaA11yWrapper *)wrapper { 65 if ( [ wrapper accessibleAction ] ) { 66 for ( int cnt = 0; cnt < [ wrapper accessibleAction ] -> getAccessibleActionCount(); cnt++ ) { 67 if ( [ action isEqualToString: [ AquaA11yActionWrapper nativeActionNameFor: CreateNSString ( [ wrapper accessibleAction ] -> getAccessibleActionDescription ( cnt ) ) ] ] ) { 68 [ wrapper accessibleAction ] -> doAccessibleAction ( cnt ); 69 break; 70 } 71 } 72 } 73} 74 75@end 76 77/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 78