1*dde7d3faSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*dde7d3faSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*dde7d3faSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*dde7d3faSAndrew Rist * distributed with this work for additional information 6*dde7d3faSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*dde7d3faSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*dde7d3faSAndrew Rist * "License"); you may not use this file except in compliance 9*dde7d3faSAndrew Rist * with the License. You may obtain a copy of the License at 10*dde7d3faSAndrew Rist * 11*dde7d3faSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*dde7d3faSAndrew Rist * 13*dde7d3faSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*dde7d3faSAndrew Rist * software distributed under the License is distributed on an 15*dde7d3faSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*dde7d3faSAndrew Rist * KIND, either express or implied. See the License for the 17*dde7d3faSAndrew Rist * specific language governing permissions and limitations 18*dde7d3faSAndrew Rist * under the License. 19*dde7d3faSAndrew Rist * 20*dde7d3faSAndrew Rist *************************************************************/ 21*dde7d3faSAndrew Rist 22*dde7d3faSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_comphelper.hxx" 26cdf0e10cSrcweir #include <comphelper/accessibleselectionhelper.hxx> 27cdf0e10cSrcweir 28cdf0e10cSrcweir //......................................................................... 29cdf0e10cSrcweir namespace comphelper 30cdf0e10cSrcweir { 31cdf0e10cSrcweir //......................................................................... 32cdf0e10cSrcweir 33cdf0e10cSrcweir using namespace ::com::sun::star::uno; 34cdf0e10cSrcweir using namespace ::com::sun::star::awt; 35cdf0e10cSrcweir using namespace ::com::sun::star::lang; 36cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 37cdf0e10cSrcweir 38cdf0e10cSrcweir //===================================================================== 39cdf0e10cSrcweir //= OCommonAccessibleSelection 40cdf0e10cSrcweir //===================================================================== 41cdf0e10cSrcweir //--------------------------------------------------------------------- OCommonAccessibleSelection()42cdf0e10cSrcweir OCommonAccessibleSelection::OCommonAccessibleSelection( ) 43cdf0e10cSrcweir { 44cdf0e10cSrcweir } 45cdf0e10cSrcweir 46cdf0e10cSrcweir //-------------------------------------------------------------------- selectAccessibleChild(sal_Int32 nChildIndex)47cdf0e10cSrcweir void SAL_CALL OCommonAccessibleSelection::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 48cdf0e10cSrcweir { 49cdf0e10cSrcweir implSelect( nChildIndex, sal_True ); 50cdf0e10cSrcweir } 51cdf0e10cSrcweir 52cdf0e10cSrcweir //-------------------------------------------------------------------- isAccessibleChildSelected(sal_Int32 nChildIndex)53cdf0e10cSrcweir sal_Bool SAL_CALL OCommonAccessibleSelection::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 54cdf0e10cSrcweir { 55cdf0e10cSrcweir return( implIsSelected( nChildIndex ) ); 56cdf0e10cSrcweir } 57cdf0e10cSrcweir 58cdf0e10cSrcweir //-------------------------------------------------------------------- clearAccessibleSelection()59cdf0e10cSrcweir void SAL_CALL OCommonAccessibleSelection::clearAccessibleSelection( ) throw (RuntimeException) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir implSelect( ACCESSIBLE_SELECTION_CHILD_ALL, sal_False ); 62cdf0e10cSrcweir } 63cdf0e10cSrcweir 64cdf0e10cSrcweir //-------------------------------------------------------------------- selectAllAccessibleChildren()65cdf0e10cSrcweir void SAL_CALL OCommonAccessibleSelection::selectAllAccessibleChildren( ) throw (RuntimeException) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir implSelect( ACCESSIBLE_SELECTION_CHILD_ALL, sal_True ); 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir //-------------------------------------------------------------------- getSelectedAccessibleChildCount()71cdf0e10cSrcweir sal_Int32 SAL_CALL OCommonAccessibleSelection::getSelectedAccessibleChildCount( ) throw (RuntimeException) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir sal_Int32 nRet = 0; 74cdf0e10cSrcweir Reference< XAccessibleContext > xParentContext( implGetAccessibleContext() ); 75cdf0e10cSrcweir 76cdf0e10cSrcweir OSL_ENSURE( xParentContext.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" ); 77cdf0e10cSrcweir 78cdf0e10cSrcweir if( xParentContext.is() ) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir for( sal_Int32 i = 0, nChildCount = xParentContext->getAccessibleChildCount(); i < nChildCount; i++ ) 81cdf0e10cSrcweir if( implIsSelected( i ) ) 82cdf0e10cSrcweir ++nRet; 83cdf0e10cSrcweir } 84cdf0e10cSrcweir 85cdf0e10cSrcweir return( nRet ); 86cdf0e10cSrcweir } 87cdf0e10cSrcweir 88cdf0e10cSrcweir //-------------------------------------------------------------------- getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex)89cdf0e10cSrcweir Reference< XAccessible > SAL_CALL OCommonAccessibleSelection::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir Reference< XAccessible > xRet; 92cdf0e10cSrcweir Reference< XAccessibleContext > xParentContext( implGetAccessibleContext() ); 93cdf0e10cSrcweir 94cdf0e10cSrcweir OSL_ENSURE( xParentContext.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" ); 95cdf0e10cSrcweir 96cdf0e10cSrcweir if( xParentContext.is() ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir for( sal_Int32 i = 0, nChildCount = xParentContext->getAccessibleChildCount(), nPos = 0; ( i < nChildCount ) && !xRet.is(); i++ ) 99cdf0e10cSrcweir if( implIsSelected( i ) && ( nPos++ == nSelectedChildIndex ) ) 100cdf0e10cSrcweir xRet = xParentContext->getAccessibleChild( i ); 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir return( xRet ); 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir //-------------------------------------------------------------------- deselectAccessibleChild(sal_Int32 nSelectedChildIndex)107cdf0e10cSrcweir void SAL_CALL OCommonAccessibleSelection::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir implSelect( nSelectedChildIndex, sal_False ); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir 112cdf0e10cSrcweir //===================================================================== 113cdf0e10cSrcweir //= OAccessibleSelectionHelper 114cdf0e10cSrcweir //===================================================================== 115cdf0e10cSrcweir //--------------------------------------------------------------------- OAccessibleSelectionHelper()116cdf0e10cSrcweir OAccessibleSelectionHelper::OAccessibleSelectionHelper( ) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir //-------------------------------------------------------------------- OAccessibleSelectionHelper(IMutex * _pExternalLock)121cdf0e10cSrcweir OAccessibleSelectionHelper::OAccessibleSelectionHelper( IMutex* _pExternalLock ) : OAccessibleComponentHelper(_pExternalLock) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir //-------------------------------------------------------------------- IMPLEMENT_FORWARD_XINTERFACE2(OAccessibleSelectionHelper,OAccessibleComponentHelper,OAccessibleSelectionHelper_Base)126cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( OAccessibleSelectionHelper, OAccessibleComponentHelper, OAccessibleSelectionHelper_Base ) 127cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( OAccessibleSelectionHelper, OAccessibleComponentHelper, OAccessibleSelectionHelper_Base ) 128cdf0e10cSrcweir // (order matters: the first is the class name, the second is the class doing the ref counting) 129cdf0e10cSrcweir 130cdf0e10cSrcweir //-------------------------------------------------------------------- 131cdf0e10cSrcweir Reference< XAccessibleContext > OAccessibleSelectionHelper::implGetAccessibleContext() throw ( RuntimeException ) 132cdf0e10cSrcweir { 133cdf0e10cSrcweir return( this ); 134cdf0e10cSrcweir } 135cdf0e10cSrcweir 136cdf0e10cSrcweir //-------------------------------------------------------------------- selectAccessibleChild(sal_Int32 nChildIndex)137cdf0e10cSrcweir void SAL_CALL OAccessibleSelectionHelper::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 140cdf0e10cSrcweir OCommonAccessibleSelection::selectAccessibleChild( nChildIndex ); 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir //-------------------------------------------------------------------- isAccessibleChildSelected(sal_Int32 nChildIndex)144cdf0e10cSrcweir sal_Bool SAL_CALL OAccessibleSelectionHelper::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 147cdf0e10cSrcweir return( OCommonAccessibleSelection::isAccessibleChildSelected( nChildIndex ) ); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir //-------------------------------------------------------------------- clearAccessibleSelection()151cdf0e10cSrcweir void SAL_CALL OAccessibleSelectionHelper::clearAccessibleSelection( ) throw (RuntimeException) 152cdf0e10cSrcweir { 153cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 154cdf0e10cSrcweir OCommonAccessibleSelection::clearAccessibleSelection(); 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir //-------------------------------------------------------------------- selectAllAccessibleChildren()158cdf0e10cSrcweir void SAL_CALL OAccessibleSelectionHelper::selectAllAccessibleChildren( ) throw (RuntimeException) 159cdf0e10cSrcweir { 160cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 161cdf0e10cSrcweir OCommonAccessibleSelection::selectAllAccessibleChildren(); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir //-------------------------------------------------------------------- getSelectedAccessibleChildCount()165cdf0e10cSrcweir sal_Int32 SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) throw (RuntimeException) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 168cdf0e10cSrcweir return( OCommonAccessibleSelection::getSelectedAccessibleChildCount() ); 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir //-------------------------------------------------------------------- getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex)172cdf0e10cSrcweir Reference< XAccessible > SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 175cdf0e10cSrcweir return( OCommonAccessibleSelection::getSelectedAccessibleChild( nSelectedChildIndex ) ); 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir //-------------------------------------------------------------------- deselectAccessibleChild(sal_Int32 nSelectedChildIndex)179cdf0e10cSrcweir void SAL_CALL OAccessibleSelectionHelper::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 182cdf0e10cSrcweir OCommonAccessibleSelection::deselectAccessibleChild( nSelectedChildIndex ); 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir //......................................................................... 186cdf0e10cSrcweir } // namespace comphelper 187cdf0e10cSrcweir //......................................................................... 188cdf0e10cSrcweir 189