1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22 #include <com/sun/star/accessibility/XAccessible.hpp>
23 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
24 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
25 #include <com/sun/star/accessibility/AccessibleRole.hpp>
26 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
27 #include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
28
29 #include "AccTableEventListener.hxx"
30 #include "AccObjectManagerAgent.hxx"
31 #include "unomsaaevent.hxx"
32
33 using namespace com::sun::star::uno;
34 using namespace com::sun::star::accessibility;
35
AccTableEventListener(com::sun::star::accessibility::XAccessible * pAcc,AccObjectManagerAgent * Agent)36 AccTableEventListener::AccTableEventListener(com::sun::star::accessibility::XAccessible* pAcc, AccObjectManagerAgent* Agent)
37 :AccDescendantManagerEventListener(pAcc, Agent)
38 {}
~AccTableEventListener()39 AccTableEventListener::~AccTableEventListener()
40 {
41 }
42
43 /**
44 * Uno's event notifier when event is captured
45 * @param AccessibleEventObject the event object which contains information about event
46 */
notifyEvent(const::com::sun::star::accessibility::AccessibleEventObject & aEvent)47 void AccTableEventListener::notifyEvent( const ::com::sun::star::accessibility::AccessibleEventObject& aEvent )
48 throw (::com::sun::star::uno::RuntimeException)
49 {
50 switch (aEvent.EventId)
51 {
52 case AccessibleEventId::ACTIVE_DESCENDANT_CHANGED:
53 handleActiveDescendantChangedEvent(aEvent.OldValue, aEvent.NewValue);
54 break;
55
56 case AccessibleEventId::TABLE_CAPTION_CHANGED:
57 {
58
59 pAgent->NotifyAccEvent(UM_EVENT_TABLE_CAPTION_CHANGED, pAccessible);
60 break;
61 }
62 case AccessibleEventId::TABLE_COLUMN_DESCRIPTION_CHANGED:
63 {
64
65 pAgent->NotifyAccEvent(UM_EVENT_TABLE_COLUMN_DESCRIPTION_CHANGED, pAccessible);
66 break;
67 }
68 case AccessibleEventId::TABLE_COLUMN_HEADER_CHANGED:
69 {
70
71 pAgent->NotifyAccEvent(UM_EVENT_TABLE_COLUMN_HEADER_CHANGED, pAccessible);
72 break;
73 }
74 case AccessibleEventId::TABLE_ROW_HEADER_CHANGED:
75 {
76
77 pAgent->NotifyAccEvent(UM_EVENT_TABLE_ROW_HEADER_CHANGED, pAccessible);
78 break;
79 }
80 case AccessibleEventId::TABLE_MODEL_CHANGED:
81 {
82
83 handleTableModelChangeEvent(aEvent.NewValue);
84 break;
85 }
86 case AccessibleEventId::TABLE_SUMMARY_CHANGED:
87 {
88
89 pAgent->NotifyAccEvent(UM_EVENT_TABLE_SUMMARY_CHANGED, pAccessible);
90 break;
91 }
92 case AccessibleEventId::TABLE_ROW_DESCRIPTION_CHANGED:
93 {
94
95 pAgent->NotifyAccEvent(UM_EVENT_TABLE_ROW_DESCRIPTION_CHANGED, pAccessible);
96 break;
97 }
98 default:
99 AccDescendantManagerEventListener::notifyEvent(aEvent);
100 break;
101 }
102 }
103
104 /**
105 * handle the ACTIVE_DESCENDANT_CHANGED event
106 * @param oldValue the child to lose active
107 * @param newValue the child to get active
108 */
handleActiveDescendantChangedEvent(Any oldValue,Any newValue)109 void AccTableEventListener::handleActiveDescendantChangedEvent(Any oldValue, Any newValue)
110 {
111 Reference< XAccessible > xChild;
112 if(newValue >>= xChild )
113 {
114 if(xChild.is())
115 {
116 XAccessible* pAcc = xChild.get();
117 pAgent->InsertAccObj(pAcc,pAccessible);
118 pAgent->NotifyAccEvent(UM_EVENT_ACTIVE_DESCENDANT_CHANGED, pAcc);
119 }
120 }
121 else if (oldValue >>= xChild)
122 {
123 //delete an existing child
124 if(xChild.is())
125 {
126 XAccessible* pAcc = xChild.get();
127 pAgent->DeleteAccObj( pAcc );
128 }
129 }
130
131 }
handleTableModelChangeEvent(Any newValue)132 void AccTableEventListener::handleTableModelChangeEvent(Any newValue)
133 {
134 AccessibleTableModelChange aModelChange;
135 if (newValue >>= aModelChange)
136 {
137 if( pAccessible )
138 {
139 //delete all oldValue's existing children
140 pAgent->DeleteChildrenAccObj( pAccessible );
141 //add all oldValue's existing children
142 pAgent->InsertChildrenAccObj( pAccessible );
143 }
144 pAgent->NotifyAccEvent(UM_EVENT_TABLE_MODEL_CHANGED, pAccessible);
145 }
146 }
147