LibreOffice Module accessibility (master) 1
AccessibleGridControl.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
23#include <com/sun/star/accessibility/AccessibleEventId.hpp>
24#include <com/sun/star/accessibility/AccessibleRole.hpp>
25#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
27#include <utility>
29#include <vcl/svapp.hxx>
30
31namespace accessibility
32{
33
34using namespace ::com::sun::star::uno;
35using namespace ::com::sun::star;
36using namespace ::com::sun::star::lang;
37using namespace ::com::sun::star::accessibility;
38using namespace ::vcl;
39using namespace ::vcl::table;
40
42 const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, const css::uno::Reference< css::accessibility::XAccessible >& _rxCreator,
44 : AccessibleGridControlBase( _rxParent, _rTable, TCTYPE_GRIDCONTROL ),
45 m_aCreator(_rxCreator)
46{
47}
48
49
51{
53
54 m_aCreator.clear();
55
56 if ( m_xTable.is() )
57 {
58 m_xTable->dispose();
59 m_xTable.clear();
60 }
61 if ( m_xRowHeaderBar.is() )
62 {
63 m_xRowHeaderBar->dispose();
64 m_xRowHeaderBar.clear();
65 }
66 if ( m_xColumnHeaderBar.is() )
67 {
68 m_xColumnHeaderBar->dispose();
69 m_xColumnHeaderBar.clear();
70 }
72}
73
75{
77}
78
79// css::accessibility::XAccessibleContext ---------------------------------------------------------
80
81
83{
84 SolarMutexGuard aSolarGuard;
87}
88
89
90css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
92{
93 SolarMutexGuard aSolarGuard;
94
95 if (nChildIndex<0 || nChildIndex>=implGetAccessibleChildCount())
96 throw IndexOutOfBoundsException();
97
98 css::uno::Reference< css::accessibility::XAccessible > xChild;
99 if (isAlive())
100 {
101 if(nChildIndex == 0 && m_aTable.HasColHeader())
102 {
103 if(!m_xColumnHeaderBar.is())
104 {
106 }
107 xChild = m_xColumnHeaderBar.get();
108 }
109 else if(m_aTable.HasRowHeader() && (nChildIndex == 1 || nChildIndex == 0))
110 {
111 if(!m_xRowHeaderBar.is())
112 {
114 }
115 xChild = m_xRowHeaderBar.get();
116 }
117 else
118 {
119 if(!m_xTable.is())
120 {
122 }
123 xChild = m_xTable.get();
124 }
125 }
126 return xChild;
127}
128
129
131{
133
135 return AccessibleRole::PANEL;
136}
137
138
139// css::accessibility::XAccessibleComponent -------------------------------------------------------
140
141css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
143{
144 SolarMutexGuard aSolarGuard;
146
147 css::uno::Reference< css::accessibility::XAccessible > xChild;
148 sal_Int32 nIndex = 0;
151 else
152 {
153 // try whether point is in one of the fixed children
154 // (table, header bars, corner control)
155 Point aPoint( VCLPoint( rPoint ) );
156 for( nIndex = 0; (nIndex < 3) && !xChild.is(); ++nIndex )
157 {
158 css::uno::Reference< css::accessibility::XAccessible > xCurrChild( implGetFixedChild( nIndex ) );
159 css::uno::Reference< css::accessibility::XAccessibleComponent >
160 xCurrChildComp( xCurrChild, uno::UNO_QUERY );
161
162 if( xCurrChildComp.is() &&
163 VCLRectangle( xCurrChildComp->getBounds() ).Contains( aPoint ) )
164 xChild = xCurrChild;
165 }
166 }
167 return xChild;
168}
169
170
172{
173 SolarMutexGuard aSolarGuard;
176}
177
178// XServiceInfo ---------------------------------------------------------------
179
181{
182 return "com.sun.star.accessibility.AccessibleGridControl";
183}
184
185
186// internal virtual methods ---------------------------------------------------
187
189{
191 OSL_ENSURE( pParent, "implGetBoundingBox - missing parent window" );
192 return m_aTable.GetWindowExtentsRelative( *pParent );
193}
194
195
197{
199}
200// internal helper methods ----------------------------------------------------
201
202css::uno::Reference< css::accessibility::XAccessible > AccessibleGridControl::implGetTable()
203{
204 if( !m_xTable.is() )
205 {
207 }
208 return m_xTable;
209}
210
211
212css::uno::Reference< css::accessibility::XAccessible >
214{
215 css::uno::Reference< css::accessibility::XAccessible > xRet;
217
218 if( eObjType == TCTYPE_ROWHEADERBAR )
219 pxMember = &m_xRowHeaderBar;
220 else if( eObjType == TCTYPE_COLUMNHEADERBAR )
221 pxMember = &m_xColumnHeaderBar;
222
223 if( pxMember )
224 {
225 if( !pxMember->is() )
226 {
227 *pxMember = new AccessibleGridControlHeader(
228 m_aCreator, m_aTable, eObjType );
229 }
230 xRet = pxMember->get();
231 }
232 return xRet;
233}
234
235css::uno::Reference< css::accessibility::XAccessible >
237{
238 css::uno::Reference< css::accessibility::XAccessible > xRet;
239 switch( nChildIndex )
240 {
242 case 0:
244 break;
246 case 1:
248 break;
250 case 2:
251 xRet = implGetTable();
252 break;
253 }
254 return xRet;
255}
256
258{
259 css::uno::Reference< css::accessibility::XAccessible > xCreator(m_aCreator);
260 OSL_ENSURE( xCreator.is(), "extended/AccessibleGridControl::createAccessibleTable: my creator died - how this?" );
261 return new AccessibleGridControlTable( xCreator, m_aTable );
262}
263
264void AccessibleGridControl::commitCellEvent(sal_Int16 _nEventId,const Any& _rNewValue,const Any& _rOldValue)
265{
266 sal_Int64 nChildCount = implGetAccessibleChildCount();
267 if(nChildCount != 0)
268 {
269 for(sal_Int64 i=0;i<nChildCount;i++)
270 {
271 css::uno::Reference< css::accessibility::XAccessible > xAccessible = getAccessibleChild(i);
272 if(css::uno::Reference< css::accessibility::XAccessible >(m_xTable) == xAccessible)
273 {
274 Reference<XAccessible> xCell = m_xTable->getAccessibleCellAt(
276 AccessibleGridControlTableCell* pCell = static_cast<AccessibleGridControlTableCell*>(xCell.get());
277 pCell->commitEvent(_nEventId, _rNewValue, _rOldValue);
278 }
279 }
280 }
281 else
282 {
283 if ( m_xTable.is() )
284 m_xTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
285 }
286}
287
288void AccessibleGridControl::commitTableEvent(sal_Int16 _nEventId,const Any& _rNewValue,const Any& _rOldValue)
289{
290 if ( !m_xTable.is() )
291 return;
292
293 if(_nEventId == AccessibleEventId::ACTIVE_DESCENDANT_CHANGED)
294 {
295 const sal_Int32 nCurrentRow = m_aTable.GetCurrentRow();
296 const sal_Int32 nCurrentCol = m_aTable.GetCurrentColumn();
297 css::uno::Reference< css::accessibility::XAccessible > xChild;
298 if (nCurrentRow > -1 && nCurrentCol > -1)
299 xChild = m_xTable->getAccessibleCellAt(nCurrentRow, nCurrentCol);
300
301 m_xTable->commitEvent(_nEventId, Any(xChild),_rOldValue);
302 }
303 else
304 m_xTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
305}
306
307// = AccessibleGridControlAccess
308
309
311 css::uno::Reference< css::accessibility::XAccessible > xParent, ::vcl::table::IAccessibleTable& rTable )
312 : m_xParent(std::move( xParent ))
313 , m_pTable( & rTable )
314{
315}
316
317
319{
320}
321
322
324{
326
327 m_pTable = nullptr;
328 if (m_xContext.is())
329 {
330 m_xContext->dispose();
331 m_xContext.clear();
332 }
333}
334
335
336css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL AccessibleGridControlAccess::getAccessibleContext()
337{
339
340 // if the context died meanwhile (we're no listener, so it won't tell us explicitly when this happens),
341 // then reset and re-create.
342 if ( m_xContext.is() && !m_xContext->isAlive() )
343 m_xContext = nullptr;
344
345 if (!m_xContext.is() && m_pTable)
347
348 return m_xContext;
349}
350
351
352} // namespace accessibility
353
354/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference< AccessibleGridControl > m_xContext
css::uno::Reference< css::accessibility::XAccessible > m_xParent
AccessibleGridControlAccess(css::uno::Reference< css::accessibility::XAccessible > _xParent, ::vcl::table::IAccessibleTable &_rTable)
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
The GridControl accessible objects inherit from this base class.
::vcl::table::IAccessibleTable & m_aTable
The SVT Table control.
virtual void commitEvent(sal_Int16 nEventId, const css::uno::Any &rNewValue, const css::uno::Any &rOldValue)
Commits an event to all listeners.
virtual void SAL_CALL disposing() override
Commits DeFunc event to listeners and cleans up members.
This class represents the accessible object of a header bar of a Grid Control (row or column header b...
This class represents the accessible object of the data table of a Grid control.
This class represents the complete accessible Grid Control object.
virtual void SAL_CALL disposing() override
Commits DeFunc event to listeners and cleans up members.
void commitCellEvent(sal_Int16 nEventId, const css::uno::Any &rNewValue, const css::uno::Any &rOldValue)
commitCellEvent commit the event at all listeners of the table
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
css::uno::Reference< css::accessibility::XAccessible > implGetFixedChild(sal_Int64 nChildIndex)
This method returns one of the children that are always present: Data table, row and column header ba...
virtual tools::Rectangle implGetBoundingBox() override
rtl::Reference< AccessibleGridControlHeader > m_xRowHeaderBar
The header bar for rows.
AccessibleGridControl(const css::uno::Reference< css::accessibility::XAccessible > &_rxParent, const css::uno::Reference< css::accessibility::XAccessible > &_rxCreator, ::vcl::table::IAccessibleTable &_rTable)
css::uno::Reference< css::accessibility::XAccessible > implGetTable()
This method creates (once) and returns the accessible data table child.
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &rPoint) override
rtl::Reference< AccessibleGridControlTable > createAccessibleTable()
This method creates and returns an accessible table.
virtual void SAL_CALL grabFocus() override
Grabs the focus to the Grid Control.
void commitTableEvent(sal_Int16 nEventId, const css::uno::Any &rNewValue, const css::uno::Any &rOldValue)
commitTableEvent commit the event at all listeners of the table
virtual sal_Int16 SAL_CALL getAccessibleRole() override
virtual OUString SAL_CALL getImplementationName() override
css::uno::WeakReference< css::accessibility::XAccessible > m_aCreator
the css::accessibility::XAccessible which created the AccessibleGridControl
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 nChildIndex) override
css::uno::Reference< css::accessibility::XAccessible > implGetHeaderBar(::vcl::table::AccessibleTableControlObjType eObjType)
This method creates (once) and returns the specified header bar.
rtl::Reference< AccessibleGridControlHeader > m_xColumnHeaderBar
The header bar for columns (first row of the table).
rtl::Reference< AccessibleGridControlTable > m_xTable
The data table child.
virtual tools::Rectangle implGetBoundingBoxOnScreen() override
bool Contains(const Point &rPOINT) const
virtual vcl::Window * GetAccessibleParentWindow() const=0
virtual bool HasColHeader()=0
virtual sal_Int32 GetCurrentColumn() const=0
virtual void GrabFocus()=0
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleControl(sal_Int32 _nIndex)=0
virtual tools::Rectangle GetWindowExtentsRelative(const vcl::Window &rRelativeWindow) const=0
virtual sal_Int32 GetCurrentRow() const=0
virtual tools::Rectangle GetWindowExtentsAbsolute() const=0
virtual sal_Int32 GetAccessibleControlCount() const=0
virtual bool HasRowHeader()=0
virtual bool ConvertPointToControlIndex(sal_Int32 &_rnIndex, const Point &_rPoint)=0
inline ::tools::Rectangle VCLRectangle(const css::awt::Rectangle &rAWTRect)
inline ::Point VCLPoint(const css::awt::Point &rAWTPoint)
sal_Int32 nIndex
int i
AccessibleTableControlObjType
TCTYPE_GRIDCONTROL