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 "AccObjectManagerAgent.hxx"
23 #include "AccObjectWinManager.hxx"
24
25 #include "UAccCOM2.h"
26
27 using namespace com::sun::star::uno;
28 using namespace com::sun::star::accessibility;
29
30 /**
31 * Construction/Destruction.
32 * @param
33 * @return
34 */
AccObjectManagerAgent()35 AccObjectManagerAgent::AccObjectManagerAgent():
36 pWinManager(NULL)
37 {
38 if( pWinManager == NULL )
39 {
40 pWinManager = AccObjectWinManager::CreateAccObjectWinManagerInstance(this);
41 }
42 }
43
~AccObjectManagerAgent()44 AccObjectManagerAgent::~AccObjectManagerAgent()
45 {
46 delete pWinManager;
47 pWinManager = NULL;
48 }
49
50 /**
51 * Interface of updating MSAA name when UNO name_changed event occurs.
52 * @param pXAcc Uno XAccessible interface of control.
53 * @return
54 */
UpdateAccName(XAccessible * pXAcc)55 void AccObjectManagerAgent::UpdateAccName( XAccessible* pXAcc )
56 {
57 if( pWinManager )
58 pWinManager->UpdateAccName( pXAcc );
59 }
60
61 /**
62 * Interface of updating MSAA name when UNO action changed event occurs.
63 * @param pXAcc Uno XAccessible interface of control.
64 * @return
65 */
UpdateAction(XAccessible * pXAcc)66 void AccObjectManagerAgent::UpdateAction( XAccessible* pXAcc )
67 {
68 if( pWinManager )
69 pWinManager->UpdateAction( pXAcc );
70 }
71
72 /**
73 * Interface of updating MSAA value when UNO value_changed event occurs.
74 * @param pXAcc Uno XAccessible interface of control.
75 * @param pAny New value.
76 * @return
77 */
UpdateValue(XAccessible * pXAcc,Any pAny)78 void AccObjectManagerAgent::UpdateValue( XAccessible* pXAcc, Any pAny )
79 {
80 if( pWinManager )
81 pWinManager->SetValue( pXAcc, pAny );
82 }
83
84 /**
85 * Interface of updating MSAA value when UNO value_changed event occurs.If we can not
86 * find new value,we'll get new value from pXAcc to update com value.
87 * @param pXAcc Uno XAccessible interface of control.
88 * @return
89 */
UpdateValue(XAccessible * pXAcc)90 void AccObjectManagerAgent::UpdateValue( XAccessible* pXAcc )
91 {
92 if( pWinManager )
93 pWinManager->UpdateValue( pXAcc );
94 }
95
96 /**
97 * Interface of updating MSAA name when UNO name_changed event occurs.
98 * @param pXAcc Uno XAccessible interface of control.
99 * @param newName New UNO accessible name.
100 * @return
101 */
UpdateAccName(XAccessible * pXAcc,Any newName)102 void AccObjectManagerAgent::UpdateAccName( XAccessible* pXAcc, Any newName)
103 {
104 if( pWinManager )
105 pWinManager->SetAccName( pXAcc, newName );
106 }
107
108
109 /**
110 * Interface of updating MSAA location when UNO location_changed event occurs.
111 * @param pXAcc Uno XAccessible interface of control.
112 * @param pXAcc Uno The top position of new location.
113 * @param pXAcc Uno The left position of new location.
114 * @param pXAcc Uno The width of new location.
115 * @param pXAcc Uno The width of new location.
116 * @return
117 */
UpdateLocation(XAccessible *,long,long,long,long)118 void AccObjectManagerAgent::UpdateLocation( XAccessible* /* pXAcc */, long /*top*/, long /*left*/, long /*width*/, long /*height*/ )
119 {
120 #ifdef _IMPL_WIN
121 if( pWinManager )
122 pWinManager->SetLocation( pXAcc, top, left, width, height );
123 #endif
124 }
125
126 /**
127 * Interface of updating MSAA name when UNO description_changed event occurs.
128 * @param pXAcc Uno XAccessible interface of control.
129 * @param newDesc New UNO accessible description.
130 * @return
131 */
UpdateDescription(XAccessible * pXAcc,Any newDesc)132 void AccObjectManagerAgent::UpdateDescription( XAccessible* pXAcc, Any newDesc )
133 {
134 if( pWinManager )
135 pWinManager->SetDescription( pXAcc, newDesc );
136 }
137
138 /**
139 * When a new UNO XAccessible object is found by listener,we'll create a corresponding
140 * com object and insert it to our manager list.
141 * @param pXAcc Uno XAccessible interface of control.
142 * @param pWnd The top window handle containing control.
143 * @return If the method is correctly processed.
144 */
InsertAccObj(XAccessible * pXAcc,XAccessible * pParentXAcc,long pWnd)145 unsigned char AccObjectManagerAgent::InsertAccObj( XAccessible* pXAcc,XAccessible* pParentXAcc,long pWnd)
146 {
147 if( pWinManager )
148 return (unsigned char)pWinManager->InsertAccObj( pXAcc, pParentXAcc,HWND((void*)pWnd) );
149
150 return sal_False;
151 }
152
153 /**
154 * save the pair <topwindowhandle, XAccessible>
155 * @param hWnd, top window handle
156 * @param pXAcc XAccessible interface for top window
157 * @return void
158 */
SaveTopWindowHandle(long hWnd,com::sun::star::accessibility::XAccessible * pXAcc)159 void AccObjectManagerAgent::SaveTopWindowHandle(long hWnd, com::sun::star::accessibility::XAccessible* pXAcc)
160 {
161 if( pWinManager )
162 pWinManager->SaveTopWindowHandle( HWND((void*)hWnd), pXAcc );
163 }
164
165
166 /**
167 * When a UNO XAccessible object's new children are found by listener,we'll create
168 * corresponding com objects and insert them to our manager list.
169 * @param pXAcc Uno XAccessible interface of control.
170 * @param pWnd The top window handle containing control.
171 * @return If the method is correctly processed.
172 */
InsertChildrenAccObj(XAccessible * pXAcc,long pWnd)173 unsigned char AccObjectManagerAgent::InsertChildrenAccObj( XAccessible* pXAcc,
174 long pWnd)
175 {
176 if( pWinManager )
177 return (unsigned char)pWinManager->InsertChildrenAccObj( pXAcc, HWND((void*)pWnd) );
178
179 return sal_False;
180 }
181
182 /**
183 * When a new UNO XAccessible object is destroied,we'll delete its corresponding
184 * com object and remove it from our manager list.
185 * @param pXAcc Uno XAccessible interface of control.
186 * @return
187 */
DeleteAccObj(XAccessible * pXAcc)188 void AccObjectManagerAgent::DeleteAccObj( XAccessible* pXAcc )
189 {
190 if( pWinManager )
191 pWinManager->DeleteAccObj( pXAcc );
192 }
193
194 /**
195 * When new UNO children XAccessible objects are destroyed,we'll delete their
196 * corresponding com objects and remove them from our manager list.
197 * @param pXAcc Uno XAccessible interface of control.
198 * @return
199 */
DeleteChildrenAccObj(XAccessible * pXAcc)200 void AccObjectManagerAgent::DeleteChildrenAccObj( XAccessible* pXAcc )
201 {
202 if( pWinManager )
203 pWinManager->DeleteChildrenAccObj( pXAcc );
204 }
205
206 /**
207 * Interface of decreasing MSAA state when some UNO state is decreased.
208 * @param pXAcc Uno XAccessible interface of control.
209 * @param pState The lost state of control.
210 * @return
211 */
DecreaseState(XAccessible * pXAcc,unsigned short pState)212 void AccObjectManagerAgent::DecreaseState( XAccessible* pXAcc,unsigned short pState )
213 {
214 if(pWinManager)
215 {
216 pWinManager->DecreaseState( pXAcc, pState );
217 }
218 }
219
220 /**
221 * Interface of increasing MSAA name when some UNO state is increased.
222 * @param pXAcc Uno XAccessible interface of control.
223 * @param pState The new state of control.
224 * @return
225 */
IncreaseState(XAccessible * pXAcc,unsigned short pState)226 void AccObjectManagerAgent::IncreaseState( XAccessible* pXAcc,unsigned short pState )
227 {
228 if(pWinManager)
229 {
230 pWinManager->IncreaseState( pXAcc, pState );
231 }
232 }
233
UpdateState(com::sun::star::accessibility::XAccessible * pXAcc)234 void AccObjectManagerAgent::UpdateState( com::sun::star::accessibility::XAccessible* pXAcc )
235 {
236 if(pWinManager)
237 pWinManager->UpdateState(pXAcc);
238 }
239
240 /**
241 * Interface of notify MSAA event when some UNO event occurred.
242 * @param pXAcc Uno XAccessible interface of control.
243 * @param pEvent UNO event ID.
244 * @return If the method is correctly processed.
245 */
NotifyAccEvent(short pEvent,XAccessible * pXAcc)246 unsigned char AccObjectManagerAgent::NotifyAccEvent( short pEvent,XAccessible* pXAcc )
247 {
248 if(pWinManager)
249 return (unsigned char)pWinManager->NotifyAccEvent(pXAcc,pEvent);
250
251 return sal_False;
252 }
253
254 /**
255 * Judge whether a XAccessible object is a container object.
256 * @param pXAcc Uno XAccessible interface of control.
257 * @return If the method is correctly processed.
258 */
IsContainer(XAccessible * pXAcc)259 unsigned short AccObjectManagerAgent::IsContainer( XAccessible* pXAcc )
260 {
261 if(pWinManager)
262 return (unsigned char)pWinManager->IsContainer(pXAcc);
263
264 return sal_False;
265 }
266
267 /**
268 * Return com object interface by querying XAccessible interface.
269 * @param pXAcc Uno XAccessible interface of control.
270 * @return Com interface.
271 */
GetIMAccByXAcc(XAccessible * pXAcc)272 IMAccessible* AccObjectManagerAgent::GetIMAccByXAcc(XAccessible* pXAcc)
273 {
274 if(pWinManager)
275 return pWinManager->GetIMAccByXAcc(pXAcc);
276
277 return NULL;
278 }
279
280 /**
281 * Notify manger when a XAccessible object is destroying.
282 * @param pXAcc Uno XAccessible interface of control.
283 * @return.
284 */
NotifyDestroy(XAccessible * pXAcc)285 void AccObjectManagerAgent::NotifyDestroy(XAccessible* pXAcc)
286 {
287 if(pWinManager)
288 pWinManager->NotifyDestroy(pXAcc);
289 }
290
291 /**
292 * Return com object interface by querying child id.
293 * @param pXAcc Uno XAccessible interface of control.
294 * @return Com interface.
295 */
GetIAccessibleFromResID(long childID,IMAccessible ** pIMAcc)296 void AccObjectManagerAgent::GetIAccessibleFromResID(long childID,IMAccessible** pIMAcc)
297 {
298 if(pWinManager)
299 *pIMAcc = pWinManager->GetIAccessibleFromResID(childID);
300 }
301
302 /**
303 * Return object interface by querying interface.
304 * @param pXAcc Uno XAccessible interface of control.
305 * @return Com interface.
306 */
GetIAccessibleFromXAccessible(XAccessible * pXAcc,IAccessible ** ppXI)307 unsigned char AccObjectManagerAgent::GetIAccessibleFromXAccessible(XAccessible* pXAcc, IAccessible** ppXI)
308 {
309 if(pWinManager)
310 {
311 *ppXI = (IAccessible*)pWinManager->GetIMAccByXAcc(pXAcc);
312 if(*ppXI)
313 return sal_True;
314 }
315 return sal_False;
316 }
317
GetParentXAccessible(XAccessible * pXAcc)318 XAccessible* AccObjectManagerAgent::GetParentXAccessible( XAccessible* pXAcc )
319 {
320 if(pWinManager)
321 return pWinManager->GetParentXAccessible( pXAcc );
322
323 return NULL;
324 }
325
GetParentRole(XAccessible * pXAcc)326 short AccObjectManagerAgent::GetParentRole( XAccessible* pXAcc )
327 {
328 if(pWinManager)
329 return pWinManager->GetParentRole( pXAcc );
330
331 return -1;
332 }
333
UpdateDescription(XAccessible * pXAcc)334 void AccObjectManagerAgent::UpdateDescription( XAccessible* pXAcc )
335 {
336 if(pWinManager)
337 pWinManager->UpdateDescription( pXAcc );
338 }
339
UpdateChildState(com::sun::star::accessibility::XAccessible * pXAcc)340 void AccObjectManagerAgent::UpdateChildState(com::sun::star::accessibility::XAccessible* pXAcc)
341 {
342 if(pWinManager)
343 pWinManager->UpdateChildState( pXAcc );
344 }
345
346
IsSpecialToolboItem(com::sun::star::accessibility::XAccessible * pXAcc)347 bool AccObjectManagerAgent::IsSpecialToolboItem(com::sun::star::accessibility::XAccessible* pXAcc)
348 {
349 if(pWinManager)
350 return pWinManager->IsSpecialToolboItem( pXAcc );
351
352 return false;
353 }
354
GetRole(com::sun::star::accessibility::XAccessible * pXAcc)355 short AccObjectManagerAgent::GetRole(com::sun::star::accessibility::XAccessible* pXAcc)
356 {
357 if(pWinManager)
358 return pWinManager->GetRole( pXAcc );
359
360 return -1;
361 }
362
GetAccDocByAccTopWin(XAccessible * pXAcc)363 XAccessible* AccObjectManagerAgent::GetAccDocByAccTopWin( XAccessible* pXAcc )
364 {
365 if (pWinManager)
366 {
367 return pWinManager->GetAccDocByAccTopWin( pXAcc );
368 }
369 return NULL;
370 }
IsTopWinAcc(com::sun::star::accessibility::XAccessible * pXAcc)371 bool AccObjectManagerAgent::IsTopWinAcc( com::sun::star::accessibility::XAccessible* pXAcc )
372 {
373 if (pWinManager)
374 {
375 return pWinManager->IsTopWinAcc( pXAcc );
376 }
377 return NULL;
378 }
379
IsStateManageDescendant(com::sun::star::accessibility::XAccessible * pXAcc)380 bool AccObjectManagerAgent::IsStateManageDescendant(com::sun::star::accessibility::XAccessible* pXAcc)
381 {
382 if(pWinManager)
383 return pWinManager->IsStateManageDescendant( pXAcc );
384
385 return sal_False;
386 }
387