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