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>
22 #include <osx/a11yfactory.h>
24 #include "a11yselectionwrapper.h"
25 #include "a11ytablewrapper.h"
27 using namespace ::com::sun::star::accessibility;
28 using namespace ::com::sun::star::uno;
30 @implementation AquaA11ySelectionWrapper : NSObject
32 +(id)selectedChildrenAttributeForElement:(AquaA11yWrapper *)wrapper
34 Reference< XAccessibleSelection > xAccessibleSelection = [ wrapper accessibleSelection ];
35 if( xAccessibleSelection.is() )
37 NSMutableArray * children = [ [ NSMutableArray alloc ] init ];
39 sal_Int64 n = xAccessibleSelection -> getSelectedAccessibleChildCount();
41 // Fix hanging when selecting a column or row in Calc
42 // When a Calc column is selected, the child count will be
43 // at least a million. Constructing that many C++ Calc objects
44 // takes several minutes even on a fast Silicon Mac so apply
45 // the maximum table cell limit here.
48 else if ( n > MAXIMUM_ACCESSIBLE_TABLE_CELLS )
49 n = MAXIMUM_ACCESSIBLE_TABLE_CELLS;
51 for ( sal_Int64 i=0 ; i < n ; ++i ) {
52 [ children addObject: [ AquaA11yFactory wrapperForAccessible: xAccessibleSelection -> getSelectedAccessibleChild( i ) ] ];
66 +(void)addAttributeNamesTo:(NSMutableArray *)attributeNames
68 [ attributeNames addObject: NSAccessibilitySelectedChildrenAttribute ];
71 +(BOOL)isAttributeSettable:(NSString *)attribute forElement:(AquaA11yWrapper *)wrapper
74 if ( [ attribute isEqualToString: NSAccessibilitySelectedChildrenAttribute ] )
84 +(void)setSelectedChildrenAttributeForElement:(AquaA11yWrapper *)wrapper to:(id)value
86 Reference< XAccessibleSelection > xAccessibleSelection = [ wrapper accessibleSelection ];
88 xAccessibleSelection -> clearAccessibleSelection();
90 unsigned c = [ value count ];
91 for ( unsigned i = 0 ; i < c ; ++i ) {
92 xAccessibleSelection -> selectAccessibleChild( [ [ value objectAtIndex: i ] accessibleContext ] -> getAccessibleIndexInParent() );
94 } catch ( Exception&) {
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */