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 <osx/salinst.h>
23 #include "a11ywrappercombobox.h"
24 #include "a11yrolehelper.h"
26 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
28 using namespace ::com::sun::star::accessibility;
29 using namespace ::com::sun::star::uno;
31 // Wrapper for AXCombobox role
33 @implementation AquaA11yWrapperComboBox : AquaA11yWrapper
36 #pragma mark Specialized Init Method
38 -(id)initWithAccessibleContext: (Reference < XAccessibleContext >) rxAccessibleContext {
39 self = [ super initWithAccessibleContext: rxAccessibleContext ];
48 #pragma mark Private Helper Method
50 -(AquaA11yWrapper *)textArea {
51 // FIXME: May cause problems when stored. Then get dynamically each time (bad performance!)
52 if ( textArea == nil ) {
53 NSAutoreleasePool * pool = [ [ NSAutoreleasePool alloc ] init ];
54 NSArray * elementChildren = [ super childrenAttribute ];
55 if ( [ elementChildren count ] > 0 ) {
56 NSEnumerator * enumerator = [ elementChildren objectEnumerator ];
58 while ( ( child = [ enumerator nextObject ] ) ) {
59 AquaA11yWrapper * element = static_cast<AquaA11yWrapper *>(child);
60 if ( [ [ AquaA11yRoleHelper getNativeRoleFrom: [ element accessibleContext ] ] isEqualToString: NSAccessibilityTextAreaRole ] ) {
72 #pragma mark Wrapped Attributes From Contained Text Area
75 if ( [ self textArea ] != nil ) {
76 return [ [ self textArea ] valueAttribute ];
81 -(id)numberOfCharactersAttribute {
82 if ( [ self textArea ] != nil ) {
83 return [ [ self textArea ] numberOfCharactersAttribute ];
85 return [ NSNumber numberWithInt: 0 ];
88 -(id)selectedTextAttribute {
89 if ( [ self textArea ] != nil ) {
90 return [ [ self textArea ] selectedTextAttribute ];
95 -(id)selectedTextRangeAttribute {
96 if ( [ self textArea ] != nil ) {
97 return [ [ self textArea ] selectedTextRangeAttribute ];
99 return [ NSValue valueWithRange: NSMakeRange ( 0, 0 ) ];
102 -(id)visibleCharacterRangeAttribute {
103 if ( [ self textArea ] != nil ) {
104 return [ [ self textArea ] visibleCharacterRangeAttribute ];
106 return [ NSValue valueWithRange: NSMakeRange ( 0, 0 ) ];
110 #pragma mark Accessibility Protocol
112 -(BOOL)accessibilityIsAttributeSettable:(NSString *)attribute {
113 if ( [ self textArea ] != nil && (
114 [ attribute isEqualToString: NSAccessibilitySelectedTextAttribute ]
115 || [ attribute isEqualToString: NSAccessibilitySelectedTextRangeAttribute ]
116 || [ attribute isEqualToString: NSAccessibilityVisibleCharacterRangeAttribute ] ) ) {
117 return [ [ self textArea ] accessibilityIsAttributeSettable: attribute ];
119 return [ super accessibilityIsAttributeSettable: attribute ];
122 -(void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute {
123 if ( [ self textArea ] != nil && (
124 [ attribute isEqualToString: NSAccessibilitySelectedTextAttribute ]
125 || [ attribute isEqualToString: NSAccessibilitySelectedTextRangeAttribute ]
126 || [ attribute isEqualToString: NSAccessibilityVisibleCharacterRangeAttribute ] ) ) {
127 return [ [ self textArea ] accessibilitySetValue: value forAttribute: attribute ];
129 return [ super accessibilitySetValue: value forAttribute: attribute ];
132 -(NSArray *)accessibilityAttributeNames {
133 // Default Attributes
134 NSMutableArray * attributeNames = [ NSMutableArray arrayWithArray: [ super accessibilityAttributeNames ] ];
135 // Special Attributes and removing unwanted attributes depending on role
136 [ attributeNames removeObjectsInArray: [ NSArray arrayWithObjects:
137 NSAccessibilityTitleAttribute,
138 NSAccessibilityChildrenAttribute,
141 [ attributeNames addObjectsFromArray: [ NSArray arrayWithObjects:
142 NSAccessibilityExpandedAttribute,
143 NSAccessibilityValueAttribute,
144 NSAccessibilityNumberOfCharactersAttribute,
145 NSAccessibilitySelectedTextAttribute,
146 NSAccessibilitySelectedTextRangeAttribute,
147 NSAccessibilityVisibleCharacterRangeAttribute,
150 return attributeNames;
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */