LibreOffice Module accessibility (master) 1
AccessibleGridControlTableCell.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 <vcl/svapp.hxx>
24#include <tools/gen.hxx>
25#include <tools/debug.hxx>
26#include <com/sun/star/accessibility/AccessibleStateType.hpp>
27#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
28
29namespace accessibility
30{
31 namespace
32 {
33 // FIXME this is a copy'n'paste from
34 // source/extended/AccessibleBrowseBoxTableCell.cxx, get rid of that...
36 void checkIndex_Impl( sal_Int32 _nIndex, std::u16string_view _sText )
37 {
38 if ( _nIndex >= static_cast<sal_Int32>(_sText.size()) )
39 throw css::lang::IndexOutOfBoundsException();
40 }
41 }
42 using namespace ::com::sun::star::lang;
43 using namespace comphelper;
44 using namespace ::com::sun::star::uno;
45 using ::com::sun::star::accessibility::XAccessible;
46 using namespace ::com::sun::star::accessibility;
47 using namespace ::vcl;
48 using namespace ::vcl::table;
49
50
51 // = AccessibleGridControlCell
52
53
55 const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, ::vcl::table::IAccessibleTable& _rTable,
56 sal_Int32 _nRowPos, sal_uInt16 _nColPos, ::vcl::table::AccessibleTableControlObjType _eType )
57 :AccessibleGridControlBase( _rxParent, _rTable, _eType )
58 ,m_nRowPos( _nRowPos )
59 ,m_nColPos( _nColPos )
60 {
61 }
62
64 {
65 SolarMutexGuard aSolarGuard;
66
68 }
69
71 {
73
75
76 OUString sAccName;
83 else
84 assert(false && "Unhandled table cell type");
85 return sAccName;
86 }
87
88 // implementation of a table cell
90 {
93 }
94
96 {
98 return m_aTable.GetAccessible()->getAccessibleContext()->getLocale();
99 }
100
101 void AccessibleGridControlTableCell::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
102 {
103 nStartIndex = 0;
104 nEndIndex = 0;
105 }
106
107 AccessibleGridControlTableCell::AccessibleGridControlTableCell(const css::uno::Reference<XAccessible >& _rxParent,
109 sal_Int32 _nRowPos,
110 sal_uInt16 _nColPos)
111 :AccessibleGridControlCell( _rxParent, _rTable, _nRowPos, _nColPos, TCTYPE_TABLECELL )
112 {
113 }
114
115 // XInterface
116
119 const css::uno::Type& rType )
120 {
121 Any aRet = AccessibleGridControlCell::queryInterface(rType);
122 if ( !aRet.hasValue() )
124 return aRet;
125 }
126
129 {
130 AccessibleGridControlCell::acquire();
131 }
132
135 {
136 AccessibleGridControlCell::release();
137 }
138
139 css::awt::Rectangle SAL_CALL AccessibleGridControlTableCell::getCharacterBounds( sal_Int32 nIndex )
140 {
141 SolarMutexGuard aSolarGuard;
142
145 throw IndexOutOfBoundsException();
146
148 }
149
150 sal_Int32 SAL_CALL AccessibleGridControlTableCell::getIndexAtPoint( const css::awt::Point& _aPoint )
151 {
152 SolarMutexGuard aSolarGuard;
153
155
157 }
158
163 {
164 return "com.sun.star.accessibility.AccessibleGridControlTableCell";
165 }
166
169 {
170 return 0;
171 }
172
174 css::uno::Reference< css::accessibility::XAccessible > SAL_CALL AccessibleGridControlTableCell::getAccessibleChild( sal_Int64 )
175 {
176 throw css::lang::IndexOutOfBoundsException();
177 }
178
182 {
183 sal_Int64 nStateSet = 0;
184
185 if( isAlive() )
186 {
187 // SHOWING done with mxParent
188 if( implIsShowing() )
189 nStateSet |= AccessibleStateType::SHOWING;
190
191 m_aTable.FillAccessibleStateSetForCell( nStateSet, getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) );
192 }
193 else
194 nStateSet |= AccessibleStateType::DEFUNC;
195
196 return nStateSet;
197 }
198
199
200 // css::accessibility::XAccessible
201
203 css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL AccessibleGridControlTableCell::getAccessibleContext()
204 {
206
208 return this;
209 }
210
211 // css::accessibility::XAccessibleContext
212
214 {
215 SolarMutexGuard aSolarGuard;
216
218
219 return (static_cast<sal_Int64>(getRowPos()) * static_cast<sal_Int64>(m_aTable.GetColumnCount())) + getColumnPos();
220 }
221
223 {
224 return -1;
225 }
227 {
228 SolarMutexGuard aSolarGuard;
229
231 throw IndexOutOfBoundsException();
232
233 return false;
234 }
236 {
237 SolarMutexGuard aSolarGuard;
238
240 }
241 css::uno::Sequence< css::beans::PropertyValue > SAL_CALL AccessibleGridControlTableCell::getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& )
242 {
243 SolarMutexGuard aSolarGuard;
244
245 OUString sText( implGetText() );
246
247 if ( !implIsValidIndex( nIndex, sText.getLength() ) )
248 throw IndexOutOfBoundsException();
249
250 return css::uno::Sequence< css::beans::PropertyValue >();
251 }
253 {
254 SolarMutexGuard aSolarGuard;
255
256 return implGetText().getLength();
257 }
258
260 {
261 return OUString();
262 }
264 {
265 return 0;
266 }
268 {
269 return 0;
270 }
271 sal_Bool SAL_CALL AccessibleGridControlTableCell::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
272 {
273 SolarMutexGuard aSolarGuard;
274
275 if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
276 throw IndexOutOfBoundsException();
277
278 return false;
279 }
281 {
282 SolarMutexGuard aSolarGuard;
283
284 return implGetText( );
285 }
286 OUString SAL_CALL AccessibleGridControlTableCell::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
287 {
288 SolarMutexGuard aSolarGuard;
289
290 return OCommonAccessibleText::implGetTextRange( implGetText(), nStartIndex, nEndIndex );
291 }
292 css::accessibility::TextSegment SAL_CALL AccessibleGridControlTableCell::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType )
293 {
294 SolarMutexGuard aSolarGuard;
295
297 }
298 css::accessibility::TextSegment SAL_CALL AccessibleGridControlTableCell::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType )
299 {
300 SolarMutexGuard aSolarGuard;
301
303 }
304 css::accessibility::TextSegment SAL_CALL AccessibleGridControlTableCell::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType )
305 {
306 SolarMutexGuard aSolarGuard;
307
309 }
310 sal_Bool SAL_CALL AccessibleGridControlTableCell::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
311 {
312 SolarMutexGuard aSolarGuard;
313
314 OUString sText = implGetText();
315 checkIndex_Impl( nStartIndex, sText );
316 checkIndex_Impl( nEndIndex, sText );
317
319 return false;
320 }
321 sal_Bool SAL_CALL AccessibleGridControlTableCell::scrollSubstringTo( sal_Int32, sal_Int32, AccessibleScrollType )
322 {
323 return false;
324 }
325
327 {
329 DBG_ASSERT( pParent, "implGetBoundingBox - missing parent window" );
330 tools::Rectangle aGridRect = m_aTable.GetWindowExtentsRelative( *pParent );
333 tools::Long nX = aGridRect.Left() + aCellRect.Left();
334 tools::Long nY = aGridRect.Top() + aCellRect.Top();
335 tools::Rectangle aCell( Point( nX, nY ), aCellRect.GetSize());
336 return aCell;
337 }
338
340 {
344 tools::Long nX = aGridRect.Left() + aCellRect.Left();
345 tools::Long nY = aGridRect.Top() + aCellRect.Top();
346 tools::Rectangle aCell( Point( nX, nY ), aCellRect.GetSize());
347 return aCell;
348 }
349}
350
351/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
The GridControl accessible objects inherit from this base class.
::vcl::table::IAccessibleTable & m_aTable
The SVT Table control.
bool implIsShowing()
Determines whether the Grid control is really showing inside of its parent accessible window.
::vcl::table::AccessibleTableControlObjType m_eObjType
The type of this object (for names, descriptions, state sets, ...).
AccessibleGridControlCell(const css::uno::Reference< css::accessibility::XAccessible > &_rxParent, ::vcl::table::IAccessibleTable &_rTable, sal_Int32 _nRowPos, sal_uInt16 _nColPos, ::vcl::table::AccessibleTableControlObjType _eType)
virtual OUString SAL_CALL getAccessibleName() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 nChildIndex) override
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
virtual void SAL_CALL acquire() noexcept override
Acquires the object (calls acquire() on base class).
virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
virtual OUString SAL_CALL getTextRange(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Queries for a new interface.
virtual sal_Bool SAL_CALL setSelection(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
virtual sal_Bool SAL_CALL scrollSubstringTo(sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override
virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes(sal_Int32 nIndex, const css::uno::Sequence< OUString > &aRequestedAttributes) override
virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
AccessibleGridControlTableCell(const css::uno::Reference< css::accessibility::XAccessible > &_rxParent, ::vcl::table::IAccessibleTable &_rTable, sal_Int32 _nRowId, sal_uInt16 _nColId)
virtual tools::Rectangle implGetBoundingBox() override
Derived classes return the bounding box relative to the parent window.
virtual tools::Rectangle implGetBoundingBoxOnScreen() override
‍** Derived classes return the bounding box in screen coordinates.
virtual void SAL_CALL release() noexcept override
Releases the object (calls release() on base class).
virtual void implGetSelection(sal_Int32 &nStartIndex, sal_Int32 &nEndIndex) override final
virtual css::awt::Rectangle SAL_CALL getCharacterBounds(sal_Int32 nIndex) override
virtual sal_Unicode SAL_CALL getCharacter(sal_Int32 nIndex) override
virtual sal_Bool SAL_CALL copyText(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
virtual sal_Int32 SAL_CALL getIndexAtPoint(const css::awt::Point &aPoint) override
sal_Int64 implCreateStateSet() override
Return a bitset of states of the current object.
virtual sal_Bool SAL_CALL setCaretPosition(sal_Int32 nIndex) override
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
css::accessibility::TextSegment getTextBeforeIndex(sal_Int32 nIndex, sal_Int16 aTextType)
css::accessibility::TextSegment getTextAtIndex(sal_Int32 nIndex, sal_Int16 aTextType)
static bool implIsValidIndex(sal_Int32 nIndex, sal_Int32 nLength)
static bool implIsValidRange(sal_Int32 nStartIndex, sal_Int32 nEndIndex, sal_Int32 nLength)
static sal_Unicode implGetCharacter(std::u16string_view rText, sal_Int32 nIndex)
css::accessibility::TextSegment getTextBehindIndex(sal_Int32 nIndex, sal_Int16 aTextType)
static OUString implGetTextRange(std::u16string_view rText, sal_Int32 nStartIndex, sal_Int32 nEndIndex)
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
constexpr tools::Long Top() const
constexpr Size GetSize() const
constexpr tools::Long Left() const
virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow, sal_Int32 _nColumnPos, const Point &_rPoint)=0
virtual void GoToCell(sal_Int32 _nColumnPos, sal_Int32 _nRow)=0
virtual tools::Rectangle GetFieldCharacterBounds(sal_Int32 _nRow, sal_Int32 _nColumnPos, sal_Int32 nIndex)=0
virtual OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const=0
virtual vcl::Window * GetAccessibleParentWindow() const=0
virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessible()=0
virtual tools::Rectangle GetWindowExtentsRelative(const vcl::Window &rRelativeWindow) const=0
virtual tools::Rectangle GetWindowExtentsAbsolute() const=0
virtual tools::Rectangle calcCellRect(sal_Int32 _nRowPos, sal_Int32 _nColPos)=0
virtual sal_Int32 GetColumnCount() const=0
virtual void FillAccessibleStateSetForCell(sal_Int64 &_rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos) const=0
virtual OUString GetAccessibleObjectName(AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const=0
css::awt::Rectangle AWTRectangle(const ::tools::Rectangle &rVCLRect)
inline ::Point VCLPoint(const css::awt::Point &rAWTPoint)
#define DBG_ASSERT(sCon, aError)
sal_Int32 nIndex
double getLength(const B2DPolygon &rCandidate)
long Long
AccessibleTableControlObjType
TCTYPE_TABLECELL
TCTYPE_ROWHEADERCELL
TCTYPE_COLUMNHEADERCELL
unsigned char sal_Bool
sal_uInt16 sal_Unicode