LibreOffice Module accessibility (master) 1
AccessibleBrowseBoxTableBase.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/AccessibleRole.hpp>
24#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
25
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;
33
34
35namespace accessibility {
36
37
38// Ctor/Dtor/disposing --------------------------------------------------------
39
41 const Reference< XAccessible >& rxParent,
44 BrowseBoxAccessibleElement( rxParent, rBrowseBox,nullptr, eObjType )
45{
46}
47
48// XAccessibleContext ---------------------------------------------------------
49
51{
52 SolarMethodGuard aGuard(getMutex());
54 return implGetChildCount();
55}
56
58{
59 osl::MutexGuard aGuard( getMutex() );
61 return AccessibleRole::TABLE;
62}
63
64// XAccessibleTable -----------------------------------------------------------
65
67{
68 SolarMethodGuard aGuard(getMutex());
70 return implGetRowCount();
71}
72
74{
75 SolarMethodGuard aGuard(getMutex());
77 return implGetColumnCount();
78}
79
81 sal_Int32 nRow, sal_Int32 nColumn )
82{
83 SolarMethodGuard aGuard(getMutex());
85 ensureIsValidAddress( nRow, nColumn );
86 return 1; // merged cells not supported
87}
88
90 sal_Int32 nRow, sal_Int32 nColumn )
91{
92 SolarMethodGuard aGuard(getMutex());
94 ensureIsValidAddress( nRow, nColumn );
95 return 1; // merged cells not supported
96}
97
99{
101 return nullptr; // not supported
102}
103
105{
107 return nullptr; // not supported
108}
109
111 sal_Int32 nRow, sal_Int32 nColumn )
112{
113 SolarMethodGuard aGuard(getMutex());
115 ensureIsValidAddress( nRow, nColumn );
116 return static_cast<sal_Int64>(nRow) * static_cast<sal_Int64>(implGetColumnCount()) + nColumn;
117}
118
119sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleRow( sal_Int64 nChildIndex )
120{
121 SolarMethodGuard aGuard(getMutex());
123 ensureIsValidIndex( nChildIndex );
124 return implGetRow( nChildIndex );
125}
126
127sal_Int32 SAL_CALL AccessibleBrowseBoxTableBase::getAccessibleColumn( sal_Int64 nChildIndex )
128{
129 SolarMethodGuard aGuard(getMutex());
131 ensureIsValidIndex( nChildIndex );
132 return implGetColumn( nChildIndex );
133}
134
135// XInterface -----------------------------------------------------------------
136
138{
140 return aAny.hasValue() ?
142}
143
145{
146 BrowseBoxAccessibleElement::acquire();
147}
148
150{
151 BrowseBoxAccessibleElement::release();
152}
153
154// XTypeProvider --------------------------------------------------------------
155
157{
158 return ::comphelper::concatSequences(
161}
162
164{
165 return css::uno::Sequence<sal_Int8>();
166}
167
168// internal virtual methods ---------------------------------------------------
169
171{
172 return mpBrowseBox->GetRowCount();
173}
174
176{
177 sal_uInt16 nColumns = mpBrowseBox->GetColumnCount();
178 // do not count the "handle column"
179 if( nColumns && implHasHandleColumn() )
180 --nColumns;
181 return nColumns;
182}
183
184// internal helper methods ----------------------------------------------------
185
187{
188 return mpBrowseBox->HasRowHeader();
189}
190
191sal_uInt16 AccessibleBrowseBoxTableBase::implToVCLColumnPos( sal_Int32 nColumn ) const
192{
193 sal_uInt16 nVCLPos = 0;
194 if( (0 <= nColumn) && (nColumn < implGetColumnCount()) )
195 {
196 // regard "handle column"
197 if( implHasHandleColumn() )
198 ++nColumn;
199 nVCLPos = static_cast< sal_uInt16 >( nColumn );
200 }
201 return nVCLPos;
202}
203
205{
206 return static_cast<sal_Int64>(implGetRowCount()) * static_cast<sal_Int64>(implGetColumnCount());
207}
208
209sal_Int32 AccessibleBrowseBoxTableBase::implGetRow( sal_Int64 nChildIndex ) const
210{
211 sal_Int32 nColumns = implGetColumnCount();
212 return nColumns ? (nChildIndex / nColumns) : 0;
213}
214
215sal_Int32 AccessibleBrowseBoxTableBase::implGetColumn( sal_Int64 nChildIndex ) const
216{
217 sal_Int32 nColumns = implGetColumnCount();
218 return nColumns ? (nChildIndex % nColumns) : 0;
219}
220
222{
223 return mpBrowseBox->IsRowSelected( nRow );
224}
225
227{
228 if( implHasHandleColumn() )
229 --nColumn;
230 return mpBrowseBox->IsColumnSelected( nColumn );
231}
232
233void AccessibleBrowseBoxTableBase::implSelectRow( sal_Int32 nRow, bool bSelect )
234{
235 mpBrowseBox->SelectRow( nRow, bSelect );
236}
237
238void AccessibleBrowseBoxTableBase::implSelectColumn( sal_Int32 nColumnPos, bool bSelect )
239{
240 mpBrowseBox->SelectColumn( static_cast<sal_uInt16>(nColumnPos), bSelect );
241}
242
244{
246}
247
249{
251}
252
254{
256}
257
259{
261}
262
264{
265 if( nRow >= implGetRowCount() )
266 throw lang::IndexOutOfBoundsException( "row index is invalid", *this );
267}
268
270{
271 if( nColumn >= implGetColumnCount() )
272 throw lang::IndexOutOfBoundsException( "column index is invalid", *this );
273}
274
276 sal_Int32 nRow, sal_Int32 nColumn )
277{
278 ensureIsValidRow( nRow );
279 ensureIsValidColumn( nColumn );
280}
281
283{
284 if( nChildIndex >= implGetChildCount() )
285 throw lang::IndexOutOfBoundsException( "child index is invalid", *this );
286}
287
288
289} // namespace accessibility
290
291
292/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AccessibleBrowseBoxObjType
::vcl::IAccessibleTableProvider * mpBrowseBox
The VCL BrowseBox control.
AccessibleBrowseBoxTableBase(const css::uno::Reference< css::accessibility::XAccessible > &rxParent, ::vcl::IAccessibleTableProvider &rBrowseBox, AccessibleBrowseBoxObjType eObjType)
Constructor sets specified name and description.
virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
void implGetSelectedRows(css::uno::Sequence< sal_Int32 > &rSeq)
Fills a sequence with sorted indexes of completely selected rows.
void implGetSelectedColumns(css::uno::Sequence< sal_Int32 > &rSeq)
Fills a sequence with sorted indexes of completely selected columns.
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual void SAL_CALL release() noexcept override
Releases the object (calls release() on base class).
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Queries for a new interface.
virtual void SAL_CALL acquire() noexcept override
Acquires the object (calls acquire() on base class).
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption() override
sal_Int32 implGetColumn(sal_Int64 nChildIndex) const
virtual sal_Int64 SAL_CALL getAccessibleIndex(sal_Int32 nRow, sal_Int32 nColumn) override
virtual sal_Int32 SAL_CALL getAccessibleColumn(sal_Int64 nChildIndex) override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual sal_Int32 SAL_CALL getAccessibleRow(sal_Int64 nChildIndex) override
sal_uInt16 implToVCLColumnPos(sal_Int32 nColumn) const
virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
void implSelectRow(sal_Int32 nRow, bool bSelect)
Selects/deselects a row (tries to expand selection).
sal_Int32 implGetRow(sal_Int64 nChildIndex) const
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary() override
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
virtual sal_Int16 SAL_CALL getAccessibleRole() override
void implSelectColumn(sal_Int32 nColumnPos, bool bSelect)
Selects/deselects a column (tries to expand selection).
virtual sal_Int32 SAL_CALL getAccessibleRowCount() override
void ensureIsValidAddress(sal_Int32 nRow, sal_Int32 nColumn)
virtual sal_Int32 SAL_CALL getAccessibleColumnCount() 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 GetSelectedColumnCount() const=0
virtual void SelectRow(sal_Int32 _nRow, bool _bSelect=true, bool bExpand=true)=0
virtual sal_Int32 GetRowCount() const=0
virtual void GetAllSelectedRows(css::uno::Sequence< sal_Int32 > &_rRows) const=0
virtual sal_uInt16 GetColumnCount() const=0
virtual bool IsRowSelected(sal_Int32 _nRow) const=0
virtual void SelectColumn(sal_uInt16 _nColumnPos, bool _bSelect=true)=0
virtual bool HasRowHeader() const=0
virtual void GetAllSelectedColumns(css::uno::Sequence< sal_Int32 > &_rColumns) const=0
virtual sal_Int32 GetSelectedRowCount() const=0
virtual bool IsColumnSelected(sal_Int32 _nColumnPos) const=0