bump product version to 5.0.4.1
[LibreOffice.git] / winaccessibility / source / service / AccFrameEventListener.cxx
blob29cb395720ba82c0c48d20555996a5b26be58370
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(com::sun::star::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 ::com::sun::star::accessibility::AccessibleEventObject& aEvent )
53 throw (::com::sun::star::uno::RuntimeException)
55 SolarMutexGuard g;
57 switch (aEvent.EventId)
59 case AccessibleEventId::CHILD:
60 HandleChildChangedEvent(aEvent.OldValue, aEvent.NewValue);
61 break;
62 case AccessibleEventId::VISIBLE_DATA_CHANGED:
63 HandleVisibleDataChangedEvent();
64 break;
65 case AccessibleEventId::BOUNDRECT_CHANGED:
66 HandleBoundrectChangedEvent();
67 break;
68 default:
69 AccEventListener::notifyEvent(aEvent);
70 break;
74 /**
75 * handle the CHILD event
76 * @param oldValue the child to be deleted
77 * @param newValue the child to be added
79 void AccFrameEventListener::HandleChildChangedEvent(Any oldValue, Any newValue)
81 Reference< XAccessible > xChild;
82 if( newValue >>= xChild)
84 //create a new child
85 if(xChild.is())
87 XAccessible* pAcc = xChild.get();
89 VCLXWindow* pvclwindow =
90 dynamic_cast<VCLXWindow*>(m_xAccessible.get());
91 vcl::Window* window = pvclwindow->GetWindow();
92 const SystemEnvData* systemdata=window->GetSystemData();
94 //add this child
95 pAgent->InsertAccObj(pAcc, m_xAccessible.get(),
96 reinterpret_cast<sal_Int64>(systemdata->hWnd));
97 //add all oldValue's existing children
98 pAgent->InsertChildrenAccObj(pAcc);
99 pAgent->NotifyAccEvent(UM_EVENT_CHILD_ADDED, pAcc);
101 else
104 else if (oldValue >>= xChild)
106 //delete a existing child
107 if(xChild.is())
109 XAccessible* pAcc = xChild.get();
110 pAgent->NotifyAccEvent(UM_EVENT_CHILD_REMOVED, pAcc);
111 //delete all oldValue's existing children
112 pAgent->DeleteChildrenAccObj( pAcc );
113 //delete this child
114 pAgent->DeleteAccObj( pAcc );
116 else
123 * set the new state and fire the MSAA event
124 * @param state new state id
125 * @param enable true if state is set, false if state is unset
127 void AccFrameEventListener::SetComponentState(short state, bool enable )
129 // only the following state can be fired state event.
130 switch (state)
132 case AccessibleStateType::ICONIFIED:
133 // no msaa state
134 break;
135 case AccessibleStateType::VISIBLE:
136 // UNO !VISIBLE == MSAA INVISIBLE
137 if( enable )
138 pAgent->IncreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
139 else
140 pAgent->DecreaseState(m_xAccessible.get(), AccessibleStateType::VISIBLE);
141 break;
142 case AccessibleStateType::ACTIVE:
143 // Only frames should be active
144 // no msaa state mapping
145 break;
146 default:
147 break;
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */