LibreOffice Module accessibility (master) 1
AccessibleBrowseBoxTableCell.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
24#include <com/sun/star/accessibility/AccessibleStateType.hpp>
25#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
26
27namespace accessibility
28{
29 namespace
30 {
32 void checkIndex_Impl( sal_Int32 _nIndex, std::u16string_view _sText )
33 {
34 if ( _nIndex >= static_cast<sal_Int32>(_sText.size()) )
35 throw css::lang::IndexOutOfBoundsException();
36 }
37
38 sal_Int32 getIndex_Impl( sal_Int32 _nRow, sal_uInt16 _nColumn, sal_uInt16 _nColumnCount )
39 {
40 return _nRow * _nColumnCount + _nColumn;
41 }
42 }
43 using namespace ::com::sun::star::lang;
44 using namespace comphelper;
45 using namespace ::com::sun::star::uno;
46 using ::com::sun::star::accessibility::XAccessible;
47 using namespace ::com::sun::star::accessibility;
48
49
50 // implementation of a table cell
52 {
53 return mpBrowseBox->GetAccessibleCellText( getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) );
54 }
55
57 {
58 return mpBrowseBox->GetAccessible()->getAccessibleContext()->getLocale();
59 }
60
61 void AccessibleBrowseBoxTableCell::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
62 {
63 nStartIndex = 0;
64 nEndIndex = 0;
65 }
66
69 const css::uno::Reference< css::awt::XWindow >& _xFocusWindow,
70 sal_Int32 _nRowPos,
71 sal_uInt16 _nColPos,
72 sal_Int32 _nOffset )
73 :AccessibleBrowseBoxCell( _rxParent, _rBrowseBox, _xFocusWindow, _nRowPos, _nColPos )
74 {
76 sal_Int32 nIndex = getIndex_Impl( _nRowPos, _nColPos, _rBrowseBox.GetColumnCount() );
77 setAccessibleName( _rBrowseBox.GetAccessibleObjectName( AccessibleBrowseBoxObjType::TableCell, nIndex ) );
78 setAccessibleDescription( _rBrowseBox.GetAccessibleObjectDescription( AccessibleBrowseBoxObjType::TableCell, nIndex ) );
79 // Need to register as event listener
80 Reference< XComponent > xComponent(_rxParent, UNO_QUERY);
81 if( xComponent.is() )
82 xComponent->addEventListener(static_cast< XEventListener *> (this));
83 }
84
85 // XInterface -------------------------------------------------------------
86
88 css::uno::Any SAL_CALL AccessibleBrowseBoxTableCell::queryInterface( const css::uno::Type& rType )
89 {
90 Any aRet = AccessibleBrowseBoxCell::queryInterface(rType);
91 if ( !aRet.hasValue() )
93 return aRet;
94 }
95
98 {
99 AccessibleBrowseBoxCell::acquire();
100 }
101
104 {
105 AccessibleBrowseBoxCell::release();
106 }
107
108 css::awt::Rectangle SAL_CALL AccessibleBrowseBoxTableCell::getCharacterBounds( sal_Int32 nIndex )
109 {
110 SolarMethodGuard aGuard(getMutex());
112
113 css::awt::Rectangle aRect;
114
115 if ( mpBrowseBox )
116 {
118 throw IndexOutOfBoundsException();
119
121 }
122
123 return aRect;
124 }
125
126 sal_Int32 SAL_CALL AccessibleBrowseBoxTableCell::getIndexAtPoint( const css::awt::Point& _aPoint )
127 {
129 // OSL_FAIL("Need to be done by base class!");
130 SolarMethodGuard aGuard(getMutex());
132
134 }
135
140 {
141 return "com.sun.star.comp.svtools.AccessibleBrowseBoxTableCell";
142 }
143
146 {
147 return 0;
148 }
149
151 css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
153 {
154 throw css::lang::IndexOutOfBoundsException();
155 }
156
160 {
161 SolarMethodGuard aGuard(getMutex());
162
163 sal_Int64 nStateSet = 0;
164
165 if( isAlive() )
166 {
167 // SHOWING done with mxParent
168 if( implIsShowing() )
169 nStateSet |= AccessibleStateType::SHOWING;
170
171 mpBrowseBox->FillAccessibleStateSetForCell( nStateSet, getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) );
172 }
173 else
174 nStateSet |= AccessibleStateType::DEFUNC;
175
176 return nStateSet;
177 }
178
179
180 // XAccessible ------------------------------------------------------------
181
184 {
185 osl::MutexGuard aGuard( getMutex() );
187 return this;
188 }
189
190 // XAccessibleContext -----------------------------------------------------
191
193 {
194 SolarMethodGuard aGuard(getMutex());
196
197 return /*vcl::BBINDEX_FIRSTCONTROL*/ m_nOffset + (static_cast<sal_Int64>(getRowPos()) * static_cast<sal_Int64>(mpBrowseBox->GetColumnCount())) + getColumnPos();
198 }
199
201 {
202 return -1;
203 }
204
206 {
207 SolarMethodGuard aGuard(getMutex());
209
211 throw IndexOutOfBoundsException();
212
213 return false;
214 }
216 {
217 SolarMethodGuard aGuard(getMutex());
219
221 }
222 css::uno::Sequence< css::beans::PropertyValue > SAL_CALL AccessibleBrowseBoxTableCell::getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& )
223 {
224 SolarMethodGuard aGuard(getMutex());
226
227 OUString sText( implGetText() );
228
229 if ( !implIsValidIndex( nIndex, sText.getLength() ) )
230 throw IndexOutOfBoundsException();
231
232 return css::uno::Sequence< css::beans::PropertyValue >();
233 }
235 {
236 SolarMethodGuard aGuard(getMutex());
238
239 return implGetText().getLength();
240 }
241
243 {
244 SolarMethodGuard aGuard(getMutex());
246
248 }
250 {
251 SolarMethodGuard aGuard(getMutex());
253
255 }
257 {
258 SolarMethodGuard aGuard(getMutex());
260
262 }
263 sal_Bool SAL_CALL AccessibleBrowseBoxTableCell::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
264 {
265 SolarMethodGuard aGuard(getMutex());
267
268 if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
269 throw IndexOutOfBoundsException();
270
271 return false;
272 }
274 {
275 SolarMethodGuard aGuard(getMutex());
277
278 return implGetText( );
279 }
280 OUString SAL_CALL AccessibleBrowseBoxTableCell::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
281 {
282 SolarMethodGuard aGuard(getMutex());
284
285 return OCommonAccessibleText::implGetTextRange( implGetText(), nStartIndex, nEndIndex );
286 }
287 css::accessibility::TextSegment SAL_CALL AccessibleBrowseBoxTableCell::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType )
288 {
289 SolarMethodGuard aGuard(getMutex());
291
293 }
294 css::accessibility::TextSegment SAL_CALL AccessibleBrowseBoxTableCell::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType )
295 {
296 SolarMethodGuard aGuard(getMutex());
298
300 }
301 css::accessibility::TextSegment SAL_CALL AccessibleBrowseBoxTableCell::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType )
302 {
303 SolarMethodGuard aGuard(getMutex());
305
307 }
308 sal_Bool SAL_CALL AccessibleBrowseBoxTableCell::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
309 {
310 SolarMethodGuard aGuard(getMutex());
312
313 OUString sText = implGetText();
314 checkIndex_Impl( nStartIndex, sText );
315 checkIndex_Impl( nEndIndex, sText );
316
318 return false;
319 }
320 sal_Bool SAL_CALL AccessibleBrowseBoxTableCell::scrollSubstringTo( sal_Int32, sal_Int32, AccessibleScrollType )
321 {
322 return false;
323 }
324 void AccessibleBrowseBoxTableCell::disposing( const EventObject& _rSource )
325 {
326 if ( _rSource.Source == mxParent )
327 {
328 dispose();
329 }
330 }
331
332}
333
334/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define OFFSET_DEFAULT
::vcl::IAccessibleTableProvider * mpBrowseBox
The VCL BrowseBox control.
void setAccessibleDescription(const OUString &rDescription)
Changes the description of the object and notifies listeners.
void setAccessibleName(const OUString &rName)
Changes the name of the object and notifies listeners.
bool implIsShowing()
Determines whether the BrowseBox control is really showing inside of its parent accessible window.
css::uno::Reference< css::accessibility::XAccessible > mxParent
The parent accessible object.
common accessibility-functionality for browse box elements which occupy a cell
virtual sal_Int32 SAL_CALL getSelectionStart() override
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
virtual sal_Bool SAL_CALL setSelection(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
virtual sal_Int32 SAL_CALL getCharacterCount() override
virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
virtual OUString SAL_CALL getImplementationName() override
virtual OUString SAL_CALL getText() final override
virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
AccessibleBrowseBoxTableCell(const css::uno::Reference< css::accessibility::XAccessible > &_rxParent, ::vcl::IAccessibleTableProvider &_rBrowseBox, const css::uno::Reference< css::awt::XWindow > &_xFocusWindow, sal_Int32 _nRowId, sal_uInt16 _nColId, sal_Int32 _nOffset)
virtual sal_Unicode SAL_CALL getCharacter(sal_Int32 nIndex) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 nChildIndex) override
virtual void SAL_CALL release() noexcept override
Releases the object (calls release() on base class).
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Queries for a new interface.
virtual OUString SAL_CALL getSelectedText() override
virtual sal_Bool SAL_CALL scrollSubstringTo(sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override
virtual void SAL_CALL acquire() noexcept override
Acquires the object (calls acquire() on base class).
virtual void implGetSelection(sal_Int32 &nStartIndex, sal_Int32 &nEndIndex) override
virtual sal_Int32 SAL_CALL getSelectionEnd() override
virtual void SAL_CALL disposing() override
Commits DeFunc event to listeners and cleans up members.
virtual sal_Int32 SAL_CALL getCaretPosition() override
virtual css::awt::Rectangle SAL_CALL getCharacterBounds(sal_Int32 nIndex) override
virtual sal_Bool SAL_CALL copyText(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override
virtual css::lang::Locale implGetLocale() override
virtual OUString SAL_CALL getTextRange(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes(sal_Int32 nIndex, const css::uno::Sequence< OUString > &aRequestedAttributes) 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
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
virtual void FillAccessibleStateSetForCell(sal_Int64 &_rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos) const=0
virtual sal_uInt16 GetColumnCount() const=0
virtual tools::Rectangle GetFieldCharacterBounds(sal_Int32 _nRow, sal_Int32 _nColumnPos, sal_Int32 nIndex)=0
virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow, sal_Int32 _nColumnPos, const Point &_rPoint)=0
virtual OUString GetAccessibleObjectName(AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos=-1) const=0
virtual OUString GetAccessibleCellText(sal_Int32 _nRow, sal_uInt16 _nColumnPos) const=0
virtual OUString GetAccessibleObjectDescription(AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos=-1) const=0
virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessible()=0
css::awt::Rectangle AWTRectangle(const ::tools::Rectangle &rVCLRect)
inline ::Point VCLPoint(const css::awt::Point &rAWTPoint)
sal_Int32 _nOffset
sal_Int32 nIndex
double getLength(const B2DPolygon &rCandidate)
void dispose()
BBINDEX_FIRSTCONTROL
unsigned char sal_Bool
sal_uInt16 sal_Unicode