1*323de322SAndrew Rist/************************************************************** 2cdf0e10cSrcweir * 3*323de322SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*323de322SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*323de322SAndrew Rist * distributed with this work for additional information 6*323de322SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*323de322SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*323de322SAndrew Rist * "License"); you may not use this file except in compliance 9*323de322SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*323de322SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*323de322SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*323de322SAndrew Rist * software distributed under the License is distributed on an 15*323de322SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*323de322SAndrew Rist * KIND, either express or implied. See the License for the 17*323de322SAndrew Rist * specific language governing permissions and limitations 18*323de322SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*323de322SAndrew Rist *************************************************************/ 21*323de322SAndrew Rist 22*323de322SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir// MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir#include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir#include "aqua/salinst.h" 28cdf0e10cSrcweir 29cdf0e10cSrcweir#include "aqua11ywrappercombobox.h" 30cdf0e10cSrcweir#include "aqua11yrolehelper.h" 31cdf0e10cSrcweir 32cdf0e10cSrcweir#include <com/sun/star/accessibility/AccessibleStateType.hpp> 33cdf0e10cSrcweir 34cdf0e10cSrcweirusing namespace ::com::sun::star::accessibility; 35cdf0e10cSrcweirusing namespace ::com::sun::star::uno; 36cdf0e10cSrcweir 37cdf0e10cSrcweir// Wrapper for AXCombobox role 38cdf0e10cSrcweir 39cdf0e10cSrcweir@implementation AquaA11yWrapperComboBox : AquaA11yWrapper 40cdf0e10cSrcweir 41cdf0e10cSrcweir#pragma mark - 42cdf0e10cSrcweir#pragma mark Specialized Init Method 43cdf0e10cSrcweir 44cdf0e10cSrcweir-(id)initWithAccessibleContext: (Reference < XAccessibleContext >) rxAccessibleContext { 45cdf0e10cSrcweir self = [ super initWithAccessibleContext: rxAccessibleContext ]; 46cdf0e10cSrcweir if ( self != nil ) 47cdf0e10cSrcweir { 48cdf0e10cSrcweir textArea = nil; 49cdf0e10cSrcweir } 50cdf0e10cSrcweir return self; 51cdf0e10cSrcweir} 52cdf0e10cSrcweir 53cdf0e10cSrcweir#pragma mark - 54cdf0e10cSrcweir#pragma mark Private Helper Method 55cdf0e10cSrcweir 56cdf0e10cSrcweir-(AquaA11yWrapper *)textArea { 57cdf0e10cSrcweir // FIXME: May cause problems when stored. Then get dynamically each time (bad performance!) 58cdf0e10cSrcweir if ( textArea == nil ) { 59cdf0e10cSrcweir NSAutoreleasePool * pool = [ [ NSAutoreleasePool alloc ] init ]; 60cdf0e10cSrcweir NSArray * elementChildren = [ super childrenAttribute ]; 61cdf0e10cSrcweir if ( [ elementChildren count ] > 0 ) { 62cdf0e10cSrcweir NSEnumerator * enumerator = [ elementChildren objectEnumerator ]; 63cdf0e10cSrcweir id child; 64cdf0e10cSrcweir while ( ( child = [ enumerator nextObject ] ) ) { 65cdf0e10cSrcweir AquaA11yWrapper * element = ( AquaA11yWrapper * ) child; 66cdf0e10cSrcweir if ( [ [ AquaA11yRoleHelper getNativeRoleFrom: [ element accessibleContext ] ] isEqualToString: NSAccessibilityTextAreaRole ] ) { 67cdf0e10cSrcweir textArea = element; 68cdf0e10cSrcweir break; 69cdf0e10cSrcweir } 70cdf0e10cSrcweir } 71cdf0e10cSrcweir } 72cdf0e10cSrcweir [ pool release ]; 73cdf0e10cSrcweir } 74cdf0e10cSrcweir return textArea; 75cdf0e10cSrcweir} 76cdf0e10cSrcweir 77cdf0e10cSrcweir#pragma mark - 78cdf0e10cSrcweir#pragma mark Wrapped Attributes From Contained Text Area 79cdf0e10cSrcweir 80cdf0e10cSrcweir-(id)valueAttribute { 81cdf0e10cSrcweir if ( [ self textArea ] != nil ) { 82cdf0e10cSrcweir return [ [ self textArea ] valueAttribute ]; 83cdf0e10cSrcweir } 84cdf0e10cSrcweir return @""; 85cdf0e10cSrcweir} 86cdf0e10cSrcweir 87cdf0e10cSrcweir-(id)numberOfCharactersAttribute { 88cdf0e10cSrcweir if ( [ self textArea ] != nil ) { 89cdf0e10cSrcweir return [ [ self textArea ] numberOfCharactersAttribute ]; 90cdf0e10cSrcweir } 91cdf0e10cSrcweir return [ NSNumber numberWithInt: 0 ]; 92cdf0e10cSrcweir} 93cdf0e10cSrcweir 94cdf0e10cSrcweir-(id)selectedTextAttribute { 95cdf0e10cSrcweir if ( [ self textArea ] != nil ) { 96cdf0e10cSrcweir return [ [ self textArea ] selectedTextAttribute ]; 97cdf0e10cSrcweir } 98cdf0e10cSrcweir return @""; 99cdf0e10cSrcweir} 100cdf0e10cSrcweir 101cdf0e10cSrcweir-(id)selectedTextRangeAttribute { 102cdf0e10cSrcweir if ( [ self textArea ] != nil ) { 103cdf0e10cSrcweir return [ [ self textArea ] selectedTextRangeAttribute ]; 104cdf0e10cSrcweir } 105cdf0e10cSrcweir return [ NSValue valueWithRange: NSMakeRange ( 0, 0 ) ]; 106cdf0e10cSrcweir} 107cdf0e10cSrcweir 108cdf0e10cSrcweir-(id)visibleCharacterRangeAttribute { 109cdf0e10cSrcweir if ( [ self textArea ] != nil ) { 110cdf0e10cSrcweir return [ [ self textArea ] visibleCharacterRangeAttribute ]; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir return [ NSValue valueWithRange: NSMakeRange ( 0, 0 ) ]; 113cdf0e10cSrcweir} 114cdf0e10cSrcweir 115cdf0e10cSrcweir#pragma mark - 116cdf0e10cSrcweir#pragma mark Accessibility Protocol 117cdf0e10cSrcweir 118cdf0e10cSrcweir-(BOOL)accessibilityIsAttributeSettable:(NSString *)attribute { 119cdf0e10cSrcweir if ( [ self textArea ] != nil && ( 120cdf0e10cSrcweir [ attribute isEqualToString: NSAccessibilitySelectedTextAttribute ] 121cdf0e10cSrcweir || [ attribute isEqualToString: NSAccessibilitySelectedTextRangeAttribute ] 122cdf0e10cSrcweir || [ attribute isEqualToString: NSAccessibilityVisibleCharacterRangeAttribute ] ) ) { 123cdf0e10cSrcweir return [ [ self textArea ] accessibilityIsAttributeSettable: attribute ]; 124cdf0e10cSrcweir } 125cdf0e10cSrcweir return [ super accessibilityIsAttributeSettable: attribute ]; 126cdf0e10cSrcweir} 127cdf0e10cSrcweir 128cdf0e10cSrcweir-(void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute { 129cdf0e10cSrcweir if ( [ self textArea ] != nil && ( 130cdf0e10cSrcweir [ attribute isEqualToString: NSAccessibilitySelectedTextAttribute ] 131cdf0e10cSrcweir || [ attribute isEqualToString: NSAccessibilitySelectedTextRangeAttribute ] 132cdf0e10cSrcweir || [ attribute isEqualToString: NSAccessibilityVisibleCharacterRangeAttribute ] ) ) { 133cdf0e10cSrcweir return [ [ self textArea ] accessibilitySetValue: value forAttribute: attribute ]; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir return [ super accessibilitySetValue: value forAttribute: attribute ]; 136cdf0e10cSrcweir} 137cdf0e10cSrcweir 138cdf0e10cSrcweir-(NSArray *)accessibilityAttributeNames { 139cdf0e10cSrcweir // Default Attributes 140cdf0e10cSrcweir NSMutableArray * attributeNames = [ NSMutableArray arrayWithArray: [ super accessibilityAttributeNames ] ]; 141cdf0e10cSrcweir // Special Attributes and removing unwanted attributes depending on role 142cdf0e10cSrcweir [ attributeNames removeObjectsInArray: [ NSArray arrayWithObjects: 143cdf0e10cSrcweir NSAccessibilityTitleAttribute, 144cdf0e10cSrcweir NSAccessibilityChildrenAttribute, 145cdf0e10cSrcweir nil ] 146cdf0e10cSrcweir ]; 147cdf0e10cSrcweir [ attributeNames addObjectsFromArray: [ NSArray arrayWithObjects: 148cdf0e10cSrcweir NSAccessibilityExpandedAttribute, 149cdf0e10cSrcweir NSAccessibilityValueAttribute, 150cdf0e10cSrcweir NSAccessibilityNumberOfCharactersAttribute, 151cdf0e10cSrcweir NSAccessibilitySelectedTextAttribute, 152cdf0e10cSrcweir NSAccessibilitySelectedTextRangeAttribute, 153cdf0e10cSrcweir NSAccessibilityVisibleCharacterRangeAttribute, 154cdf0e10cSrcweir nil ] 155cdf0e10cSrcweir ]; 156cdf0e10cSrcweir return attributeNames; 157cdf0e10cSrcweir} 158cdf0e10cSrcweir 159cdf0e10cSrcweir@end 160