1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
23 using ::com::sun::star::uno::Reference
;
24 using ::com::sun::star::uno::Sequence
;
25 using ::com::sun::star::uno::Any
;
27 using namespace ::com::sun::star
;
28 using namespace ::com::sun::star::accessibility
;
29 using namespace ::svt
;
32 namespace accessibility
{
35 // Ctor/Dtor/disposing --------------------------------------------------------
37 AccessibleBrowseBoxHeaderBar::AccessibleBrowseBoxHeaderBar(
38 const Reference
< XAccessible
>& rxParent
,
39 vcl::IAccessibleTableProvider
& rBrowseBox
,
40 vcl::AccessibleBrowseBoxObjType eObjType
) :
41 AccessibleBrowseBoxTableBase( rxParent
, rBrowseBox
,eObjType
)
43 OSL_ENSURE( isRowBar() || isColumnBar(),
44 "extended/AccessibleBrowseBoxHeaderBar - invalid object type" );
47 AccessibleBrowseBoxHeaderBar::~AccessibleBrowseBoxHeaderBar()
51 // XAccessibleContext ---------------------------------------------------------
53 Reference
< XAccessible
> SAL_CALL
54 AccessibleBrowseBoxHeaderBar::getAccessibleChild( sal_Int32 nChildIndex
)
56 SolarMethodGuard
aGuard(getMutex());
59 ensureIsValidHeaderIndex( nChildIndex
);
60 return implGetChild( nChildIndex
, implToVCLColumnPos( nChildIndex
) );
63 sal_Int32 SAL_CALL
AccessibleBrowseBoxHeaderBar::getAccessibleIndexInParent()
65 return isRowBar() ? vcl::BBINDEX_ROWHEADERBAR
: vcl::BBINDEX_COLUMNHEADERBAR
;
68 // XAccessibleComponent -------------------------------------------------------
70 Reference
< XAccessible
> SAL_CALL
71 AccessibleBrowseBoxHeaderBar::getAccessibleAtPoint( const awt::Point
& rPoint
)
73 SolarMethodGuard
aGuard(getMutex());
77 sal_uInt16 nColumnPos
= 0;
78 bool bConverted
= isRowBar() ?
79 mpBrowseBox
->ConvertPointToRowHeader( nRow
, VCLPoint( rPoint
) ) :
80 mpBrowseBox
->ConvertPointToColumnHeader( nColumnPos
, VCLPoint( rPoint
) );
82 return bConverted
? implGetChild( nRow
, nColumnPos
) : Reference
< XAccessible
>();
85 void SAL_CALL
AccessibleBrowseBoxHeaderBar::grabFocus()
87 SolarMethodGuard
aGuard(getMutex());
90 // focus on header not supported
93 // XAccessibleTable -----------------------------------------------------------
95 OUString SAL_CALL
AccessibleBrowseBoxHeaderBar::getAccessibleRowDescription( sal_Int32 nRow
)
97 SolarMethodGuard
aGuard(getMutex());
100 ensureIsValidRow( nRow
);
101 return OUString(); // no headers in headers
104 OUString SAL_CALL
AccessibleBrowseBoxHeaderBar::getAccessibleColumnDescription( sal_Int32 nColumn
)
106 SolarMethodGuard
aGuard(getMutex());
109 ensureIsValidColumn( nColumn
);
110 return OUString(); // no headers in headers
113 Reference
< XAccessibleTable
> SAL_CALL
AccessibleBrowseBoxHeaderBar::getAccessibleRowHeaders()
115 SolarMethodGuard
aGuard(getMutex());
118 return nullptr; // no headers in headers
121 Reference
< XAccessibleTable
> SAL_CALL
AccessibleBrowseBoxHeaderBar::getAccessibleColumnHeaders()
123 SolarMethodGuard
aGuard(getMutex());
126 return nullptr; // no headers in headers
129 Sequence
< sal_Int32
> SAL_CALL
AccessibleBrowseBoxHeaderBar::getSelectedAccessibleRows()
131 SolarMethodGuard
aGuard(getMutex());
134 Sequence
< sal_Int32
> aSelSeq
;
135 // row of column header bar not selectable
137 implGetSelectedRows( aSelSeq
);
141 Sequence
< sal_Int32
> SAL_CALL
AccessibleBrowseBoxHeaderBar::getSelectedAccessibleColumns()
143 SolarMethodGuard
aGuard(getMutex());
146 Sequence
< sal_Int32
> aSelSeq
;
147 // column of row header bar ("handle column") not selectable
149 implGetSelectedColumns( aSelSeq
);
153 sal_Bool SAL_CALL
AccessibleBrowseBoxHeaderBar::isAccessibleRowSelected( sal_Int32 nRow
)
155 SolarMethodGuard
aGuard(getMutex());
158 ensureIsValidRow( nRow
);
159 return isRowBar() && implIsRowSelected( nRow
);
162 sal_Bool SAL_CALL
AccessibleBrowseBoxHeaderBar::isAccessibleColumnSelected( sal_Int32 nColumn
)
164 SolarMethodGuard
aGuard(getMutex());
167 ensureIsValidColumn( nColumn
);
168 return isColumnBar() && implIsColumnSelected( nColumn
);
171 Reference
< XAccessible
> SAL_CALL
AccessibleBrowseBoxHeaderBar::getAccessibleCellAt(
172 sal_Int32 nRow
, sal_Int32 nColumn
)
174 SolarMethodGuard
aGuard(getMutex());
177 ensureIsValidAddress( nRow
, nColumn
);
179 return implGetChild( nRow
, implToVCLColumnPos( nColumn
) );
182 sal_Bool SAL_CALL
AccessibleBrowseBoxHeaderBar::isAccessibleSelected(
183 sal_Int32 nRow
, sal_Int32 nColumn
)
185 SolarMethodGuard
aGuard(getMutex());
188 ensureIsValidAddress( nRow
, nColumn
);
189 return isRowBar() ? implIsRowSelected( nRow
) : implIsColumnSelected( nColumn
);
192 // XAccessibleSelection -------------------------------------------------------
194 void SAL_CALL
AccessibleBrowseBoxHeaderBar::selectAccessibleChild( sal_Int32 nChildIndex
)
196 SolarMethodGuard
aGuard(getMutex());
199 ensureIsValidHeaderIndex( nChildIndex
);
201 implSelectRow( nChildIndex
, true );
203 implSelectColumn( implToVCLColumnPos( nChildIndex
), true );
206 sal_Bool SAL_CALL
AccessibleBrowseBoxHeaderBar::isAccessibleChildSelected( sal_Int32 nChildIndex
)
208 // using interface methods - no mutex
210 isAccessibleRowSelected( nChildIndex
) :
211 isAccessibleColumnSelected( nChildIndex
);
214 void SAL_CALL
AccessibleBrowseBoxHeaderBar::clearAccessibleSelection()
216 SolarMethodGuard
aGuard(getMutex());
219 mpBrowseBox
->SetNoSelection();
222 void SAL_CALL
AccessibleBrowseBoxHeaderBar::selectAllAccessibleChildren()
224 SolarMethodGuard
aGuard(getMutex());
227 // no multiselection of columns possible
229 mpBrowseBox
->SelectAll();
231 implSelectColumn( implToVCLColumnPos( 0 ), true );
234 sal_Int32 SAL_CALL
AccessibleBrowseBoxHeaderBar::getSelectedAccessibleChildCount()
236 SolarMethodGuard
aGuard(getMutex());
239 return isRowBar() ? implGetSelectedRowCount() : implGetSelectedColumnCount();
242 Reference
< XAccessible
> SAL_CALL
243 AccessibleBrowseBoxHeaderBar::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
)
245 SolarMethodGuard
aGuard(getMutex());
248 // method may throw lang::IndexOutOfBoundsException
249 sal_Int32 nIndex
= implGetChildIndexFromSelectedIndex( nSelectedChildIndex
);
250 return implGetChild( nIndex
, implToVCLColumnPos( nIndex
) );
253 void SAL_CALL
AccessibleBrowseBoxHeaderBar::deselectAccessibleChild(
254 sal_Int32 nSelectedChildIndex
)
256 SolarMethodGuard
aGuard(getMutex());
259 // method may throw lang::IndexOutOfBoundsException
260 if ( isAccessibleChildSelected(nSelectedChildIndex
) )
263 implSelectRow( nSelectedChildIndex
, false );
265 implSelectColumn( implToVCLColumnPos( nSelectedChildIndex
), false );
269 // XInterface -----------------------------------------------------------------
271 Any SAL_CALL
AccessibleBrowseBoxHeaderBar::queryInterface( const uno::Type
& rType
)
273 Any
aAny( AccessibleBrowseBoxTableBase::queryInterface( rType
) );
274 return aAny
.hasValue() ?
275 aAny
: AccessibleBrowseBoxHeaderBarImplHelper::queryInterface( rType
);
278 void SAL_CALL
AccessibleBrowseBoxHeaderBar::acquire() throw ()
280 AccessibleBrowseBoxTableBase::acquire();
283 void SAL_CALL
AccessibleBrowseBoxHeaderBar::release() throw ()
285 AccessibleBrowseBoxTableBase::release();
288 // XServiceInfo ---------------------------------------------------------------
290 OUString SAL_CALL
AccessibleBrowseBoxHeaderBar::getImplementationName()
292 return OUString( "com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderBar" );
295 Sequence
< sal_Int8
> SAL_CALL
AccessibleBrowseBoxHeaderBar::getImplementationId()
297 return css::uno::Sequence
<sal_Int8
>();
300 // internal virtual methods ---------------------------------------------------
302 tools::Rectangle
AccessibleBrowseBoxHeaderBar::implGetBoundingBox()
304 return mpBrowseBox
->calcHeaderRect(isColumnBar(), false);
307 tools::Rectangle
AccessibleBrowseBoxHeaderBar::implGetBoundingBoxOnScreen()
309 return mpBrowseBox
->calcHeaderRect(isColumnBar());
312 sal_Int32
AccessibleBrowseBoxHeaderBar::implGetRowCount() const
314 // column header bar: only 1 row
315 return isRowBar() ? AccessibleBrowseBoxTableBase::implGetRowCount() : 1;
318 sal_Int32
AccessibleBrowseBoxHeaderBar::implGetColumnCount() const
320 // row header bar ("handle column"): only 1 column
321 return isColumnBar() ? AccessibleBrowseBoxTableBase::implGetColumnCount() : 1;
324 // internal helper methods ----------------------------------------------------
326 Reference
< XAccessible
> AccessibleBrowseBoxHeaderBar::implGetChild(
327 sal_Int32 nRow
, sal_uInt16 nColumnPos
)
330 mpBrowseBox
->CreateAccessibleRowHeader( nRow
) :
331 mpBrowseBox
->CreateAccessibleColumnHeader( nColumnPos
);
334 sal_Int32
AccessibleBrowseBoxHeaderBar::implGetChildIndexFromSelectedIndex(
335 sal_Int32 nSelectedChildIndex
)
337 Sequence
< sal_Int32
> aSelSeq
;
339 implGetSelectedRows( aSelSeq
);
341 implGetSelectedColumns( aSelSeq
);
343 if( (nSelectedChildIndex
< 0) || (nSelectedChildIndex
>= aSelSeq
.getLength()) )
344 throw lang::IndexOutOfBoundsException();
346 return aSelSeq
[ nSelectedChildIndex
];
349 void AccessibleBrowseBoxHeaderBar::ensureIsValidHeaderIndex( sal_Int32 nIndex
)
352 ensureIsValidRow( nIndex
);
354 ensureIsValidColumn( nIndex
);
358 } // namespace accessibility
361 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */