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: aqua11ywrappercombobox.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"
36 #include "aqua11ywrappercombobox.h"
37 #include "aqua11yrolehelper.h"
38 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
40 using namespace ::com::sun::star::accessibility;
41 using namespace ::com::sun::star::uno;
43 // Wrapper for AXCombobox role
45 @implementation AquaA11yWrapperComboBox : AquaA11yWrapper
48 #pragma mark Specialized Init Method
50 -(id)initWithAccessibleContext: (Reference < XAccessibleContext >) rxAccessibleContext {
51 self = [ super initWithAccessibleContext: rxAccessibleContext ];
60 #pragma mark Private Helper Method
62 -(AquaA11yWrapper *)textArea {
63 // FIXME: May cause problems when stored. Then get dynamically each time (bad performance!)
64 if ( textArea == nil ) {
65 NSAutoreleasePool * pool = [ [ NSAutoreleasePool alloc ] init ];
66 NSArray * elementChildren = [ super childrenAttribute ];
67 if ( [ elementChildren count ] > 0 ) {
68 NSEnumerator * enumerator = [ elementChildren objectEnumerator ];
70 while ( ( child = [ enumerator nextObject ] ) ) {
71 AquaA11yWrapper * element = ( AquaA11yWrapper * ) child;
72 if ( [ [ AquaA11yRoleHelper getNativeRoleFrom: [ element accessibleContext ] ] isEqualToString: NSAccessibilityTextAreaRole ] ) {
84 #pragma mark Wrapped Attributes From Contained Text Area
87 if ( [ self textArea ] != nil ) {
88 return [ [ self textArea ] valueAttribute ];
93 -(id)numberOfCharactersAttribute {
94 if ( [ self textArea ] != nil ) {
95 return [ [ self textArea ] numberOfCharactersAttribute ];
97 return [ NSNumber numberWithInt: 0 ];
100 -(id)selectedTextAttribute {
101 if ( [ self textArea ] != nil ) {
102 return [ [ self textArea ] selectedTextAttribute ];
107 -(id)selectedTextRangeAttribute {
108 if ( [ self textArea ] != nil ) {
109 return [ [ self textArea ] selectedTextRangeAttribute ];
111 return [ NSValue valueWithRange: NSMakeRange ( 0, 0 ) ];
114 -(id)visibleCharacterRangeAttribute {
115 if ( [ self textArea ] != nil ) {
116 return [ [ self textArea ] visibleCharacterRangeAttribute ];
118 return [ NSValue valueWithRange: NSMakeRange ( 0, 0 ) ];
122 #pragma mark Accessibility Protocol
124 -(MacOSBOOL)accessibilityIsAttributeSettable:(NSString *)attribute {
125 if ( [ self textArea ] != nil && (
126 [ attribute isEqualToString: NSAccessibilitySelectedTextAttribute ]
127 || [ attribute isEqualToString: NSAccessibilitySelectedTextRangeAttribute ]
128 || [ attribute isEqualToString: NSAccessibilityVisibleCharacterRangeAttribute ] ) ) {
129 return [ [ self textArea ] accessibilityIsAttributeSettable: attribute ];
131 return [ super accessibilityIsAttributeSettable: attribute ];
134 -(void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute {
135 if ( [ self textArea ] != nil && (
136 [ attribute isEqualToString: NSAccessibilitySelectedTextAttribute ]
137 || [ attribute isEqualToString: NSAccessibilitySelectedTextRangeAttribute ]
138 || [ attribute isEqualToString: NSAccessibilityVisibleCharacterRangeAttribute ] ) ) {
139 return [ [ self textArea ] accessibilitySetValue: value forAttribute: attribute ];
141 return [ super accessibilitySetValue: value forAttribute: attribute ];
144 -(NSArray *)accessibilityAttributeNames {
145 // Default Attributes
146 NSMutableArray * attributeNames = [ NSMutableArray arrayWithArray: [ super accessibilityAttributeNames ] ];
147 // Special Attributes and removing unwanted attributes depending on role
148 [ attributeNames removeObjectsInArray: [ NSArray arrayWithObjects:
149 NSAccessibilityTitleAttribute,
150 NSAccessibilityChildrenAttribute,
153 [ attributeNames addObjectsFromArray: [ NSArray arrayWithObjects:
154 NSAccessibilityExpandedAttribute,
155 NSAccessibilityValueAttribute,
156 NSAccessibilityNumberOfCharactersAttribute,
157 NSAccessibilitySelectedTextAttribute,
158 NSAccessibilitySelectedTextRangeAttribute,
159 NSAccessibilityVisibleCharacterRangeAttribute,
162 return attributeNames;