Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / winaccessibility / source / service / AccListEventListener.cxx
blob9852fe8105385608c6d12a339d3aea60b991c64b
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 <AccListEventListener.hxx>
29 #include <AccObjectManagerAgent.hxx>
30 #include <unomsaaevent.hxx>
32 using namespace com::sun::star::uno;
33 using namespace com::sun::star::accessibility;
35 AccListEventListener::AccListEventListener(css::accessibility::XAccessible* pAcc, AccObjectManagerAgent* Agent)
36 :AccDescendantManagerEventListener(pAcc, Agent)
40 AccListEventListener::~AccListEventListener()
44 /**
45 * Uno's event notifier when event is captured
46 * @param AccessibleEventObject the event object which contains information about event
48 void AccListEventListener::notifyEvent( const css::accessibility::AccessibleEventObject& aEvent )
50 SolarMutexGuard g;
52 switch (aEvent.EventId)
54 case AccessibleEventId::ACTIVE_DESCENDANT_CHANGED:
55 HandleActiveDescendantChangedEvent(aEvent.OldValue, aEvent.NewValue);
56 break;
57 case AccessibleEventId::INVALIDATE_ALL_CHILDREN:
58 // Since List items a transient a child events are mostly used
59 // to attach/detach listeners, it is safe to ignore it here
60 //TODO: investigate again
61 break;
62 case AccessibleEventId::VALUE_CHANGED:
63 HandleValueChangedEvent(aEvent.OldValue, aEvent.NewValue);
64 break;
65 default:
66 AccDescendantManagerEventListener::notifyEvent(aEvent);
67 break;
71 /**
72 * handle the ACTIVE_DESCENDANT_CHANGED event
73 * @param oldValue the child to lose active
74 * @param newValue the child to get active
76 void AccListEventListener::HandleActiveDescendantChangedEvent(Any oldValue, Any newValue)
78 Reference< XAccessible > xChild;
80 if(newValue >>= xChild )
82 if(xChild.is())
84 XAccessible* pAcc = xChild.get();
86 // Valueset has cache the child item xacc,Update state if no insert obj
87 bool bHasCache = pAgent->InsertAccObj(pAcc, m_xAccessible.get());
88 if (!bHasCache)
90 pAgent->UpdateState(pAcc);
93 pAgent->IncreaseState( pAcc, AccessibleStateType::FOCUSED);
95 pAgent->NotifyAccEvent(UM_EVENT_ACTIVE_DESCENDANT_CHANGED, pAcc);
98 if (oldValue >>= xChild)
100 if(xChild.is())
102 XAccessible* pAcc = xChild.get();
103 pAgent->DeleteAccObj( pAcc );
109 * handle the VALUE_CHANGED event
111 * @param oldValue the old value of the source of event
112 * @param newValue the new value of the source of event
114 void AccListEventListener::HandleValueChangedEvent(Any, Any)
116 //to enable value changed event
117 if (GetParentRole() == AccessibleRole::COMBO_BOX)
119 XAccessible* pParentAcc =
120 pAgent->GetParentXAccessible(m_xAccessible.get());
121 pAgent->UpdateValue(pParentAcc);
122 pAgent->NotifyAccEvent(UM_EVENT_OBJECT_VALUECHANGE, pParentAcc);
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */