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/accessiblecontexthelper.hxx>
21 #include <comphelper/accessibleselectionhelper.hxx>
28 using namespace ::com::sun::star::uno
;
29 using namespace ::com::sun::star::awt
;
30 using namespace ::com::sun::star::lang
;
31 using namespace ::com::sun::star::accessibility
;
33 OCommonAccessibleSelection::OCommonAccessibleSelection( )
37 OCommonAccessibleSelection::~OCommonAccessibleSelection() {}
40 void OCommonAccessibleSelection::selectAccessibleChild( sal_Int64 nChildIndex
)
42 implSelect( nChildIndex
, true );
46 bool OCommonAccessibleSelection::isAccessibleChildSelected( sal_Int64 nChildIndex
)
48 return implIsSelected( nChildIndex
);
52 void OCommonAccessibleSelection::clearAccessibleSelection( )
54 implSelect( ACCESSIBLE_SELECTION_CHILD_ALL
, false );
58 void OCommonAccessibleSelection::selectAllAccessibleChildren( )
60 implSelect( ACCESSIBLE_SELECTION_CHILD_ALL
, true );
64 sal_Int64
OCommonAccessibleSelection::getSelectedAccessibleChildCount( )
67 Reference
< XAccessibleContext
> xParentContext( implGetAccessibleContext() );
69 OSL_ENSURE( xParentContext
.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" );
71 if( xParentContext
.is() )
73 for( sal_Int64 i
= 0, nChildCount
= xParentContext
->getAccessibleChildCount(); i
< nChildCount
; i
++ )
74 if( implIsSelected( i
) )
82 Reference
< XAccessible
> OCommonAccessibleSelection::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex
)
84 Reference
< XAccessible
> xRet
;
85 Reference
< XAccessibleContext
> xParentContext( implGetAccessibleContext() );
87 OSL_ENSURE( xParentContext
.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" );
89 if( xParentContext
.is() )
91 for( sal_Int64 i
= 0, nChildCount
= xParentContext
->getAccessibleChildCount(), nPos
= 0; ( i
< nChildCount
) && !xRet
.is(); i
++ )
92 if( implIsSelected( i
) && ( nPos
++ == nSelectedChildIndex
) )
93 xRet
= xParentContext
->getAccessibleChild( i
);
100 void OCommonAccessibleSelection::deselectAccessibleChild( sal_Int64 nSelectedChildIndex
)
102 implSelect( nSelectedChildIndex
, false );
105 OAccessibleSelectionHelper::OAccessibleSelectionHelper()
110 Reference
< XAccessibleContext
> OAccessibleSelectionHelper::implGetAccessibleContext()
116 void SAL_CALL
OAccessibleSelectionHelper::selectAccessibleChild( sal_Int64 nChildIndex
)
118 OExternalLockGuard
aGuard( this );
119 OCommonAccessibleSelection::selectAccessibleChild( nChildIndex
);
123 sal_Bool SAL_CALL
OAccessibleSelectionHelper::isAccessibleChildSelected( sal_Int64 nChildIndex
)
125 OExternalLockGuard
aGuard( this );
126 return OCommonAccessibleSelection::isAccessibleChildSelected( nChildIndex
);
130 void SAL_CALL
OAccessibleSelectionHelper::clearAccessibleSelection( )
132 OExternalLockGuard
aGuard( this );
133 OCommonAccessibleSelection::clearAccessibleSelection();
137 void SAL_CALL
OAccessibleSelectionHelper::selectAllAccessibleChildren( )
139 OExternalLockGuard
aGuard( this );
140 OCommonAccessibleSelection::selectAllAccessibleChildren();
144 sal_Int64 SAL_CALL
OAccessibleSelectionHelper::getSelectedAccessibleChildCount( )
146 OExternalLockGuard
aGuard( this );
147 return OCommonAccessibleSelection::getSelectedAccessibleChildCount();
151 Reference
< XAccessible
> SAL_CALL
OAccessibleSelectionHelper::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex
)
153 OExternalLockGuard
aGuard( this );
154 return OCommonAccessibleSelection::getSelectedAccessibleChild( nSelectedChildIndex
);
158 void SAL_CALL
OAccessibleSelectionHelper::deselectAccessibleChild( sal_Int64 nSelectedChildIndex
)
160 OExternalLockGuard
aGuard( this );
161 OCommonAccessibleSelection::deselectAccessibleChild( nSelectedChildIndex
);
165 } // namespace comphelper
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */