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
28 #include "AccParagraphEventListener.hxx"
29 #include "AccObjectManagerAgent.hxx"
30 #include "unomsaaevent.hxx"
31
32 using namespace com::sun::star::uno;
33 using namespace com::sun::star::accessibility;
34
AccParagraphEventListener(com::sun::star::accessibility::XAccessible * pAcc,AccObjectManagerAgent * Agent)35 AccParagraphEventListener::AccParagraphEventListener(com::sun::star::accessibility::XAccessible* pAcc, AccObjectManagerAgent* Agent)
36 :AccContainerEventListener(pAcc, Agent)
37 {}
~AccParagraphEventListener()38 AccParagraphEventListener::~AccParagraphEventListener()
39 {
40 }
41
42 /**
43 * Uno's event notifier when event is captured
44 * @param AccessibleEventObject the event object which contains information about event
45 */
notifyEvent(const::com::sun::star::accessibility::AccessibleEventObject & aEvent)46 void AccParagraphEventListener::notifyEvent( const ::com::sun::star::accessibility::AccessibleEventObject& aEvent )
47 throw (::com::sun::star::uno::RuntimeException)
48 {
49 switch (aEvent.EventId)
50 {
51 case AccessibleEventId::CARET_CHANGED:
52 handleCaretChangedEvent(aEvent.OldValue, aEvent.NewValue);
53 break;
54 case AccessibleEventId::VISIBLE_DATA_CHANGED:
55 handleVisibleDataChangedEvent();
56 break;
57 case AccessibleEventId::BOUNDRECT_CHANGED:
58 handleBoundrectChangedEvent();
59 break;
60 //Added for paragraph selected state.
61 case AccessibleEventId::STATE_CHANGED:
62 {
63 short State;
64 if( (aEvent.NewValue >>= State) && (State == AccessibleStateType::SELECTED) )
65 {
66 pAgent->IncreaseState( pAccessible, State);
67 break;
68 }
69 else if( (aEvent.OldValue >>= State) && (State == AccessibleStateType::SELECTED) )
70 {
71 pAgent->DecreaseState( pAccessible, State);
72 break;
73 }
74
75 AccContainerEventListener::notifyEvent(aEvent);
76 break;
77 }
78
79 case AccessibleEventId::TEXT_SELECTION_CHANGED:
80 handleTextSelectionChangedEvent();
81 break;
82
83 default:
84 AccContainerEventListener::notifyEvent(aEvent);
85 break;
86 }
87 }
88
89 /**
90 * handle the CARET_CHANGED event
91 * @param oldValue in UNO, this parameter is always NULL
92 * @param newValue in UNO, this parameter is always NULL
93 */
handleCaretChangedEvent(Any oldValue,Any newValue)94 void AccParagraphEventListener::handleCaretChangedEvent(Any oldValue, Any newValue)
95 {
96 pAgent->UpdateLocation(pAccessible);
97 pAgent->NotifyAccEvent(UM_EVENT_OBJECT_CARETCHANGE, pAccessible);
98 }
99
100 /**
101 * handle the VISIBLE_DATA_CHANGED event
102 */
handleVisibleDataChangedEvent()103 void AccParagraphEventListener::handleVisibleDataChangedEvent()
104 {
105 AccEventListener::handleVisibleDataChangedEvent();
106 }
107
108 /**
109 * handle the BOUNDRECT_CHANGED event
110 */
handleBoundrectChangedEvent()111 void AccParagraphEventListener::handleBoundrectChangedEvent()
112 {
113 AccEventListener::handleBoundrectChangedEvent();
114 }
115
116 /**
117 * set the new state and fire the MSAA event
118 * @param state new state id
119 * @param enable true if state is set, false if state is unset
120 */
setComponentState(short state,bool enable)121 void AccParagraphEventListener::setComponentState(short state, bool enable )
122 {
123 // only the following state can be fired state event.
124 switch (state)
125 {
126 case AccessibleStateType::EDITABLE:
127 // no msaa state
128 break;
129 case AccessibleStateType::MULTI_LINE:
130 // no msaa state mapping
131 break;
132 case AccessibleStateType::SINGLE_LINE:
133 // no msaa state mapping
134 break;
135 default:
136 AccContainerEventListener::setComponentState(state, enable);
137 break;
138 }
139 }
140
handleTextSelectionChangedEvent()141 void AccParagraphEventListener::handleTextSelectionChangedEvent()
142 {
143 pAgent->NotifyAccEvent(UM_EVENT_TEXT_SELECTION_CHANGED, pAccessible);
144 }
145
146