LibreOffice Module winaccessibility (master) 1
AccWindowEventListener.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
35AccWindowEventListener::AccWindowEventListener(css::accessibility::XAccessible* pAcc, AccObjectManagerAgent* Agent)
36 :AccEventListener(pAcc, Agent)
37{}
39{
40}
41
46void AccWindowEventListener::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();
96 //delete this child
97 pAgent->DeleteAccObj( pAcc );
98 }
99 }
100}
101
107void AccWindowEventListener::SetComponentState(sal_Int64 state, bool enable )
108{
109 // only the following state can be fired state event.
110 switch (state)
111 {
112 case AccessibleStateType::ICONIFIED:
113 // no msaa state
114 break;
115 case AccessibleStateType::VISIBLE:
116 // UNO !VISIBLE == MSAA INVISIBLE
117 if( enable )
118 pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
119 else
120 pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
121 break;
122 case AccessibleStateType::SHOWING:
123 // UNO !SHOWING == MSAA OFFSCREEN
124 if( enable )
125 {
126 pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::SHOWING);
127 }
128 else
129 pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::SHOWING);
130 break;
131 default:
132 break;
133 }
134}
135
136/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
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...
virtual void SAL_CALL notifyEvent(const css::accessibility::AccessibleEventObject &aEvent) override
Uno's event notifier when event is captured.
virtual ~AccWindowEventListener() override
AccWindowEventListener(css::accessibility::XAccessible *pAcc, AccObjectManagerAgent *Agent)
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