LibreOffice Module accessibility (master) 1
AccessibleGridControlTableBase.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
20#include <com/sun/star/accessibility/AccessibleRole.hpp>
21#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
24#include <vcl/svapp.hxx>
26
27using css::uno::Reference;
28using css::uno::Sequence;
29using css::uno::Any;
30
31using namespace ::com::sun::star;
32using namespace ::com::sun::star::accessibility;
33using namespace ::vcl;
34using namespace ::vcl::table;
35
36
37namespace accessibility {
38
39
41 const Reference< XAccessible >& rxParent,
42 IAccessibleTable& rTable,
44 GridControlAccessibleElement( rxParent, rTable, eObjType )
45{
46}
47
48// XAccessibleContext ---------------------------------------------------------
49
51{
52 SolarMutexGuard aSolarGuard;
53
55 sal_Int64 nChildren = 0;
57 nChildren = m_aTable.GetRowCount();
58 else if(m_eObjType == TCTYPE_TABLE)
59 nChildren = static_cast<sal_Int64>(m_aTable.GetRowCount()) * static_cast<sal_Int64>(m_aTable.GetColumnCount());
61 nChildren = m_aTable.GetColumnCount();
62 return nChildren;
63}
64
66{
68
70 return AccessibleRole::TABLE;
71}
72
73// XAccessibleTable -----------------------------------------------------------
74
76{
77 SolarMutexGuard aSolarGuard;
78
80 return m_aTable.GetRowCount();
81}
82
84{
85 SolarMutexGuard aSolarGuard;
86
88 return m_aTable.GetColumnCount();
89}
90
92 sal_Int32 nRow, sal_Int32 nColumn )
93{
94 SolarMutexGuard aSolarGuard;
95
97 ensureIsValidAddress( nRow, nColumn );
98 return 1; // merged cells not supported
99}
100
102 sal_Int32 nRow, sal_Int32 nColumn )
103{
104 SolarMutexGuard aSolarGuard;
105
107 ensureIsValidAddress( nRow, nColumn );
108 return 1; // merged cells not supported
109}
110
112{
114
116 return nullptr; // not supported
117}
118
120{
122
124 return nullptr; // not supported
125}
126
128 sal_Int32 nRow, sal_Int32 nColumn )
129{
130 SolarMutexGuard aSolarGuard;
131
133 ensureIsValidAddress( nRow, nColumn );
134 return static_cast<sal_Int64>(nRow) * static_cast<sal_Int64>(m_aTable.GetColumnCount()) + nColumn;
135}
136
137sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleRow( sal_Int64 nChildIndex )
138{
139 SolarMutexGuard aSolarGuard;
140
142 ensureIsValidIndex( nChildIndex );
143 return implGetRow( nChildIndex );
144}
145
146sal_Int32 SAL_CALL AccessibleGridControlTableBase::getAccessibleColumn( sal_Int64 nChildIndex )
147{
148 SolarMutexGuard aSolarGuard;
149
151 ensureIsValidIndex( nChildIndex );
152 return implGetColumn( nChildIndex );
153}
154
155// XInterface -----------------------------------------------------------------
156
158{
160 return aAny.hasValue() ?
162}
163
165{
166 GridControlAccessibleElement::acquire();
167}
168
170{
171 GridControlAccessibleElement::release();
172}
173
174// XTypeProvider --------------------------------------------------------------
175
177{
178 return ::comphelper::concatSequences(
181}
182
184{
185 return css::uno::Sequence<sal_Int8>();
186}
187
188// internal helper methods ----------------------------------------------------
189
190sal_Int32 AccessibleGridControlTableBase::implGetRow( sal_Int64 nChildIndex ) const
191{
192 sal_Int32 nColumns = m_aTable.GetColumnCount();
193 return nColumns ? (nChildIndex / nColumns) : 0;
194}
195
196sal_Int32 AccessibleGridControlTableBase::implGetColumn( sal_Int64 nChildIndex ) const
197{
198 sal_Int32 nColumns = m_aTable.GetColumnCount();
199 return nColumns ? (nChildIndex % nColumns) : 0;
200}
201
203{
204 sal_Int32 const selectionCount( m_aTable.GetSelectedRowCount() );
205 rSeq.realloc( selectionCount );
206 auto pSeq = rSeq.getArray();
207 for ( sal_Int32 i=0; i<selectionCount; ++i )
209}
210
212{
213 if( nRow >= m_aTable.GetRowCount() )
214 throw lang::IndexOutOfBoundsException( "row index is invalid", *this );
215}
216
218{
219 if( nColumn >= m_aTable.GetColumnCount() )
220 throw lang::IndexOutOfBoundsException( "column index is invalid", *this );
221}
222
224 sal_Int32 nRow, sal_Int32 nColumn )
225{
226 ensureIsValidRow( nRow );
227 ensureIsValidColumn( nColumn );
228}
229
231{
232 if (nChildIndex >= static_cast<sal_Int64>(m_aTable.GetRowCount()) * static_cast<sal_Int64>(m_aTable.GetColumnCount()))
233 throw lang::IndexOutOfBoundsException( "child index is invalid", *this );
234}
235
236
237} // namespace accessibility
238
239
240/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::vcl::table::IAccessibleTable & m_aTable
The SVT Table control.
::vcl::table::AccessibleTableControlObjType m_eObjType
The type of this object (for names, descriptions, state sets, ...).
virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption() override
void implGetSelectedRows(css::uno::Sequence< sal_Int32 > &rSeq)
Fills a sequence with sorted indexes of completely selected rows.
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary() override
virtual sal_Int32 SAL_CALL getAccessibleRow(sal_Int64 nChildIndex) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
AccessibleGridControlTableBase(const css::uno::Reference< css::accessibility::XAccessible > &rxParent, ::vcl::table::IAccessibleTable &rTable, ::vcl::table::AccessibleTableControlObjType eObjType)
Constructor sets specified name and description.
virtual void SAL_CALL release() noexcept override
Releases the object (calls release() on base class).
virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
virtual sal_Int32 SAL_CALL getAccessibleRowCount() override
virtual sal_Int32 SAL_CALL getAccessibleColumn(sal_Int64 nChildIndex) override
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Queries for a new interface.
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual void SAL_CALL acquire() noexcept override
Acquires the object (calls acquire() on base class).
void ensureIsValidAddress(sal_Int32 nRow, sal_Int32 nColumn)
virtual sal_Int32 SAL_CALL getAccessibleColumnCount() override
virtual sal_Int64 SAL_CALL getAccessibleIndex(sal_Int32 nRow, sal_Int32 nColumn) override
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual sal_Int32 GetRowCount() const=0
virtual sal_Int32 GetSelectedRowCount() const=0
virtual sal_Int32 GetColumnCount() const=0
virtual sal_Int32 GetSelectedRowIndex(sal_Int32 const i_selectionIndex) const=0
int i
AccessibleTableControlObjType
TCTYPE_ROWHEADERBAR
TCTYPE_COLUMNHEADERBAR
TCTYPE_TABLE