LibreOffice Module winaccessibility (master) 1
AccDescendantManagerEventListener.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 : AccComponentEventListener(pAcc, Agent)
37{
38}
39
41{
42}
43
48void AccDescendantManagerEventListener::notifyEvent( const css::accessibility::AccessibleEventObject& aEvent )
49{
51
52 switch (aEvent.EventId)
53 {
54 case AccessibleEventId::SELECTION_CHANGED:
55 HandleSelectionChangedEvent(aEvent.OldValue, aEvent.NewValue);
56 break;
57 case AccessibleEventId::CHILD:
58 HandleChildChangedEvent(aEvent.OldValue, aEvent.NewValue);
59 break;
60 case AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS:
62 break;
63 case AccessibleEventId::SELECTION_CHANGED_ADD:
65 break;
66 case AccessibleEventId::SELECTION_CHANGED_REMOVE:
68 break;
69 case AccessibleEventId::SELECTION_CHANGED_WITHIN:
71 break;
72 default:
74 break;
75 }
76}
77
84{
85
87 if( newValue >>= xChild)
88 {
89 //create a new child
90 if(xChild.is())
91 {
92 XAccessible* pAcc = xChild.get();
93 pAgent->InsertAccObj(pAcc, m_xAccessible.get());
95
97
98 }
99 }
100
101 if (oldValue >>= xChild)
102 {
103 if(xChild.is())
104 {
105 XAccessible* pAcc = xChild.get();
106
109 pAgent->DeleteAccObj( pAcc );
110 }
111 }
112
113}
114
119{
120 bool bSend =false;
122 if(newValue >>= xChild )
123 {
124 if(xChild.is())
125 {
126 XAccessible* pAcc = xChild.get();
127 //if the Role is the SC cell ,don't add the selected state.
128 if (pAgent->GetRole(pAcc) != AccessibleRole::TABLE_CELL)
129 {
130 pAgent->IncreaseState( pAcc, AccessibleStateType::SELECTED);
131 }
132
134 bSend=true;
135 }
136 }
137 if(oldValue >>= xChild )
138 {
139 if(xChild.is())
140 {
141 XAccessible* pAcc = xChild.get();
142 pAgent->DecreaseState( pAcc, AccessibleStateType::SELECTED);
143 }
144 }
145 if (!bSend)
146 {
148 }
149}
150
151
153{
155 if(newValue >>= xChild )
156 {
157 if(xChild.is())
158 {
159 XAccessible* pAcc = xChild.get();
160
161 pAgent->InsertAccObj(pAcc, m_xAccessible.get());
163 }
164 }
165 if (oldValue >>= xChild)
166 {
167 if(xChild.is())
168 {
169 XAccessible* pAcc = xChild.get();
171 pAgent->DeleteAccObj( pAcc );
172 }
173 }
174}
175
177{
179 if(Value >>= xChild )
180 {
181 if(xChild.is())
182 {
183 XAccessible* pAcc = xChild.get();
184 pAgent->NotifyAccEvent(eWinEvent, pAcc);
185
187 {
189 {
190 // The object has just been sent in a SELECTION_CHANGED_REMOVE event
191 // and accessibility tools may query for the object and call methods on
192 // it as a response to this.
193 // Therefore, don't delete the object yet, but remember it for deletion
194 // once the next event of a different type occurs.
195 m_aUnselectedChildrenForDeletion.push_back(pAcc);
196 }
197 else
198 {
199 // handle any pending deletions for objects previously removed from selection
200 for (XAccessible* pAcc2 : m_aUnselectedChildrenForDeletion)
201 pAgent->DeleteAccObj(pAcc2);
203 }
204 }
205 return true;
206 }
207 }
208 return false;
209}
210void AccDescendantManagerEventListener::HandleSelectionChangedAddEvent(const Any& /*oldValue*/, const Any &newValue)
211{
213 {
214 return ;
215 }
217}
218
219void AccDescendantManagerEventListener::HandleSelectionChangedRemoveEvent(const Any& /*oldValue*/, const Any &newValue)
220{
222 {
223 return ;
224 }
226}
227
228void AccDescendantManagerEventListener::HandleSelectionChangedWithinEvent(const Any& /*oldValue*/, const Any &newValue)
229{
231 {
232 return ;
233 }
235}
236
237/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
AccComponentEventListener is inherited from AccEventListener.
virtual void SAL_CALL notifyEvent(const css::accessibility::AccessibleEventObject &aEvent) override
Uno's event notifier when event is captured.
virtual void HandleSelectionChangedWithinEvent(const css::uno::Any &oldValue, const css::uno::Any &newValue)
AccDescendantManagerEventListener(css::accessibility::XAccessible *pAcc, AccObjectManagerAgent *Agent)
virtual void HandleSelectionChangedRemoveEvent(const css::uno::Any &oldValue, const css::uno::Any &newValue)
virtual void SAL_CALL notifyEvent(const css::accessibility::AccessibleEventObject &aEvent) override
Uno's event notifier when event is captured.
virtual void HandleChildChangedNoFocusEvent(css::uno::Any oldValue, css::uno::Any newValue)
std::vector< com::sun::star::accessibility::XAccessible * > m_aUnselectedChildrenForDeletion
bool NotifyChildEvent(UnoMSAAEvent eWinEvent, const css::uno::Any &Value)
virtual void HandleSelectionChangedAddEvent(const css::uno::Any &oldValue, const css::uno::Any &newValue)
virtual void HandleSelectionChangedEvent(css::uno::Any oldValue, css::uno::Any newValue)
handle the SELECTION_CHANGED event
virtual void HandleChildChangedEvent(css::uno::Any oldValue, css::uno::Any newValue)
handle the CHILD event
AccObjectManagerAgent * pAgent
css::uno::Reference< css::accessibility::XAccessible > m_xAccessible
void DecreaseState(css::accessibility::XAccessible *pXAcc, sal_Int64 pState)
Interface of decreasing MSAA state when some UNO state is decreased.
short GetRole(css::accessibility::XAccessible *pXAcc)
virtual void DeleteAccObj(css::accessibility::XAccessible *pXAcc)
When a new UNO XAccessible object is destroyed, we delete its corresponding com object and remove it ...
bool IsStateManageDescendant(css::accessibility::XAccessible *pXAcc)
void IncreaseState(css::accessibility::XAccessible *pXAcc, sal_Int64 pState)
Interface of increasing MSAA name when some UNO state is increased.
void DeleteChildrenAccObj(css::accessibility::XAccessible *pXAcc)
When new UNO children XAccessible objects are destroyed, we delete their corresponding com objects an...
virtual bool InsertAccObj(css::accessibility::XAccessible *pXAcc, css::accessibility::XAccessible *pParentXAcc, HWND hWnd=nullptr)
When a new UNO XAccessible object is found by listener, we create a corresponding com object and inse...
bool NotifyAccEvent(UnoMSAAEvent eEvent, css::accessibility::XAccessible *pXAcc=nullptr)
Interface of notify MSAA event when some UNO event occurred.
bool InsertChildrenAccObj(css::accessibility::XAccessible *pXAcc, HWND hWnd=nullptr)
When a UNO XAccessible object's new children are found by listener, we create corresponding com objec...
Value
UnoMSAAEvent
@ SELECTION_CHANGED_REMOVE
@ SELECTION_CHANGED_WITHIN