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 "aqua11yvaluewrapper.h" 32#include "aqua11ywrapperstatictext.h" 33 34using namespace ::com::sun::star::uno; 35 36// Wrapper for XAccessibleValue 37// Remember: A UNO-Value is a single numeric value. Regarding the Mac A11y-API, a value can be anything! 38 39@implementation AquaA11yValueWrapper : NSObject 40 41+(id)valueAttributeForElement:(AquaA11yWrapper *)wrapper { 42 // TODO: Detect Type from Any 43 if ( [ wrapper accessibleValue ] != nil ) { 44 long value = 0; 45 [ wrapper accessibleValue ] -> getCurrentValue() >>= value; 46 return [ NSNumber numberWithLong: value ]; 47 } 48 return [ NSNumber numberWithLong: 0 ]; 49} 50 51+(id)minValueAttributeForElement:(AquaA11yWrapper *)wrapper { 52 // TODO: Detect Type from Any 53 if ( [ wrapper accessibleValue ] != nil ) { 54 long value = 0; 55 [ wrapper accessibleValue ] -> getMinimumValue() >>= value; 56 return [ NSNumber numberWithLong: value ]; 57 } 58 return [ NSNumber numberWithLong: 0 ]; 59} 60 61+(id)maxValueAttributeForElement:(AquaA11yWrapper *)wrapper { 62 // TODO: Detect Type from Any 63 if ( [ wrapper accessibleValue ] != nil ) { 64 long value = 0; 65 [ wrapper accessibleValue ] -> getMaximumValue() >>= value; 66 return [ NSNumber numberWithLong: value ]; 67 } 68 return [ NSNumber numberWithLong: 0 ]; 69} 70 71+(void)setValueAttributeForElement:(AquaA11yWrapper *)wrapper to:(id)value { 72 // TODO: Detect Type from NSNumber 73 if ( [ value isKindOfClass: [ NSNumber class ] ] 74 && [ wrapper accessibleValue ] != nil ) { 75 NSNumber * number = (NSNumber *) value; 76 Any numberAny ( [ number longValue ] ); 77 [ wrapper accessibleValue ] -> setCurrentValue ( numberAny ); 78 } 79} 80 81+(void)addAttributeNamesTo:(NSMutableArray *)attributeNames { 82 [ attributeNames addObject: NSAccessibilityValueAttribute ]; 83} 84 85+(BOOL)isAttributeSettable:(NSString *)attribute forElement:(AquaA11yWrapper *)wrapper { 86 BOOL isSettable = NO; 87 if ( [ wrapper accessibleValue ] != nil 88 && [ attribute isEqualToString: NSAccessibilityValueAttribute ] 89 && ! [ wrapper isKindOfClass: [ AquaA11yWrapperStaticText class ] ] ) { 90 isSettable = YES; 91 } 92 return isSettable; 93} 94 95@end 96