LibreOffice Module winaccessibility (master) 1
AccMenuEventListener.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
35AccMenuEventListener::AccMenuEventListener(css::accessibility::XAccessible* pAcc, AccObjectManagerAgent* Agent)
36 :AccComponentEventListener(pAcc, Agent)
37{}
39{
40}
41
46void AccMenuEventListener::notifyEvent( const css::accessibility::AccessibleEventObject& aEvent )
47{
49
50 switch (aEvent.EventId)
51 {
52 case AccessibleEventId::CHILD:
53 HandleChildChangedEvent(aEvent.OldValue, aEvent.NewValue);
54 break;
55 case AccessibleEventId::SELECTION_CHANGED:
56 //don't need to process anything,just same as word behavior
57 //handleSelectionChangedEvent();
58 break;
59 default:
61 break;
62 }
63}
64
70void AccMenuEventListener::HandleChildChangedEvent(Any oldValue, Any newValue)
71{
72
74 if( newValue >>= xChild)
75 {
76 //create a new child
77 if(xChild.is())
78 {
79 XAccessible* pAcc = xChild.get();
80 //add this child
81 pAgent->InsertAccObj(pAcc, m_xAccessible.get());
82 //add all oldValue's existing children
85 }
86 }
87 else if (oldValue >>= xChild)
88 {
89 //delete an existing child
90 if(xChild.is())
91 {
92 XAccessible* pAcc = xChild.get();
94 //delete all oldValue's existing children
96 //delete this child
97 pAgent->DeleteAccObj( pAcc );
98 }
99 }
100
101}
102
107{
109}
110
115{
116 if( set )
117 {
118 // new value
119 switch(state)
120 {
121 //for sub menu is popup, there is a menu selected event.
122 case AccessibleStateType::SELECTED:
123 pAgent->IncreaseState(m_xAccessible.get(), state);
125 break;
126 default:
128 break;
129 }
130 }
131 else
132 {
133 switch(state)
134 {
135 //for sub menu is popup, there is a menu selected event.
136 case AccessibleStateType::SELECTED:
137 pAgent->DecreaseState(m_xAccessible.get(), state);
138
139 break;
140 default:
142 break;
143 }
144 }
145}
146
147/* 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 FireStatePropertyChange(sal_Int64 state, bool set) override
fire the MSAA state changed event
AccObjectManagerAgent * pAgent
css::uno::Reference< css::accessibility::XAccessible > m_xAccessible
AccMenuEventListener(css::accessibility::XAccessible *pAcc, AccObjectManagerAgent *Agent)
virtual ~AccMenuEventListener() override
virtual void HandleSelectionChangedEventNoArgs()
handle the SELECTION_CHANGED event
virtual void SAL_CALL notifyEvent(const css::accessibility::AccessibleEventObject &aEvent) override
Uno's event notifier when event is captured.
virtual void HandleChildChangedEvent(css::uno::Any oldValue, css::uno::Any newValue)
handle the CHILD event
virtual void FireStatePropertyChange(sal_Int64 state, bool set) override
handle the Menu_popup event
void DecreaseState(css::accessibility::XAccessible *pXAcc, sal_Int64 pState)
Interface of decreasing MSAA state when some UNO state is decreased.
virtual void DeleteAccObj(css::accessibility::XAccessible *pXAcc)
When a new UNO XAccessible object is destroyed, we delete its corresponding com object and remove it ...
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.
void UpdateChildState(css::accessibility::XAccessible *pXAcc)
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...
void set(css::uno::UnoInterfaceReference const &value)