Fix GNU C++ version check
[LibreOffice.git] / winaccessibility / source / service / AccListEventListener.cxx
blobf2a76c26d8e01f27cbbff62f5c1e8ae65823b483
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 <AccObjectWinManager.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, AccObjectWinManager& rManager)
36 :AccDescendantManagerEventListener(pAcc, rManager)
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 = m_rObjManager.InsertAccObj(pAcc, m_xAccessible.get());
88 if (!bHasCache)
90 m_rObjManager.UpdateState(pAcc);
93 m_rObjManager.IncreaseState( pAcc, AccessibleStateType::FOCUSED);
95 m_rObjManager.NotifyAccEvent(pAcc, UnoMSAAEvent::ACTIVE_DESCENDANT_CHANGED);
98 if (oldValue >>= xChild)
100 if(xChild.is())
102 XAccessible* pAcc = xChild.get();
103 m_rObjManager.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 = m_rObjManager.GetParentXAccessible(m_xAccessible.get());
120 m_rObjManager.UpdateValue(pParentAcc);
121 m_rObjManager.NotifyAccEvent(pParentAcc, UnoMSAAEvent::OBJECT_VALUECHANGE);
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */