Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / winaccessibility / source / service / AccFrameEventListener.cxx
blobcd4a64b22bca97ac44a8484dbe4322d653679b58
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(), systemdata->hWnd);
95 //add all oldValue's existing children
96 pAgent->InsertChildrenAccObj(pAcc);
97 pAgent->NotifyAccEvent(UnoMSAAEvent::CHILD_ADDED, pAcc);
100 else if (oldValue >>= xChild)
102 //delete an existing child
103 if(xChild.is())
105 XAccessible* pAcc = xChild.get();
106 pAgent->NotifyAccEvent(UnoMSAAEvent::CHILD_REMOVED, pAcc);
107 //delete all oldValue's existing children
108 pAgent->DeleteChildrenAccObj( pAcc );
109 //delete this child
110 pAgent->DeleteAccObj( pAcc );
117 * set the new state and fire the MSAA event
118 * @param state new state id
119 * @param enable true if state is set, false if state is unset
121 void AccFrameEventListener::SetComponentState(sal_Int64 state, bool enable )
123 // only the following state can be fired state event.
124 switch (state)
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;
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */