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_comphelper.hxx" 26 #include <comphelper/accessibleselectionhelper.hxx> 27 28 //......................................................................... 29 namespace comphelper 30 { 31 //......................................................................... 32 33 using namespace ::com::sun::star::uno; 34 using namespace ::com::sun::star::awt; 35 using namespace ::com::sun::star::lang; 36 using namespace ::com::sun::star::accessibility; 37 38 //===================================================================== 39 //= OCommonAccessibleSelection 40 //===================================================================== 41 //--------------------------------------------------------------------- OCommonAccessibleSelection()42 OCommonAccessibleSelection::OCommonAccessibleSelection( ) 43 { 44 } 45 46 //-------------------------------------------------------------------- selectAccessibleChild(sal_Int32 nChildIndex)47 void SAL_CALL OCommonAccessibleSelection::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 48 { 49 implSelect( nChildIndex, sal_True ); 50 } 51 52 //-------------------------------------------------------------------- isAccessibleChildSelected(sal_Int32 nChildIndex)53 sal_Bool SAL_CALL OCommonAccessibleSelection::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 54 { 55 return( implIsSelected( nChildIndex ) ); 56 } 57 58 //-------------------------------------------------------------------- clearAccessibleSelection()59 void SAL_CALL OCommonAccessibleSelection::clearAccessibleSelection( ) throw (RuntimeException) 60 { 61 implSelect( ACCESSIBLE_SELECTION_CHILD_ALL, sal_False ); 62 } 63 64 //-------------------------------------------------------------------- selectAllAccessibleChildren()65 void SAL_CALL OCommonAccessibleSelection::selectAllAccessibleChildren( ) throw (RuntimeException) 66 { 67 implSelect( ACCESSIBLE_SELECTION_CHILD_ALL, sal_True ); 68 } 69 70 //-------------------------------------------------------------------- getSelectedAccessibleChildCount()71 sal_Int32 SAL_CALL OCommonAccessibleSelection::getSelectedAccessibleChildCount( ) throw (RuntimeException) 72 { 73 sal_Int32 nRet = 0; 74 Reference< XAccessibleContext > xParentContext( implGetAccessibleContext() ); 75 76 OSL_ENSURE( xParentContext.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" ); 77 78 if( xParentContext.is() ) 79 { 80 for( sal_Int32 i = 0, nChildCount = xParentContext->getAccessibleChildCount(); i < nChildCount; i++ ) 81 if( implIsSelected( i ) ) 82 ++nRet; 83 } 84 85 return( nRet ); 86 } 87 88 //-------------------------------------------------------------------- getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex)89 Reference< XAccessible > SAL_CALL OCommonAccessibleSelection::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 90 { 91 Reference< XAccessible > xRet; 92 Reference< XAccessibleContext > xParentContext( implGetAccessibleContext() ); 93 94 OSL_ENSURE( xParentContext.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" ); 95 96 if( xParentContext.is() ) 97 { 98 for( sal_Int32 i = 0, nChildCount = xParentContext->getAccessibleChildCount(), nPos = 0; ( i < nChildCount ) && !xRet.is(); i++ ) 99 if( implIsSelected( i ) && ( nPos++ == nSelectedChildIndex ) ) 100 xRet = xParentContext->getAccessibleChild( i ); 101 } 102 103 return( xRet ); 104 } 105 106 //-------------------------------------------------------------------- deselectAccessibleChild(sal_Int32 nSelectedChildIndex)107 void SAL_CALL OCommonAccessibleSelection::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 108 { 109 implSelect( nSelectedChildIndex, sal_False ); 110 } 111 112 //===================================================================== 113 //= OAccessibleSelectionHelper 114 //===================================================================== 115 //--------------------------------------------------------------------- OAccessibleSelectionHelper()116 OAccessibleSelectionHelper::OAccessibleSelectionHelper( ) 117 { 118 } 119 120 //-------------------------------------------------------------------- OAccessibleSelectionHelper(IMutex * _pExternalLock)121 OAccessibleSelectionHelper::OAccessibleSelectionHelper( IMutex* _pExternalLock ) : OAccessibleComponentHelper(_pExternalLock) 122 { 123 } 124 125 //-------------------------------------------------------------------- IMPLEMENT_FORWARD_XINTERFACE2(OAccessibleSelectionHelper,OAccessibleComponentHelper,OAccessibleSelectionHelper_Base)126 IMPLEMENT_FORWARD_XINTERFACE2( OAccessibleSelectionHelper, OAccessibleComponentHelper, OAccessibleSelectionHelper_Base ) 127 IMPLEMENT_FORWARD_XTYPEPROVIDER2( OAccessibleSelectionHelper, OAccessibleComponentHelper, OAccessibleSelectionHelper_Base ) 128 // (order matters: the first is the class name, the second is the class doing the ref counting) 129 130 //-------------------------------------------------------------------- 131 Reference< XAccessibleContext > OAccessibleSelectionHelper::implGetAccessibleContext() throw ( RuntimeException ) 132 { 133 return( this ); 134 } 135 136 //-------------------------------------------------------------------- selectAccessibleChild(sal_Int32 nChildIndex)137 void SAL_CALL OAccessibleSelectionHelper::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 138 { 139 OExternalLockGuard aGuard( this ); 140 OCommonAccessibleSelection::selectAccessibleChild( nChildIndex ); 141 } 142 143 //-------------------------------------------------------------------- isAccessibleChildSelected(sal_Int32 nChildIndex)144 sal_Bool SAL_CALL OAccessibleSelectionHelper::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 145 { 146 OExternalLockGuard aGuard( this ); 147 return( OCommonAccessibleSelection::isAccessibleChildSelected( nChildIndex ) ); 148 } 149 150 //-------------------------------------------------------------------- clearAccessibleSelection()151 void SAL_CALL OAccessibleSelectionHelper::clearAccessibleSelection( ) throw (RuntimeException) 152 { 153 OExternalLockGuard aGuard( this ); 154 OCommonAccessibleSelection::clearAccessibleSelection(); 155 } 156 157 //-------------------------------------------------------------------- selectAllAccessibleChildren()158 void SAL_CALL OAccessibleSelectionHelper::selectAllAccessibleChildren( ) throw (RuntimeException) 159 { 160 OExternalLockGuard aGuard( this ); 161 OCommonAccessibleSelection::selectAllAccessibleChildren(); 162 } 163 164 //-------------------------------------------------------------------- getSelectedAccessibleChildCount()165 sal_Int32 SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) throw (RuntimeException) 166 { 167 OExternalLockGuard aGuard( this ); 168 return( OCommonAccessibleSelection::getSelectedAccessibleChildCount() ); 169 } 170 171 //-------------------------------------------------------------------- getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex)172 Reference< XAccessible > SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 173 { 174 OExternalLockGuard aGuard( this ); 175 return( OCommonAccessibleSelection::getSelectedAccessibleChild( nSelectedChildIndex ) ); 176 } 177 178 //-------------------------------------------------------------------- deselectAccessibleChild(sal_Int32 nSelectedChildIndex)179 void SAL_CALL OAccessibleSelectionHelper::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 180 { 181 OExternalLockGuard aGuard( this ); 182 OCommonAccessibleSelection::deselectAccessibleChild( nSelectedChildIndex ); 183 } 184 185 //......................................................................... 186 } // namespace comphelper 187 //......................................................................... 188 189