LibreOffice Module winaccessibility (master) 1
AccComponentEventListener.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
20#include <com/sun/star/accessibility/XAccessible.hpp>
21#include <com/sun/star/accessibility/AccessibleStateType.hpp>
22#include <com/sun/star/accessibility/AccessibleEventId.hpp>
23#include <com/sun/star/accessibility/AccessibleRole.hpp>
24#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
25
26#include <vcl/svapp.hxx>
27
30#include <unomsaaevent.hxx>
31
32using namespace com::sun::star::uno;
33using namespace com::sun::star::accessibility;
34
36 :AccEventListener(pAcc, Agent)
37{
38}
39
41{
42}
43
49void AccComponentEventListener::notifyEvent( const css::accessibility::AccessibleEventObject& aEvent )
50{
52
53 switch (aEvent.EventId)
54 {
55 case AccessibleEventId::VALUE_CHANGED:
56 HandleValueChangedEvent(aEvent.OldValue, aEvent.NewValue);
57 break;
58 case AccessibleEventId::ACTION_CHANGED:
60 break;
61 case AccessibleEventId::TEXT_CHANGED:
62 HandleTextChangedEvent(aEvent.OldValue, aEvent.NewValue);
63 break;
64 case AccessibleEventId::CARET_CHANGED:
65 HandleCaretChangedEvent(aEvent.OldValue, aEvent.NewValue);
66 break;
67 case AccessibleEventId::VISIBLE_DATA_CHANGED:
69 break;
70 case AccessibleEventId::BOUNDRECT_CHANGED:
72 break;
73 case AccessibleEventId::SELECTION_CHANGED:
75 break;
76 //to add TEXT_SELECTION_CHANGED event
77 case AccessibleEventId::TEXT_SELECTION_CHANGED:
79 break;
80 //End
81 default:
83 break;
84 }
85}
86
94{
97}
98
103{
106}
107
115{
116 pAgent->UpdateValue(m_xAccessible.get(), newValue);
118}
119
127{
129}
130
137void AccComponentEventListener::SetComponentState(sal_Int64 state, bool enable)
138{
139 // only the following state can be fired state event.
140 switch (state)
141 {
142 case AccessibleStateType::CHECKED:
143 case AccessibleStateType::PRESSED:
144 case AccessibleStateType::SELECTED:
145 case AccessibleStateType::ARMED:
146 case AccessibleStateType::INDETERMINATE:
147 case AccessibleStateType::SHOWING:
148 FireStatePropertyChange(state, enable);
149 break;
150 case AccessibleStateType::VISIBLE:
151 if (GetRole() == AccessibleRole::MENU_ITEM)
152 {
153 if(enable)
154 {
155 pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
156 pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::FOCUSABLE);
157 }
158 else
159 {
160 pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
161 pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::FOCUSABLE);
162 }
163 }
164 else
165 {
166 FireStatePropertyChange(state, enable);
167 }
168 break;
169 case AccessibleStateType::FOCUSED:
171 break;
172 case AccessibleStateType::ENABLED:
173 if(enable)
174 {
176 pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::DEFUNC);
177 // 8. label should have no FOCUSABLE state, Firefox has READONLY state, we can also have.
178 if ( GetRole() != AccessibleRole::LABEL
179 && GetRole() != AccessibleRole::STATIC
180 && GetRole() != AccessibleRole::NOTIFICATION
181 && GetRole() != AccessibleRole::SCROLL_BAR)
182 {
183 pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::FOCUSABLE);
184 }
185 }
186 else
187 {
189 pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::DEFUNC);
190 pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::FOCUSABLE);
191 }
192 break;
193 case AccessibleStateType::ACTIVE:
194 // Only frames should be active
195 // no msaa state mapping
196 break;
197 default:
198 break;
199 }
200}
201
209{
210 if( set)
211 {
212 // new value
213 switch(state)
214 {
215 case AccessibleStateType::CHECKED:
216 case AccessibleStateType::INDETERMINATE:
217 pAgent->IncreaseState(m_xAccessible.get(), state);
219
221 {
223 }
224 break;
225 case AccessibleStateType::PRESSED:
226 pAgent->IncreaseState(m_xAccessible.get(), state);
228 break;
229 case AccessibleStateType::SELECTED:
230 pAgent->IncreaseState(m_xAccessible.get(), state);
231 break;
232 case AccessibleStateType::ARMED:
233 pAgent->IncreaseState(m_xAccessible.get(), state);
235 break;
236 case AccessibleStateType::SHOWING:
237 pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::DEFUNC);
238 // UNO !SHOWING == MSAA OFFSCREEN
239 pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::SHOWING );
241 break;
242 case AccessibleStateType::VISIBLE:
243 // UNO !VISIBLE == MSAA INVISIBLE
244 pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE );
245 break;
246 default:
247 break;
248 }
249 }
250 else
251 {
252 // old value
253 switch(state)
254 {
255 case AccessibleStateType::CHECKED:
256 case AccessibleStateType::INDETERMINATE:
257 pAgent->DecreaseState(m_xAccessible.get(), state);
259
261 {
263 }
264 break;
265 case AccessibleStateType::PRESSED:
266 pAgent->DecreaseState(m_xAccessible.get(), state);
268 break;
269 case AccessibleStateType::SELECTED:
270 pAgent->DecreaseState(m_xAccessible.get(), state);
271 //if the state is unset, no need to send MSAA SELECTION event
272 //pAgent->NotifyAccEvent(UnoMSAAEvent::STATE_SELECTED, m_xAccessible.get());
273 break;
274 case AccessibleStateType::ARMED:
275 {
276 pAgent->DecreaseState(m_xAccessible.get(), state);
277 //if the state is unset, no need to send MSAA MENU event
278 //pAgent->NotifyAccEvent(UnoMSAAEvent::STATE_ARMED, m_xAccessible.get());
279 }
280 break;
281 case AccessibleStateType::SHOWING:
282 pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::DEFUNC);
283 // UNO !SHOWING == MSAA OFFSCREEN
284 pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::SHOWING);
285 break;
286 case AccessibleStateType::VISIBLE:
287 // UNO !VISIBLE == MSAA INVISIBLE
288 pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
289 break;
290
291 default:
292 break;
293 }
294 }
295}
296
303{
304 if(enable)
305 {
306 if (GetParentRole() != AccessibleRole::COMBO_BOX)
308 }
309 else
310 {
311 //if lose focus, no need to send MSAA FOCUS event
312 pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::FOCUSED);
313 }
314}
315
317{
319}
320
321//add TEXT_SELECTION_CHANGED event
323{
325}
326
327/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
virtual void HandleCaretChangedEvent(css::uno::Any oldValue, css::uno::Any newValue)
handle the CARET_CHANGED event
virtual ~AccComponentEventListener() override
virtual void HandleActionChangedEvent()
handle the NAME_CHANGED event
virtual void FireStateFocusedChange(bool enable) override
handle the focused event
virtual void HandleTextChangedEvent(css::uno::Any oldValue, css::uno::Any newValue)
handle the TEXT_CHANGED event
virtual void SetComponentState(sal_Int64 state, bool enable) override
set the new state and fire the MSAA event
AccComponentEventListener(css::accessibility::XAccessible *pAcc, AccObjectManagerAgent *Agent)
virtual void HandleValueChangedEvent(css::uno::Any oldValue, css::uno::Any newValue)
handle the VALUE_CHANGED event
virtual void SAL_CALL notifyEvent(const css::accessibility::AccessibleEventObject &aEvent) override
Uno's event notifier when event is captured.
virtual void FireStatePropertyChange(sal_Int64 state, bool set) override
fire the MSAA state changed event
AccEventListener is the general event listener for all controls.
virtual short GetRole()
get the role of accessible object which is observed
virtual void HandleVisibleDataChangedEvent()
handle the VISIBLE_DATA_CHANGED event
virtual short GetParentRole()
get the role of accessible parent object which is observed
AccObjectManagerAgent * pAgent
virtual void HandleBoundrectChangedEvent()
handle the BOUNDRECT_CHANGED event
virtual void SAL_CALL notifyEvent(const css::accessibility::AccessibleEventObject &aEvent) override
Uno's event notifier when event is captured.
css::uno::Reference< css::accessibility::XAccessible > m_xAccessible
bool IsSpecialToolbarItem(css::accessibility::XAccessible *pXAcc)
void DecreaseState(css::accessibility::XAccessible *pXAcc, sal_Int64 pState)
Interface of decreasing MSAA state when some UNO state is decreased.
void UpdateValue(css::accessibility::XAccessible *pXAcc)
void UpdateAction(css::accessibility::XAccessible *pXAcc)
Interface of updating MSAA name when UNO action changed event occurs.
void IncreaseState(css::accessibility::XAccessible *pXAcc, sal_Int64 pState)
Interface of increasing MSAA name when some UNO state is increased.
bool NotifyAccEvent(UnoMSAAEvent eEvent, css::accessibility::XAccessible *pXAcc=nullptr)
Interface of notify MSAA event when some UNO event occurred.
void UpdateState(css::accessibility::XAccessible *pXAcc)
void set(css::uno::UnoInterfaceReference const &value)
@ TEXT_SELECTION_CHANGED
@ OBJECT_DEFACTIONCHANGE