CWS-TOOLING: integrate CWS os146
[LibreOffice.git] / comphelper / source / misc / accessibleselectionhelper.cxx
blob8e31410b337e248c39b45cf92a9840762f3b0093
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_comphelper.hxx"
30 #include <comphelper/accessibleselectionhelper.hxx>
32 //.........................................................................
33 namespace comphelper
35 //.........................................................................
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::awt;
39 using namespace ::com::sun::star::lang;
40 using namespace ::com::sun::star::accessibility;
42 //=====================================================================
43 //= OCommonAccessibleSelection
44 //=====================================================================
45 //---------------------------------------------------------------------
46 OCommonAccessibleSelection::OCommonAccessibleSelection( )
50 //--------------------------------------------------------------------
51 void SAL_CALL OCommonAccessibleSelection::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
53 implSelect( nChildIndex, sal_True );
56 //--------------------------------------------------------------------
57 sal_Bool SAL_CALL OCommonAccessibleSelection::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
59 return( implIsSelected( nChildIndex ) );
62 //--------------------------------------------------------------------
63 void SAL_CALL OCommonAccessibleSelection::clearAccessibleSelection( ) throw (RuntimeException)
65 implSelect( ACCESSIBLE_SELECTION_CHILD_ALL, sal_False );
68 //--------------------------------------------------------------------
69 void SAL_CALL OCommonAccessibleSelection::selectAllAccessibleChildren( ) throw (RuntimeException)
71 implSelect( ACCESSIBLE_SELECTION_CHILD_ALL, sal_True );
74 //--------------------------------------------------------------------
75 sal_Int32 SAL_CALL OCommonAccessibleSelection::getSelectedAccessibleChildCount( ) throw (RuntimeException)
77 sal_Int32 nRet = 0;
78 Reference< XAccessibleContext > xParentContext( implGetAccessibleContext() );
80 OSL_ENSURE( xParentContext.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" );
82 if( xParentContext.is() )
84 for( sal_Int32 i = 0, nChildCount = xParentContext->getAccessibleChildCount(); i < nChildCount; i++ )
85 if( implIsSelected( i ) )
86 ++nRet;
89 return( nRet );
92 //--------------------------------------------------------------------
93 Reference< XAccessible > SAL_CALL OCommonAccessibleSelection::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
95 Reference< XAccessible > xRet;
96 Reference< XAccessibleContext > xParentContext( implGetAccessibleContext() );
98 OSL_ENSURE( xParentContext.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" );
100 if( xParentContext.is() )
102 for( sal_Int32 i = 0, nChildCount = xParentContext->getAccessibleChildCount(), nPos = 0; ( i < nChildCount ) && !xRet.is(); i++ )
103 if( implIsSelected( i ) && ( nPos++ == nSelectedChildIndex ) )
104 xRet = xParentContext->getAccessibleChild( i );
107 return( xRet );
110 //--------------------------------------------------------------------
111 void SAL_CALL OCommonAccessibleSelection::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
113 implSelect( nSelectedChildIndex, sal_False );
116 //=====================================================================
117 //= OAccessibleSelectionHelper
118 //=====================================================================
119 //---------------------------------------------------------------------
120 OAccessibleSelectionHelper::OAccessibleSelectionHelper( )
124 //--------------------------------------------------------------------
125 OAccessibleSelectionHelper::OAccessibleSelectionHelper( IMutex* _pExternalLock ) : OAccessibleComponentHelper(_pExternalLock)
129 //--------------------------------------------------------------------
130 IMPLEMENT_FORWARD_XINTERFACE2( OAccessibleSelectionHelper, OAccessibleComponentHelper, OAccessibleSelectionHelper_Base )
131 IMPLEMENT_FORWARD_XTYPEPROVIDER2( OAccessibleSelectionHelper, OAccessibleComponentHelper, OAccessibleSelectionHelper_Base )
132 // (order matters: the first is the class name, the second is the class doing the ref counting)
134 //--------------------------------------------------------------------
135 Reference< XAccessibleContext > OAccessibleSelectionHelper::implGetAccessibleContext() throw ( RuntimeException )
137 return( this );
140 //--------------------------------------------------------------------
141 void SAL_CALL OAccessibleSelectionHelper::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
143 OExternalLockGuard aGuard( this );
144 OCommonAccessibleSelection::selectAccessibleChild( nChildIndex );
147 //--------------------------------------------------------------------
148 sal_Bool SAL_CALL OAccessibleSelectionHelper::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
150 OExternalLockGuard aGuard( this );
151 return( OCommonAccessibleSelection::isAccessibleChildSelected( nChildIndex ) );
154 //--------------------------------------------------------------------
155 void SAL_CALL OAccessibleSelectionHelper::clearAccessibleSelection( ) throw (RuntimeException)
157 OExternalLockGuard aGuard( this );
158 OCommonAccessibleSelection::clearAccessibleSelection();
161 //--------------------------------------------------------------------
162 void SAL_CALL OAccessibleSelectionHelper::selectAllAccessibleChildren( ) throw (RuntimeException)
164 OExternalLockGuard aGuard( this );
165 OCommonAccessibleSelection::selectAllAccessibleChildren();
168 //--------------------------------------------------------------------
169 sal_Int32 SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) throw (RuntimeException)
171 OExternalLockGuard aGuard( this );
172 return( OCommonAccessibleSelection::getSelectedAccessibleChildCount() );
175 //--------------------------------------------------------------------
176 Reference< XAccessible > SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
178 OExternalLockGuard aGuard( this );
179 return( OCommonAccessibleSelection::getSelectedAccessibleChild( nSelectedChildIndex ) );
182 //--------------------------------------------------------------------
183 void SAL_CALL OAccessibleSelectionHelper::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
185 OExternalLockGuard aGuard( this );
186 OCommonAccessibleSelection::deselectAccessibleChild( nSelectedChildIndex );
189 //.........................................................................
190 } // namespace comphelper
191 //.........................................................................