tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / accessibility / source / extended / AccessibleBrowseBoxHeaderBar.cxx
blob3918c455130833ff98a86901e10971f41642d436
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <extended/AccessibleBrowseBoxHeaderBar.hxx>
21 #include <vcl/accessibletableprovider.hxx>
22 #include <vcl/unohelp.hxx>
23 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
25 using ::com::sun::star::uno::Reference;
26 using ::com::sun::star::uno::Sequence;
27 using ::com::sun::star::uno::Any;
29 using namespace ::com::sun::star;
30 using namespace ::com::sun::star::accessibility;
33 namespace accessibility {
36 // Ctor/Dtor/disposing --------------------------------------------------------
38 AccessibleBrowseBoxHeaderBar::AccessibleBrowseBoxHeaderBar(
39 const Reference< XAccessible >& rxParent,
40 vcl::IAccessibleTableProvider& rBrowseBox,
41 AccessibleBrowseBoxObjType eObjType ) :
42 AccessibleBrowseBoxTableBase( rxParent, rBrowseBox,eObjType )
44 OSL_ENSURE( isRowBar() || isColumnBar(),
45 "extended/AccessibleBrowseBoxHeaderBar - invalid object type" );
48 AccessibleBrowseBoxHeaderBar::~AccessibleBrowseBoxHeaderBar()
52 // XAccessibleContext ---------------------------------------------------------
54 Reference< XAccessible > SAL_CALL
55 AccessibleBrowseBoxHeaderBar::getAccessibleChild( sal_Int64 nChildIndex )
57 SolarMethodGuard aGuard(getMutex());
58 ensureIsAlive();
60 ensureIsValidHeaderIndex( nChildIndex );
61 return implGetChild( nChildIndex, implToVCLColumnPos( nChildIndex ) );
64 sal_Int64 SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleIndexInParent()
66 return isRowBar() ? vcl::BBINDEX_ROWHEADERBAR : vcl::BBINDEX_COLUMNHEADERBAR;
69 // XAccessibleComponent -------------------------------------------------------
71 Reference< XAccessible > SAL_CALL
72 AccessibleBrowseBoxHeaderBar::getAccessibleAtPoint( const awt::Point& rPoint )
74 SolarMethodGuard aGuard(getMutex());
75 ensureIsAlive();
77 sal_Int32 nRow = 0;
78 sal_uInt16 nColumnPos = 0;
79 bool bConverted
80 = isRowBar()
81 ? mpBrowseBox->ConvertPointToRowHeader(nRow, vcl::unohelper::ConvertToVCLPoint(rPoint))
82 : mpBrowseBox->ConvertPointToColumnHeader(nColumnPos,
83 vcl::unohelper::ConvertToVCLPoint(rPoint));
85 return bConverted ? implGetChild( nRow, nColumnPos ) : Reference< XAccessible >();
88 void SAL_CALL AccessibleBrowseBoxHeaderBar::grabFocus()
90 SolarMethodGuard aGuard(getMutex());
92 ensureIsAlive();
93 // focus on header not supported
96 // XAccessibleTable -----------------------------------------------------------
98 OUString SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleRowDescription( sal_Int32 nRow )
100 SolarMethodGuard aGuard(getMutex());
102 ensureIsAlive();
103 ensureIsValidRow( nRow );
104 return OUString(); // no headers in headers
107 OUString SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleColumnDescription( sal_Int32 nColumn )
109 SolarMethodGuard aGuard(getMutex());
111 ensureIsAlive();
112 ensureIsValidColumn( nColumn );
113 return OUString(); // no headers in headers
116 Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleRowHeaders()
118 SolarMethodGuard aGuard(getMutex());
120 ensureIsAlive();
121 return nullptr; // no headers in headers
124 Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleColumnHeaders()
126 SolarMethodGuard aGuard(getMutex());
128 ensureIsAlive();
129 return nullptr; // no headers in headers
132 Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxHeaderBar::getSelectedAccessibleRows()
134 SolarMethodGuard aGuard(getMutex());
135 ensureIsAlive();
137 Sequence< sal_Int32 > aSelSeq;
138 // row of column header bar not selectable
139 if( isRowBar() )
140 implGetSelectedRows( aSelSeq );
141 return aSelSeq;
144 Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxHeaderBar::getSelectedAccessibleColumns()
146 SolarMethodGuard aGuard(getMutex());
147 ensureIsAlive();
149 Sequence< sal_Int32 > aSelSeq;
150 // column of row header bar ("handle column") not selectable
151 if( isColumnBar() )
152 implGetSelectedColumns( aSelSeq );
153 return aSelSeq;
156 sal_Bool SAL_CALL AccessibleBrowseBoxHeaderBar::isAccessibleRowSelected( sal_Int32 nRow )
158 SolarMethodGuard aGuard(getMutex());
160 ensureIsAlive();
161 ensureIsValidRow( nRow );
162 return isRowBar() && implIsRowSelected( nRow );
165 sal_Bool SAL_CALL AccessibleBrowseBoxHeaderBar::isAccessibleColumnSelected( sal_Int32 nColumn )
167 SolarMethodGuard aGuard(getMutex());
169 ensureIsAlive();
170 ensureIsValidColumn( nColumn );
171 return isColumnBar() && implIsColumnSelected( nColumn );
174 Reference< XAccessible > SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleCellAt(
175 sal_Int32 nRow, sal_Int32 nColumn )
177 SolarMethodGuard aGuard(getMutex());
179 ensureIsAlive();
180 ensureIsValidAddress( nRow, nColumn );
182 return implGetChild( nRow, implToVCLColumnPos( nColumn ) );
185 sal_Bool SAL_CALL AccessibleBrowseBoxHeaderBar::isAccessibleSelected(
186 sal_Int32 nRow, sal_Int32 nColumn )
188 SolarMethodGuard aGuard(getMutex());
189 ensureIsAlive();
191 ensureIsValidAddress( nRow, nColumn );
192 return isRowBar() ? implIsRowSelected( nRow ) : implIsColumnSelected( nColumn );
195 // XAccessibleSelection -------------------------------------------------------
197 void SAL_CALL AccessibleBrowseBoxHeaderBar::selectAccessibleChild( sal_Int64 nChildIndex )
199 SolarMethodGuard aGuard(getMutex());
200 ensureIsAlive();
202 ensureIsValidHeaderIndex( nChildIndex );
203 if( isRowBar() )
204 implSelectRow( nChildIndex, true );
205 else
206 implSelectColumn( implToVCLColumnPos( nChildIndex ), true );
209 sal_Bool SAL_CALL AccessibleBrowseBoxHeaderBar::isAccessibleChildSelected( sal_Int64 nChildIndex )
211 // using interface methods - no mutex
212 return isRowBar() ?
213 isAccessibleRowSelected( nChildIndex ) :
214 isAccessibleColumnSelected( nChildIndex );
217 void SAL_CALL AccessibleBrowseBoxHeaderBar::clearAccessibleSelection()
219 SolarMethodGuard aGuard(getMutex());
220 ensureIsAlive();
222 mpBrowseBox->SetNoSelection();
225 void SAL_CALL AccessibleBrowseBoxHeaderBar::selectAllAccessibleChildren()
227 SolarMethodGuard aGuard(getMutex());
228 ensureIsAlive();
230 // no multiselection of columns possible
231 if( isRowBar() )
232 mpBrowseBox->SelectAll();
233 else
234 implSelectColumn( implToVCLColumnPos( 0 ), true );
237 sal_Int64 SAL_CALL AccessibleBrowseBoxHeaderBar::getSelectedAccessibleChildCount()
239 SolarMethodGuard aGuard(getMutex());
240 ensureIsAlive();
242 return isRowBar() ? implGetSelectedRowCount() : implGetSelectedColumnCount();
245 Reference< XAccessible > SAL_CALL
246 AccessibleBrowseBoxHeaderBar::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex )
248 SolarMethodGuard aGuard(getMutex());
249 ensureIsAlive();
251 // method may throw lang::IndexOutOfBoundsException
252 sal_Int64 nIndex = implGetChildIndexFromSelectedIndex( nSelectedChildIndex );
253 assert(nIndex < std::numeric_limits<sal_Int32>::max());
254 return implGetChild( nIndex, implToVCLColumnPos( nIndex ) );
257 void SAL_CALL AccessibleBrowseBoxHeaderBar::deselectAccessibleChild(
258 sal_Int64 nSelectedChildIndex )
260 SolarMethodGuard aGuard(getMutex());
261 ensureIsAlive();
263 // method may throw lang::IndexOutOfBoundsException
264 if ( isAccessibleChildSelected(nSelectedChildIndex) )
266 if( isRowBar() )
267 implSelectRow( nSelectedChildIndex, false );
268 else
269 implSelectColumn( implToVCLColumnPos( nSelectedChildIndex ), false );
273 // XInterface -----------------------------------------------------------------
275 Any SAL_CALL AccessibleBrowseBoxHeaderBar::queryInterface( const uno::Type& rType )
277 Any aAny( AccessibleBrowseBoxTableBase::queryInterface( rType ) );
278 return aAny.hasValue() ?
279 aAny : AccessibleBrowseBoxHeaderBarImplHelper::queryInterface( rType );
282 void SAL_CALL AccessibleBrowseBoxHeaderBar::acquire() noexcept
284 AccessibleBrowseBoxTableBase::acquire();
287 void SAL_CALL AccessibleBrowseBoxHeaderBar::release() noexcept
289 AccessibleBrowseBoxTableBase::release();
292 // XServiceInfo ---------------------------------------------------------------
294 OUString SAL_CALL AccessibleBrowseBoxHeaderBar::getImplementationName()
296 return u"com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderBar"_ustr;
299 Sequence< sal_Int8 > SAL_CALL AccessibleBrowseBoxHeaderBar::getImplementationId()
301 return css::uno::Sequence<sal_Int8>();
304 // internal virtual methods ---------------------------------------------------
306 tools::Rectangle AccessibleBrowseBoxHeaderBar::implGetBoundingBox()
308 return mpBrowseBox->calcHeaderRect(isColumnBar(), false);
311 AbsoluteScreenPixelRectangle AccessibleBrowseBoxHeaderBar::implGetBoundingBoxOnScreen()
313 return AbsoluteScreenPixelRectangle(mpBrowseBox->calcHeaderRect(isColumnBar()));
316 sal_Int32 AccessibleBrowseBoxHeaderBar::implGetRowCount() const
318 // column header bar: only 1 row
319 return isRowBar() ? AccessibleBrowseBoxTableBase::implGetRowCount() : 1;
322 sal_Int32 AccessibleBrowseBoxHeaderBar::implGetColumnCount() const
324 // row header bar ("handle column"): only 1 column
325 return isColumnBar() ? AccessibleBrowseBoxTableBase::implGetColumnCount() : 1;
328 // internal helper methods ----------------------------------------------------
330 Reference< XAccessible > AccessibleBrowseBoxHeaderBar::implGetChild(
331 sal_Int32 nRow, sal_uInt16 nColumnPos )
333 return isRowBar() ?
334 mpBrowseBox->CreateAccessibleRowHeader( nRow ) :
335 mpBrowseBox->CreateAccessibleColumnHeader( nColumnPos );
338 sal_Int64 AccessibleBrowseBoxHeaderBar::implGetChildIndexFromSelectedIndex(
339 sal_Int64 nSelectedChildIndex )
341 Sequence< sal_Int32 > aSelSeq;
342 if( isRowBar() )
343 implGetSelectedRows( aSelSeq );
344 else
345 implGetSelectedColumns( aSelSeq );
347 if( (nSelectedChildIndex < 0) || (nSelectedChildIndex >= aSelSeq.getLength()) )
348 throw lang::IndexOutOfBoundsException();
350 return aSelSeq[ nSelectedChildIndex ];
353 void AccessibleBrowseBoxHeaderBar::ensureIsValidHeaderIndex( sal_Int32 nIndex )
355 if( isRowBar() )
356 ensureIsValidRow( nIndex );
357 else
358 ensureIsValidColumn( nIndex );
362 } // namespace accessibility
365 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */