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>
24 using ::com::sun::star::uno::Reference
;
25 using ::com::sun::star::uno::Sequence
;
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 AccessibleBrowseBoxTable::AccessibleBrowseBoxTable(
38 const Reference
< XAccessible
>& rxParent
,
39 vcl::IAccessibleTableProvider
& rBrowseBox
) :
40 AccessibleBrowseBoxTableBase( rxParent
, rBrowseBox
, vcl::BBTYPE_TABLE
)
44 AccessibleBrowseBoxTable::~AccessibleBrowseBoxTable()
48 // XAccessibleContext ---------------------------------------------------------
50 Reference
< XAccessible
> SAL_CALL
51 AccessibleBrowseBoxTable::getAccessibleChild( sal_Int32 nChildIndex
)
53 SolarMethodGuard
aGuard(getMutex());
56 ensureIsValidIndex( nChildIndex
);
57 return mpBrowseBox
->CreateAccessibleCell(
58 implGetRow( nChildIndex
), static_cast<sal_Int16
>(implGetColumn( nChildIndex
)) );
61 sal_Int32 SAL_CALL
AccessibleBrowseBoxTable::getAccessibleIndexInParent()
63 osl::MutexGuard
aGuard( getMutex() );
65 return vcl::BBINDEX_TABLE
;
68 // XAccessibleComponent -------------------------------------------------------
70 Reference
< XAccessible
> SAL_CALL
71 AccessibleBrowseBoxTable::getAccessibleAtPoint( const awt::Point
& rPoint
)
73 SolarMethodGuard
aGuard(getMutex());
76 Reference
< XAccessible
> xChild
;
78 sal_uInt16 nColumnPos
= 0;
79 if( mpBrowseBox
->ConvertPointToCellAddress( nRow
, nColumnPos
, VCLPoint( rPoint
) ) )
80 xChild
= mpBrowseBox
->CreateAccessibleCell( nRow
, nColumnPos
);
85 void SAL_CALL
AccessibleBrowseBoxTable::grabFocus()
87 SolarMethodGuard
aGuard(getMutex());
89 mpBrowseBox
->GrabTableFocus();
92 // XAccessibleTable -----------------------------------------------------------
94 OUString SAL_CALL
AccessibleBrowseBoxTable::getAccessibleRowDescription( sal_Int32 nRow
)
96 SolarMethodGuard
aGuard(getMutex());
98 ensureIsValidRow( nRow
);
99 return mpBrowseBox
->GetRowDescription( nRow
);
102 OUString SAL_CALL
AccessibleBrowseBoxTable::getAccessibleColumnDescription( sal_Int32 nColumn
)
104 SolarMethodGuard
aGuard(getMutex());
107 ensureIsValidColumn( nColumn
);
108 return mpBrowseBox
->GetColumnDescription( static_cast<sal_uInt16
>(nColumn
) );
111 Reference
< XAccessibleTable
> SAL_CALL
AccessibleBrowseBoxTable::getAccessibleRowHeaders()
113 ::osl::MutexGuard
aGuard( getMutex() );
115 return implGetHeaderBar( vcl::BBINDEX_ROWHEADERBAR
);
118 Reference
< XAccessibleTable
> SAL_CALL
AccessibleBrowseBoxTable::getAccessibleColumnHeaders()
120 ::osl::MutexGuard
aGuard( getMutex() );
122 return implGetHeaderBar( vcl::BBINDEX_COLUMNHEADERBAR
);
125 Sequence
< sal_Int32
> SAL_CALL
AccessibleBrowseBoxTable::getSelectedAccessibleRows()
127 SolarMethodGuard
aGuard(getMutex());
130 Sequence
< sal_Int32
> aSelSeq
;
131 implGetSelectedRows( aSelSeq
);
135 Sequence
< sal_Int32
> SAL_CALL
AccessibleBrowseBoxTable::getSelectedAccessibleColumns()
137 SolarMethodGuard
aGuard(getMutex());
140 Sequence
< sal_Int32
> aSelSeq
;
141 implGetSelectedColumns( aSelSeq
);
145 sal_Bool SAL_CALL
AccessibleBrowseBoxTable::isAccessibleRowSelected( sal_Int32 nRow
)
147 SolarMethodGuard
aGuard(getMutex());
150 ensureIsValidRow( nRow
);
151 return implIsRowSelected( nRow
);
154 sal_Bool SAL_CALL
AccessibleBrowseBoxTable::isAccessibleColumnSelected( sal_Int32 nColumn
)
156 SolarMethodGuard
aGuard(getMutex());
159 ensureIsValidColumn( nColumn
);
160 return implIsColumnSelected( nColumn
);
163 Reference
< XAccessible
> SAL_CALL
AccessibleBrowseBoxTable::getAccessibleCellAt(
164 sal_Int32 nRow
, sal_Int32 nColumn
)
166 SolarMethodGuard
aGuard(getMutex());
169 ensureIsValidAddress( nRow
, nColumn
);
170 return mpBrowseBox
->CreateAccessibleCell( nRow
, static_cast<sal_Int16
>(nColumn
) );
173 sal_Bool SAL_CALL
AccessibleBrowseBoxTable::isAccessibleSelected(
174 sal_Int32 nRow
, sal_Int32 nColumn
)
176 SolarMethodGuard
aGuard(getMutex());
179 ensureIsValidAddress( nRow
, nColumn
);
180 return implIsRowSelected( nRow
) || implIsColumnSelected( nColumn
);
183 // XServiceInfo ---------------------------------------------------------------
185 OUString SAL_CALL
AccessibleBrowseBoxTable::getImplementationName()
187 return OUString( "com.sun.star.comp.svtools.AccessibleBrowseBoxTable" );
190 // internal virtual methods ---------------------------------------------------
192 tools::Rectangle
AccessibleBrowseBoxTable::implGetBoundingBox()
194 return mpBrowseBox
->calcTableRect(false);
197 tools::Rectangle
AccessibleBrowseBoxTable::implGetBoundingBoxOnScreen()
199 return mpBrowseBox
->calcTableRect();
202 // internal helper methods ----------------------------------------------------
204 Reference
< XAccessibleTable
> AccessibleBrowseBoxTable::implGetHeaderBar(
205 sal_Int32 nChildIndex
)
207 Reference
< XAccessible
> xRet
;
208 Reference
< XAccessibleContext
> xContext( mxParent
, uno::UNO_QUERY
);
213 xRet
= xContext
->getAccessibleChild( nChildIndex
);
215 catch (const lang::IndexOutOfBoundsException
&)
217 OSL_FAIL( "implGetHeaderBar - wrong child index" );
219 // RuntimeException goes to caller
221 return Reference
< XAccessibleTable
>( xRet
, uno::UNO_QUERY
);
225 } // namespace accessibility
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */