LibreOffice Module accessibility (master) 1
vclxaccessiblemenu.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#include <com/sun/star/accessibility/AccessibleRole.hpp>
23#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
25#include <vcl/menu.hxx>
26
27
28using namespace ::com::sun::star;
29using namespace ::com::sun::star::lang;
30using namespace ::com::sun::star::uno;
31using namespace ::com::sun::star::accessibility;
32using namespace ::comphelper;
33
34
35// VCLXAccessibleMenu
36
37
39{
40 bool bFocused = false;
41
42 if ( IsHighlighted() && !IsChildHighlighted() )
43 bFocused = true;
44
45 return bFocused;
46}
47
48
50{
51 bool bPopupMenuOpen = false;
52
53 if ( m_pParent )
54 {
55 PopupMenu* pPopupMenu = m_pParent->GetPopupMenu( m_pParent->GetItemId( m_nItemPos ) );
56 if ( pPopupMenu && pPopupMenu->IsMenuVisible() )
57 bPopupMenuOpen = true;
58 }
59
60 return bPopupMenuOpen;
61}
62
63
64// XServiceInfo
65
66
68{
69 return "com.sun.star.comp.toolkit.AccessibleMenu";
70}
71
72
74{
75 return { "com.sun.star.awt.AccessibleMenu" };
76}
77
78
79// XAccessibleContext
80
81
83{
84 OExternalLockGuard aGuard( this );
85
86 return GetChildCount();
87}
88
89
91{
92 OExternalLockGuard aGuard( this );
93
94 if ( i < 0 || i >= GetChildCount() )
95 throw IndexOutOfBoundsException();
96
97 return GetChild( i );
98}
99
100
102{
103 OExternalLockGuard aGuard( this );
104
105 return AccessibleRole::MENU;
106}
107
108
109// XAccessibleComponent
110
111
113{
114 OExternalLockGuard aGuard( this );
115
116 return GetChildAt( rPoint );
117}
118
119
120// XAccessibleSelection
121
122
123void VCLXAccessibleMenu::selectAccessibleChild( sal_Int64 nChildIndex )
124{
125 OExternalLockGuard aGuard( this );
126
127 if ( nChildIndex < 0 || nChildIndex >= GetChildCount() )
128 throw IndexOutOfBoundsException();
129
130 SelectChild( nChildIndex );
131}
132
133
135{
136 OExternalLockGuard aGuard( this );
137
138 if ( nChildIndex < 0 || nChildIndex >= GetChildCount() )
139 throw IndexOutOfBoundsException();
140
141 return IsChildSelected( nChildIndex );
142}
143
144
146{
147 OExternalLockGuard aGuard( this );
148
149 DeSelectAll();
150}
151
152
154{
155 // This method makes no sense in a menu, and so does nothing.
156}
157
158
160{
161 OExternalLockGuard aGuard( this );
162
164}
165
167{
168 sal_Int64 nRet = 0;
169
170 for ( sal_Int64 i = 0, nCount = GetChildCount(); i < nCount; i++ )
171 {
172 if ( IsChildSelected( i ) )
173 ++nRet;
174 }
175
176 return nRet;
177}
178
180{
181 OExternalLockGuard aGuard( this );
182
183 if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
184 throw IndexOutOfBoundsException();
185
187
188 for ( sal_Int64 i = 0, j = 0, nCount = GetChildCount(); i < nCount; i++ )
189 {
190 if ( IsChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
191 {
192 xChild = GetChild( i );
193 break;
194 }
195 }
196
197 return xChild;
198}
199
200
202{
203 OExternalLockGuard aGuard( this );
204
205 if ( nChildIndex < 0 || nChildIndex >= GetChildCount() )
206 throw IndexOutOfBoundsException();
207
208 DeSelectAll();
209}
210
211
213{
214 OExternalLockGuard aGuard( this );
215
216 if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
217 throw IndexOutOfBoundsException();
218
219 return OUString( );
220}
221
222/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsMenuVisible() const
PopupMenu * GetPopupMenu(sal_uInt16 nItemId) const
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount() override
virtual sal_Int16 SAL_CALL getAccessibleRole() override
sal_Int64 implGetSelectedAccessibleChildCount()
virtual void SAL_CALL selectAllAccessibleChildren() override
virtual void SAL_CALL selectAccessibleChild(sal_Int64 nChildIndex) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 i) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(sal_Int64 nSelectedChildIndex) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
virtual void SAL_CALL deselectAccessibleChild(sal_Int64 nChildIndex) override
virtual sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int64 nChildIndex) override
virtual bool IsPopupMenuOpen() override
virtual OUString SAL_CALL getAccessibleActionDescription(sal_Int32 nIndex) override
virtual void SAL_CALL clearAccessibleSelection() override
virtual bool IsFocused() override
virtual OUString SAL_CALL getImplementationName() override
int nCount
int i
unsigned char sal_Bool