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>
25 #include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
27 #include <vcl/svapp.hxx>
29 #include <AccTableEventListener.hxx>
30 #include <AccObjectManagerAgent.hxx>
31 #include <unomsaaevent.hxx>
33 using namespace com::sun::star::uno
;
34 using namespace com::sun::star::accessibility
;
36 AccTableEventListener::AccTableEventListener(css::accessibility::XAccessible
* pAcc
, AccObjectManagerAgent
* Agent
)
37 :AccDescendantManagerEventListener(pAcc
, Agent
)
39 AccTableEventListener::~AccTableEventListener()
44 * Uno's event notifier when event is captured
45 * @param AccessibleEventObject the event object which contains information about event
47 void AccTableEventListener::notifyEvent( const css::accessibility::AccessibleEventObject
& aEvent
)
51 switch (aEvent
.EventId
)
53 case AccessibleEventId::ACTIVE_DESCENDANT_CHANGED
:
54 HandleActiveDescendantChangedEvent(aEvent
.OldValue
, aEvent
.NewValue
);
57 case AccessibleEventId::TABLE_CAPTION_CHANGED
:
59 pAgent
->NotifyAccEvent(UnoMSAAEvent::TABLE_CAPTION_CHANGED
, m_xAccessible
.get());
62 case AccessibleEventId::TABLE_COLUMN_DESCRIPTION_CHANGED
:
64 pAgent
->NotifyAccEvent(UnoMSAAEvent::TABLE_COLUMN_DESCRIPTION_CHANGED
, m_xAccessible
.get());
67 case AccessibleEventId::TABLE_COLUMN_HEADER_CHANGED
:
69 pAgent
->NotifyAccEvent(UnoMSAAEvent::TABLE_COLUMN_HEADER_CHANGED
, m_xAccessible
.get());
72 case AccessibleEventId::TABLE_ROW_HEADER_CHANGED
:
74 pAgent
->NotifyAccEvent(UnoMSAAEvent::TABLE_ROW_HEADER_CHANGED
, m_xAccessible
.get());
77 case AccessibleEventId::TABLE_MODEL_CHANGED
:
79 HandleTableModelChangeEvent(aEvent
.NewValue
);
82 case AccessibleEventId::TABLE_SUMMARY_CHANGED
:
84 pAgent
->NotifyAccEvent(UnoMSAAEvent::TABLE_SUMMARY_CHANGED
, m_xAccessible
.get());
87 case AccessibleEventId::TABLE_ROW_DESCRIPTION_CHANGED
:
89 pAgent
->NotifyAccEvent(UnoMSAAEvent::TABLE_ROW_DESCRIPTION_CHANGED
, m_xAccessible
.get());
93 AccDescendantManagerEventListener::notifyEvent(aEvent
);
99 * handle the ACTIVE_DESCENDANT_CHANGED event
100 * @param oldValue the child to lose active
101 * @param newValue the child to get active
103 void AccTableEventListener::HandleActiveDescendantChangedEvent(Any oldValue
, Any newValue
)
105 Reference
< XAccessible
> xChild
;
106 if(newValue
>>= xChild
)
110 XAccessible
* pAcc
= xChild
.get();
111 pAgent
->InsertAccObj(pAcc
, m_xAccessible
.get());
112 pAgent
->NotifyAccEvent(UnoMSAAEvent::ACTIVE_DESCENDANT_CHANGED
, pAcc
);
115 else if (oldValue
>>= xChild
)
117 //delete an existing child
120 XAccessible
* pAcc
= xChild
.get();
121 pAgent
->DeleteAccObj( pAcc
);
126 void AccTableEventListener::HandleTableModelChangeEvent(Any newValue
)
128 AccessibleTableModelChange aModelChange
;
129 if (newValue
>>= aModelChange
)
131 if (m_xAccessible
.is())
133 //delete all oldValue's existing children
134 pAgent
->DeleteChildrenAccObj(m_xAccessible
.get());
135 //add all oldValue's existing children
136 pAgent
->InsertChildrenAccObj(m_xAccessible
.get());
138 pAgent
->NotifyAccEvent(UnoMSAAEvent::TABLE_MODEL_CHANGED
, m_xAccessible
.get());
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */