1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_vcl.hxx"
26
27#include "aqua/salinst.h"
28#include "aqua/aqua11yfactory.h"
29
30#include "aqua11yselectionwrapper.h"
31
32using namespace ::com::sun::star::accessibility;
33using namespace ::com::sun::star::uno;
34
35@implementation AquaA11ySelectionWrapper : NSObject
36
37+(id)selectedChildrenAttributeForElement:(AquaA11yWrapper *)wrapper
38{
39    Reference< XAccessibleSelection > xAccessibleSelection = [ wrapper accessibleSelection ];
40    if( xAccessibleSelection.is() )
41    {
42        NSMutableArray * children = [ [ NSMutableArray alloc ] init ];
43        try {
44            sal_Int32 n = xAccessibleSelection -> getSelectedAccessibleChildCount();
45            for ( sal_Int32 i=0 ; i < n ; ++i ) {
46                [ children addObject: [ AquaA11yFactory wrapperForAccessible: xAccessibleSelection -> getSelectedAccessibleChild( i ) ] ];
47            }
48
49            return children;
50
51        } catch ( Exception& e)
52        {
53        }
54    }
55
56    return nil;
57}
58
59
60+(void)addAttributeNamesTo:(NSMutableArray *)attributeNames
61{
62    [ attributeNames addObject: NSAccessibilitySelectedChildrenAttribute ];
63}
64
65+(BOOL)isAttributeSettable:(NSString *)attribute forElement:(AquaA11yWrapper *)wrapper
66{
67    (void)wrapper;
68    if ( [ attribute isEqualToString: NSAccessibilitySelectedChildrenAttribute ] )
69    {
70        return YES;
71    }
72    else
73    {
74        return NO;
75    }
76}
77
78+(void)setSelectedChildrenAttributeForElement:(AquaA11yWrapper *)wrapper to:(id)value
79{
80    Reference< XAccessibleSelection > xAccessibleSelection = [ wrapper accessibleSelection ];
81    try {
82        xAccessibleSelection -> clearAccessibleSelection();
83
84        unsigned c = [ value count ];
85        for ( unsigned i = 0 ; i < c ; ++i ) {
86            xAccessibleSelection -> selectAccessibleChild( [ [ value objectAtIndex: i ] accessibleContext ] -> getAccessibleIndexInParent() );
87        }
88    } catch ( Exception& e) {
89    }
90}
91
92@end
93