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/AccessibleBrowseBoxTable.hxx>
21 #include <vcl/accessibletableprovider.hxx>
22 #include <vcl/unohelp.hxx>
23 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
26 using ::com::sun::star::uno::Reference
;
27 using ::com::sun::star::uno::Sequence
;
29 using namespace ::com::sun::star
;
30 using namespace ::com::sun::star::accessibility
;
33 namespace accessibility
{
36 // Ctor/Dtor/disposing --------------------------------------------------------
38 AccessibleBrowseBoxTable::AccessibleBrowseBoxTable(
39 const Reference
< XAccessible
>& rxParent
,
40 vcl::IAccessibleTableProvider
& rBrowseBox
) :
41 AccessibleBrowseBoxTableBase( rxParent
, rBrowseBox
, AccessibleBrowseBoxObjType::Table
)
45 AccessibleBrowseBoxTable::~AccessibleBrowseBoxTable()
49 // XAccessibleContext ---------------------------------------------------------
51 Reference
< XAccessible
> SAL_CALL
52 AccessibleBrowseBoxTable::getAccessibleChild( sal_Int64 nChildIndex
)
54 SolarMethodGuard
aGuard(getMutex());
57 ensureIsValidIndex( nChildIndex
);
58 return mpBrowseBox
->CreateAccessibleCell(
59 implGetRow( nChildIndex
), static_cast<sal_Int16
>(implGetColumn( nChildIndex
)) );
62 sal_Int64 SAL_CALL
AccessibleBrowseBoxTable::getAccessibleIndexInParent()
64 osl::MutexGuard
aGuard( getMutex() );
66 return vcl::BBINDEX_TABLE
;
69 // XAccessibleComponent -------------------------------------------------------
71 Reference
< XAccessible
> SAL_CALL
72 AccessibleBrowseBoxTable::getAccessibleAtPoint( const awt::Point
& rPoint
)
74 SolarMethodGuard
aGuard(getMutex());
77 Reference
< XAccessible
> xChild
;
79 sal_uInt16 nColumnPos
= 0;
80 if (mpBrowseBox
->ConvertPointToCellAddress(nRow
, nColumnPos
,
81 vcl::unohelper::ConvertToVCLPoint(rPoint
)))
82 xChild
= mpBrowseBox
->CreateAccessibleCell( nRow
, nColumnPos
);
87 void SAL_CALL
AccessibleBrowseBoxTable::grabFocus()
89 SolarMethodGuard
aGuard(getMutex());
91 mpBrowseBox
->GrabTableFocus();
94 // XAccessibleTable -----------------------------------------------------------
96 OUString SAL_CALL
AccessibleBrowseBoxTable::getAccessibleRowDescription( sal_Int32 nRow
)
98 SolarMethodGuard
aGuard(getMutex());
100 ensureIsValidRow( nRow
);
101 return mpBrowseBox
->GetRowDescription( nRow
);
104 OUString SAL_CALL
AccessibleBrowseBoxTable::getAccessibleColumnDescription( sal_Int32 nColumn
)
106 SolarMethodGuard
aGuard(getMutex());
109 ensureIsValidColumn( nColumn
);
110 return mpBrowseBox
->GetColumnDescription( static_cast<sal_uInt16
>(nColumn
) );
113 Reference
< XAccessibleTable
> SAL_CALL
AccessibleBrowseBoxTable::getAccessibleRowHeaders()
115 ::osl::MutexGuard
aGuard( getMutex() );
117 return implGetHeaderBar( vcl::BBINDEX_ROWHEADERBAR
);
120 Reference
< XAccessibleTable
> SAL_CALL
AccessibleBrowseBoxTable::getAccessibleColumnHeaders()
122 ::osl::MutexGuard
aGuard( getMutex() );
124 return implGetHeaderBar( vcl::BBINDEX_COLUMNHEADERBAR
);
127 Sequence
< sal_Int32
> SAL_CALL
AccessibleBrowseBoxTable::getSelectedAccessibleRows()
129 SolarMethodGuard
aGuard(getMutex());
132 Sequence
< sal_Int32
> aSelSeq
;
133 implGetSelectedRows( aSelSeq
);
137 Sequence
< sal_Int32
> SAL_CALL
AccessibleBrowseBoxTable::getSelectedAccessibleColumns()
139 SolarMethodGuard
aGuard(getMutex());
142 Sequence
< sal_Int32
> aSelSeq
;
143 implGetSelectedColumns( aSelSeq
);
147 sal_Bool SAL_CALL
AccessibleBrowseBoxTable::isAccessibleRowSelected( sal_Int32 nRow
)
149 SolarMethodGuard
aGuard(getMutex());
152 ensureIsValidRow( nRow
);
153 return implIsRowSelected( nRow
);
156 sal_Bool SAL_CALL
AccessibleBrowseBoxTable::isAccessibleColumnSelected( sal_Int32 nColumn
)
158 SolarMethodGuard
aGuard(getMutex());
161 ensureIsValidColumn( nColumn
);
162 return implIsColumnSelected( nColumn
);
165 Reference
< XAccessible
> SAL_CALL
AccessibleBrowseBoxTable::getAccessibleCellAt(
166 sal_Int32 nRow
, sal_Int32 nColumn
)
168 SolarMethodGuard
aGuard(getMutex());
171 ensureIsValidAddress( nRow
, nColumn
);
172 return mpBrowseBox
->CreateAccessibleCell( nRow
, static_cast<sal_Int16
>(nColumn
) );
175 sal_Bool SAL_CALL
AccessibleBrowseBoxTable::isAccessibleSelected(
176 sal_Int32 nRow
, sal_Int32 nColumn
)
178 SolarMethodGuard
aGuard(getMutex());
181 ensureIsValidAddress( nRow
, nColumn
);
182 return implIsRowSelected( nRow
) || implIsColumnSelected( nColumn
);
185 // XServiceInfo ---------------------------------------------------------------
187 OUString SAL_CALL
AccessibleBrowseBoxTable::getImplementationName()
189 return u
"com.sun.star.comp.svtools.AccessibleBrowseBoxTable"_ustr
;
192 // internal virtual methods ---------------------------------------------------
194 tools::Rectangle
AccessibleBrowseBoxTable::implGetBoundingBox()
196 return mpBrowseBox
->calcTableRect(false);
199 AbsoluteScreenPixelRectangle
AccessibleBrowseBoxTable::implGetBoundingBoxOnScreen()
201 return AbsoluteScreenPixelRectangle(mpBrowseBox
->calcTableRect());
204 // internal helper methods ----------------------------------------------------
206 Reference
< XAccessibleTable
> AccessibleBrowseBoxTable::implGetHeaderBar(
207 sal_Int32 nChildIndex
)
209 assert(nChildIndex
== vcl::BBINDEX_ROWHEADERBAR
|| nChildIndex
== vcl::BBINDEX_COLUMNHEADERBAR
);
211 Reference
< XAccessible
> xRet
;
212 Reference
< XAccessibleContext
> xContext( mxParent
, uno::UNO_QUERY
);
215 if (nChildIndex
== vcl::BBINDEX_COLUMNHEADERBAR
|| mpBrowseBox
->HasRowHeader())
219 xRet
= xContext
->getAccessibleChild( nChildIndex
);
221 catch (const lang::IndexOutOfBoundsException
&)
223 OSL_FAIL( "implGetHeaderBar - wrong child index" );
225 // RuntimeException goes to caller
228 return Reference
< XAccessibleTable
>( xRet
, uno::UNO_QUERY
);
232 } // namespace accessibility
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */