Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / winaccessibility / source / service / AccFrameEventListener.cxx
blob2d31bdffb5516a4b1af2263cee9657e602836e65
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 <AccFrameEventListener.hxx>
29 #include <AccObjectManagerAgent.hxx>
30 #include <unomsaaevent.hxx>
32 using namespace com::sun::star::uno;
33 using namespace com::sun::star::accessibility;
35 #include <vcl/window.hxx>
36 #include <toolkit/awt/vclxwindow.hxx>
37 #include <vcl/sysdata.hxx>
39 AccFrameEventListener::AccFrameEventListener(css::accessibility::XAccessible* pAcc, AccObjectManagerAgent* Agent)
40 :AccEventListener(pAcc, Agent)
44 AccFrameEventListener::~AccFrameEventListener()
48 /**
49 * Uno's event notifier when event is captured
50 * @param AccessibleEventObject the event object which contains information about event
52 void AccFrameEventListener::notifyEvent( const css::accessibility::AccessibleEventObject& aEvent )
54 SolarMutexGuard g;
56 switch (aEvent.EventId)
58 case AccessibleEventId::CHILD:
59 HandleChildChangedEvent(aEvent.OldValue, aEvent.NewValue);
60 break;
61 case AccessibleEventId::VISIBLE_DATA_CHANGED:
62 HandleVisibleDataChangedEvent();
63 break;
64 case AccessibleEventId::BOUNDRECT_CHANGED:
65 HandleBoundrectChangedEvent();
66 break;
67 default:
68 AccEventListener::notifyEvent(aEvent);
69 break;
73 /**
74 * handle the CHILD event
75 * @param oldValue the child to be deleted
76 * @param newValue the child to be added
78 void AccFrameEventListener::HandleChildChangedEvent(Any oldValue, Any newValue)
80 Reference< XAccessible > xChild;
81 if( newValue >>= xChild)
83 //create a new child
84 if(xChild.is())
86 XAccessible* pAcc = xChild.get();
88 VCLXWindow* pvclwindow = dynamic_cast<VCLXWindow*>(m_xAccessible.get());
89 assert(pvclwindow);
90 const SystemEnvData* systemdata
91 = pvclwindow->GetWindow()->GetSystemData();
93 //add this child
94 pAgent->InsertAccObj(pAcc, m_xAccessible.get(),
95 reinterpret_cast<sal_Int64>(systemdata->hWnd));
96 //add all oldValue's existing children
97 pAgent->InsertChildrenAccObj(pAcc);
98 pAgent->NotifyAccEvent(UM_EVENT_CHILD_ADDED, pAcc);
101 else if (oldValue >>= xChild)
103 //delete an existing child
104 if(xChild.is())
106 XAccessible* pAcc = xChild.get();
107 pAgent->NotifyAccEvent(UM_EVENT_CHILD_REMOVED, pAcc);
108 //delete all oldValue's existing children
109 pAgent->DeleteChildrenAccObj( pAcc );
110 //delete this child
111 pAgent->DeleteAccObj( pAcc );
118 * set the new state and fire the MSAA event
119 * @param state new state id
120 * @param enable true if state is set, false if state is unset
122 void AccFrameEventListener::SetComponentState(short state, bool enable )
124 // only the following state can be fired state event.
125 switch (state)
127 case AccessibleStateType::ICONIFIED:
128 // no msaa state
129 break;
130 case AccessibleStateType::VISIBLE:
131 // UNO !VISIBLE == MSAA INVISIBLE
132 if( enable )
133 pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
134 else
135 pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
136 break;
137 case AccessibleStateType::ACTIVE:
138 // Only frames should be active
139 // no msaa state mapping
140 break;
141 default:
142 break;
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */