Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / winaccessibility / source / service / AccObjectManagerAgent.cxx
blob3ed3984c882825e25091dbea12fcb3db27305b9d
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 );
101 * When a new UNO XAccessible object is found by listener, we create a corresponding
102 * com object and insert it to our manager list.
103 * @param pXAcc Uno XAccessible interface of control.
104 * @param pWnd The top window handle containing control.
105 * @return If the method is correctly processed.
107 bool AccObjectManagerAgent::InsertAccObj(
108 XAccessible* pXAcc, XAccessible* pParentXAcc, HWND hWnd)
110 if( pWinManager )
111 return pWinManager->InsertAccObj(pXAcc, pParentXAcc, hWnd);
113 return false;
117 * save the pair <topwindowhandle, XAccessible>
118 * @param hWnd, top window handle
119 * @param pXAcc XAccessible interface for top window
120 * @return void
122 void
123 AccObjectManagerAgent::SaveTopWindowHandle(HWND hWnd, XAccessible* pXAcc)
125 if( pWinManager )
126 pWinManager->SaveTopWindowHandle(hWnd, pXAcc);
131 * When a UNO XAccessible object's new children are found by listener, we create
132 * corresponding com objects and insert them 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
138 AccObjectManagerAgent::InsertChildrenAccObj(XAccessible* pXAcc, HWND hWnd)
140 if( pWinManager )
141 return pWinManager->InsertChildrenAccObj(pXAcc, hWnd);
143 return false;
147 * When a new UNO XAccessible object is destroyed, we delete its corresponding
148 * com object and remove it from our manager list.
149 * @param pXAcc Uno XAccessible interface of control.
150 * @return
152 void AccObjectManagerAgent::DeleteAccObj( XAccessible* pXAcc )
154 if( pWinManager )
155 pWinManager->DeleteAccObj( pXAcc );
159 * When new UNO children XAccessible objects are destroyed, we delete their
160 * corresponding com objects and remove them from our manager list.
161 * @param pXAcc Uno XAccessible interface of control.
162 * @return
164 void AccObjectManagerAgent::DeleteChildrenAccObj( XAccessible* pXAcc )
166 if( pWinManager )
167 pWinManager->DeleteChildrenAccObj( pXAcc );
171 * Interface of decreasing MSAA state when some UNO state is decreased.
172 * @param pXAcc Uno XAccessible interface of control.
173 * @param pState The lost state of control.
174 * @return
176 void AccObjectManagerAgent::DecreaseState( XAccessible* pXAcc, sal_Int64 pState )
178 if(pWinManager)
180 pWinManager->DecreaseState( pXAcc, pState );
185 * Interface of increasing MSAA name when some UNO state is increased.
186 * @param pXAcc Uno XAccessible interface of control.
187 * @param pState The new state of control.
188 * @return
190 void AccObjectManagerAgent::IncreaseState( XAccessible* pXAcc, sal_Int64 pState )
192 if(pWinManager)
194 pWinManager->IncreaseState( pXAcc, pState );
198 void AccObjectManagerAgent::UpdateState( css::accessibility::XAccessible* pXAcc )
200 if(pWinManager)
201 pWinManager->UpdateState(pXAcc);
205 * Interface of notify MSAA event when some UNO event occurred.
206 * @param pXAcc Uno XAccessible interface of control.
207 * @param eEvent event type.
208 * @return If the method is correctly processed.
210 bool AccObjectManagerAgent::NotifyAccEvent(UnoMSAAEvent eEvent, XAccessible* pXAcc)
212 if(pWinManager)
213 return pWinManager->NotifyAccEvent(pXAcc, eEvent);
215 return false;
219 * Judge whether a XAccessible object is a container object.
220 * @param pXAcc Uno XAccessible interface of control.
221 * @return If the method is correctly processed.
223 bool AccObjectManagerAgent::IsContainer( XAccessible* pXAcc )
225 if(pWinManager)
226 return AccObjectWinManager::IsContainer(pXAcc);
228 return false;
232 * Return com object interface by querying XAccessible interface.
233 * @param pXAcc Uno XAccessible interface of control.
234 * @return Com interface.
236 IMAccessible* AccObjectManagerAgent::GetIMAccByXAcc(XAccessible* pXAcc)
238 if(pWinManager)
239 return pWinManager->GetIMAccByXAcc(pXAcc);
241 return nullptr;
245 * Notify manager when a XAccessible object is destroying.
246 * @param pXAcc Uno XAccessible interface of control.
247 * @return.
249 void AccObjectManagerAgent::NotifyDestroy(XAccessible* pXAcc)
251 if(pWinManager)
252 pWinManager->NotifyDestroy(pXAcc);
256 * Return com object interface by querying child id.
257 * @param pXAcc Uno XAccessible interface of control.
258 * @return Com interface.
260 void AccObjectManagerAgent::GetIAccessibleFromResID(long childID,IMAccessible** pIMAcc)
262 if(pWinManager)
263 *pIMAcc = pWinManager->GetIAccessibleFromResID(childID);
267 * Return object interface by querying interface.
268 * @param pXAcc Uno XAccessible interface of control.
269 * @return Com interface.
271 bool AccObjectManagerAgent::GetIAccessibleFromXAccessible(
272 XAccessible* pXAcc, IAccessible** ppXI)
274 if(pWinManager)
276 *ppXI = pWinManager->GetIMAccByXAcc(pXAcc);
277 if(*ppXI)
278 return true;
280 return false;
283 XAccessible* AccObjectManagerAgent::GetParentXAccessible( XAccessible* pXAcc )
285 if(pWinManager)
286 return pWinManager->GetParentXAccessible( pXAcc );
288 return nullptr;
291 short AccObjectManagerAgent::GetParentRole( XAccessible* pXAcc )
293 if(pWinManager)
294 return pWinManager->GetParentRole( pXAcc );
296 return -1;
299 void AccObjectManagerAgent::UpdateChildState(XAccessible* pXAcc)
301 if(pWinManager)
302 pWinManager->UpdateChildState( pXAcc );
306 bool AccObjectManagerAgent::IsSpecialToolbarItem(XAccessible* pXAcc)
308 if(pWinManager)
309 return pWinManager->IsSpecialToolbarItem(pXAcc);
311 return false;
314 short AccObjectManagerAgent::GetRole(XAccessible* pXAcc)
316 if(pWinManager)
317 return AccObjectWinManager::GetRole( pXAcc );
319 return -1;
322 XAccessible* AccObjectManagerAgent::GetAccDocByAccTopWin( XAccessible* pXAcc )
324 if (pWinManager)
326 return pWinManager->GetAccDocByAccTopWin( pXAcc );
328 return nullptr;
330 bool AccObjectManagerAgent::IsTopWinAcc(XAccessible* pXAcc)
332 if (pWinManager)
334 return pWinManager->IsTopWinAcc( pXAcc );
336 return false;
339 bool AccObjectManagerAgent::IsStateManageDescendant(XAccessible* pXAcc)
341 if(pWinManager)
342 return AccObjectWinManager::IsStateManageDescendant( pXAcc );
344 return false;
348 * Implementation of interface XMSAAService's method getAccObjectPtr()
349 * that returns the corresponding COM interface with the MS event.
350 * @return Com interface.
352 sal_Int64 AccObjectManagerAgent::Get_ToATInterface(
353 sal_Int64 hWnd, sal_Int64 lParam, sal_Int64 wParam)
355 return static_cast<sal_Int64>(pWinManager->Get_ToATInterface(
356 static_cast<HWND>(reinterpret_cast<void*>(hWnd)), lParam, wParam));
359 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */