LibreOffice Module winaccessibility (master) 1
AccDialogEventListener.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
35AccDialogEventListener::AccDialogEventListener(css::accessibility::XAccessible* pAcc, AccObjectManagerAgent* Agent)
36 :AccEventListener(pAcc, Agent)
37{}
39{
40}
41
46void AccDialogEventListener::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::VISIBLE_DATA_CHANGED:
57 break;
58 case AccessibleEventId::BOUNDRECT_CHANGED:
60 break;
61 default:
63 break;
64 }
65}
66
73{
75 if( newValue >>= xChild)
76 {
77 //create a new child
78 if(xChild.is())
79 {
80 XAccessible* pAcc = xChild.get();
81 //add this child
82 pAgent->InsertAccObj(pAcc, m_xAccessible.get());
83 //add all oldValue's existing children
86 }
87 }
88 else if (oldValue >>= xChild)
89 {
90 //delete an existing child
91 if(xChild.is())
92 {
93 XAccessible* pAcc = xChild.get();
95 //delete all oldValue's existing children
97 //delete this child
98 pAgent->DeleteAccObj( pAcc );
99 }
100 }
101
102}
103
109void AccDialogEventListener::SetComponentState(sal_Int64 state, bool enable)
110{
111 // only the following state can be fired state event.
112 switch (state)
113 {
114 case AccessibleStateType::ICONIFIED:
115 // no msaa state mapping
116 break;
117 case AccessibleStateType::VISIBLE:
118 // UNO !VISIBLE == MSAA INVISIBLE
119 if( enable )
120 pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
121 else
122 pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
123 break;
124 case AccessibleStateType::ACTIVE:
125 // Only frames should be active
126 // no msaa state mapping
127 break;
128 default:
129 break;
130 }
131}
132
133/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
virtual void SAL_CALL notifyEvent(const css::accessibility::AccessibleEventObject &aEvent) override
Uno's event notifier when event is captured.
AccDialogEventListener(css::accessibility::XAccessible *pAcc, AccObjectManagerAgent *Agent)
virtual ~AccDialogEventListener() override
virtual void HandleChildChangedEvent(css::uno::Any oldValue, css::uno::Any newValue)
handle the CHILD event
virtual void SetComponentState(sal_Int64 state, bool enable) override
set the new state and fire the MSAA event
AccEventListener is the general event listener for all controls.
virtual void HandleVisibleDataChangedEvent()
handle the VISIBLE_DATA_CHANGED event
AccObjectManagerAgent * pAgent
virtual void HandleBoundrectChangedEvent()
handle the BOUNDRECT_CHANGED event
virtual void SAL_CALL notifyEvent(const css::accessibility::AccessibleEventObject &aEvent) override
Uno's event notifier when event is captured.
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.
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.
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...