LibreOffice Module comphelper (master)  1
accessibleselectionhelper.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
21 
22 
23 namespace comphelper
24 {
25 
26 
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;
31 
33  {
34  }
35 
37 
38 
40  {
41  implSelect( nChildIndex, true );
42  }
43 
44 
46  {
47  return implIsSelected( nChildIndex );
48  }
49 
50 
52  {
54  }
55 
56 
58  {
60  }
61 
62 
64  {
65  sal_Int32 nRet = 0;
66  Reference< XAccessibleContext > xParentContext( implGetAccessibleContext() );
67 
68  OSL_ENSURE( xParentContext.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" );
69 
70  if( xParentContext.is() )
71  {
72  for( sal_Int32 i = 0, nChildCount = xParentContext->getAccessibleChildCount(); i < nChildCount; i++ )
73  if( implIsSelected( i ) )
74  ++nRet;
75  }
76 
77  return nRet;
78  }
79 
80 
81  Reference< XAccessible > OCommonAccessibleSelection::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
82  {
83  Reference< XAccessible > xRet;
84  Reference< XAccessibleContext > xParentContext( implGetAccessibleContext() );
85 
86  OSL_ENSURE( xParentContext.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" );
87 
88  if( xParentContext.is() )
89  {
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 );
93  }
94 
95  return xRet;
96  }
97 
98 
99  void OCommonAccessibleSelection::deselectAccessibleChild( sal_Int32 nSelectedChildIndex )
100  {
101  implSelect( nSelectedChildIndex, false );
102  }
103 
104  OAccessibleSelectionHelper::OAccessibleSelectionHelper()
105  {
106  }
107 
108 
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)
112 
113 
114  Reference< XAccessibleContext > OAccessibleSelectionHelper::implGetAccessibleContext()
115  {
116  return this;
117  }
118 
119 
120  void SAL_CALL OAccessibleSelectionHelper::selectAccessibleChild( sal_Int32 nChildIndex )
121  {
122  OExternalLockGuard aGuard( this );
124  }
125 
126 
127  sal_Bool SAL_CALL OAccessibleSelectionHelper::isAccessibleChildSelected( sal_Int32 nChildIndex )
128  {
129  OExternalLockGuard aGuard( this );
131  }
132 
133 
134  void SAL_CALL OAccessibleSelectionHelper::clearAccessibleSelection( )
135  {
136  OExternalLockGuard aGuard( this );
138  }
139 
140 
141  void SAL_CALL OAccessibleSelectionHelper::selectAllAccessibleChildren( )
142  {
143  OExternalLockGuard aGuard( this );
145  }
146 
147 
148  sal_Int32 SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChildCount( )
149  {
150  OExternalLockGuard aGuard( this );
152  }
153 
154 
155  Reference< XAccessible > SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
156  {
157  OExternalLockGuard aGuard( this );
158  return OCommonAccessibleSelection::getSelectedAccessibleChild( nSelectedChildIndex );
159  }
160 
161 
162  void SAL_CALL OAccessibleSelectionHelper::deselectAccessibleChild( sal_Int32 nSelectedChildIndex )
163  {
164  OExternalLockGuard aGuard( this );
166  }
167 
168 
169 } // namespace comphelper
170 
171 
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::cppu::ImplHelper1< css::accessibility::XAccessibleSelection > OAccessibleSelectionHelper_Base
#define IMPLEMENT_FORWARD_XTYPEPROVIDER2(classname, baseclass1, baseclass2)
Definition: uno3.hxx:136
virtual css::uno::Reference< css::accessibility::XAccessibleContext > implGetAccessibleContext()=0
void selectAccessibleChild(sal_Int32 nChildIndex)
non-virtual versions of the methods which can be implemented using implIsSelected an...
virtual void implSelect(sal_Int32 nAccessibleChildIndex, bool bSelect)=0
virtual bool implIsSelected(sal_Int32 nAccessibleChildIndex)=0
css::uno::Reference< css::accessibility::XAccessible > getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex)
int i
unsigned char sal_Bool
void deselectAccessibleChild(sal_Int32 nSelectedChildIndex)
#define ACCESSIBLE_SELECTION_CHILD_ALL
#define IMPLEMENT_FORWARD_XINTERFACE2(classname, refcountbase, baseclass2)
Definition: uno3.hxx:99
bool isAccessibleChildSelected(sal_Int32 nChildIndex)
sal_uInt16 nPos