bump product version to 5.0.4.1
[LibreOffice.git] / winaccessibility / source / service / AccTableEventListener.cxx
blob2b477f7153de5ecc8c0b4f617560604e8444bcc8
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>
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(com::sun::star::accessibility::XAccessible* pAcc, AccObjectManagerAgent* Agent)
37 :AccDescendantManagerEventListener(pAcc, Agent)
39 AccTableEventListener::~AccTableEventListener()
43 /**
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 ::com::sun::star::accessibility::AccessibleEventObject& aEvent )
48 throw (::com::sun::star::uno::RuntimeException)
50 SolarMutexGuard g;
52 switch (aEvent.EventId)
54 case AccessibleEventId::ACTIVE_DESCENDANT_CHANGED:
55 HandleActiveDescendantChangedEvent(aEvent.OldValue, aEvent.NewValue);
56 break;
58 case AccessibleEventId::TABLE_CAPTION_CHANGED:
61 pAgent->NotifyAccEvent(UM_EVENT_TABLE_CAPTION_CHANGED, m_xAccessible.get());
62 break;
64 case AccessibleEventId::TABLE_COLUMN_DESCRIPTION_CHANGED:
67 pAgent->NotifyAccEvent(UM_EVENT_TABLE_COLUMN_DESCRIPTION_CHANGED, m_xAccessible.get());
68 break;
70 case AccessibleEventId::TABLE_COLUMN_HEADER_CHANGED:
73 pAgent->NotifyAccEvent(UM_EVENT_TABLE_COLUMN_HEADER_CHANGED, m_xAccessible.get());
74 break;
76 case AccessibleEventId::TABLE_ROW_HEADER_CHANGED:
79 pAgent->NotifyAccEvent(UM_EVENT_TABLE_ROW_HEADER_CHANGED, m_xAccessible.get());
80 break;
82 case AccessibleEventId::TABLE_MODEL_CHANGED:
85 HandleTableModelChangeEvent(aEvent.NewValue);
86 break;
88 case AccessibleEventId::TABLE_SUMMARY_CHANGED:
91 pAgent->NotifyAccEvent(UM_EVENT_TABLE_SUMMARY_CHANGED, m_xAccessible.get());
92 break;
94 case AccessibleEventId::TABLE_ROW_DESCRIPTION_CHANGED:
97 pAgent->NotifyAccEvent(UM_EVENT_TABLE_ROW_DESCRIPTION_CHANGED, m_xAccessible.get());
98 break;
100 default:
101 AccDescendantManagerEventListener::notifyEvent(aEvent);
102 break;
107 * handle the ACTIVE_DESCENDANT_CHANGED event
108 * @param oldValue the child to lose active
109 * @param newValue the child to get active
111 void AccTableEventListener::HandleActiveDescendantChangedEvent(Any oldValue, Any newValue)
113 Reference< XAccessible > xChild;
114 if(newValue >>= xChild )
116 if(xChild.is())
118 XAccessible* pAcc = xChild.get();
119 pAgent->InsertAccObj(pAcc, m_xAccessible.get());
120 pAgent->NotifyAccEvent(UM_EVENT_ACTIVE_DESCENDANT_CHANGED, pAcc);
123 else if (oldValue >>= xChild)
125 //delete an existing child
126 if(xChild.is())
128 XAccessible* pAcc = xChild.get();
129 pAgent->DeleteAccObj( pAcc );
134 void AccTableEventListener::HandleTableModelChangeEvent(Any newValue)
136 AccessibleTableModelChange aModelChange;
137 if (newValue >>= aModelChange)
139 if (m_xAccessible.is())
141 //delete all oldValue's existing children
142 pAgent->DeleteChildrenAccObj(m_xAccessible.get());
143 //add all oldValue's existing children
144 pAgent->InsertChildrenAccObj(m_xAccessible.get());
146 pAgent->NotifyAccEvent(UM_EVENT_TABLE_MODEL_CHANGED, m_xAccessible.get());
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */