1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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()
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
)
56 switch (aEvent
.EventId
)
58 case AccessibleEventId::CHILD
:
59 HandleChildChangedEvent(aEvent
.OldValue
, aEvent
.NewValue
);
61 case AccessibleEventId::VISIBLE_DATA_CHANGED
:
62 HandleVisibleDataChangedEvent();
64 case AccessibleEventId::BOUNDRECT_CHANGED
:
65 HandleBoundrectChangedEvent();
68 AccEventListener::notifyEvent(aEvent
);
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
)
86 XAccessible
* pAcc
= xChild
.get();
88 VCLXWindow
* pvclwindow
= dynamic_cast<VCLXWindow
*>(m_xAccessible
.get());
90 const SystemEnvData
* systemdata
91 = pvclwindow
->GetWindow()->GetSystemData();
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
106 XAccessible
* pAcc
= xChild
.get();
107 pAgent
->NotifyAccEvent(UM_EVENT_CHILD_REMOVED
, pAcc
);
108 //delete all oldValue's existing children
109 pAgent
->DeleteChildrenAccObj( pAcc
);
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.
127 case AccessibleStateType::ICONIFIED
:
130 case AccessibleStateType::VISIBLE
:
131 // UNO !VISIBLE == MSAA INVISIBLE
133 pAgent
->IncreaseState(m_xAccessible
.get(), AccessibleStateType::VISIBLE
);
135 pAgent
->DecreaseState(m_xAccessible
.get(), AccessibleStateType::VISIBLE
);
137 case AccessibleStateType::ACTIVE
:
138 // Only frames should be active
139 // no msaa state mapping
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */