1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: accessibleselectionhelper.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_comphelper.hxx"
33 #include <comphelper/accessibleselectionhelper.hxx>
35 //.........................................................................
38 //.........................................................................
40 using namespace ::com::sun::star::uno
;
41 using namespace ::com::sun::star::awt
;
42 using namespace ::com::sun::star::lang
;
43 using namespace ::com::sun::star::accessibility
;
45 //=====================================================================
46 //= OCommonAccessibleSelection
47 //=====================================================================
48 //---------------------------------------------------------------------
49 OCommonAccessibleSelection::OCommonAccessibleSelection( )
53 //--------------------------------------------------------------------
54 void SAL_CALL
OCommonAccessibleSelection::selectAccessibleChild( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
56 implSelect( nChildIndex
, sal_True
);
59 //--------------------------------------------------------------------
60 sal_Bool SAL_CALL
OCommonAccessibleSelection::isAccessibleChildSelected( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
62 return( implIsSelected( nChildIndex
) );
65 //--------------------------------------------------------------------
66 void SAL_CALL
OCommonAccessibleSelection::clearAccessibleSelection( ) throw (RuntimeException
)
68 implSelect( ACCESSIBLE_SELECTION_CHILD_ALL
, sal_False
);
71 //--------------------------------------------------------------------
72 void SAL_CALL
OCommonAccessibleSelection::selectAllAccessibleChildren( ) throw (RuntimeException
)
74 implSelect( ACCESSIBLE_SELECTION_CHILD_ALL
, sal_True
);
77 //--------------------------------------------------------------------
78 sal_Int32 SAL_CALL
OCommonAccessibleSelection::getSelectedAccessibleChildCount( ) throw (RuntimeException
)
81 Reference
< XAccessibleContext
> xParentContext( implGetAccessibleContext() );
83 OSL_ENSURE( xParentContext
.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" );
85 if( xParentContext
.is() )
87 for( sal_Int32 i
= 0, nChildCount
= xParentContext
->getAccessibleChildCount(); i
< nChildCount
; i
++ )
88 if( implIsSelected( i
) )
95 //--------------------------------------------------------------------
96 Reference
< XAccessible
> SAL_CALL
OCommonAccessibleSelection::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
98 Reference
< XAccessible
> xRet
;
99 Reference
< XAccessibleContext
> xParentContext( implGetAccessibleContext() );
101 OSL_ENSURE( xParentContext
.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" );
103 if( xParentContext
.is() )
105 for( sal_Int32 i
= 0, nChildCount
= xParentContext
->getAccessibleChildCount(), nPos
= 0; ( i
< nChildCount
) && !xRet
.is(); i
++ )
106 if( implIsSelected( i
) && ( nPos
++ == nSelectedChildIndex
) )
107 xRet
= xParentContext
->getAccessibleChild( i
);
113 //--------------------------------------------------------------------
114 void SAL_CALL
OCommonAccessibleSelection::deselectAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
116 implSelect( nSelectedChildIndex
, sal_False
);
119 //=====================================================================
120 //= OAccessibleSelectionHelper
121 //=====================================================================
122 //---------------------------------------------------------------------
123 OAccessibleSelectionHelper::OAccessibleSelectionHelper( )
127 //--------------------------------------------------------------------
128 OAccessibleSelectionHelper::OAccessibleSelectionHelper( IMutex
* _pExternalLock
) : OAccessibleComponentHelper(_pExternalLock
)
132 //--------------------------------------------------------------------
133 IMPLEMENT_FORWARD_XINTERFACE2( OAccessibleSelectionHelper
, OAccessibleComponentHelper
, OAccessibleSelectionHelper_Base
)
134 IMPLEMENT_FORWARD_XTYPEPROVIDER2( OAccessibleSelectionHelper
, OAccessibleComponentHelper
, OAccessibleSelectionHelper_Base
)
135 // (order matters: the first is the class name, the second is the class doing the ref counting)
137 //--------------------------------------------------------------------
138 Reference
< XAccessibleContext
> OAccessibleSelectionHelper::implGetAccessibleContext() throw ( RuntimeException
)
143 //--------------------------------------------------------------------
144 void SAL_CALL
OAccessibleSelectionHelper::selectAccessibleChild( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
146 OExternalLockGuard
aGuard( this );
147 OCommonAccessibleSelection::selectAccessibleChild( nChildIndex
);
150 //--------------------------------------------------------------------
151 sal_Bool SAL_CALL
OAccessibleSelectionHelper::isAccessibleChildSelected( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
153 OExternalLockGuard
aGuard( this );
154 return( OCommonAccessibleSelection::isAccessibleChildSelected( nChildIndex
) );
157 //--------------------------------------------------------------------
158 void SAL_CALL
OAccessibleSelectionHelper::clearAccessibleSelection( ) throw (RuntimeException
)
160 OExternalLockGuard
aGuard( this );
161 OCommonAccessibleSelection::clearAccessibleSelection();
164 //--------------------------------------------------------------------
165 void SAL_CALL
OAccessibleSelectionHelper::selectAllAccessibleChildren( ) throw (RuntimeException
)
167 OExternalLockGuard
aGuard( this );
168 OCommonAccessibleSelection::selectAllAccessibleChildren();
171 //--------------------------------------------------------------------
172 sal_Int32 SAL_CALL
OAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) throw (RuntimeException
)
174 OExternalLockGuard
aGuard( this );
175 return( OCommonAccessibleSelection::getSelectedAccessibleChildCount() );
178 //--------------------------------------------------------------------
179 Reference
< XAccessible
> SAL_CALL
OAccessibleSelectionHelper::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
181 OExternalLockGuard
aGuard( this );
182 return( OCommonAccessibleSelection::getSelectedAccessibleChild( nSelectedChildIndex
) );
185 //--------------------------------------------------------------------
186 void SAL_CALL
OAccessibleSelectionHelper::deselectAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
188 OExternalLockGuard
aGuard( this );
189 OCommonAccessibleSelection::deselectAccessibleChild( nSelectedChildIndex
);
192 //.........................................................................
193 } // namespace comphelper
194 //.........................................................................