LibreOffice Module winaccessibility (master) 1
AccFrameEventListener.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
35#include <vcl/window.hxx>
37#include <vcl/sysdata.hxx>
38
39AccFrameEventListener::AccFrameEventListener(css::accessibility::XAccessible* pAcc, AccObjectManagerAgent* Agent)
40 :AccEventListener(pAcc, Agent)
41{
42}
43
45{
46}
47
52void AccFrameEventListener::notifyEvent( const css::accessibility::AccessibleEventObject& aEvent )
53{
55
56 switch (aEvent.EventId)
57 {
58 case AccessibleEventId::CHILD:
59 HandleChildChangedEvent(aEvent.OldValue, aEvent.NewValue);
60 break;
61 case AccessibleEventId::VISIBLE_DATA_CHANGED:
63 break;
64 case AccessibleEventId::BOUNDRECT_CHANGED:
66 break;
67 default:
69 break;
70 }
71}
72
78void AccFrameEventListener::HandleChildChangedEvent(Any oldValue, Any newValue)
79{
81 if( newValue >>= xChild)
82 {
83 //create a new child
84 if(xChild.is())
85 {
86 XAccessible* pAcc = xChild.get();
87
88 VCLXWindow* pvclwindow = dynamic_cast<VCLXWindow*>(m_xAccessible.get());
89 assert(pvclwindow);
90 const SystemEnvData* systemdata
91 = pvclwindow->GetWindow()->GetSystemData();
92
93 //add this child
94 pAgent->InsertAccObj(pAcc, m_xAccessible.get(), systemdata->hWnd);
95 //add all oldValue's existing children
98 }
99 }
100 else if (oldValue >>= xChild)
101 {
102 //delete an existing child
103 if(xChild.is())
104 {
105 XAccessible* pAcc = xChild.get();
107 //delete all oldValue's existing children
109 //delete this child
110 pAgent->DeleteAccObj( pAcc );
111 }
112 }
113
114}
115
121void AccFrameEventListener::SetComponentState(sal_Int64 state, bool enable )
122{
123 // only the following state can be fired state event.
124 switch (state)
125 {
126 case AccessibleStateType::ICONIFIED:
127 // no msaa state
128 break;
129 case AccessibleStateType::VISIBLE:
130 // UNO !VISIBLE == MSAA INVISIBLE
131 if( enable )
132 pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
133 else
134 pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
135 break;
136 case AccessibleStateType::ACTIVE:
137 // Only frames should be active
138 // no msaa state mapping
139 break;
140 default:
141 break;
142 }
143}
144
145/* 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
virtual void HandleChildChangedEvent(css::uno::Any oldValue, css::uno::Any newValue)
handle the CHILD event
AccFrameEventListener(css::accessibility::XAccessible *pAcc, AccObjectManagerAgent *Agent)
virtual void SAL_CALL notifyEvent(const css::accessibility::AccessibleEventObject &aEvent) override
Uno's event notifier when event is captured.
virtual ~AccFrameEventListener() override
virtual void SetComponentState(sal_Int64 state, bool enable) override
set the new state and fire the MSAA 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.
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...
vcl::Window * GetWindow() const
virtual const SystemEnvData * GetSystemData() const