Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <comphelper/accessibleselectionhelper.hxx>
21 :
22 :
23 : namespace comphelper
24 : {
25 :
26 :
27 : using namespace ::com::sun::star::uno;
28 : using namespace ::com::sun::star::awt;
29 : using namespace ::com::sun::star::lang;
30 : using namespace ::com::sun::star::accessibility;
31 :
32 3 : OCommonAccessibleSelection::OCommonAccessibleSelection( )
33 : {
34 3 : }
35 :
36 3 : OCommonAccessibleSelection::~OCommonAccessibleSelection() {}
37 :
38 :
39 1 : void SAL_CALL OCommonAccessibleSelection::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
40 : {
41 1 : implSelect( nChildIndex, true );
42 1 : }
43 :
44 :
45 0 : bool SAL_CALL OCommonAccessibleSelection::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
46 : {
47 0 : return implIsSelected( nChildIndex );
48 : }
49 :
50 :
51 1 : void SAL_CALL OCommonAccessibleSelection::clearAccessibleSelection( ) throw (RuntimeException)
52 : {
53 1 : implSelect( ACCESSIBLE_SELECTION_CHILD_ALL, false );
54 1 : }
55 :
56 :
57 0 : void SAL_CALL OCommonAccessibleSelection::selectAllAccessibleChildren( ) throw (RuntimeException)
58 : {
59 0 : implSelect( ACCESSIBLE_SELECTION_CHILD_ALL, true );
60 0 : }
61 :
62 :
63 0 : sal_Int32 SAL_CALL OCommonAccessibleSelection::getSelectedAccessibleChildCount( ) throw (RuntimeException)
64 : {
65 0 : sal_Int32 nRet = 0;
66 0 : Reference< XAccessibleContext > xParentContext( implGetAccessibleContext() );
67 :
68 : OSL_ENSURE( xParentContext.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" );
69 :
70 0 : if( xParentContext.is() )
71 : {
72 0 : for( sal_Int32 i = 0, nChildCount = xParentContext->getAccessibleChildCount(); i < nChildCount; i++ )
73 0 : if( implIsSelected( i ) )
74 0 : ++nRet;
75 : }
76 :
77 0 : return nRet;
78 : }
79 :
80 :
81 0 : Reference< XAccessible > SAL_CALL OCommonAccessibleSelection::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
82 : {
83 0 : Reference< XAccessible > xRet;
84 0 : Reference< XAccessibleContext > xParentContext( implGetAccessibleContext() );
85 :
86 : OSL_ENSURE( xParentContext.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" );
87 :
88 0 : if( xParentContext.is() )
89 : {
90 0 : for( sal_Int32 i = 0, nChildCount = xParentContext->getAccessibleChildCount(), nPos = 0; ( i < nChildCount ) && !xRet.is(); i++ )
91 0 : if( implIsSelected( i ) && ( nPos++ == nSelectedChildIndex ) )
92 0 : xRet = xParentContext->getAccessibleChild( i );
93 : }
94 :
95 0 : return xRet;
96 : }
97 :
98 :
99 0 : void SAL_CALL OCommonAccessibleSelection::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
100 : {
101 0 : implSelect( nSelectedChildIndex, false );
102 0 : }
103 :
104 0 : OAccessibleSelectionHelper::OAccessibleSelectionHelper( IMutex* _pExternalLock ) : OAccessibleComponentHelper(_pExternalLock)
105 : {
106 0 : }
107 :
108 :
109 0 : IMPLEMENT_FORWARD_XINTERFACE2( OAccessibleSelectionHelper, OAccessibleComponentHelper, OAccessibleSelectionHelper_Base )
110 0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( OAccessibleSelectionHelper, OAccessibleComponentHelper, OAccessibleSelectionHelper_Base )
111 : // (order matters: the first is the class name, the second is the class doing the ref counting)
112 :
113 :
114 0 : Reference< XAccessibleContext > OAccessibleSelectionHelper::implGetAccessibleContext() throw ( RuntimeException )
115 : {
116 0 : return this;
117 : }
118 :
119 :
120 0 : void SAL_CALL OAccessibleSelectionHelper::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
121 : {
122 0 : OExternalLockGuard aGuard( this );
123 0 : OCommonAccessibleSelection::selectAccessibleChild( nChildIndex );
124 0 : }
125 :
126 :
127 0 : sal_Bool SAL_CALL OAccessibleSelectionHelper::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
128 : {
129 0 : OExternalLockGuard aGuard( this );
130 0 : return OCommonAccessibleSelection::isAccessibleChildSelected( nChildIndex );
131 : }
132 :
133 :
134 0 : void SAL_CALL OAccessibleSelectionHelper::clearAccessibleSelection( ) throw (RuntimeException, std::exception)
135 : {
136 0 : OExternalLockGuard aGuard( this );
137 0 : OCommonAccessibleSelection::clearAccessibleSelection();
138 0 : }
139 :
140 :
141 0 : void SAL_CALL OAccessibleSelectionHelper::selectAllAccessibleChildren( ) throw (RuntimeException, std::exception)
142 : {
143 0 : OExternalLockGuard aGuard( this );
144 0 : OCommonAccessibleSelection::selectAllAccessibleChildren();
145 0 : }
146 :
147 :
148 0 : sal_Int32 SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) throw (RuntimeException, std::exception)
149 : {
150 0 : OExternalLockGuard aGuard( this );
151 0 : return OCommonAccessibleSelection::getSelectedAccessibleChildCount();
152 : }
153 :
154 :
155 0 : Reference< XAccessible > SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
156 : {
157 0 : OExternalLockGuard aGuard( this );
158 0 : return OCommonAccessibleSelection::getSelectedAccessibleChild( nSelectedChildIndex );
159 : }
160 :
161 :
162 0 : void SAL_CALL OAccessibleSelectionHelper::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
163 : {
164 0 : OExternalLockGuard aGuard( this );
165 0 : OCommonAccessibleSelection::deselectAccessibleChild( nSelectedChildIndex );
166 0 : }
167 :
168 :
169 : } // namespace comphelper
170 :
171 :
172 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|