bump product version to 5.0.4.1
[LibreOffice.git] / winaccessibility / source / service / AccObjectManagerAgent.cxx
blob7606f39b8cc90cba0ad4db03ebd5e8e68bde773c
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 "AccObjectManagerAgent.hxx"
21 #include "AccObjectWinManager.hxx"
23 #include "UAccCOM.h"
25 using namespace com::sun::star::uno;
26 using namespace com::sun::star::accessibility;
28 /**
29 * Construction/Destruction.
30 * @param
31 * @return
33 AccObjectManagerAgent::AccObjectManagerAgent()
34 : pWinManager(new AccObjectWinManager(this))
38 AccObjectManagerAgent::~AccObjectManagerAgent()
42 /**
43 * Interface of updating MSAA name when UNO name_changed event occurs.
44 * @param pXAcc Uno XAccessible interface of control.
45 * @return
47 void AccObjectManagerAgent::UpdateAccName( XAccessible* pXAcc )
49 if( pWinManager )
50 pWinManager->UpdateAccName( pXAcc );
53 /**
54 * Interface of updating MSAA name when UNO action changed event occurs.
55 * @param pXAcc Uno XAccessible interface of control.
56 * @return
58 void AccObjectManagerAgent::UpdateAction( XAccessible* pXAcc )
60 if( pWinManager )
61 pWinManager->UpdateAction( pXAcc );
64 /**
65 * Interface of updating MSAA value when UNO value_changed event occurs.
66 * @param pXAcc Uno XAccessible interface of control.
67 * @param pAny New value.
68 * @return
70 void AccObjectManagerAgent::UpdateValue( XAccessible* pXAcc, Any pAny )
72 if( pWinManager )
73 pWinManager->SetValue( pXAcc, pAny );
76 /**
77 * Interface of updating MSAA value when UNO value_changed event occurs.If we can not
78 * find new value,we'll get new value from pXAcc to update com value.
79 * @param pXAcc Uno XAccessible interface of control.
80 * @return
82 void AccObjectManagerAgent::UpdateValue( XAccessible* pXAcc )
84 if( pWinManager )
85 pWinManager->UpdateValue( pXAcc );
88 /**
89 * Interface of updating MSAA name when UNO name_changed event occurs.
90 * @param pXAcc Uno XAccessible interface of control.
91 * @param newName New UNO accessible name.
92 * @return
94 void AccObjectManagerAgent::UpdateAccName( XAccessible* pXAcc, Any newName)
96 if( pWinManager )
97 pWinManager->SetAccName( pXAcc, newName );
102 * Interface of updating MSAA location when UNO location_changed event occurs.
103 * @param pXAcc Uno XAccessible interface of control.
104 * @param pXAcc Uno The top position of new location.
105 * @param pXAcc Uno The left position of new location.
106 * @param pXAcc Uno The width of new location.
107 * @param pXAcc Uno The width of new location.
108 * @return
110 void AccObjectManagerAgent::UpdateLocation( XAccessible* /* pXAcc */, long /*top*/, long /*left*/, long /*width*/, long /*height*/ )
112 #ifdef _IMPL_WIN
113 if( pWinManager )
114 pWinManager->SetLocation( pXAcc, top, left, width, height );
115 #endif
119 * Interface of updating MSAA name when UNO description_changed event occurs.
120 * @param pXAcc Uno XAccessible interface of control.
121 * @param newDesc New UNO accessible description.
122 * @return
124 void AccObjectManagerAgent::UpdateDescription( XAccessible* pXAcc, Any newDesc )
126 if( pWinManager )
127 pWinManager->SetDescription( pXAcc, newDesc );
131 * When a new UNO XAccessible object is found by listener,we'll create a corresponding
132 * com object and insert it to our manager list.
133 * @param pXAcc Uno XAccessible interface of control.
134 * @param pWnd The top window handle containing control.
135 * @return If the method is correctly processed.
137 bool AccObjectManagerAgent::InsertAccObj(
138 XAccessible* pXAcc, XAccessible* pParentXAcc, sal_Int64 nWnd)
140 if( pWinManager )
141 return pWinManager->InsertAccObj(pXAcc, pParentXAcc,
142 static_cast<HWND>(reinterpret_cast<void*>(nWnd)));
144 return false;
148 * save the pair <topwindowhandle, XAccessible>
149 * @param hWnd, top window handle
150 * @param pXAcc XAccessible interface for top window
151 * @return void
153 void
154 AccObjectManagerAgent::SaveTopWindowHandle(sal_Int64 hWnd, XAccessible* pXAcc)
156 if( pWinManager )
157 pWinManager->SaveTopWindowHandle(
158 static_cast<HWND>(reinterpret_cast<void*>(hWnd)), pXAcc);
163 * When a UNO XAccessible object's new children are found by listener,we'll create
164 * corresponding com objects and insert them to our manager list.
165 * @param pXAcc Uno XAccessible interface of control.
166 * @param pWnd The top window handle containing control.
167 * @return If the method is correctly processed.
169 bool
170 AccObjectManagerAgent::InsertChildrenAccObj(XAccessible* pXAcc, sal_Int64 pWnd)
172 if( pWinManager )
173 return pWinManager->InsertChildrenAccObj( pXAcc, HWND((void*)pWnd) );
175 return false;
179 * When a new UNO XAccessible object is destroied,we'll delete its corresponding
180 * com object and remove it from our manager list.
181 * @param pXAcc Uno XAccessible interface of control.
182 * @return
184 void AccObjectManagerAgent::DeleteAccObj( XAccessible* pXAcc )
186 if( pWinManager )
187 pWinManager->DeleteAccObj( pXAcc );
191 * When new UNO children XAccessible objects are destroyed,we'll delete their
192 * corresponding com objects and remove them from our manager list.
193 * @param pXAcc Uno XAccessible interface of control.
194 * @return
196 void AccObjectManagerAgent::DeleteChildrenAccObj( XAccessible* pXAcc )
198 if( pWinManager )
199 pWinManager->DeleteChildrenAccObj( pXAcc );
203 * Interface of decreasing MSAA state when some UNO state is decreased.
204 * @param pXAcc Uno XAccessible interface of control.
205 * @param pState The lost state of control.
206 * @return
208 void AccObjectManagerAgent::DecreaseState( XAccessible* pXAcc,unsigned short pState )
210 if(pWinManager)
212 pWinManager->DecreaseState( pXAcc, pState );
217 * Interface of increasing MSAA name when some UNO state is increased.
218 * @param pXAcc Uno XAccessible interface of control.
219 * @param pState The new state of control.
220 * @return
222 void AccObjectManagerAgent::IncreaseState( XAccessible* pXAcc,unsigned short pState )
224 if(pWinManager)
226 pWinManager->IncreaseState( pXAcc, pState );
230 void AccObjectManagerAgent::UpdateState( com::sun::star::accessibility::XAccessible* pXAcc )
232 if(pWinManager)
233 pWinManager->UpdateState(pXAcc);
237 * Interface of notify MSAA event when some UNO event occurred.
238 * @param pXAcc Uno XAccessible interface of control.
239 * @param pEvent UNO event ID.
240 * @return If the method is correctly processed.
242 bool AccObjectManagerAgent::NotifyAccEvent(short pEvent, XAccessible* pXAcc)
244 if(pWinManager)
245 return pWinManager->NotifyAccEvent(pXAcc,pEvent);
247 return false;
251 * Judge whether a XAccessible object is a container object.
252 * @param pXAcc Uno XAccessible interface of control.
253 * @return If the method is correctly processed.
255 bool AccObjectManagerAgent::IsContainer( XAccessible* pXAcc )
257 if(pWinManager)
258 return pWinManager->IsContainer(pXAcc);
260 return false;
264 * Return com object interface by querying XAccessible interface.
265 * @param pXAcc Uno XAccessible interface of control.
266 * @return Com interface.
268 IMAccessible* AccObjectManagerAgent::GetIMAccByXAcc(XAccessible* pXAcc)
270 if(pWinManager)
271 return pWinManager->GetIMAccByXAcc(pXAcc);
273 return NULL;
277 * Notify manger when a XAccessible object is destroying.
278 * @param pXAcc Uno XAccessible interface of control.
279 * @return.
281 void AccObjectManagerAgent::NotifyDestroy(XAccessible* pXAcc)
283 if(pWinManager)
284 pWinManager->NotifyDestroy(pXAcc);
288 * Return com object interface by querying child id.
289 * @param pXAcc Uno XAccessible interface of control.
290 * @return Com interface.
292 void AccObjectManagerAgent::GetIAccessibleFromResID(long childID,IMAccessible** pIMAcc)
294 if(pWinManager)
295 *pIMAcc = pWinManager->GetIAccessibleFromResID(childID);
299 * Return object interface by querying interface.
300 * @param pXAcc Uno XAccessible interface of control.
301 * @return Com interface.
303 bool AccObjectManagerAgent::GetIAccessibleFromXAccessible(
304 XAccessible* pXAcc, IAccessible** ppXI)
306 if(pWinManager)
308 *ppXI = (IAccessible*)pWinManager->GetIMAccByXAcc(pXAcc);
309 if(*ppXI)
310 return true;
312 return false;
315 XAccessible* AccObjectManagerAgent::GetParentXAccessible( XAccessible* pXAcc )
317 if(pWinManager)
318 return pWinManager->GetParentXAccessible( pXAcc );
320 return NULL;
323 short AccObjectManagerAgent::GetParentRole( XAccessible* pXAcc )
325 if(pWinManager)
326 return pWinManager->GetParentRole( pXAcc );
328 return -1;
331 void AccObjectManagerAgent::UpdateDescription( XAccessible* pXAcc )
333 if(pWinManager)
334 pWinManager->UpdateDescription( pXAcc );
337 void AccObjectManagerAgent::UpdateChildState(XAccessible* pXAcc)
339 if(pWinManager)
340 pWinManager->UpdateChildState( pXAcc );
344 bool AccObjectManagerAgent::IsSpecialToolboItem(XAccessible* pXAcc)
346 if(pWinManager)
347 return pWinManager->IsSpecialToolboItem( pXAcc );
349 return false;
352 short AccObjectManagerAgent::GetRole(XAccessible* pXAcc)
354 if(pWinManager)
355 return pWinManager->GetRole( pXAcc );
357 return -1;
360 XAccessible* AccObjectManagerAgent::GetAccDocByAccTopWin( XAccessible* pXAcc )
362 if (pWinManager)
364 return pWinManager->GetAccDocByAccTopWin( pXAcc );
366 return NULL;
368 bool AccObjectManagerAgent::IsTopWinAcc(XAccessible* pXAcc)
370 if (pWinManager)
372 return pWinManager->IsTopWinAcc( pXAcc );
374 return NULL;
377 bool AccObjectManagerAgent::IsStateManageDescendant(XAccessible* pXAcc)
379 if(pWinManager)
380 return pWinManager->IsStateManageDescendant( pXAcc );
382 return false;
386 * Implementation of interface XMSAAService's method getAccObjectPtr()
387 * that returns the corresponding COM interface with the MS event.
388 * @return Com interface.
390 sal_Int64 AccObjectManagerAgent::Get_ToATInterface(
391 sal_Int64 hWnd, sal_Int64 lParam, sal_Int64 wParam)
393 return static_cast<sal_Int64>(pWinManager->Get_ToATInterface(
394 static_cast<HWND>(reinterpret_cast<void*>(hWnd)), lParam, wParam));
397 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */