1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "a11yvaluewrapper.h"
22 #include "a11ywrapperstatictext.h"
24 using namespace ::com::sun::star::uno;
26 // Wrapper for XAccessibleValue
27 // Remember: A UNO-Value is a single numeric value. Regarding the Mac A11y-API, a value can be anything!
29 @implementation AquaA11yValueWrapper : NSObject
31 +(id)valueAttributeForElement:(AquaA11yWrapper *)wrapper {
32 // TODO: Detect Type from Any
33 if ( [ wrapper accessibleValue ] ) {
35 [ wrapper accessibleValue ] -> getCurrentValue() >>= value;
36 return [ NSNumber numberWithLong: value ];
38 return [ NSNumber numberWithLong: 0 ];
41 +(id)minValueAttributeForElement:(AquaA11yWrapper *)wrapper {
42 // TODO: Detect Type from Any
43 if ( [ wrapper accessibleValue ] ) {
45 [ wrapper accessibleValue ] -> getMinimumValue() >>= value;
46 return [ NSNumber numberWithLong: value ];
48 return [ NSNumber numberWithLong: 0 ];
51 +(id)maxValueAttributeForElement:(AquaA11yWrapper *)wrapper {
52 // TODO: Detect Type from Any
53 if ( [ wrapper accessibleValue ] ) {
55 [ wrapper accessibleValue ] -> getMaximumValue() >>= value;
56 return [ NSNumber numberWithLong: value ];
58 return [ NSNumber numberWithLong: 0 ];
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 = (NSNumber *) value;
66 Any numberAny ( [ number longValue ] );
67 [ wrapper accessibleValue ] -> setCurrentValue ( numberAny );
71 +(void)addAttributeNamesTo:(NSMutableArray *)attributeNames {
72 [ attributeNames addObject: NSAccessibilityValueAttribute ];
75 +(BOOL)isAttributeSettable:(NSString *)attribute forElement:(AquaA11yWrapper *)wrapper {
77 if ( [ wrapper accessibleValue ]
78 && [ attribute isEqualToString: NSAccessibilityValueAttribute ]
79 && ! [ wrapper isKindOfClass: [ AquaA11yWrapperStaticText class ] ] ) {
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */