LibreOffice Module accessibility (master) 1
AccessibleBrowseBox.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/lang/IndexOutOfBoundsException.hpp>
24#include <utility>
28#include <sal/types.h>
29
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;
38
39// Ctor/Dtor/disposing
40
42 const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, const css::uno::Reference< css::accessibility::XAccessible >& _rxCreator,
44 : AccessibleBrowseBoxBase( _rxParent, _rBrowseBox,nullptr, AccessibleBrowseBoxObjType::BrowseBox ),
45 m_aCreator(_rxCreator)
46{
48}
49
50void AccessibleBrowseBox::setCreator( const css::uno::Reference< css::accessibility::XAccessible >& _rxCreator )
51{
52#if OSL_DEBUG_LEVEL > 0
53 css::uno::Reference< css::accessibility::XAccessible > xCreator(m_aCreator);
54 OSL_ENSURE( !xCreator.is(), "extended/AccessibleBrowseBox::setCreator: creator already set!" );
55#endif
56 m_aCreator = _rxCreator;
57}
58
59
61{
62}
63
64
66{
67 ::osl::MutexGuard aGuard( getMutex() );
68
69 m_aCreator.clear();
70
71 if ( mxTable.is() )
72 {
73 mxTable->dispose();
74 mxTable.clear();
75 }
76 if ( mxRowHeaderBar.is() )
77 {
78 mxRowHeaderBar->dispose();
79 mxRowHeaderBar.clear();
80 }
81 if ( mxColumnHeaderBar.is() )
82 {
83 mxColumnHeaderBar->dispose();
84 mxColumnHeaderBar.clear();
85 }
86
88}
89
90
91// css::accessibility::XAccessibleContext
92
94{
95 SolarMethodGuard aGuard(getMutex());
97
99}
100
101
102css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
104{
105 SolarMethodGuard aGuard(getMutex());
107
108 if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
109 throw lang::IndexOutOfBoundsException();
110
111 css::uno::Reference< css::accessibility::XAccessible > xRet;
112 if( nChildIndex >= 0 )
113 {
114 if( nChildIndex < vcl::BBINDEX_FIRSTCONTROL )
115 xRet = implGetFixedChild( nChildIndex );
116 else
117 {
118 // additional controls
119 nChildIndex -= vcl::BBINDEX_FIRSTCONTROL;
120 if( nChildIndex < mpBrowseBox->GetAccessibleControlCount() )
121 xRet = mpBrowseBox->CreateAccessibleControl( nChildIndex );
122 }
123 }
124
125 if( !xRet.is() )
126 throw lang::IndexOutOfBoundsException();
127 return xRet;
128}
129
130// css::accessibility::XAccessibleComponent
131
132css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
134{
135 SolarMethodGuard aGuard(getMutex());
137
138 css::uno::Reference< css::accessibility::XAccessible > xChild;
139 sal_Int32 nIndex = 0;
142 else
143 {
144 // try whether point is in one of the fixed children
145 // (table, header bars, corner control)
146 Point aPoint( VCLPoint( rPoint ) );
147 for( nIndex = 0; (nIndex < vcl::BBINDEX_FIRSTCONTROL) && !xChild.is(); ++nIndex )
148 {
149 css::uno::Reference< css::accessibility::XAccessible > xCurrChild( implGetFixedChild( nIndex ) );
150 css::uno::Reference< css::accessibility::XAccessibleComponent >
151 xCurrChildComp( xCurrChild, uno::UNO_QUERY );
152
153 if( xCurrChildComp.is() &&
154 VCLRectangle( xCurrChildComp->getBounds() ).Contains( aPoint ) )
155 xChild = xCurrChild;
156 }
157 }
158 return xChild;
159}
160
161
163{
164 SolarMethodGuard aGuard(getMutex());
166
168}
169
170// XServiceInfo
171
173{
174 return "com.sun.star.comp.svtools.AccessibleBrowseBox";
175}
176
177
178// internal virtual methods
179
181{
183 OSL_ENSURE( pParent, "implGetBoundingBox - missing parent window" );
184 return mpBrowseBox->GetWindowExtentsRelative( *pParent );
185}
186
187
189{
191}
192
193// internal helper methods
194css::uno::Reference< css::accessibility::XAccessible > AccessibleBrowseBox::implGetTable()
195{
196 if( !mxTable.is() )
197 {
199
200 }
201 return mxTable;
202}
203
204css::uno::Reference< css::accessibility::XAccessible >
206{
207 css::uno::Reference< css::accessibility::XAccessible > xRet;
209
210 if( eObjType == AccessibleBrowseBoxObjType::RowHeaderBar )
211 pxMember = &mxRowHeaderBar;
212 else if( eObjType == AccessibleBrowseBoxObjType::ColumnHeaderBar )
213 pxMember = &mxColumnHeaderBar;
214
215 if( pxMember )
216 {
217 if( !pxMember->is() )
218 {
220 m_aCreator, *mpBrowseBox, eObjType );
221 *pxMember = pHeaderBar;
222 }
223 xRet = pxMember->get();
224 }
225 return xRet;
226}
227
228css::uno::Reference< css::accessibility::XAccessible >
230{
231 css::uno::Reference< css::accessibility::XAccessible > xRet;
232 switch( nChildIndex )
233 {
235 xRet = implGetHeaderBar( AccessibleBrowseBoxObjType::ColumnHeaderBar );
236 break;
238 xRet = implGetHeaderBar( AccessibleBrowseBoxObjType::RowHeaderBar );
239 break;
241 xRet = implGetTable();
242 break;
243 }
244 return xRet;
245}
246
248{
249 css::uno::Reference< css::accessibility::XAccessible > xCreator(m_aCreator);
250 OSL_ENSURE( xCreator.is(), "extended/AccessibleBrowseBox::createAccessibleTable: my creator died - how this?" );
251 return new AccessibleBrowseBoxTable( xCreator, *mpBrowseBox );
252}
253
254void AccessibleBrowseBox::commitTableEvent(sal_Int16 _nEventId,const Any& _rNewValue,const Any& _rOldValue)
255{
256 if ( mxTable.is() )
257 {
258 mxTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
259 }
260}
261
263 const Any& _rNewValue,
264 const Any& _rOldValue,bool _bColumnHeaderBar)
265{
267 if ( xHeaderBar.is() )
268 xHeaderBar->commitEvent(_nEventId,_rNewValue,_rOldValue);
269}
270
271
272// = AccessibleBrowseBoxAccess
273
274AccessibleBrowseBoxAccess::AccessibleBrowseBoxAccess( css::uno::Reference< css::accessibility::XAccessible > _xParent, ::vcl::IAccessibleTableProvider& _rBrowseBox )
275 :m_xParent(std::move( _xParent ))
276 ,m_rBrowseBox( _rBrowseBox )
277{
278}
279
280
282{
283}
284
285
287{
288 std::unique_lock aGuard( m_aMutex );
289
290 if (m_xContext.is())
291 {
292 m_xContext->dispose();
293 m_xContext.clear();
294 }
295}
296
297
298css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL AccessibleBrowseBoxAccess::getAccessibleContext()
299{
300 std::unique_lock aGuard( m_aMutex );
301
302 // if the context died meanwhile (there is no listener, so it won't tell us explicitly when this happens),
303 // then reset and re-create.
304 if ( m_xContext.is() && !m_xContext->isAlive() )
305 m_xContext = nullptr;
306
307 if ( !m_xContext.is() )
309
310 return m_xContext;
311}
312
313
314
315} // namespace accessibility
316
317/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AccessibleBrowseBoxObjType
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
AccessibleBrowseBoxAccess(css::uno::Reference< css::accessibility::XAccessible > _xParent, ::vcl::IAccessibleTableProvider &_rBrowseBox)
::vcl::IAccessibleTableProvider & m_rBrowseBox
css::uno::Reference< css::accessibility::XAccessible > m_xParent
rtl::Reference< AccessibleBrowseBox > m_xContext
The BrowseBox accessible objects inherit from this base class.
::vcl::IAccessibleTableProvider * mpBrowseBox
The VCL BrowseBox control.
css::uno::Reference< css::awt::XWindow > m_xFocusWindow
This is the window which get all the nice focus events.
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 BrowseBox control (row or column hea...
This class represents the accessible object of the data table of a BrowseBox control.
This class represents the complete accessible BrowseBox object.
virtual tools::Rectangle implGetBoundingBoxOnScreen() override
css::uno::Reference< css::accessibility::XAccessible > implGetTable()
This method creates (once) and returns the accessible data table child.
css::uno::WeakReference< css::accessibility::XAccessible > m_aCreator
the css::accessibility::XAccessible which created the AccessibleBrowseBox
virtual rtl::Reference< AccessibleBrowseBoxTable > createAccessibleTable()
This method creates and returns an accessible table.
AccessibleBrowseBox(const css::uno::Reference< css::accessibility::XAccessible > &_rxParent, const css::uno::Reference< css::accessibility::XAccessible > &_rxCreator, ::vcl::IAccessibleTableProvider &_rBrowseBox)
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...
void setCreator(const css::uno::Reference< css::accessibility::XAccessible > &_rxCreator)
sets the XAccessible which created the context
virtual tools::Rectangle implGetBoundingBox() override
rtl::Reference< AccessibleBrowseBoxHeaderBar > mxColumnHeaderBar
The header bar for columns (first row of the table).
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 nChildIndex) override
rtl::Reference< AccessibleBrowseBoxTable > mxTable
The data table child.
void commitHeaderBarEvent(sal_Int16 nEventId, const css::uno::Any &rNewValue, const css::uno::Any &rOldValue, bool _bColumnHeaderBar)
commitHeaderBarEvent commit the event at all listeners of the column/row header bar
virtual void SAL_CALL disposing() override
Commits DeFunc event to listeners and cleans up members.
virtual void SAL_CALL grabFocus() override
Grabs the focus to the BrowseBox.
rtl::Reference< AccessibleBrowseBoxHeaderBar > mxRowHeaderBar
The header bar for rows ("handle column").
css::uno::Reference< css::accessibility::XAccessible > implGetHeaderBar(AccessibleBrowseBoxObjType eObjType)
This method creates (once) and returns the specified header bar.
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &rPoint) override
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
bool Contains(const Point &rPOINT) const
virtual vcl::Window * GetWindowInstance()=0
virtual tools::Rectangle GetWindowExtentsRelative(const vcl::Window &rRelativeWindow) const=0
virtual vcl::Window * GetAccessibleParentWindow() const=0
virtual sal_Int32 GetAccessibleControlCount() const=0
virtual tools::Rectangle GetWindowExtentsAbsolute() const=0
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleControl(sal_Int32 _nIndex)=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
BBINDEX_FIRSTCONTROL
BBINDEX_TABLE
BBINDEX_COLUMNHEADERBAR
BBINDEX_ROWHEADERBAR