Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / winaccessibility / source / service / AccObjectManagerAgent.cxx
blobabc75f71c7785a20f3adaeb4a52752daa6926ef8
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 #if defined __clang__
24 #pragma clang diagnostic push
25 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
26 #endif
27 #include <UAccCOM.h>
28 #if defined __clang__
29 #pragma clang diagnostic pop
30 #endif
32 using namespace com::sun::star::uno;
33 using namespace com::sun::star::accessibility;
35 /**
36 * Construction/Destruction.
37 * @param
38 * @return
40 AccObjectManagerAgent::AccObjectManagerAgent()
41 : pWinManager(new AccObjectWinManager(this))
45 AccObjectManagerAgent::~AccObjectManagerAgent()
49 /**
50 * Interface of updating MSAA name when UNO name_changed event occurs.
51 * @param pXAcc Uno XAccessible interface of control.
52 * @return
54 void AccObjectManagerAgent::UpdateAccName( XAccessible* pXAcc )
56 if( pWinManager )
57 pWinManager->UpdateAccName( pXAcc );
60 /**
61 * Interface of updating MSAA name when UNO action changed event occurs.
62 * @param pXAcc Uno XAccessible interface of control.
63 * @return
65 void AccObjectManagerAgent::UpdateAction( XAccessible* pXAcc )
67 if( pWinManager )
68 pWinManager->UpdateAction( pXAcc );
71 /**
72 * Interface of updating MSAA value when UNO value_changed event occurs.
73 * @param pXAcc Uno XAccessible interface of control.
74 * @param pAny New value.
75 * @return
77 void AccObjectManagerAgent::UpdateValue( XAccessible* pXAcc, Any pAny )
79 if( pWinManager )
80 pWinManager->SetValue( pXAcc, pAny );
83 /**
84 * Interface of updating MSAA value when UNO value_changed event occurs. If we can not
85 * find new value, we'll get new value from pXAcc to update com value.
86 * @param pXAcc Uno XAccessible interface of control.
87 * @return
89 void AccObjectManagerAgent::UpdateValue( XAccessible* pXAcc )
91 if( pWinManager )
92 pWinManager->UpdateValue( pXAcc );
95 /**
96 * Interface of updating MSAA name when UNO name_changed event occurs.
97 * @param pXAcc Uno XAccessible interface of control.
98 * @param newName New UNO accessible name.
99 * @return
101 void AccObjectManagerAgent::UpdateAccName( XAccessible* pXAcc, Any newName)
103 if( pWinManager )
104 pWinManager->SetAccName( pXAcc, newName );
109 * Interface of updating MSAA location when UNO location_changed event occurs.
110 * @param pXAcc Uno XAccessible interface of control.
111 * @param pXAcc Uno The top position of new location.
112 * @param pXAcc Uno The left position of new location.
113 * @param pXAcc Uno The width of new location.
114 * @param pXAcc Uno The width of new location.
115 * @return
117 void AccObjectManagerAgent::UpdateLocation( XAccessible* /* pXAcc */, long /*top*/, long /*left*/, long /*width*/, long /*height*/ )
119 #ifdef _IMPL_WIN
120 if( pWinManager )
121 pWinManager->SetLocation( pXAcc, top, left, width, height );
122 #endif
126 * Interface of updating MSAA name when UNO description_changed event occurs.
127 * @param pXAcc Uno XAccessible interface of control.
128 * @param newDesc New UNO accessible description.
129 * @return
131 void AccObjectManagerAgent::UpdateDescription( XAccessible* pXAcc, Any newDesc )
133 if( pWinManager )
134 pWinManager->SetDescription( pXAcc, newDesc );
138 * When a new UNO XAccessible object is found by listener, we create a corresponding
139 * com object and insert it to our manager list.
140 * @param pXAcc Uno XAccessible interface of control.
141 * @param pWnd The top window handle containing control.
142 * @return If the method is correctly processed.
144 bool AccObjectManagerAgent::InsertAccObj(
145 XAccessible* pXAcc, XAccessible* pParentXAcc, sal_Int64 nWnd)
147 if( pWinManager )
148 return pWinManager->InsertAccObj(pXAcc, pParentXAcc,
149 static_cast<HWND>(reinterpret_cast<void*>(nWnd)));
151 return false;
155 * save the pair <topwindowhandle, XAccessible>
156 * @param hWnd, top window handle
157 * @param pXAcc XAccessible interface for top window
158 * @return void
160 void
161 AccObjectManagerAgent::SaveTopWindowHandle(sal_Int64 hWnd, XAccessible* pXAcc)
163 if( pWinManager )
164 pWinManager->SaveTopWindowHandle(
165 static_cast<HWND>(reinterpret_cast<void*>(hWnd)), pXAcc);
170 * When a UNO XAccessible object's new children are found by listener, we create
171 * corresponding com objects and insert them to our manager list.
172 * @param pXAcc Uno XAccessible interface of control.
173 * @param pWnd The top window handle containing control.
174 * @return If the method is correctly processed.
176 bool
177 AccObjectManagerAgent::InsertChildrenAccObj(XAccessible* pXAcc, sal_Int64 pWnd)
179 if( pWinManager )
180 return pWinManager->InsertChildrenAccObj( pXAcc, HWND(reinterpret_cast<void*>(pWnd)) );
182 return false;
186 * When a new UNO XAccessible object is destroyed, we delete its corresponding
187 * com object and remove it from our manager list.
188 * @param pXAcc Uno XAccessible interface of control.
189 * @return
191 void AccObjectManagerAgent::DeleteAccObj( XAccessible* pXAcc )
193 if( pWinManager )
194 pWinManager->DeleteAccObj( pXAcc );
198 * When new UNO children XAccessible objects are destroyed, we delete their
199 * corresponding com objects and remove them from our manager list.
200 * @param pXAcc Uno XAccessible interface of control.
201 * @return
203 void AccObjectManagerAgent::DeleteChildrenAccObj( XAccessible* pXAcc )
205 if( pWinManager )
206 pWinManager->DeleteChildrenAccObj( pXAcc );
210 * Interface of decreasing MSAA state when some UNO state is decreased.
211 * @param pXAcc Uno XAccessible interface of control.
212 * @param pState The lost state of control.
213 * @return
215 void AccObjectManagerAgent::DecreaseState( XAccessible* pXAcc,unsigned short pState )
217 if(pWinManager)
219 pWinManager->DecreaseState( pXAcc, pState );
224 * Interface of increasing MSAA name when some UNO state is increased.
225 * @param pXAcc Uno XAccessible interface of control.
226 * @param pState The new state of control.
227 * @return
229 void AccObjectManagerAgent::IncreaseState( XAccessible* pXAcc,unsigned short pState )
231 if(pWinManager)
233 pWinManager->IncreaseState( pXAcc, pState );
237 void AccObjectManagerAgent::UpdateState( css::accessibility::XAccessible* pXAcc )
239 if(pWinManager)
240 pWinManager->UpdateState(pXAcc);
244 * Interface of notify MSAA event when some UNO event occurred.
245 * @param pXAcc Uno XAccessible interface of control.
246 * @param pEvent UNO event ID.
247 * @return If the method is correctly processed.
249 bool AccObjectManagerAgent::NotifyAccEvent(short pEvent, XAccessible* pXAcc)
251 if(pWinManager)
252 return pWinManager->NotifyAccEvent(pXAcc,pEvent);
254 return false;
258 * Judge whether a XAccessible object is a container object.
259 * @param pXAcc Uno XAccessible interface of control.
260 * @return If the method is correctly processed.
262 bool AccObjectManagerAgent::IsContainer( XAccessible* pXAcc )
264 if(pWinManager)
265 return AccObjectWinManager::IsContainer(pXAcc);
267 return false;
271 * Return com object interface by querying XAccessible interface.
272 * @param pXAcc Uno XAccessible interface of control.
273 * @return Com interface.
275 IMAccessible* AccObjectManagerAgent::GetIMAccByXAcc(XAccessible* pXAcc)
277 if(pWinManager)
278 return pWinManager->GetIMAccByXAcc(pXAcc);
280 return nullptr;
284 * Notify manager when a XAccessible object is destroying.
285 * @param pXAcc Uno XAccessible interface of control.
286 * @return.
288 void AccObjectManagerAgent::NotifyDestroy(XAccessible* pXAcc)
290 if(pWinManager)
291 pWinManager->NotifyDestroy(pXAcc);
295 * Return com object interface by querying child id.
296 * @param pXAcc Uno XAccessible interface of control.
297 * @return Com interface.
299 void AccObjectManagerAgent::GetIAccessibleFromResID(long childID,IMAccessible** pIMAcc)
301 if(pWinManager)
302 *pIMAcc = pWinManager->GetIAccessibleFromResID(childID);
306 * Return object interface by querying interface.
307 * @param pXAcc Uno XAccessible interface of control.
308 * @return Com interface.
310 bool AccObjectManagerAgent::GetIAccessibleFromXAccessible(
311 XAccessible* pXAcc, IAccessible** ppXI)
313 if(pWinManager)
315 *ppXI = reinterpret_cast<IAccessible*>(pWinManager->GetIMAccByXAcc(pXAcc));
316 if(*ppXI)
317 return true;
319 return false;
322 XAccessible* AccObjectManagerAgent::GetParentXAccessible( XAccessible* pXAcc )
324 if(pWinManager)
325 return pWinManager->GetParentXAccessible( pXAcc );
327 return nullptr;
330 short AccObjectManagerAgent::GetParentRole( XAccessible* pXAcc )
332 if(pWinManager)
333 return pWinManager->GetParentRole( pXAcc );
335 return -1;
338 void AccObjectManagerAgent::UpdateDescription( XAccessible* pXAcc )
340 if(pWinManager)
341 pWinManager->UpdateDescription( pXAcc );
344 void AccObjectManagerAgent::UpdateChildState(XAccessible* pXAcc)
346 if(pWinManager)
347 pWinManager->UpdateChildState( pXAcc );
351 bool AccObjectManagerAgent::IsSpecialToolboItem(XAccessible* pXAcc)
353 if(pWinManager)
354 return pWinManager->IsSpecialToolboItem( pXAcc );
356 return false;
359 short AccObjectManagerAgent::GetRole(XAccessible* pXAcc)
361 if(pWinManager)
362 return AccObjectWinManager::GetRole( pXAcc );
364 return -1;
367 XAccessible* AccObjectManagerAgent::GetAccDocByAccTopWin( XAccessible* pXAcc )
369 if (pWinManager)
371 return pWinManager->GetAccDocByAccTopWin( pXAcc );
373 return nullptr;
375 bool AccObjectManagerAgent::IsTopWinAcc(XAccessible* pXAcc)
377 if (pWinManager)
379 return pWinManager->IsTopWinAcc( pXAcc );
381 return NULL;
384 bool AccObjectManagerAgent::IsStateManageDescendant(XAccessible* pXAcc)
386 if(pWinManager)
387 return AccObjectWinManager::IsStateManageDescendant( pXAcc );
389 return false;
393 * Implementation of interface XMSAAService's method getAccObjectPtr()
394 * that returns the corresponding COM interface with the MS event.
395 * @return Com interface.
397 sal_Int64 AccObjectManagerAgent::Get_ToATInterface(
398 sal_Int64 hWnd, sal_Int64 lParam, sal_Int64 wParam)
400 return static_cast<sal_Int64>(pWinManager->Get_ToATInterface(
401 static_cast<HWND>(reinterpret_cast<void*>(hWnd)), lParam, wParam));
404 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */