1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <comphelper/accessibleselectionhelper.hxx>
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
;
32 OCommonAccessibleSelection::OCommonAccessibleSelection( )
36 OCommonAccessibleSelection::~OCommonAccessibleSelection() {}
39 void SAL_CALL
OCommonAccessibleSelection::selectAccessibleChild( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
41 implSelect( nChildIndex
, true );
45 bool SAL_CALL
OCommonAccessibleSelection::isAccessibleChildSelected( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
47 return implIsSelected( nChildIndex
);
51 void SAL_CALL
OCommonAccessibleSelection::clearAccessibleSelection( ) throw (RuntimeException
)
53 implSelect( ACCESSIBLE_SELECTION_CHILD_ALL
, false );
57 void SAL_CALL
OCommonAccessibleSelection::selectAllAccessibleChildren( ) throw (RuntimeException
)
59 implSelect( ACCESSIBLE_SELECTION_CHILD_ALL
, true );
63 sal_Int32 SAL_CALL
OCommonAccessibleSelection::getSelectedAccessibleChildCount( ) throw (RuntimeException
)
66 Reference
< XAccessibleContext
> xParentContext( implGetAccessibleContext() );
68 OSL_ENSURE( xParentContext
.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" );
70 if( xParentContext
.is() )
72 for( sal_Int32 i
= 0, nChildCount
= xParentContext
->getAccessibleChildCount(); i
< nChildCount
; i
++ )
73 if( implIsSelected( i
) )
81 Reference
< XAccessible
> SAL_CALL
OCommonAccessibleSelection::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
83 Reference
< XAccessible
> xRet
;
84 Reference
< XAccessibleContext
> xParentContext( implGetAccessibleContext() );
86 OSL_ENSURE( xParentContext
.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" );
88 if( xParentContext
.is() )
90 for( sal_Int32 i
= 0, nChildCount
= xParentContext
->getAccessibleChildCount(), nPos
= 0; ( i
< nChildCount
) && !xRet
.is(); i
++ )
91 if( implIsSelected( i
) && ( nPos
++ == nSelectedChildIndex
) )
92 xRet
= xParentContext
->getAccessibleChild( i
);
99 void SAL_CALL
OCommonAccessibleSelection::deselectAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
101 implSelect( nSelectedChildIndex
, false );
104 OAccessibleSelectionHelper::OAccessibleSelectionHelper( IMutex
* _pExternalLock
) : OAccessibleComponentHelper(_pExternalLock
)
109 IMPLEMENT_FORWARD_XINTERFACE2( OAccessibleSelectionHelper
, OAccessibleComponentHelper
, OAccessibleSelectionHelper_Base
)
110 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)
114 Reference
< XAccessibleContext
> OAccessibleSelectionHelper::implGetAccessibleContext() throw ( RuntimeException
)
120 void SAL_CALL
OAccessibleSelectionHelper::selectAccessibleChild( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
122 OExternalLockGuard
aGuard( this );
123 OCommonAccessibleSelection::selectAccessibleChild( nChildIndex
);
127 sal_Bool SAL_CALL
OAccessibleSelectionHelper::isAccessibleChildSelected( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
129 OExternalLockGuard
aGuard( this );
130 return OCommonAccessibleSelection::isAccessibleChildSelected( nChildIndex
);
134 void SAL_CALL
OAccessibleSelectionHelper::clearAccessibleSelection( ) throw (RuntimeException
, std::exception
)
136 OExternalLockGuard
aGuard( this );
137 OCommonAccessibleSelection::clearAccessibleSelection();
141 void SAL_CALL
OAccessibleSelectionHelper::selectAllAccessibleChildren( ) throw (RuntimeException
, std::exception
)
143 OExternalLockGuard
aGuard( this );
144 OCommonAccessibleSelection::selectAllAccessibleChildren();
148 sal_Int32 SAL_CALL
OAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) throw (RuntimeException
, std::exception
)
150 OExternalLockGuard
aGuard( this );
151 return OCommonAccessibleSelection::getSelectedAccessibleChildCount();
155 Reference
< XAccessible
> SAL_CALL
OAccessibleSelectionHelper::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
157 OExternalLockGuard
aGuard( this );
158 return OCommonAccessibleSelection::getSelectedAccessibleChild( nSelectedChildIndex
);
162 void SAL_CALL
OAccessibleSelectionHelper::deselectAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
164 OExternalLockGuard
aGuard( this );
165 OCommonAccessibleSelection::deselectAccessibleChild( nSelectedChildIndex
);
169 } // namespace comphelper
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */