fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / winaccessibility / source / service / AccDescendantManagerEventListener.cxx
blobe292911b909373518efdbd667fd0fa30c4e267a8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <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>
26 #include <vcl/svapp.hxx>
28 #include "AccDescendantManagerEventListener.hxx"
29 #include "AccObjectManagerAgent.hxx"
30 #include "unomsaaevent.hxx"
32 using namespace com::sun::star::uno;
33 using namespace com::sun::star::accessibility;
35 AccDescendantManagerEventListener::AccDescendantManagerEventListener(com::sun::star::accessibility::XAccessible* pAcc, AccObjectManagerAgent* Agent)
36 : AccComponentEventListener(pAcc, Agent)
40 AccDescendantManagerEventListener::~AccDescendantManagerEventListener()
44 /**
45 * Uno's event notifier when event is captured
46 * @param AccessibleEventObject the event object which contains information about event
48 void AccDescendantManagerEventListener::notifyEvent( const ::com::sun::star::accessibility::AccessibleEventObject& aEvent )
49 throw (::com::sun::star::uno::RuntimeException)
51 SolarMutexGuard g;
53 switch (aEvent.EventId)
55 case AccessibleEventId::SELECTION_CHANGED:
56 HandleSelectionChangedEvent(aEvent.OldValue, aEvent.NewValue);
57 break;
58 case AccessibleEventId::CHILD:
59 HandleChildChangedEvent(aEvent.OldValue, aEvent.NewValue);
60 break;
61 case AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS:
62 HandleChildChangedNoFocusEvent(aEvent.OldValue, aEvent.NewValue);
63 break;
64 case AccessibleEventId::SELECTION_CHANGED_ADD:
65 HandleSelectionChangedAddEvent(aEvent.OldValue, aEvent.NewValue);
66 break;
67 case AccessibleEventId::SELECTION_CHANGED_REMOVE:
68 HandleSelectionChangedRemoveEvent(aEvent.OldValue, aEvent.NewValue);
69 break;
70 case AccessibleEventId::SELECTION_CHANGED_WITHIN:
71 HandleSelectionChangedWithinEvent(aEvent.OldValue, aEvent.NewValue);
72 break;
73 default:
74 AccComponentEventListener::notifyEvent(aEvent);
75 break;
79 /**
80 * handle the CHILD event
81 * @param oldValue the child to be deleted
82 * @param newValue the child to be added
84 void AccDescendantManagerEventListener::HandleChildChangedEvent(Any oldValue, Any newValue)
87 Reference< XAccessible > xChild;
88 if( newValue >>= xChild)
90 //create a new child
91 if(xChild.is())
93 XAccessible* pAcc = xChild.get();
94 pAgent->InsertAccObj(pAcc, m_xAccessible.get());
95 pAgent->InsertChildrenAccObj(pAcc);
97 pAgent->NotifyAccEvent(UM_EVENT_CHILD_ADDED, pAcc);
100 else
104 if (oldValue >>= xChild)
106 if(xChild.is())
108 XAccessible* pAcc = xChild.get();
110 pAgent->NotifyAccEvent(UM_EVENT_CHILD_REMOVED, pAcc);
111 pAgent->DeleteChildrenAccObj( pAcc );
112 pAgent->DeleteAccObj( pAcc );
114 else
121 * handle the SELECTION_CHANGED event
123 void AccDescendantManagerEventListener::HandleSelectionChangedEvent(Any oldValue, Any newValue)
125 bool bSend =false;
126 Reference< XAccessible > xChild;
127 if(newValue >>= xChild )
129 if(xChild.is())
131 XAccessible* pAcc = xChild.get();
132 //if the Role is the SC cell ,don't add the selected state.
133 if (pAgent->GetRole(pAcc) != AccessibleRole::TABLE_CELL)
135 pAgent->IncreaseState( pAcc, AccessibleStateType::SELECTED);
138 pAgent->NotifyAccEvent(UM_EVENT_SELECTION_CHANGED, pAcc);
139 bSend=true;
142 if(oldValue >>= xChild )
144 if(xChild.is())
146 XAccessible* pAcc = xChild.get();
147 pAgent->DecreaseState( pAcc, AccessibleStateType::SELECTED);
150 if (!bSend)
152 pAgent->NotifyAccEvent(UM_EVENT_SELECTION_CHANGED, m_xAccessible.get());
157 void AccDescendantManagerEventListener::HandleChildChangedNoFocusEvent(Any oldValue, Any newValue)
159 Reference< XAccessible > xChild;
160 if(newValue >>= xChild )
162 if(xChild.is())
164 XAccessible* pAcc = xChild.get();
166 pAgent->InsertAccObj(pAcc, m_xAccessible.get());
167 pAgent->InsertChildrenAccObj(pAcc);
170 if (oldValue >>= xChild)
172 if(xChild.is())
174 XAccessible* pAcc = xChild.get();
175 pAgent->DeleteChildrenAccObj( pAcc );
176 pAgent->DeleteAccObj( pAcc );
181 bool AccDescendantManagerEventListener::NotifyChildEvent(short nWinEvent,const Any &Value)
183 Reference< XAccessible > xChild;
184 if(Value >>= xChild )
186 if(xChild.is())
188 XAccessible* pAcc = xChild.get();
189 pAgent->NotifyAccEvent(nWinEvent, pAcc);
191 if (pAgent && pAgent->IsStateManageDescendant(m_xAccessible.get())
192 && (nWinEvent == UM_EVENT_SELECTION_CHANGED_REMOVE))
194 pAgent->DeleteAccObj( pAcc );
196 return true;
199 return false;
201 void AccDescendantManagerEventListener::HandleSelectionChangedAddEvent(const Any& /*oldValue*/, const Any &newValue)
203 if(NotifyChildEvent(UM_EVENT_SELECTION_CHANGED_ADD,newValue))
205 return ;
207 pAgent->NotifyAccEvent(UM_EVENT_SELECTION_CHANGED_ADD, m_xAccessible.get());
210 void AccDescendantManagerEventListener::HandleSelectionChangedRemoveEvent(const Any& /*oldValue*/, const Any &newValue)
212 if(NotifyChildEvent(UM_EVENT_SELECTION_CHANGED_REMOVE,newValue))
214 return ;
216 pAgent->NotifyAccEvent(UM_EVENT_SELECTION_CHANGED_REMOVE, m_xAccessible.get());
219 void AccDescendantManagerEventListener::HandleSelectionChangedWithinEvent(const Any& /*oldValue*/, const Any &newValue)
221 if(NotifyChildEvent(UM_EVENT_SELECTION_CHANGED_WITHIN,newValue))
223 return ;
225 pAgent->NotifyAccEvent(UM_EVENT_SELECTION_CHANGED_WITHIN, m_xAccessible.get());
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */