1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: aqua11yvaluewrapper.mm,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_vcl.hxx"
35 #include "aqua11yvaluewrapper.h"
36 #include "aqua11ywrapperstatictext.h"
38 using namespace ::com::sun::star::uno;
40 // Wrapper for XAccessibleValue
41 // Remember: A UNO-Value is a single numeric value. Regarding the Mac A11y-API, a value can be anything!
43 @implementation AquaA11yValueWrapper : NSObject
45 +(id)valueAttributeForElement:(AquaA11yWrapper *)wrapper {
46 // TODO: Detect Type from Any
47 if ( [ wrapper accessibleValue ] != nil ) {
49 [ wrapper accessibleValue ] -> getCurrentValue() >>= value;
50 return [ NSNumber numberWithLong: value ];
52 return [ NSNumber numberWithLong: 0 ];
55 +(id)minValueAttributeForElement:(AquaA11yWrapper *)wrapper {
56 // TODO: Detect Type from Any
57 if ( [ wrapper accessibleValue ] != nil ) {
59 [ wrapper accessibleValue ] -> getMinimumValue() >>= value;
60 return [ NSNumber numberWithLong: value ];
62 return [ NSNumber numberWithLong: 0 ];
65 +(id)maxValueAttributeForElement:(AquaA11yWrapper *)wrapper {
66 // TODO: Detect Type from Any
67 if ( [ wrapper accessibleValue ] != nil ) {
69 [ wrapper accessibleValue ] -> getMaximumValue() >>= value;
70 return [ NSNumber numberWithLong: value ];
72 return [ NSNumber numberWithLong: 0 ];
75 +(void)setValueAttributeForElement:(AquaA11yWrapper *)wrapper to:(id)value {
76 // TODO: Detect Type from NSNumber
77 if ( [ value isKindOfClass: [ NSNumber class ] ]
78 && [ wrapper accessibleValue ] != nil ) {
79 NSNumber * number = (NSNumber *) value;
80 Any numberAny ( [ number longValue ] );
81 [ wrapper accessibleValue ] -> setCurrentValue ( numberAny );
85 +(void)addAttributeNamesTo:(NSMutableArray *)attributeNames {
86 [ attributeNames addObject: NSAccessibilityValueAttribute ];
89 +(MacOSBOOL)isAttributeSettable:(NSString *)attribute forElement:(AquaA11yWrapper *)wrapper {
90 MacOSBOOL isSettable = NO;
91 if ( [ wrapper accessibleValue ] != nil
92 && [ attribute isEqualToString: NSAccessibilityValueAttribute ]
93 && ! [ wrapper isKindOfClass: [ AquaA11yWrapperStaticText class ] ] ) {