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 <vcl/svapp.hxx>
22 #include <osx/salinst.h>
24 #include "a11ywrappercombobox.h"
25 #include "a11yrolehelper.h"
27 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
29 using namespace ::com::sun::star::accessibility;
30 using namespace ::com::sun::star::uno;
32 // Wrapper for AXCombobox role
34 @implementation AquaA11yWrapperComboBox : AquaA11yWrapper
37 #pragma mark Specialized Init Method
39 -(id)initWithAccessibleContext: (Reference < XAccessibleContext >) rxAccessibleContext {
40 self = [ super initWithAccessibleContext: rxAccessibleContext ];
49 #pragma mark Private Helper Method
51 -(AquaA11yWrapper *)textArea {
52 // FIXME: May cause problems when stored. Then get dynamically each time (bad performance!)
53 if ( textArea == nil ) {
54 NSAutoreleasePool * pool = [ [ NSAutoreleasePool alloc ] init ];
55 NSArray * elementChildren = [ super childrenAttribute ];
56 if ( [ elementChildren count ] > 0 ) {
57 NSEnumerator * enumerator = [ elementChildren objectEnumerator ];
59 while ( ( child = [ enumerator nextObject ] ) ) {
60 AquaA11yWrapper * element = static_cast<AquaA11yWrapper *>(child);
61 if ( [ [ AquaA11yRoleHelper getNativeRoleFrom: [ element accessibleContext ] ] isEqualToString: NSAccessibilityTextAreaRole ] ) {
73 #pragma mark Wrapped Attributes From Contained Text Area
76 if ( [ self textArea ] != nil ) {
77 return [ [ self textArea ] valueAttribute ];
82 -(id)numberOfCharactersAttribute {
83 if ( [ self textArea ] != nil ) {
84 return [ [ self textArea ] numberOfCharactersAttribute ];
86 return [ NSNumber numberWithInt: 0 ];
89 -(id)selectedTextAttribute {
90 if ( [ self textArea ] != nil ) {
91 return [ [ self textArea ] selectedTextAttribute ];
96 -(id)selectedTextRangeAttribute {
97 if ( [ self textArea ] != nil ) {
98 return [ [ self textArea ] selectedTextRangeAttribute ];
100 return [ NSValue valueWithRange: NSMakeRange ( 0, 0 ) ];
103 -(id)visibleCharacterRangeAttribute {
104 if ( [ self textArea ] != nil ) {
105 return [ [ self textArea ] visibleCharacterRangeAttribute ];
107 return [ NSValue valueWithRange: NSMakeRange ( 0, 0 ) ];
111 #pragma mark Accessibility Protocol
113 -(BOOL)accessibilityIsAttributeSettable:(NSString *)attribute {
114 // Related: tdf#148453 Acquire solar mutex during native accessibility calls
115 SolarMutexGuard aGuard;
119 if ( [ self textArea ] != nil && (
120 [ attribute isEqualToString: NSAccessibilitySelectedTextAttribute ]
121 || [ attribute isEqualToString: NSAccessibilitySelectedTextRangeAttribute ]
122 || [ attribute isEqualToString: NSAccessibilityVisibleCharacterRangeAttribute ] ) ) {
123 return [ [ self textArea ] accessibilityIsAttributeSettable: attribute ];
125 return [ super accessibilityIsAttributeSettable: attribute ];
128 -(void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute {
129 // Related: tdf#148453 Acquire solar mutex during native accessibility calls
130 SolarMutexGuard aGuard;
134 if ( [ self textArea ] != nil && (
135 [ attribute isEqualToString: NSAccessibilitySelectedTextAttribute ]
136 || [ attribute isEqualToString: NSAccessibilitySelectedTextRangeAttribute ]
137 || [ attribute isEqualToString: NSAccessibilityVisibleCharacterRangeAttribute ] ) ) {
138 return [ [ self textArea ] accessibilitySetValue: value forAttribute: attribute ];
140 return [ super accessibilitySetValue: value forAttribute: attribute ];
143 -(NSArray *)accessibilityAttributeNames {
144 // Related: tdf#148453 Acquire solar mutex during native accessibility calls
145 SolarMutexGuard aGuard;
147 return [ NSArray array ];
149 // Default Attributes
150 NSMutableArray * attributeNames = [ NSMutableArray arrayWithArray: [ super accessibilityAttributeNames ] ];
151 // Special Attributes and removing unwanted attributes depending on role
152 [ attributeNames removeObjectsInArray: [ NSArray arrayWithObjects:
153 NSAccessibilityTitleAttribute,
154 NSAccessibilityChildrenAttribute,
157 [ attributeNames addObjectsFromArray: [ NSArray arrayWithObjects:
158 NSAccessibilityExpandedAttribute,
159 NSAccessibilityValueAttribute,
160 NSAccessibilityNumberOfCharactersAttribute,
161 NSAccessibilitySelectedTextAttribute,
162 NSAccessibilitySelectedTextRangeAttribute,
163 NSAccessibilityVisibleCharacterRangeAttribute,
166 return attributeNames;
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */