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 <toolkit/helper/convert.hxx>
22 #include <vcl/accessibletableprovider.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_Int32 nChildIndex
)
54 SolarMethodGuard
aGuard(getMutex());
57 ensureIsValidIndex( nChildIndex
);
58 return mpBrowseBox
->CreateAccessibleCell(
59 implGetRow( nChildIndex
), static_cast<sal_Int16
>(implGetColumn( nChildIndex
)) );
62 sal_Int32 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
, VCLPoint( rPoint
) ) )
81 xChild
= mpBrowseBox
->CreateAccessibleCell( nRow
, nColumnPos
);
86 void SAL_CALL
AccessibleBrowseBoxTable::grabFocus()
88 SolarMethodGuard
aGuard(getMutex());
90 mpBrowseBox
->GrabTableFocus();
93 // XAccessibleTable -----------------------------------------------------------
95 OUString SAL_CALL
AccessibleBrowseBoxTable::getAccessibleRowDescription( sal_Int32 nRow
)
97 SolarMethodGuard
aGuard(getMutex());
99 ensureIsValidRow( nRow
);
100 return mpBrowseBox
->GetRowDescription( nRow
);
103 OUString SAL_CALL
AccessibleBrowseBoxTable::getAccessibleColumnDescription( sal_Int32 nColumn
)
105 SolarMethodGuard
aGuard(getMutex());
108 ensureIsValidColumn( nColumn
);
109 return mpBrowseBox
->GetColumnDescription( static_cast<sal_uInt16
>(nColumn
) );
112 Reference
< XAccessibleTable
> SAL_CALL
AccessibleBrowseBoxTable::getAccessibleRowHeaders()
114 ::osl::MutexGuard
aGuard( getMutex() );
116 return implGetHeaderBar( vcl::BBINDEX_ROWHEADERBAR
);
119 Reference
< XAccessibleTable
> SAL_CALL
AccessibleBrowseBoxTable::getAccessibleColumnHeaders()
121 ::osl::MutexGuard
aGuard( getMutex() );
123 return implGetHeaderBar( vcl::BBINDEX_COLUMNHEADERBAR
);
126 Sequence
< sal_Int32
> SAL_CALL
AccessibleBrowseBoxTable::getSelectedAccessibleRows()
128 SolarMethodGuard
aGuard(getMutex());
131 Sequence
< sal_Int32
> aSelSeq
;
132 implGetSelectedRows( aSelSeq
);
136 Sequence
< sal_Int32
> SAL_CALL
AccessibleBrowseBoxTable::getSelectedAccessibleColumns()
138 SolarMethodGuard
aGuard(getMutex());
141 Sequence
< sal_Int32
> aSelSeq
;
142 implGetSelectedColumns( aSelSeq
);
146 sal_Bool SAL_CALL
AccessibleBrowseBoxTable::isAccessibleRowSelected( sal_Int32 nRow
)
148 SolarMethodGuard
aGuard(getMutex());
151 ensureIsValidRow( nRow
);
152 return implIsRowSelected( nRow
);
155 sal_Bool SAL_CALL
AccessibleBrowseBoxTable::isAccessibleColumnSelected( sal_Int32 nColumn
)
157 SolarMethodGuard
aGuard(getMutex());
160 ensureIsValidColumn( nColumn
);
161 return implIsColumnSelected( nColumn
);
164 Reference
< XAccessible
> SAL_CALL
AccessibleBrowseBoxTable::getAccessibleCellAt(
165 sal_Int32 nRow
, sal_Int32 nColumn
)
167 SolarMethodGuard
aGuard(getMutex());
170 ensureIsValidAddress( nRow
, nColumn
);
171 return mpBrowseBox
->CreateAccessibleCell( nRow
, static_cast<sal_Int16
>(nColumn
) );
174 sal_Bool SAL_CALL
AccessibleBrowseBoxTable::isAccessibleSelected(
175 sal_Int32 nRow
, sal_Int32 nColumn
)
177 SolarMethodGuard
aGuard(getMutex());
180 ensureIsValidAddress( nRow
, nColumn
);
181 return implIsRowSelected( nRow
) || implIsColumnSelected( nColumn
);
184 // XServiceInfo ---------------------------------------------------------------
186 OUString SAL_CALL
AccessibleBrowseBoxTable::getImplementationName()
188 return "com.sun.star.comp.svtools.AccessibleBrowseBoxTable";
191 // internal virtual methods ---------------------------------------------------
193 tools::Rectangle
AccessibleBrowseBoxTable::implGetBoundingBox()
195 return mpBrowseBox
->calcTableRect(false);
198 tools::Rectangle
AccessibleBrowseBoxTable::implGetBoundingBoxOnScreen()
200 return mpBrowseBox
->calcTableRect();
203 // internal helper methods ----------------------------------------------------
205 Reference
< XAccessibleTable
> AccessibleBrowseBoxTable::implGetHeaderBar(
206 sal_Int32 nChildIndex
)
208 Reference
< XAccessible
> xRet
;
209 Reference
< XAccessibleContext
> xContext( mxParent
, uno::UNO_QUERY
);
214 xRet
= xContext
->getAccessibleChild( nChildIndex
);
216 catch (const lang::IndexOutOfBoundsException
&)
218 OSL_FAIL( "implGetHeaderBar - wrong child index" );
220 // RuntimeException goes to caller
222 return Reference
< XAccessibleTable
>( xRet
, uno::UNO_QUERY
);
226 } // namespace accessibility
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */